module_wrapper.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _MODULE_WRAPPER_H_
  2. #define _MODULE_WRAPPER_H_
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include "sys.h"
  6. #define SEND_SIZE 1024 //发送缓存大小
  7. extern uint8 tcp_connect_status;
  8. extern uint8_t module_start_status;
  9. extern uint8 module_init_status;
  10. typedef void (*at_event_callback_t)(void);
  11. typedef struct at_event_st {
  12. const char *event_header;
  13. at_event_callback_t event_callback;
  14. } at_event_t;
  15. enum tcp_status_en
  16. {
  17. TCP_CLOSED, //tcp关闭
  18. TCP_OPEN, //tcp打开
  19. TCP_CONNECTING //tcp正在连接
  20. };
  21. enum module_status_en
  22. {
  23. MODULE_FAIL, //无效
  24. MODULE_OK, //有效
  25. };
  26. enum send_rai_en
  27. {
  28. KEPP_RRC, //不释放RRC
  29. NO_RRC, //立即释放RRC
  30. ONE_RRC //返回释放RRC
  31. };
  32. typedef struct at_module_st {
  33. void (*start)(void);
  34. int (*init)(void);
  35. void (*connect)(const char *ip, const char *port);
  36. void (*udpopen)(const char *ip, const char *port);
  37. void (*reconnect)(const char *ip, const char *port);
  38. void (*udpreopen)(const char *ip, const char *port);
  39. int (*tcpstate)(void);
  40. int (*send)(const void *buf, int len);
  41. int (*send_rai)(const void *data, int len,int rai);
  42. int (*recv_timeout)(void *buf, int len, int timeout);
  43. int (*close)(void);
  44. void (*handle_event)(void);
  45. void (*cmd_back)(char *cmd, char *data, int size);
  46. void (*cmd)(char *cmd);
  47. int (*low_power)(void);
  48. } at_module_t;
  49. int at_module_register(at_module_t *module);
  50. int at_module_register_default(void);
  51. void at_module_start(void);
  52. int at_module_init(void);
  53. void at_module_connect(const char *ip, const char *port);
  54. void at_module_udpopen(const char *ip, const char *port);
  55. void at_module_reconnect(const char *ip, const char *port);
  56. void at_module_udpreopen(const char *ip, const char *port);
  57. void at_module_close(void);
  58. int at_module_tcpstate(void);
  59. int at_module_send(const void *buf, size_t len);
  60. int at_module_send_rai(const void *buf, size_t len, int rai);
  61. int at_module_recv_timeout(void *buf, int len, int timeout);
  62. void at_module_handle_event(void);
  63. void at_module_cmd_back(char *cmd, char *data, int size);
  64. void at_module_cmd(char *cmd);
  65. void at_module_low_power(void);
  66. #endif