| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- /**
- * author wulianwei
- * title 通信模块驱动封装
- */
- #include "module_wrapper.h"
- #include "string.h"
- static at_module_t *g_at_module = NULL;
- uint8 tcp_connect_status = TCP_CLOSED; //tcp连接状态 0:断开,1:连接,2 连接中
- uint8_t module_start_status = MODULE_FAIL; //模块启动
- uint8 module_init_status = MODULE_FAIL; // 模块初始化
- int at_module_register(at_module_t *module)
- {
- if (!g_at_module) {
- g_at_module = module;
- return 0;
- }
- return -1;
- }
- int at_module_register_default()
- {
- g_at_module = NULL;
- return 0;
- }
- void at_module_start(void)
- {
- if (g_at_module && g_at_module->start) {
- g_at_module->start();
- }
- }
- int at_module_init(void)
- {
- if (g_at_module && g_at_module->init) {
- return g_at_module->init();
- }
- return -1;
- }
- void at_module_connect(const char *ip, const char *port)
- {
- if (g_at_module && g_at_module->connect) {
- g_at_module->connect(ip, port);
- }
- }
- void at_module_udpopen(const char *ip, const char *port)
- {
- if (g_at_module && g_at_module->udpopen) {
- g_at_module->udpopen(ip, port);
- }
- }
- void at_module_reconnect(const char *ip, const char *port)
- {
- if (g_at_module && g_at_module->reconnect) {
- g_at_module->reconnect(ip, port);
- }
- }
- void at_module_udpreopen(const char *ip, const char *port)
- {
- if (g_at_module && g_at_module->udpreopen) {
- g_at_module->udpreopen(ip, port);
- }
- }
- void at_module_close(void)
- {
- if (g_at_module && g_at_module->close) {
- g_at_module->close();
- }
- }
- int at_module_tcpstate(void)
- {
- if (g_at_module && g_at_module->tcpstate) {
- return g_at_module->tcpstate();
- }
- return -1;
- }
- int at_module_send(const void *buf, size_t len)
- {
- if (g_at_module && g_at_module->send) {
- return g_at_module->send(buf, len);
- }
- return -1;
- }
- int at_module_send_rai(const void *buf, size_t len, int rai)
- {
- if (g_at_module && g_at_module->send_rai) {
- return g_at_module->send_rai(buf, len, rai);
- }
- return -1;
- }
- int at_module_recv_timeout(void *buf, int len, int timeout)
- {
- if (g_at_module && g_at_module->recv_timeout) {
- return g_at_module->recv_timeout(buf, len ,timeout);
- }
- return -1;
- }
- void at_module_handle_event(void)
- {
-
- if (g_at_module && g_at_module->handle_event) {
- g_at_module->handle_event();
- }
- }
- void at_module_cmd_back(char *cmd, char *data, int size)
- {
- if (g_at_module && g_at_module->cmd_back) {
- g_at_module->cmd_back(cmd,data,size);
- }
- }
- void at_module_cmd(char *cmd)
- {
- if (g_at_module && g_at_module->cmd) {
- g_at_module->cmd(cmd);
- }
- }
- void at_module_low_power(void)
- {
- if (g_at_module && g_at_module->low_power) {
- g_at_module->low_power();
- }
- }
|