- This demo application showcases a way to configure control path.
- App is available under directory c_support/
- App interacts with
Hosted Control Library
using control path APIs. APIs header could be found at ctrl_api.h
- This demo app works over Hosted Control Library
- Source files are test.c and test_utils.c
- Config file : ctrl_config.h
- Below is a list of control path commands showcased in demo app
Command line argument | Operation |
---|---|
get_sta_mac_addr | Get Mac address of Wi-Fi in station mode |
get_softap_mac_addr | Get Mac address of Wi-Fi in softAP mode |
set_sta_mac_addr | Set Mac address of Wi-Fi in station mode |
set_softap_mac_addr | Set Mac address of Wi-Fi in softAP mode |
get_wifi_mode | Get current Wi-Fi mode |
set_wifi_mode | Set Wi-Fi mode |
get_ap_scan_list | Get neighboring AP (Wi-Fi routers or Hotspot) list |
sta_connect | Connect ESP station to external AP(Wi-Fi router or hotspot), assign MAC address of ESP station to ethsta0 and up ethsta0 interface |
get_sta_config | Get details of connected AP in station mode |
sta_disconnect | Disconnect ESP station from external AP and down ethsta0 interface |
set_softap_vendor_ie | Set vendor information element for ESP softAP |
reset_softap_vendor_ie | Reset vendor information element for ESP softAP |
softap_start | Start ESP softAP, assign MAC address of ESP softAP to ethap0 and up ethap0 interface |
get_softap_config | Get softAP configuration |
softap_connected_sta_list | Get connected station info of softAP |
softap_stop | Stop ESP softAP stop and down ethap0 interface |
set_wifi_powersave_mode | Set Wi-Fi Power save mode |
get_wifi_powersave_mode | Get Wi-Fi Power save mode |
set_wifi_max_tx_power | Sets Wi-Fi maximum transmitting power |
get_wifi_curr_tx_power | Get Wi-Fi current transmitting power |
ota </path/to/ota_image.bin> | performs OTA operation using local OTA binary file |
get_fw_version | Get firmware version |
enable_wifi | Enable Wi-Fi driver |
disable_wifi | Disable Wi-Fi driver |
enable_bt | Enable Bluetooth driver |
disable_bt | Disable Bluetooth driver |
It uses APIs present in ctrl_api.h. User should first modify configuration parameters in ctrl_config.h. Then run make
in c_support/ to compile test.c
.
Please execute test.out
as below.
$ make
$ sudo ./test.out \
[ get_sta_mac_addr || get_softap_mac_addr || set_sta_mac_addr || \
set_softap_mac_addr || get_wifi_mode || set_wifi_mode || \
get_ap_scan_list || sta_connect || get_sta_config || \
sta_disconnect || set_softap_vendor_ie || reset_softap_vendor_ie || \
softap_start || get_softap_config || softap_connected_sta_list || \
softap_stop || set_wifi_powersave_mode || get_wifi_powersave_mode || \
set_wifi_max_tx_power || get_wifi_curr_tx_power || \
ota </path/to/esp_firmware_network_adapter.bin> || \
enable_wifi || disable_wifi || enable_bt || disable_bt || get_fw_version
]
For example,
$ sudo ./test.out get_wifi_mode
-
Connect to AP in station mode
- After
sta_connect
, User needs to run the DHCP client to obtain an IP address from an external AP. Then network data path will be open for higher applications to useethsta0
interface for data communication. For an example as below.
$ sudo dhclient ethsta0 -r $ sudo dhclient ethsta0 -v
- After
-
Disconnect AP in station mode
- After disconnect, user can remove DHCP lease. For example,
$ sudo dhclient ethsta0 -r
-
For softAP vendor specific IE
set_softap_vendor_ie
will be in effect only if it is done before starting of ESP softAP- Once vendor IE set, consecutive
set_softap_vendor_ie
will fail unless vendor IE is reset usingreset_softap_vendor_ie
or ESP reboot
-
SoftAP start
- After
softap_start
to start data connection, set up a DHCP server on the Raspberry Pi, or configure a static IP address for AP interface (ethap0
). For an example as below:
$ sudo dnsmasq --no-daemon --no-resolv --no-poll --dhcp-script=/system/bin/dhcp_announce --dhcp-range=192.168.4.1,192.168.4.20,1h $ sudo ifconfig ethap0 192.168.4.5
- After
-
SoftAP stop
- After stopping softAP, dnsmasq could be down/killed as per user expectation
-
OTA
- The OTA update using C currently assumes the complete binary is downloaded locally
- OTA update using HTTP URL is only supported in python demo app
- In case HTTP based OTA update is desired, user can do the same using third party HTTP client library
ex. ./test.out ota </path/to/ota_image.bin>
-
Set Wi-Fi max transmit power
- This is just a request to Wi-Fi driver. The actual power set may slightly differ from exact requested power.
stress.c use for stress testing of control path APIs. It is very similar to demo app, just additionally allows multiple iteration testing.
- Source files are stress.c and test_utils.c
- Config file : ctrl_config.h
- Change expected configuration from config file
- Run
make stress
in c_support directory to compilestress.c
. - Please execute
stress.out
as below.
$ sudo ./stress.out <Number of test iterations> [get_sta_mac_addr] [get_softap_mac_addr] \
[set_sta_mac_addr] [set_softap_mac_addr] [get_wifi_mode] [set_wifi_mode] \
[get_ap_scan_list] [sta_connect] [get_sta_config] [sta_disconnect] \
[set_softap_vendor_ie] [reset_softap_vendor_ie] [softap_start] \
[get_softap_config] [softap_connected_sta_list] [softap_stop] \
[set_wifi_powersave_mode] [get_wifi_powersave_mode] [set_wifi_max_tx_power] \
[get_wifi_curr_tx_power] [ota </path/to/esp_firmware_network_adaptor.bin>]
For example:
$ sudo ./stress.out 10 scan sta_connect sta_disconnect ap_start sta_list ap_stop wifi_tx_power