Access point

group ESP_AP

Access point.

Functions to manage access point (AP) on ESP device.

In order to be able to use AP feature, ESP_CFG_MODE_ACCESS_POINT must be enabled.

Functions

espr_t esp_ap_getip(esp_ip_t *ip, esp_ip_t *gw, esp_ip_t *nm, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Get IP of access point.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [out] ip: Pointer to variable to write IP address

  • [out] gw: Pointer to variable to write gateway address

  • [out] nm: Pointer to variable to write netmask address

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_setip(const esp_ip_t *ip, const esp_ip_t *gw, const esp_ip_t *nm, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Set IP of access point.

Configuration changes will be saved in the NVS area of ESP device.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] ip: Pointer to IP address

  • [in] gw: Pointer to gateway address. Set to NULL to use default gateway

  • [in] nm: Pointer to netmask address. Set to NULL to use default netmask

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_getmac(esp_mac_t *mac, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Get MAC of access point.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [out] mac: Pointer to output variable to save MAC address

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_setmac(const esp_mac_t *mac, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Set MAC of access point.

Configuration changes will be saved in the NVS area of ESP device.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] mac: Pointer to variable with MAC address. Memory of at least 6 bytes is required

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_get_config(esp_ap_conf_t *ap_conf, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Get configuration of Soft Access Point.

Note

Before you can get configuration access point, ESP device must be in AP mode. Check esp_set_wifi_mode for more information

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [out] ap_conf: soft access point configuration

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_configure(const char *ssid, const char *pwd, uint8_t ch, esp_ecn_t ecn, uint8_t max_sta, uint8_t hid, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Configure access point.

Configuration changes will be saved in the NVS area of ESP device.

Note

Before you can configure access point, ESP device must be in AP mode. Check esp_set_wifi_mode for more information

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] ssid: SSID name of access point

  • [in] pwd: Password for network. Either set it to NULL or less than 64 characters

  • [in] ch: Wifi RF channel

  • [in] ecn: Encryption type. Valid options are OPEN, WPA_PSK, WPA2_PSK and WPA_WPA2_PSK

  • [in] max_sta: Maximal number of stations access point can accept. Valid between 1 and 10 stations

  • [in] hid: Set to 1 to hide access point from public access

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_list_sta(esp_sta_t *sta, size_t stal, size_t *staf, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

List stations connected to access point.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] sta: Pointer to array of esp_sta_t structure to fill with stations

  • [in] stal: Number of array entries of sta parameter

  • [out] staf: Number of stations connected to access point

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

espr_t esp_ap_disconn_sta(const esp_mac_t *mac, const esp_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Disconnects connected station from SoftAP access point.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] mac: Device MAC address to disconnect. Application may use esp_ap_list_sta to obtain list of connected stations to SoftAP.

  • [in] evt_fn: Callback function called when command has finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

struct esp_ap_t
#include <esp_typedefs.h>

Access point data structure.

Public Members

esp_ecn_t ecn

Encryption mode

char ssid[ESP_CFG_MAX_SSID_LENGTH]

Access point name

int16_t rssi

Received signal strength indicator

esp_mac_t mac

MAC physical address

uint8_t ch

WiFi channel used on access point

uint8_t bgn

Information about 802.11[b|g|n] support

struct esp_sta_info_ap_t
#include <esp_typedefs.h>

Access point information on which station is connected to.

Public Members

char ssid[ESP_CFG_MAX_SSID_LENGTH]

Access point name

int16_t rssi

RSSI

esp_mac_t mac

MAC address

uint8_t ch

Channel information

struct esp_ap_conf_t
#include <esp_typedefs.h>

Soft access point data structure.

Public Members

char ssid[ESP_CFG_MAX_SSID_LENGTH]

Access point name

char pwd[ESP_CFG_MAX_PWD_LENGTH]

Access point password/passphrase

uint8_t ch

WiFi channel used on access point

esp_ecn_t ecn

Encryption mode

uint8_t max_cons

Maximum number of stations allowed connected to this AP

uint8_t hidden

broadcast the SSID, 0 No, 1 Yes