commit | author | age
|
d6b4a7
|
1 |
/********************************************************************************* |
G |
2 |
* Copyright: (C) 2023 LingYun IoT System Studio. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Filename: at-esp32.h |
|
6 |
* Description: This file is ESP32 AT command low level API functions |
|
7 |
* |
|
8 |
* Version: 1.0.0(11/08/23) |
|
9 |
* Author: Guo Wenxue <guowenxue@gmail.com> |
|
10 |
* ChangeLog: 1, Release initial version on "11/08/23 16:18:43" |
|
11 |
* |
|
12 |
********************************************************************************/ |
|
13 |
|
|
14 |
#ifndef _AT_ESP32_H_ |
|
15 |
#define _AT_ESP32_H_ |
|
16 |
|
|
17 |
#include "atcmd.h" |
|
18 |
|
|
19 |
enum |
|
20 |
{ |
|
21 |
DISABLE = 0, /* common disable */ |
|
22 |
ENABLE, /* common enable */ |
|
23 |
}; |
|
24 |
|
|
25 |
#define MAC_LEN 18 /* 11:22:33:44:55:66 */ |
|
26 |
#define IP_LEN 16 /* 255.255.255.255 */ |
|
27 |
|
|
28 |
/*+------------------------+ |
|
29 |
*| Baisc AT command | |
|
30 |
*+------------------------+*/ |
|
31 |
|
|
32 |
/* AT command: AT+RST */ |
|
33 |
extern int esp32_reset(comport_t *comport); |
|
34 |
|
|
35 |
/* AT command: AT+RESTORE */ |
|
36 |
extern int esp32_restore(comport_t *comport); |
|
37 |
|
|
38 |
/* AT command: ATE1 or ATE0 */ |
|
39 |
extern int esp32_set_echo(comport_t *comport, int enable); |
|
40 |
|
|
41 |
/* AT command: AT+GMR */ |
|
42 |
extern int esp32_get_firmware(comport_t *comport, char *version, int size); |
|
43 |
|
|
44 |
/* AT command: AT+SYSSTORE */ |
|
45 |
extern int esp32_set_sysstore(comport_t *comport, int enable); |
|
46 |
|
|
47 |
|
|
48 |
/*+------------------------+ |
|
49 |
*| WiFi AT command | |
|
50 |
*+------------------------+*/ |
|
51 |
typedef enum |
|
52 |
{ |
|
53 |
MODE_DISABLE=0, /* Wi-Fi RF will be disabled */ |
|
54 |
MODE_STATION, /* Station mode */ |
|
55 |
MODE_SOFTAP, /* SoftAP mode */ |
|
56 |
MODE_WDS, /* Wireless Distribution System: Both Station & SoftAP mode */ |
|
57 |
} workmode_t; |
|
58 |
|
|
59 |
/* AT command: AT+CWMODE */ |
|
60 |
extern int esp32_set_wmode(comport_t *comport, workmode_t mode, int autoconn); |
|
61 |
|
|
62 |
/* AT command: AT+CWDHCP */ |
|
63 |
extern int esp32_set_dhcp(comport_t *comport, workmode_t mode, int enable); |
|
64 |
|
|
65 |
/* AT command: AT+CWAUTOCONN */ |
|
66 |
extern int esp32_set_autoconn(comport_t *comport, int enable); |
|
67 |
|
|
68 |
/* AT command: AT+CIPSTAMAC/CIPAPMAC */ |
|
69 |
extern int esp32_get_macaddr(comport_t *comport, workmode_t mode, char *mac); |
|
70 |
|
|
71 |
/* AT command: AT+CIPSTA/CIPAP */ |
|
72 |
extern int esp32_get_ipaddr(comport_t *comport, workmode_t mode, char *ip, char *gateway); |
|
73 |
|
|
74 |
/* AT command: AT+CIPSTA/AT+CIPAP */ |
|
75 |
extern int esp32_set_ipaddr(comport_t *comport, workmode_t mode, char *ip, char *gateway); |
|
76 |
|
|
77 |
/* AT command: AT+CWLAP */ |
|
78 |
extern int esp32_list_ap(comport_t *comport, char *buf, int size); |
|
79 |
|
|
80 |
/* AT command: AT+CWJAP */ |
|
81 |
extern int esp32_connect_ap(comport_t *comport, char *ssid, char *pwd); |
|
82 |
|
|
83 |
/* AT command: AT+CWQAP */ |
|
84 |
extern int esp32_disconn_ap(comport_t *comport); |
|
85 |
|
|
86 |
/* AT command: AT+CWSTATE? , status value: |
|
87 |
* - 0: ESP32 station has not started any Wi-Fi connection. |
|
88 |
* - 1: ESP32 station has connected to an AP, but does not get an IPv4 address yet. |
|
89 |
* - 2: ESP32 station has connected to an AP, and got an IPv4 address. |
|
90 |
* - 3: ESP32 station is in Wi-Fi connecting or reconnecting state. |
|
91 |
* - 4: ESP32 station is in Wi-Fi disconnected state |
|
92 |
*/ |
|
93 |
extern int esp32_join_status(comport_t *comport, int *status, char *ssid); |
|
94 |
|
|
95 |
/* AT command: AT+PING */ |
|
96 |
extern int esp32_ping(comport_t *comport, char *host, int timeout); |
|
97 |
|
|
98 |
/* AT command: AT+CWSAP */ |
|
99 |
typedef enum |
|
100 |
{ |
|
101 |
MODE_OPEN, |
|
102 |
/* WEP not support */ |
|
103 |
MODE_WPAPSK = 2, |
|
104 |
MODE_WPA2PSK, |
|
105 |
MODE_WPA_WPA2PSK, |
|
106 |
} encmode_t; |
|
107 |
extern int esp32_set_softap(comport_t *comport, char *ssid, char *pwd, int channel, encmode_t encmode); |
|
108 |
|
|
109 |
/* AT command: AT+CWLIF */ |
|
110 |
extern int esp32_list_client(comport_t *comport, char *buf, int size); |
|
111 |
|
|
112 |
|
|
113 |
/*+------------------------+ |
|
114 |
*| Socket AT command | |
|
115 |
*+------------------------+*/ |
|
116 |
|
|
117 |
/* AT command: CIPMUX */ |
|
118 |
extern int esp32_set_socket_mux(comport_t *comport, int enable); |
|
119 |
|
|
120 |
/* AT command: AT+CIPSERVERMAXCONN */ |
|
121 |
extern int esp32_set_socket_clients(comport_t *comport, int max); |
|
122 |
|
|
123 |
/* AT command: AT+CIPSTO, timeout unit second */ |
|
124 |
extern int esp32_set_socket_timeout(comport_t *comport, int timeout); |
|
125 |
|
|
126 |
/* AT command: AT+CIPSERVER */ |
|
127 |
extern int esp32_set_tcp_server(comport_t *comport, int port); |
|
128 |
|
|
129 |
/* AT command: AT+CIPSERVER */ |
|
130 |
extern int esp32_del_tcp_server(comport_t *comport, int port); |
|
131 |
|
|
132 |
/* AT command: AT+CIPSTART */ |
|
133 |
extern int esp32_set_tcp_client(comport_t *comport, int mux, char *host, int port); |
|
134 |
|
|
135 |
/*+------------------------+ |
|
136 |
*| BLE AT command | |
|
137 |
*+------------------------+*/ |
|
138 |
// RFU |
|
139 |
|
|
140 |
#endif /* ----- #ifndef _AT_ESP32_H_ ----- */ |