From c13c9806f957ebc675462737f4b328d3ab89e028 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Mon, 10 Jul 2023 17:29:22 +0800 Subject: [PATCH] update gpsd.c --- gpsd/booster/at-esp32.h | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 0 deletions(-) diff --git a/gpsd/booster/at-esp32.h b/gpsd/booster/at-esp32.h new file mode 100644 index 0000000..26febee --- /dev/null +++ b/gpsd/booster/at-esp32.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2022 Guo Wenxue + * Author: Guo Wenxue <guowenxue@gmail.com> + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GPL license. + */ + +#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_ ----- */ -- Gitblit v1.9.1