123456789101112131415161718192021222324252627282930313233343536373839 |
- #ifndef __SOCKET_H_
- #define __SOCKET_H_
- #include "pt.h"
- #define SOCKET_NUM_MAX 2 //与模块相关,可以根据实际使用增减,ps:如果只使用一个,则定义为1即可
- typedef struct{
- unsigned char machine;
- unsigned char status;
- unsigned char tcpStatus;
- unsigned short port;
- char Ip[20];
- void (*UserHandle)(unsigned char );
- void (*RxCallBack)(unsigned char *, unsigned int);
- void (*SockeShutDown)(unsigned char );
- }__attribute__ ((packed)) SOCKET_INFO;
- typedef struct{
- unsigned char index;
- SOCKET_INFO socketList[SOCKET_NUM_MAX];
- }__attribute__ ((packed)) SOCKET_DEF;
- extern SOCKET_DEF gSocket;
- PT_THREAD (ptSocketTask(struct pt *pt));
- void tcpSocketInit(void);
- short tcpSocketAdd(void (*UserHandle)(unsigned char socketID),void (*RxCallBack)(unsigned char *data , unsigned int),void (*SockeShutDown)(unsigned char socketID),char *ipAddr, unsigned short port);
- void tcpSocketDel(short socketID);
- char tcpSocketSendData(unsigned char socketID,unsigned char *data, unsigned int length);
- void tcpSocketStatusUpdate(char socketID, char status,char type);
- char tcpSocketGetStatus(char socketID);
- void SocketParaUpdate(unsigned char socketID,char *ipAddr, unsigned short port);
- #endif
|