/*********************************************************************************
|
* Copyright: (C) 2023 LingYun IoT System Studio.
|
* All rights reserved.
|
*
|
* Filename: at-esp32.h
|
* Description: This file is ESP32 AT command low level API functions
|
*
|
* Version: 1.0.0(11/08/23)
|
* Author: Guo Wenxue <guowenxue@gmail.com>
|
* ChangeLog: 1, Release initial version on "11/08/23 16:18:43"
|
*
|
********************************************************************************/
|
|
#ifndef _AT_ESP32_H_
|
#define _AT_ESP32_H_
|
|
#include "atcmd.h"
|
|
enum
|
{
|
DISABLE = 0, /* common disable */
|
ENABLE, /* common enable */
|
};
|
|
#define MAC_LEN 18 /* 11:22:33:44:55:66 */
|
#define IP_LEN 16 /* 255.255.255.255 */
|
|
/*+------------------------+
|
*| Baisc AT command |
|
*+------------------------+*/
|
|
/* AT command: AT+RST */
|
extern int esp32_reset(comport_t *comport);
|
|
/* AT command: AT+RESTORE */
|
extern int esp32_restore(comport_t *comport);
|
|
/* AT command: ATE1 or ATE0 */
|
extern int esp32_set_echo(comport_t *comport, int enable);
|
|
/* AT command: AT+GMR */
|
extern int esp32_get_firmware(comport_t *comport, char *version, int size);
|
|
/* AT command: AT+SYSSTORE */
|
extern int esp32_set_sysstore(comport_t *comport, int enable);
|
|
|
/*+------------------------+
|
*| WiFi AT command |
|
*+------------------------+*/
|
typedef enum
|
{
|
MODE_DISABLE=0, /* Wi-Fi RF will be disabled */
|
MODE_STATION, /* Station mode */
|
MODE_SOFTAP, /* SoftAP mode */
|
MODE_WDS, /* Wireless Distribution System: Both Station & SoftAP mode */
|
} workmode_t;
|
|
/* AT command: AT+CWMODE */
|
extern int esp32_set_wmode(comport_t *comport, workmode_t mode, int autoconn);
|
|
/* AT command: AT+CWDHCP */
|
extern int esp32_set_dhcp(comport_t *comport, workmode_t mode, int enable);
|
|
/* AT command: AT+CWAUTOCONN */
|
extern int esp32_set_autoconn(comport_t *comport, int enable);
|
|
/* AT command: AT+CIPSTAMAC/CIPAPMAC */
|
extern int esp32_get_macaddr(comport_t *comport, workmode_t mode, char *mac);
|
|
/* AT command: AT+CIPSTA/CIPAP */
|
extern int esp32_get_ipaddr(comport_t *comport, workmode_t mode, char *ip, char *gateway);
|
|
/* AT command: AT+CIPSTA/AT+CIPAP */
|
extern int esp32_set_ipaddr(comport_t *comport, workmode_t mode, char *ip, char *gateway);
|
|
/* AT command: AT+CWLAP */
|
extern int esp32_list_ap(comport_t *comport, char *buf, int size);
|
|
/* AT command: AT+CWJAP */
|
extern int esp32_connect_ap(comport_t *comport, char *ssid, char *pwd);
|
|
/* AT command: AT+CWQAP */
|
extern int esp32_disconn_ap(comport_t *comport);
|
|
/* AT command: AT+CWSTATE? , status value:
|
* - 0: ESP32 station has not started any Wi-Fi connection.
|
* - 1: ESP32 station has connected to an AP, but does not get an IPv4 address yet.
|
* - 2: ESP32 station has connected to an AP, and got an IPv4 address.
|
* - 3: ESP32 station is in Wi-Fi connecting or reconnecting state.
|
* - 4: ESP32 station is in Wi-Fi disconnected state
|
*/
|
extern int esp32_join_status(comport_t *comport, int *status, char *ssid);
|
|
/* AT command: AT+PING */
|
extern int esp32_ping(comport_t *comport, char *host, int timeout);
|
|
/* AT command: AT+CWSAP */
|
typedef enum
|
{
|
MODE_OPEN,
|
/* WEP not support */
|
MODE_WPAPSK = 2,
|
MODE_WPA2PSK,
|
MODE_WPA_WPA2PSK,
|
} encmode_t;
|
extern int esp32_set_softap(comport_t *comport, char *ssid, char *pwd, int channel, encmode_t encmode);
|
|
/* AT command: AT+CWLIF */
|
extern int esp32_list_client(comport_t *comport, char *buf, int size);
|
|
|
/*+------------------------+
|
*| Socket AT command |
|
*+------------------------+*/
|
|
/* AT command: CIPMUX */
|
extern int esp32_set_socket_mux(comport_t *comport, int enable);
|
|
/* AT command: AT+CIPSERVERMAXCONN */
|
extern int esp32_set_socket_clients(comport_t *comport, int max);
|
|
/* AT command: AT+CIPSTO, timeout unit second */
|
extern int esp32_set_socket_timeout(comport_t *comport, int timeout);
|
|
/* AT command: AT+CIPSERVER */
|
extern int esp32_set_tcp_server(comport_t *comport, int port);
|
|
/* AT command: AT+CIPSERVER */
|
extern int esp32_del_tcp_server(comport_t *comport, int port);
|
|
/* AT command: AT+CIPSTART */
|
extern int esp32_set_tcp_client(comport_t *comport, int mux, char *host, int port);
|
|
/*+------------------------+
|
*| BLE AT command |
|
*+------------------------+*/
|
// RFU
|
|
#endif /* ----- #ifndef _AT_ESP32_H_ ----- */
|