ESP8266 Centre + NB
nb_bc35.h
浏览该文件的文档.
1 
15 /* Define to prevent recursive inclusion -------------------------------------*/
16 #ifndef __NB_BC35_H__
17 #define __NB_BC35_H__
18 
19 /* Includes ------------------------------------------------------------------*/
20 #include "ets_sys.h"
21 #include "os_type.h"
22 #include "osapi.h" /* 需要用到字符串匹配和定时器函数 */
23 
24 #include "driver/uart.h" /* 需要用到串口接收的NB响应消息和平台下发的命令 */
25 
26 /* Exported typedef -----------------------------------------------------------*/
27 /* Exported constants --------------------------------------------------------*/
28 #define AT_MODU_NAME "nb_neul95"
29 
30 #define AT_NB_OPEN_RF "AT+CFUN=1\r"
31 #define AT_NB_CLOSE_PSM "AT+CPSMS=0\r"
32 #define AT_NB_CLOSE_EDRX "AT+CEDRXS=0,5\r"
33 #define AT_NB_CGATT_ATTACH "AT+CGATT=1\r"
34 #define AT_NB_REPORT_PREFIX "AT+NMGS="
35 
36 
37 #define AT_NB_LINE_END "\r\n"
38 #define AT_NB_reboot "AT+NRB\r"
39 #define AT_NB_hw_detect "AT+CFUN?\r"
40 #define AT_NB_get_auto_connect "AT+NCONFIG?\r"
41 #define AT_CMD_PREFIX "\r\n+NNMI:"
42 #define AT_DATAF_PREFIX "+NSONMI:"
43 #define CGATT "AT+CGATT?\r"
44 #define CGATT_DEATTACH "AT+CGATT=0\r"
45 
46 #define AT_LINE_END "\r\n"
47 #define AT_CMD_BEGIN "\r\n"
48 
49 #define AT_USART_PORT 3
50 #define AT_BUARDRATE 9600
51 #define AT_CMD_TIMEOUT 10000 //ms
52 #define AT_MAX_LINK_NUM 4
53 
54 #define NB_STAT_LOCALPORT 56
55 
56 #define MAX_SOCK_NUM 5
57 #define UDP_PROTO 17
58 
59 #if defined STM32F103xE
60 #define MAX_AT_USERDATA_LEN (1024*2)
61 #else
62 #define MAX_AT_USERDATA_LEN (1024*5)
63 #endif
64 
65 #define AT_MAX_PAYLOADLEN 512
66 
67 #define IP_LEN 16
68 
69 /* Exported function -----------------------------------------------*/
70 void NB_ReportData(uint8 mid, uint8 *data_str);
71 void NB_SendCmd(uint8 *cmd, uint8 cmd_len, uint8 *response_msg);
72 void NB_ResponseTimerCb(void *arg);
73 void NB_Init(void);
74 
75 /* Handle message form NB module, call by uart rx function */
76  void NB_RxMsgHandler(uint8 *nb_msg );
77 
78 
79 int str_to_hex(const char *bufin, int len, char *bufout);
80 int32_t nb_set_cdpserver(char* host, char* port);
81 int32_t nb_hw_detect(void);
83 int nb_query_ip(void);
84 int32_t nb_send_payload(const char* buf, int len);
85 int32_t nb_check_csq(void);
86 int32_t nb_send_psk(char* pskid, char* psk);
88 int32_t nb_reboot(void);
89 int32_t nb_recv_timeout(int32_t id , uint8_t *buf, uint32_t len,char* ipaddr,int* port, int32_t timeout);
90 int32_t nb_cmd_match(const char *buf, char* featurestr,int len);
91 void nb_step(void);
92 void nb_reattach(void);
93 
94 #endif /* __NB_BC35_H__ */
95 /********************************** END OF FILE *******************************/
96 
97 
98 
99 
100 
int32_t nb_cmd_match(const char *buf, char *featurestr, int len)
void NB_ReportData(uint8 mid, uint8 *data_str)
上报数据到云端
Definition: nb_bc35.c:42
int32_t nb_send_payload(const char *buf, int len)
void NB_Init(void)
Definition: nb_bc35.c:140
void NB_ResponseTimerCb(void *arg)
uint8 response_msg[128]
Definition: nb_bc35.c:23
int32_t nb_check_csq(void)
signed int int32_t
Definition: c_types.h:36
unsigned char uint8_t
Definition: c_types.h:28
unsigned int uint32_t
Definition: c_types.h:34
int32_t nb_set_cdpserver(char *host, char *port)
void NB_SendCmd(uint8 *cmd, uint8 cmd_len, uint8 *response_msg)
向NB模组发送指令
Definition: nb_bc35.c:70
unsigned char uint8
Definition: c_types.h:43
int32_t nb_set_no_encrypt(void)
void nb_reattach(void)
int nb_query_ip(void)
int32_t nb_get_netstat(void)
int32_t nb_reboot(void)
int32_t nb_send_psk(char *pskid, char *psk)
int str_to_hex(const char *bufin, int len, char *bufout)
将十六进制码流转换为字符串形式
Definition: nb_bc35.c:196
int32_t nb_recv_timeout(int32_t id, uint8_t *buf, uint32_t len, char *ipaddr, int *port, int32_t timeout)
void nb_step(void)
int32_t nb_hw_detect(void)
void NB_RxMsgHandler(uint8 *nb_msg)
NB消息处理函数
Definition: nb_bc35.c:106