tupApi.h 2.2 KB

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