tupApi.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 USER_EVENT_EXIT (LS_API_EV_BASE+12)
  7. #define USER_EVENT_TIMEOUT (LS_API_EV_BASE+13)
  8. #define USER_EVENT_LSB (LS_API_EV_BASE+14)
  9. #define USER_EVENT_UART (LS_API_EV_BASE+15)
  10. #define USER_EVENT_USB (LS_API_EV_BASE+16)
  11. #define USER_EVENT_GPS (LS_API_EV_BASE+17)
  12. #define USER_ENENT_AGPS (LS_API_EV_BASE+18)
  13. #define USER_EVENT_VIBRAT (LS_API_EV_BASE+19)
  14. #define USER_EVENT_REC (LS_API_EV_BASE+20)
  15. #include "lsapi_sock.h"
  16. #include "lsapi_os.h"
  17. typedef enum{
  18. TUP_STATUS_TRUE,
  19. TUP_STATUS_FALSE,
  20. TUP_STATUS_WAIT,
  21. TUP_STATUS_ONLINE
  22. }TUP_CONNECT_ENUM;
  23. typedef enum{
  24. CNNT_READY,
  25. CNNT_BUSY,
  26. CNNT_OK,
  27. CNNT_ERROR,
  28. CNNT_CLOSED
  29. }CNNT_ENUM;
  30. typedef struct{
  31. CNNT_ENUM tupStatus; //连接状态或结果 0正在连接 1 连接成功,2连接失败 3连接断开
  32. T_INT32 fd;
  33. T_UINT16 port;
  34. T_INT8 *saddr; //连接服务器地址
  35. T_UINT8 tupType;//连接类型 TUP_TCP TUP_UDP
  36. LSAPI_SOCK_Callback *tupRecvCallBack; //连接回调
  37. T_UINT8 failNo; //SOCK连接错误代码
  38. T_UINT16 stacksize;//连接时创建线程的栈分配大小
  39. LSAPI_SOCK_TcpipSocketAddr_t sockAddr;//UDP时使用
  40. T_UINT8 index; //做成模块,开给对外用户sock接口模块时使用
  41. LSAPI_OSI_Timer_t *ptimer_t;//链接超时判断定时器
  42. T_UINT8 *defPara;//备用
  43. }TUPSEND_DEF;
  44. void trySendTup(T_UINT8 *data, T_UINT16 len, TUP_ENUM tup, TUPSEND_DEF *para);
  45. TUP_CONNECT_ENUM tryConnectTup(T_INT8 *seraddr, TUP_ENUM tup,TUPSEND_DEF *para);
  46. void tupParaSet(TUPSEND_DEF *para, T_UINT16 port, LSAPI_SOCK_Callback *callback,T_UINT16 stacksize);
  47. void showTupEventInfo(const char *name, T_UINT32 id,TUPSEND_DEF *para);
  48. void threadPostEvent(LSAPI_OSI_Thread_t *threadId, T_INT32 id,T_INT32 param1);
  49. void userExitThread(const char *name);
  50. #endif