Initial import of STM32 IoT sensor node
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef __ESP8266_H
|
||||
#define __ESP8266_H
|
||||
|
||||
#include <stm32f10x_conf.h>
|
||||
|
||||
// ESP8266初始化
|
||||
void esp8266_init(void);
|
||||
|
||||
// ESP8266通过USART2发送字符串数据
|
||||
void esp8266_send_string(const char *buf);
|
||||
|
||||
// ESP8266通过USART2发送AT指令
|
||||
void esp8266_send_cmd(const char *cmd);
|
||||
|
||||
// 从USART2 读取相应字符串放入 buf,等待最大时长timeout毫秒ms
|
||||
int esp8266_read_response(char *buf, int buf_size, int timeout_ms);
|
||||
|
||||
// ESP8266 连接 Wifi,成功返回1,失败返回0
|
||||
int esp8266_connect_wifi(const char *ssid, const char *passwd);
|
||||
|
||||
// ESP8266 作为客户端远程 TCP 连接。成功返回1,失败返回0
|
||||
int esp8266_tcp_connect(const char *ip, uint16_t port);
|
||||
|
||||
// 关闭tcp 连接
|
||||
void esp8266_tcp_close(void);
|
||||
|
||||
// ESP8266 TCP 协议发送数据,返回写入的字节数,0表示失败
|
||||
int esp8266_write(const char *data, uint16_t len);
|
||||
|
||||
// ESP8266 读取数据,返回读取的字节数
|
||||
uint16_t esp8266_read(char *buf, uint16_t buf_size);
|
||||
|
||||
// ESP8266 清空读缓冲区
|
||||
void esp8266_clear_read_buf(void);
|
||||
|
||||
#endif // __ESP8266_H
|
||||
Reference in New Issue
Block a user