目录
wifi_station_get_connect_status
at
at_init
at_set_custom_info
at_cmd_array_regist
AT指令数组格式
wifi_set_opmode
wifi_station_set_config
struct station_config {
uint8 ssid[32];
uint8 password[64];
uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router
// with both ssid[] and bssid[] matched. Please check about this.
uint8 bssid[6];
wifi_fast_scan_threshold_t threshold;
};
os_timer_disarm
os_timer_setfn
os_timer_arm
espconn_regist_connectcb
LOCAL struct espconn user_tcp_conn;
// Connect to tcp server as NET_DOMAIN
user_tcp_conn.proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp));
user_tcp_conn.type = ESPCONN_TCP;
user_tcp_conn.state = ESPCONN_NONE;
const char esp_tcp_server_ip[4] = {192,168,31,28}; // remote IP of TCP server
os_memcpy(user_tcp_conn.proto.tcp->remote_ip,esp_tcp_server_ip,4);
user_tcp_conn.proto.tcp->remote_port =8080; // remote port
user_tcp_conn.proto.tcp->local_port = espconn_port(); //local port of ESP8266
espconn
espconn_regist_reconcb
espconn_connect
espconn_regist_recvcb
espconn_regist_sentcb
espconn_regist_disconcb
WiFi
wifi_station_get_connect_status
wifi_get_ip_info
AT指令
1、AT+CIFSR查看本设备的IP地址
2、设备连接服务器指令:AT+CIPSTART="TCP","192.168.31.28",8080
3、客户端发送消息给服务器:发送指令:AT+CIPSEND=4
参数4表示要发送的字节数,在发送指令成功后串口将会显示'>'符号,代表可以输入信息了。
4、服务器发送消息给客户端:发送指令:AT+CIPSEND=0,4
第一个参数是要发送的编号,这边为什么是0是通过指令AT+CIPSTATUS来获取的,上面也有说,这里就不再废话了。第二个参数就是要发送的字节数。这里同样是发送"123456"但是因为设置4字节,所以也被截止了。
4、每次输入前都要先发送命令AT+CIPSEND有点麻烦,所以我们可以开启透传模式,具体如下:
- AT+CIPMODE=1 //开启透传模式
- AT+CIPSEND //开始透传
如果要结束透传的话需要发送+++,需要注意的是将重新发送新行给取消。但是透传模式只支持单连接模式,即服务器在开启多连接模式下是一对多的,就不能使用透传模式了。