0
0
Fork 0
wireless-proxy-esp32/project_components/wifi_manager/wifi_api.h

86 lines
2.3 KiB
C

#ifndef WIFI_API_H_GUARD
#define WIFI_API_H_GUARD
#include <lwip/ip4_addr.h>
#define WIFI_MODULE_ID 1
typedef enum wifi_api_json_cmd_t {
UNKNOWN = 0,
WIFI_API_JSON_STA_GET_AP_INFO = 1,
WIFI_API_JSON_CONNECT = 2,
WIFI_API_JSON_GET_SCAN = 3,
WIFI_API_JSON_DISCONNECT = 4,
WIFI_API_JSON_AP_GET_INFO = 5,
WIFI_API_JSON_GET_MODE = 6, /* req:{ }, ret:{mode, [delay_off], [delay_on]} */
WIFI_API_JSON_SET_MODE = 7, /* req:{mode, [delay_off], [delay_on]} */
WIFI_API_JSON_SET_AP_CRED = 8, /* ssid[32] + password[64] */
WIFI_API_JSON_STA_GET_STATIC_INFO = 9,
WIFI_API_JSON_STA_SET_STATIC_CONF = 10, /* static_ip_en: 0/1, static_dns_en: 0/1 */
} wifi_api_json_cmd_t;
typedef struct wifi_api_ap_info_t {
ip4_addr_t ip;
ip4_addr_t gateway;
ip4_addr_t netmask;
char ssid[32+1];
char password[64+1];
char mac[6];
signed char rssi;
ip4_addr_t dns_main;
ip4_addr_t dns_backup;
} wifi_api_ap_info_t;
typedef struct wifi_api_ap_scan_info_t {
ip4_addr_t ip;
ip4_addr_t gateway;
ip4_addr_t netmask;
char ssid[32+1];
char mac[6];
signed char rssi;
} wifi_api_ap_scan_info_t;
typedef struct wifi_api_sta_ap_static_info_t {
ip4_addr_t ip;
ip4_addr_t gateway;
ip4_addr_t netmask;
ip4_addr_t dns_main;
ip4_addr_t dns_backup;
uint8_t static_ip_en;
uint8_t static_dns_en;
} wifi_api_sta_ap_static_info_t;
typedef enum wifi_apsta_mode_e {
/* permanent */
WIFI_AP_AUTO_STA_ON = 0,
WIFI_AP_STA_OFF = 4, /* 100 */
WIFI_AP_OFF_STA_ON = 5, /* 101 */
WIFI_AP_ON_STA_OFF = 6, /* 110 */
WIFI_AP_STA_ON = 7, /* 111 */
/* temporary */
WIFI_AP_STOP = 8,
WIFI_AP_START = 9,
WIFI_STA_STOP = 10,
WIFI_STA_START = 11,
} wifi_apsta_mode_e;
void wifi_api_sta_get_ap_info(wifi_api_ap_info_t *ap_info);
void wifi_api_ap_get_info(wifi_api_ap_info_t *ap_info);
typedef void (*wifi_api_scan_done_cb)(uint16_t found, wifi_api_ap_scan_info_t *aps, void *arg);
int wifi_api_trigger_scan(uint16_t *max_ap_count, wifi_api_scan_done_cb cb, void *cb_arg);
int wifi_api_get_scan_list(uint16_t *number, wifi_api_ap_scan_info_t *ap_info);
int wifi_api_connect(const char *ssid, const char *password);
int wifi_api_disconnect(void);
int wifi_api_sta_set_static_conf(wifi_api_sta_ap_static_info_t *static_info);
#endif //WIFI_API_H_GUARD