|
ESP8266 Centre + NB
|


宏定义 | |
| #define | AT_MODU_NAME "nb_neul95" |
| #define | AT_NB_OPEN_RF "AT+CFUN=1\r" |
| #define | AT_NB_CLOSE_PSM "AT+CPSMS=0\r" |
| #define | AT_NB_CLOSE_EDRX "AT+CEDRXS=0,5\r" |
| #define | AT_NB_CGATT_ATTACH "AT+CGATT=1\r" |
| #define | AT_NB_REPORT_PREFIX "AT+NMGS=" |
| #define | AT_NB_LINE_END "\r\n" |
| #define | AT_NB_reboot "AT+NRB\r" |
| #define | AT_NB_hw_detect "AT+CFUN?\r" |
| #define | AT_NB_get_auto_connect "AT+NCONFIG?\r" |
| #define | AT_CMD_PREFIX "\r\n+NNMI:" |
| #define | AT_DATAF_PREFIX "+NSONMI:" |
| #define | CGATT "AT+CGATT?\r" |
| #define | CGATT_DEATTACH "AT+CGATT=0\r" |
| #define | AT_LINE_END "\r\n" |
| #define | AT_CMD_BEGIN "\r\n" |
| #define | AT_USART_PORT 3 |
| #define | AT_BUARDRATE 9600 |
| #define | AT_CMD_TIMEOUT 10000 |
| #define | AT_MAX_LINK_NUM 4 |
| #define | NB_STAT_LOCALPORT 56 |
| #define | MAX_SOCK_NUM 5 |
| #define | UDP_PROTO 17 |
| #define | MAX_AT_USERDATA_LEN (1024*5) |
| #define | AT_MAX_PAYLOADLEN 512 |
| #define | IP_LEN 16 |
函数 | |
| void | NB_ReportData (uint8 mid, uint8 *data_str) |
| 上报数据到云端 更多... | |
| void | NB_SendCmd (uint8 *cmd, uint8 cmd_len, uint8 *response_msg) |
| 向NB模组发送指令 更多... | |
| void | NB_ResponseTimerCb (void *arg) |
| void | NB_Init (void) |
| void | NB_RxMsgHandler (uint8 *nb_msg) |
| NB消息处理函数 更多... | |
| int | str_to_hex (const char *bufin, int len, char *bufout) |
| 将十六进制码流转换为字符串形式 更多... | |
| int32_t | nb_set_cdpserver (char *host, char *port) |
| int32_t | nb_hw_detect (void) |
| int32_t | nb_get_netstat (void) |
| int | nb_query_ip (void) |
| int32_t | nb_send_payload (const char *buf, int len) |
| int32_t | nb_check_csq (void) |
| int32_t | nb_send_psk (char *pskid, char *psk) |
| int32_t | nb_set_no_encrypt (void) |
| int32_t | nb_reboot (void) |
| int32_t | nb_recv_timeout (int32_t id, uint8_t *buf, uint32_t len, char *ipaddr, int *port, int32_t timeout) |
| int32_t | nb_cmd_match (const char *buf, char *featurestr, int len) |
| void | nb_step (void) |
| void | nb_reattach (void) |
| #define AT_MODU_NAME "nb_neul95" |
| #define AT_NB_OPEN_RF "AT+CFUN=1\r" |
| #define AT_NB_CLOSE_PSM "AT+CPSMS=0\r" |
| #define AT_NB_CLOSE_EDRX "AT+CEDRXS=0,5\r" |
| #define AT_NB_CGATT_ATTACH "AT+CGATT=1\r" |
| #define AT_NB_REPORT_PREFIX "AT+NMGS=" |
| #define AT_NB_LINE_END "\r\n" |
| #define AT_NB_reboot "AT+NRB\r" |
| #define AT_NB_hw_detect "AT+CFUN?\r" |
| #define AT_NB_get_auto_connect "AT+NCONFIG?\r" |
| #define AT_CMD_PREFIX "\r\n+NNMI:" |
| #define AT_DATAF_PREFIX "+NSONMI:" |
| #define CGATT "AT+CGATT?\r" |
| #define CGATT_DEATTACH "AT+CGATT=0\r" |
| #define AT_LINE_END "\r\n" |
| #define AT_CMD_BEGIN "\r\n" |
| #define AT_USART_PORT 3 |
| #define AT_BUARDRATE 9600 |
| #define AT_CMD_TIMEOUT 10000 |
| #define AT_MAX_LINK_NUM 4 |
| #define NB_STAT_LOCALPORT 56 |
| #define MAX_SOCK_NUM 5 |
| #define UDP_PROTO 17 |
| #define MAX_AT_USERDATA_LEN (1024*5) |
| #define AT_MAX_PAYLOADLEN 512 |
| #define IP_LEN 16 |
上报数据到云端
例如:当编解码插件中的messageId为0x11时,
| [in] | data_str | 需要上报的十六进制数据字符串 |


向NB模组发送指令
将响应消息复制到响应消息数组 response_msg[]
| [in] | cmd | 要发送的指令字符串 |
| [in] | cmd_len | 指令字符串长度 |
| [in] | res_msg | 期望接收到的响应消息,参见NB模组的AT指令参考手册 |


| void NB_ResponseTimerCb | ( | void * | arg | ) |
| void NB_Init | ( | void | ) |


| void NB_RxMsgHandler | ( | uint8 * | nb_msg | ) |
NB消息处理函数
NB消息有以下几种类型:
云端下发的控制命令。以“+NNMI:”为前缀
当NB发送消息来的时候,我们先判断在接收到这条消息之前有没有发送过指令,即判断响应标志位 response_flag是否被置位,再决定是否去匹配响应消息。
| [in] | nb_msg | 串口接收到的NB消息 |
| int str_to_hex | ( | const char * | bufin, |
| int | len, | ||
| char * | bufout | ||
| ) |
将十六进制码流转换为字符串形式
| [in] | bufin | 输入的十六进制码流 |
| [in] | len | 十六进制码流的长度 |
| [out] | bufout | 输出的十六进制字符串 |
| int32_t nb_set_cdpserver | ( | char * | host, |
| char * | port | ||
| ) |
| int32_t nb_hw_detect | ( | void | ) |
| int32_t nb_get_netstat | ( | void | ) |
| int nb_query_ip | ( | void | ) |
| int32_t nb_send_payload | ( | const char * | buf, |
| int | len | ||
| ) |
| int32_t nb_check_csq | ( | void | ) |
| int32_t nb_send_psk | ( | char * | pskid, |
| char * | psk | ||
| ) |
| int32_t nb_set_no_encrypt | ( | void | ) |
| int32_t nb_reboot | ( | void | ) |
| int32_t nb_recv_timeout | ( | int32_t | id, |
| uint8_t * | buf, | ||
| uint32_t | len, | ||
| char * | ipaddr, | ||
| int * | port, | ||
| int32_t | timeout | ||
| ) |
| int32_t nb_cmd_match | ( | const char * | buf, |
| char * | featurestr, | ||
| int | len | ||
| ) |
| void nb_step | ( | void | ) |
| void nb_reattach | ( | void | ) |
1.8.6