⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol_drv.h

📁 modem数据通信源码
💻 H
字号:
#ifndef	__PROTOCOL_DRV_H__
#define __PROTOCOL_DRV_H__

#define  NEW_SOCKET_LWIP

#ifdef __cplusplus
extern "C" {
#endif
#include "Nucleus.H"
#ifndef GDC_SDEF_H
#define	EM_ppp_Dialing		(uchar)0x04			//正在进行硬件呼叫过程
#define	EM_ppp_CANTSTART	(uchar)0x03			//硬件呼叫成功,准备开始PPP链路连接
#define	EM_ppp_NOSTART		(uchar)0x02			//硬件呼叫成功,但是还没有开始PPP链路连接
#define EM_ppp_SUCCESS		EM_SUCCESS			//呼叫成功
#define EM_ppp_FAIL			EM_ERROR			//参数错误,或者执行错误等
#define	EM_ppp_Doing		0xFF				//正在进行数据链路的连接中
#define EM_ppp_DIALFAIL		0xFE				//硬件呼叫失败
#define EM_ppp_NOINIT	    0xFD				//没有执行协议栈初始化。
#define EM_ppp_NORESPONSE	0xFC				//对方没有响应,呼叫已经失败
#define EM_ppp_CONNECTFAIL	0xFB				//和远程连接失败,呼叫已经失败
#define EM_ppp_AUTHENFAIL	0xFA				//认证过程失败,呼叫已经失败
#define EM_ppp_GETIPFAIL	0xF9				//获取IP地址失败,呼叫已经失败

//#define	EM_tcpip_DEAD		(uchar)0x02
#define	EM_tcpip_SUCCESS	EM_SUCCESS
#define	EM_tcpip_FAIL		EM_ERROR
#define	EM_tcpip_Doing		0xFF

//define protocol expand command ID
//Local port min
#define EM_PROTO_SETMINPORT  0x01
#define EM_PROTO_GETMINPORT  0x02
//maximum packet length
#define EM_PROTO_MAXDATALEN  0x03


typedef struct
{
	ulong		uiRevLen ;
	uchar		ucEvent ;
	uchar		ucRet ;
	uchar		ucReserved[2];
}ET_EVENT_STRUCT;

typedef struct
{
	// 呼叫的GPRS中心
	char	acCenter[30];
	// GPRS业务参数设置
	char	acPduContext[50];
	// 对端被呼叫的电话号码
	char	acDialNum[30];
	// 拨号方式
	uchar	ucDtmfPulse;
	uchar	ucReserve;
	// 超时时间
	uint	uiSeconds;
}ET_PPP_PARA;

typedef struct TINFO
{
    ushort  usMaxDataLen ;      //最大允许通信的数据包长。
    uchar   ucReserved[2];      //保留

}ET_INFO_STRUCT;

typedef	uchar	ucWriteBufType(uint len,char *buf);
typedef	uchar	ucReadByteType(uchar *ch);

#define EM_DISABLE_PWM   0x00
#define EM_ENABLE_PWM    0x01

typedef void    vIntoPowerSaveFuc(uchar ucType);
typedef void    vOutOfPowerSaveFuc(void);

typedef struct
{
    uint   uiEnableFlag ;
    vIntoPowerSaveFuc*     vIntoPowerSave;
    vOutOfPowerSaveFuc*    vOutOfPowerSave;

}ET_PPP_PWM_STRUCT ;

typedef	struct	TPPPINTERFACE
{

	NU_MAILBOX			*m_ptMbIcon ;

	ucWriteBufType*		ucWriteBuf;
	ucReadByteType*		ucReadByte;
    ET_PPP_PWM_STRUCT   *ptPwmStruct ;


}ET_PPP_DEVINTER ;

#endif

#define		PROTO_ALL_STATE			(uint)(0)
#define		PROTO_CONNECT_EVENT		(uint)(1)
#define		PROTO_OPEN_EVENT		(uint)(2)
#define		PROTO_LISTEN_EVENT		(uint)(3)
#define		PROTO_LINK1_SEND_EVENT	(uint)(4)
#define		PROTO_LINK2_SEND_EVENT	(uint)(5)
//#define		PROTO_LINK1_RECV_EVENT	(uint)(6)
//#define		PROTO_LINK2_RECV_EVENT	(uint)(7)
#define		PROTO_TERM_EVENT		(uint)(8)


typedef	struct
{
	void	(*EA_ppp_vSetParam)(const ET_PPP_DEVINTER *ptParam ) ;
	uchar	(*EA_ppp_ucCall)(void);
	uchar	(*EA_ppp_ucDialOff)(uchar ucMode);
	void	(*EA_ppp_vHandle)(void);
	uchar	(*EA_ppp_ucGetState)( ET_EVENT_STRUCT *ptEventState );
	uchar	(*EI_ucTestOnline)(uint times );
	void    *pvProtocolInternalExpand;

} ET_PROTOCOL_INTERNAL_EXPORT;

typedef	struct
{
	uchar	(*EA_ucAuthenPara)(DevHandle hDev,
		const char *pcUserName, const char *pcPassWord);
	uchar	(*EA_ucGetLocalDynIp)(DevHandle hDev,char *pcsIP);
	uchar	(*EA_ucTestOnline)(DevHandle hDev);
	uchar	(*EA_ucOpenTcpIp)(DevHandle hDev,uint uiSocketID,
						ushort usRemotePort,const char *pcIpAddrBuf);
	uchar	(*EA_ucListenTcpIp)(DevHandle hDev, uint uiSocketID,
						ushort usLocalPort,const char *pcRemoteIpBuf,uint uiWaitSeconds);
	uchar	(*EA_ucSendTcpIp)(DevHandle hDev, uint uiSocketID,
						  uint uiSendBufSize, const void *pvSendBuf);
	uchar	(*EA_ucRecvTcpIp)(DevHandle hDev, uint uiSocketID,
						  uint uiRecvLen, uint uiTimeOutSeconds,
						  void *pvRecvBuf, uint *puiRecvBufSize);
	uchar	(*EA_ucResetTcpIp)(DevHandle hDev,uint uiSocketID);
	uchar	(*EA_ucPing)(DevHandle hDev,const char *pcIp, uint uiSize , uint uiRetryTimes , uint uiTimeInterval);
	uchar	(*EA_ucClrTcpIpRecBuf)( DevHandle hDev , uint uiSocketID );
	uchar	(*EA_ucIfTcpIpRecBufEmpty)(DevHandle hDev,uint uiSocketID,uchar *pucBufStatus);

	uchar	(*EA_ucBlockOpenTcpIp)(DevHandle hDev , uint uiSocketID ,
						  ushort usRemotePort , const char *pcIpAddrBuf ,
						  uint uiTimeOutSeconds );

	uchar	(*EA_ucBlockSendTcpIp)(DevHandle hDev , uint uiSocketID ,
						  uint uiSendBufSize , uint uiTimeOutSeconds ,
						  const void *pvSendBuf );
    uchar   (*EA_ucCtrlProtoDebug)(DevHandle hDev, uchar ucEnInfo);
    uchar   (*EA_ucGetIfConfig)(DevHandle hDev, ET_INFO_STRUCT *ptInfo);
    uchar   (*EA_ucProtoExpand)(DevHandle hDev, ulong ucCmdId, void *argp);
#ifdef NEW_SOCKET_LWIP
	uchar (*EA_ucCreateSocket)(DevHandle hDevHandle, uint * puiSockfd);
	uchar (*EA_ucOpen)(DevHandle hDevHandle, uint uiSockfd, ushort usPort, const char *pcIp);
	uchar (*EA_ucSend)(DevHandle hDevHandle, uint uiSockfd, uint uiLen, const void *pvSend);
	uchar (*EA_ucRecv)(DevHandle hDevHandle, uint uiSockfd, uint uiLen, uint uiTimeOut, void *pvRecv, uint * puiActLen);
	uchar (*EA_ucClose)(DevHandle hDevHandle, uint uiSockfd);
	uchar (*EA_ucListen)(DevHandle hDevHandle, uint uiSockfd, ushort usPort);
	uchar (*EA_ucAccept)(DevHandle hDevHandle, uint uiSockfd, uint * puiNewSockfd, char *pcIp, ushort * pusPort);	
	uchar (*EA_ucGetSocketState)(DevHandle hDevHandle,uint uiSockfd , uint *uiState);
	uchar (*EA_ucBlockOpen)(DevHandle hDevHandle, uint uiSockfd, ushort usPort, const char *pcIp , uint uiTimeOut);
	uchar (*EA_ucBlockSend)(DevHandle hDevHandle, uint uiSockfd, uint uiLen, uint uiTimeOut , const void *pvSend) ;
	uchar (*EA_ucClrSocketRecBuf)( DevHandle hDev , uint uiSockfd );
	uchar (*EA_ucIfSocketRecBufEmpty)(DevHandle hDev,uint uiSockfd,uchar *pucBufStatus);
#endif    
	void    *pvProtocolExternalExpand;

} ET_PROTOCOL_EXTERNAL_EXPORT;

typedef struct
{
	ET_PROTOCOL_EXTERNAL_EXPORT		*ptProtocolExternal	;
	ET_PROTOCOL_INTERNAL_EXPORT		*ptProtocolInternal	;
	void    *pvProtocolExpand;                // 预留后续扩展

}ET_PROTOCOL_EXPORT_TABLE;

#ifdef PLATFORM_IN_PC
    extern ET_PROTOCOL_EXPORT_TABLE **EG_PC_ptProtocolExportTable;
    #define EG_ptProtocolExportTable (*EG_PC_ptProtocolExportTable)
#else
    extern ET_PROTOCOL_EXPORT_TABLE	*EG_ptProtocolExportTable;
#endif

#define	EA_ppp_vSetParam		EG_ptProtocolExportTable->ptProtocolInternal->EA_ppp_vSetParam
#define	EA_ppp_vHandle			EG_ptProtocolExportTable->ptProtocolInternal->EA_ppp_vHandle
#define	EA_ppp_ucCall			EG_ptProtocolExportTable->ptProtocolInternal->EA_ppp_ucCall
#define EA_ppp_ucDialOff		EG_ptProtocolExportTable->ptProtocolInternal->EA_ppp_ucDialOff
#define	EA_ppp_ucGetState		EG_ptProtocolExportTable->ptProtocolInternal->EA_ppp_ucGetState
#define EI_ucTestOnline         EG_ptProtocolExportTable->ptProtocolInternal->EI_ucTestOnline
#define	EA_ucAuthenPara			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucAuthenPara
#define EA_ucGetLocalDynIp		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucGetLocalDynIp
#define	EA_ucTestOnline			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucTestOnline
#define EA_ucOpenTcpIp			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucOpenTcpIp
#define EA_ucListenTcpIp		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucListenTcpIp
#define	EA_ucSendTcpIp			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucSendTcpIp
#define	EA_ucRecvTcpIp			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucRecvTcpIp
#define	EA_ucRecvTcpIp			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucRecvTcpIp
#define	EA_ucResetTcpIp			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucResetTcpIp
#define	EA_ucPing				EG_ptProtocolExportTable->ptProtocolExternal->EA_ucPing
#define	EA_ucClrTcpIpRecBuf		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucClrTcpIpRecBuf
#define	EA_ucIfTcpIpRecBufEmpty	EG_ptProtocolExportTable->ptProtocolExternal->EA_ucIfTcpIpRecBufEmpty
#define	EA_ucBlockOpenTcpIp		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucBlockOpenTcpIp
#define	EA_ucBlockSendTcpIp		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucBlockSendTcpIp
#define	EA_ucCtrlProtoDebug		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucCtrlProtoDebug
#define	EA_ucGetIfConfig		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucGetIfConfig
#define EA_ucProtoExpand        EG_ptProtocolExportTable->ptProtocolExternal->EA_ucProtoExpand

#ifdef NEW_SOCKET_LWIP
#define EA_ucCreateSocket       EG_ptProtocolExportTable->ptProtocolExternal->EA_ucCreateSocket
#define EA_ucOpen        		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucOpen
#define EA_ucSend        		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucSend
#define EA_ucRecv        		EG_ptProtocolExportTable->ptProtocolExternal->EA_ucRecv
#define EA_ucClose              EG_ptProtocolExportTable->ptProtocolExternal->EA_ucClose
#define EA_ucListen             EG_ptProtocolExportTable->ptProtocolExternal->EA_ucListen
#define EA_ucAccept             EG_ptProtocolExportTable->ptProtocolExternal->EA_ucAccept
#define EA_ucGetSocketState     EG_ptProtocolExportTable->ptProtocolExternal->EA_ucGetSocketState 
#define EA_ucBlockOpen			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucBlockOpen
#define EA_ucBlockSend			EG_ptProtocolExportTable->ptProtocolExternal->EA_ucBlockSend
#define EA_ucClrSocketRecBuf	EG_ptProtocolExportTable->ptProtocolExternal->EA_ucClrSocketRecBuf
#define EA_ucIfSocketRecBufEmpty	EG_ptProtocolExportTable->ptProtocolExternal->EA_ucIfSocketRecBufEmpty
#endif

#ifdef __cplusplus
}
#endif


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -