tupApi.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __TUP_API_H
  2. #define __TUP_API_H
  3. #include "stdbool.h"
  4. typedef unsigned char T_BYTE; ///< �ֽ�
  5. typedef char T_INT8; ///< 8���
  6. typedef unsigned char T_UINT8; ///< 8λ�޷�������
  7. typedef short T_INT16; ///< 16���
  8. typedef unsigned short T_UINT16; ///< 16λ�޷�������
  9. typedef int T_INT32; ///< 32���
  10. typedef unsigned int T_UINT32; ///< 32λ�޷�������
  11. typedef bool T_BOOL;
  12. typedef enum{
  13. TUP_TCP=0x30,
  14. TUP_UDP=0x31
  15. }TUP_ENUM;
  16. //#include "datatype.h"
  17. //#include "platform.h"
  18. #include "lsapi_event.h"
  19. #define USER_EVENT_EXIT (LS_API_EV_BASE+12)
  20. #define USER_EVENT_TIMEOUT (LS_API_EV_BASE+13)
  21. #define USER_EVENT_LSB (LS_API_EV_BASE+14)
  22. #define USER_EVENT_UART (LS_API_EV_BASE+15)
  23. #define USER_EVENT_TONE (LS_API_EV_BASE+16)
  24. #define USER_ENENT_AGPS (LS_API_EV_BASE+17)
  25. #define USER_EVENT_PA (LS_API_EV_BASE+18)
  26. #include "lsapi_sock.h"
  27. #include "lsapi_os.h"
  28. typedef enum{
  29. TUP_STATUS_TRUE,
  30. TUP_STATUS_FALSE,
  31. TUP_STATUS_WAIT,
  32. TUP_STATUS_ONLINE
  33. }TUP_CONNECT_ENUM;
  34. typedef enum{
  35. CNNT_READY,
  36. CNNT_BUSY,
  37. CNNT_OK,
  38. CNNT_ERROR,
  39. CNNT_CLOSED,
  40. CNNT_TOUT
  41. }CNNT_ENUM;
  42. typedef struct{
  43. T_INT32 fd;
  44. T_UINT16 port;
  45. T_INT8 *saddr; //连接服务器地址
  46. T_UINT8 tupType;//连接类型 TUP_TCP TUP_UDP
  47. LSAPI_SOCK_Callback *tupRecvCallBack; //连接回调
  48. T_UINT8 errno; //SOCK连接错误代码
  49. T_UINT16 stacksize;//连接时创建线程的栈分配大小
  50. LSAPI_SOCK_TcpipSocketAddr_t sockAddr;//UDP时使用
  51. CNNT_ENUM tupStatus; //连接状态或结果 0正在连接 1 连接成功,2连接失败 3连接断开
  52. T_UINT8 index; //做成模块,开给对外用户sock接口模块时使用
  53. LSAPI_OSI_Timer_t *ptimer_t;//链接超时判断定时器
  54. T_UINT8 *defPara;//备用
  55. }TUPSEND_DEF;
  56. void trySendTup(T_UINT8 *data, T_UINT16 len, TUP_ENUM tup, TUPSEND_DEF *para);
  57. TUP_CONNECT_ENUM tryConnectTup(T_INT8 *seraddr, TUP_ENUM tup,TUPSEND_DEF *para);
  58. void tupParaSet(TUPSEND_DEF *para, T_UINT16 port, LSAPI_SOCK_Callback *callback,T_UINT16 stacksize);
  59. void showTupEventInfo(const char *name, T_UINT32 id,TUPSEND_DEF *para,char );
  60. void userCloseSocket(T_INT32 *fd);
  61. //void ApplocationCallBack(void *param);
  62. #endif