FTM support for ESP32-C3 and connectionless mode

1. Support for FTM to work without any connection
1. Support for ESP32-C3 chip
3. Fix error case handling if FTM fails
4. Fix asynchronization, re-transmission related issues
This commit is contained in:
Nachiket Kukade
2021-01-26 12:49:18 +05:30
parent a71976ab54
commit 8de3b31d2d
9 changed files with 151 additions and 120 deletions

View File

@ -331,42 +331,42 @@ menu "Wi-Fi"
If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option.
Wi-Fi power-save mode average current would be reduced if this option is enabled.
config ESP32S2_WIFI_FTM_INITIATOR_SUPPORT
config ESP_WIFI_FTM_INITIATOR_SUPPORT
bool "FTM Initiator support"
default y
depends on IDF_TARGET_ESP32S2
depends on (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3)
config ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
config ESP_WIFI_FTM_REPORT_LOG_ENABLE
bool "FTM Report logging"
default n
depends on ESP32S2_WIFI_FTM_INITIATOR_SUPPORT
depends on ESP_WIFI_FTM_INITIATOR_SUPPORT
help
Select this option to get a detailed report of FTM Procedure with raw values
config ESP32S2_WIFI_FTM_REPORT_SHOW_RTT
depends on ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
config ESP_WIFI_FTM_REPORT_SHOW_RTT
depends on ESP_WIFI_FTM_REPORT_LOG_ENABLE
bool "Show RTT values"
default y
config ESP32S2_WIFI_FTM_REPORT_SHOW_DIAG
depends on ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
config ESP_WIFI_FTM_REPORT_SHOW_DIAG
depends on ESP_WIFI_FTM_REPORT_LOG_ENABLE
bool "Show dialog tokens"
default y
config ESP32S2_WIFI_FTM_REPORT_SHOW_T1T2T3T4
depends on ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
config ESP_WIFI_FTM_REPORT_SHOW_T1T2T3T4
depends on ESP_WIFI_FTM_REPORT_LOG_ENABLE
bool "Show T1 to T4"
default y
config ESP32S2_WIFI_FTM_REPORT_SHOW_RSSI
depends on ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
config ESP_WIFI_FTM_REPORT_SHOW_RSSI
depends on ESP_WIFI_FTM_REPORT_LOG_ENABLE
bool "Show RSSI levels"
default y
config ESP32S2_WIFI_FTM_RESPONDER_SUPPORT
config ESP_WIFI_FTM_RESPONDER_SUPPORT
bool "FTM Responder support"
default y
depends on IDF_TARGET_ESP32S2
depends on (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3)
endmenu # Wi-Fi

View File

@ -1156,16 +1156,18 @@ esp_err_t esp_wifi_statis_dump(uint32_t modules);
esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi);
/**
* @brief Start FTM Initiator session
* If successful, event WIFI_EVENT_FTM_REPORT is generated with the result of the FTM procedure
* @brief Start an FTM Initiator session by sending FTM request
* If successful, event WIFI_EVENT_FTM_REPORT is generated with the result of the FTM procedure
*
* @param cfg FTM Initiator configurations
* @attention Use this API only in Station mode
*
* @param cfg FTM Initiator session configuration
*
* @return
* - ESP_OK: succeed
* - others: failed
*/
esp_err_t esp_wifi_ftm_start_initiator(wifi_ftm_initiator_cfg_t *cfg);
esp_err_t esp_wifi_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg);
#ifdef __cplusplus
}

View File

@ -522,6 +522,8 @@ typedef struct {
*
*/
typedef struct {
uint8_t resp_mac[6]; /**< MAC address of the FTM Responder */
uint8_t channel; /**< Primary channel of the FTM Responder */
uint8_t frm_count; /**< No. of FTM frames requested in terms of 4 or 8 bursts (allowed values - 0(No pref), 16, 24, 32, 64) */
uint16_t burst_period; /**< Requested time period between consecutive FTM bursts in 100's of milliseconds (0 - No pref) */
} wifi_ftm_initiator_cfg_t;

View File

@ -56,10 +56,10 @@ uint64_t g_wifi_feature_caps =
#if (CONFIG_ESP32_SPIRAM_SUPPORT | CONFIG_ESP32S2_SPIRAM_SUPPORT)
CONFIG_FEATURE_CACHE_TX_BUF_BIT |
#endif
#if CONFIG_ESP32S2_WIFI_FTM_INITIATOR_SUPPORT
#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
CONFIG_FEATURE_FTM_INITIATOR_BIT |
#endif
#if CONFIG_ESP32S2_WIFI_FTM_RESPONDER_SUPPORT
#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT
CONFIG_FEATURE_FTM_RESPONDER_BIT |
#endif
0;
@ -255,23 +255,21 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
}
adc2_cal_include(); //This enables the ADC2 calibration constructor at start up.
#if CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_ESP32S2_WIFI_FTM_REPORT_LOG_ENABLE
#ifdef CONFIG_ESP_WIFI_FTM_REPORT_LOG_ENABLE
ftm_report_log_level_t log_lvl = {0};
#ifdef CONFIG_ESP32S2_WIFI_FTM_REPORT_SHOW_RTT
#ifdef CONFIG_ESP_WIFI_FTM_REPORT_SHOW_RTT
log_lvl.show_rtt = 1;
#endif
#ifdef CONFIG_ESP32S2_WIFI_FTM_REPORT_SHOW_DIAG
#ifdef CONFIG_ESP_WIFI_FTM_REPORT_SHOW_DIAG
log_lvl.show_diag = 1;
#endif
#ifdef CONFIG_ESP32S2_WIFI_FTM_REPORT_SHOW_T1T2T3T4
#ifdef CONFIG_ESP_WIFI_FTM_REPORT_SHOW_T1T2T3T4
log_lvl.show_t1t2t3t4 = 1;
#endif
#ifdef CONFIG_ESP32S2_WIFI_FTM_REPORT_SHOW_RSSI
#ifdef CONFIG_ESP_WIFI_FTM_REPORT_SHOW_RSSI
log_lvl.show_rxrssi = 1;
#endif
esp_wifi_set_ftm_report_log_level(&log_lvl);
#endif
#endif
esp_wifi_config_info();
return result;

View File

@ -1459,7 +1459,7 @@ For establishing a secure connection, AP and Station negotiate and agree on the
Detailed information on creating certificates and how to run wpa2_enterprise example on {IDF_TARGET_NAME} can be found in :example:`wifi/wpa2_enterprise`.
.. only:: esp32s2
.. only:: esp32s2 or esp32c3
Wi-Fi Location
-------------------------------
@ -1473,8 +1473,8 @@ FTM is used to measure Wi-Fi Round Trip Time (Wi-Fi RTT) which is the time a WiF
FTM uses timestamps given by WiFi interface hardware at the time of arrival or departure of frames exchanged between a pair of devices. One entity called FTM Initiator (mostly a Station device) discovers the FTM Responder (can be a Station or an Access Point) and negotiates to start an FTM procedure. The procedure uses multiple Action frames sent in bursts and its ACK's to gather the timestamps data. FTM Initiator gathers the data in the end to calculate an average Round-Trip-Time.
{IDF_TARGET_NAME} supports FTM in below configuration:
- {IDF_TARGET_NAME} as FTM Initiator in Station mode with the associated AP acting as FTM Responder.
- {IDF_TARGET_NAME} as FTM Responder in SoftAP mode with an associated Station acting as FTM Initiator.
- {IDF_TARGET_NAME} as FTM Initiator in Station mode.
- {IDF_TARGET_NAME} as FTM Responder in SoftAP mode.
Distance measurement using RTT is not accurate, factors such as RF interference, multi-path travel, antenna orientation and lack of calibration increase these inaccuracies. For better results it is suggested to perform FTM between two {IDF_TARGET_NAME} devices as Station and SoftAP.
Refer to IDF example :idf_file:`examples/wifi/ftm/README.md` for steps on how to setup and perform FTM.

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 |
| ----------------- | -------- |
| Supported Targets | ESP32-S2 | ESP32-C3 |
| ----------------- | -------- | -------- |
# FTM Example
@ -20,32 +20,30 @@ Wi-Fi RTT is calculated using a procedure called Fine Timing Measurement(FTM). D
> T4[i] : TOA of i'th ACK at Responder
Average RTT is calculated over all such pairs to get a more accurate result.
In this example, FTM procedure is supported only between a Station(ESP32S2) and an AP it is connected to. The AP can be a SoftAP(ESP32S2) or an External AP that supports FTM Responder mode.
Use this example to perform FTM between a Station and a SoftAP or en external AP that supports FTM Responder mode. Both Station and SoftAP need to be run on the supported ESP targets that support FTM and have it enabled.
## How to use example
With this example, users can scan for AP's that support FTM Responder role, connect with them and perform FTM procedure with different configurations. Below steps show how to do this using 2 ESP32-S2's in Station and SoftAP mode.
First make sure that FTM Initiator support on Station and FTM Responder support on SoftAP is enabled in the example configuration menu. For this, open project configuration menu (`idf.py menuconfig`), navigate to `Component config -> Wi-Fi` and check `FTM Initiator support` on Station build and `FTM Responder support` on SoftAP build. Furthermore for getting a per frame detailed report of the FTM procedure, enable `FTM Report logging` option.
Build and flash the example on respective ESP32-S2's to see below output -
With this example, users can scan for AP's that support FTM Responder role and perform FTM procedure with different configurations. Below steps show how to do this using 2 devices in Station and SoftAP mode.
First make sure that `FTM Initiator support` on Station and `FTM Responder support` on SoftAP is enabled in the project configuration menu (`idf.py menuconfig`). These options are located in `Component config -> Wi-Fi`. Furthermore for getting a per frame detailed report of the FTM procedure on the console, enable `FTM Report logging` option. Users can also access this report data in the example code.
Build and flash the example on a supported device to see below output -
```bash
==========================================================
| Steps to test FTM |
| |
| 1. Print 'help' to gain overview of commands |
| 2. Use 'scan' command for AP that support FTM |
| 1. Use 'help' to gain overview of commands |
| 2. Use 'scan' command to search for external AP's |
| OR |
| 2. Start SoftAP on another ESP32S2 with 'ap' command |
| 3. Setup connection with the AP using 'sta' command |
| 4. Initiate FTM from Station using 'ftm -I' command |
| 2. Start SoftAP on another device using 'ap' command |
| 3. Start FTM with command 'ftm -I -s <SSID>' |
| |
==========================================================
ftm>
```
Use `help` to get a list of available commands and options. Use `scan` command to scan for AP's that support FTM Responder mode.
Before testing FTM with an external AP, make sure that `FTM Responder` is visible in the respective scan result entry.
Before initiating FTM with an external AP, make sure that `FTM Responder` is visible in the respective scan result entry.
```bash
ftm> scan
@ -58,7 +56,7 @@ I (478815) ftm_station: [Velop][rssi=-115]
I (478825) ftm_station: sta scan done
```
AP's that support FTM Responder mode can be seen in the scan results. Or setup a SoftAP using another ESP32-S2 device using the `ap` command -
AP's that support FTM Responder mode can be seen in the scan results. Or setup a SoftAP on another device using the `ap` command -
```bash
ftm> ap FTM password
@ -66,53 +64,34 @@ I (91271) ftm_ap: Starting SoftAP with FTM Responder support, SSID - FTM, Passwo
ftm>
```
Use command `sta <ssid> [<pass>]` to connect with an eligible AP. Then simply issue `ftm -I` to initiate a session with default configuration of 32 FTM frames. For more configurations below options are available -
`ftm [-I] [-c <0/16/24/32/64>] [-p <0-255 (x 100 mSec)>]`
Issue `ftm -I` to initiate a session with default configuration of 32 FTM frames. For more configurations below options are available -
`ftm [-I] [-c <0/16/24/32/64>] [-p <2-255 (x 100 mSec)>] [-s SSID]`
Where -
* `-I` OR `--ftm_initiator`: FTM Initiator mode
* `-c` OR `--frm_count`: FTM frames to be exchanged (Valid values: 0=No preference, 16, 24, 32, 64, default: 32)
* `-p` OR `--burst_period`: Periodicity of FTM bursts in 100's of miliseconds (0: No preference, default: 2)
* `-s` OR `--ssid=SSID`: SSID of AP that supports FTM Responder mode
Currently FTM is only supported in below configuration -
1. Station(ESP32-S2) as Initiator in connected mode with SoftAP(ESP32-S2) as Responder
2. Station(ESP32-S2) as Initiator in connected mode with external AP as Responder
The first option should be preferred since ESP32-S2 is self calibrated for high resolution measurement. Support for more configurations like STA to STA with ASAP mode will follow in future updates.
1. Station as Initiator and SoftAP as Responder on supported ESP devices
2. Station as Initiator and an external AP that supports FTM in Responder mode
The first option should be preferred since ESP devices are self calibrated for high resolution measurement. FTM Responder support for external Stations and ASAP mode will follow in future updates.
## Example Output
Example output of an FTM Procedure -
```bash
ftm> ftm -I
I (13796) ftm_station: Starting FTM Initiator with Frm Count 32, Burst Period - 200mSec
ftm> W (23696) wifi:FTM report:
W (23696) wifi:| Diag | RTT | RSSI | T1 | T2 | T3 | T4 |
W (23706) wifi:| 3| 24850 | -18 |13598650592600 | 3973101843750 | 3973205662500 |13598754436200 |
W (23716) wifi:| 5| 32662 | -18 |13600546592600 | 3974997826562 | 3975101662500 |13600650461200 |
W (23726) wifi:| 7| 31100 | -18 |14498977692600 | 4873420043750 | 4873523662500 |14499081342450 |
W (23736) wifi:| 9| 29412 | -18 |14500856692600 | 4875299026562 | 4875402662500 |14500960357950 |
W (23746) wifi:| 11| 24850 | -18 |15399235817600 | 5773669262500 | 5773785662500 |15399352242450 |
W (23756) wifi:| 12| 27975 | -18 |15400258817600 | 5774692253125 | 5774796662500 |15400363254950 |
W (23766) wifi:| 13| 26287 | -18 |15401215817600 | 5775649242187 | 5775753662500 |15401320264200 |
W (23776) wifi:| 14| 24725 | -18 |15402158817600 | 5776592234375 | 5776696662500 |15402263270450 |
W (23786) wifi:| 15| 24850 | -18 |16298632917600 | 6673057456250 | 6673173662500 |16298749148700 |
W (23796) wifi:| 16| 29412 | -18 |16299698917600 | 6674123445312 | 6674227662500 |16299803164200 |
W (23796) wifi:| 17| 26287 | -18 |16300637917600 | 6675062435937 | 6675166662500 |16300742170450 |
W (23816) wifi:| 18| 27975 | -18 |16301580917600 | 6676005428125 | 6676109662500 |16301685179950 |
W (23826) wifi:| 19| 27850 | -18 |17198977042600 | 862506262500 | 862622262500 |17199093070450 |
W (23836) wifi:| 20| 23162 | -18 |17200051042600 | 863580251562 | 863684262500 |17200155076700 |
W (23846) wifi:| 21| 31100 | -18 |17200991042600 | 864520243750 | 864624262500 |17201095092450 |
W (23846) wifi:| 22| 26412 | -18 |17201930042600 | 865459232812 | 865563262500 |17202034098700 |
W (23856) wifi:| 23| 31100 | -18 |18099333142600 | 1762853443750 | 1762969262500 |18099448992450 |
W (23876) wifi:| 24| 23162 | -18 |18100397142600 | 1763917432812 | 1764021262500 |18100500995450 |
W (23886) wifi:| 25| 26287 | -18 |18101336142600 | 1764856423437 | 1764960262500 |18101440007950 |
W (23896) wifi:| 26| 24850 | -18 |18102343142600 | 1765863412500 | 1765967262500 |18102447017450 |
W (23896) wifi:| 27| 31100 | -18 |19000187242600 | 2663698618750 | 2663814262500 |19000302917450 |
W (23906) wifi:| 28| 24725 | -18 |19001274242600 | 2664785609375 | 2664889262500 |19001377920450 |
W (23916) wifi:| 29| 31100 | -18 |19002225242600 | 2665736600000 | 2665840262500 |19002328936200 |
W (23936) wifi:| 31| 23287 | -19 |19004133242600 | 2667644579687 | 2667748262500 |19004236948700 |
W (23936) wifi:| 32| 26287 | -18 |19899976367600 | 3563478835937 | 3563595262500 |19900092820450 |
W (23946) wifi:FTM session ends with 25 valid readings out of 31, Avg raw RTT: 27.232 nSec, Avg RSSI: -18
I (23956) ftm_station: Estimated RTT - 13 nSec, Estimated Distance - 1.95 meters
ftm> scan
I (356414) ftm_station: sta start to scan
I (358514) ftm_station: [DigitalFortress][rssi=114]
I (358524) ftm_station: [TEST][rssi=-96][FTM Responder]
I (358524) ftm_station: sta scan done
ftm> ftm -I -s TEST
Starting FTM with 18:fe:34:72:50:c9 on channel 1
I (391824) ftm_station: Starting FTM Initiator with Frm Count 32, Burst Period - 200mSec
W (391834) wifi:Starting FTM session in 0.200 Sec
W (393564) wifi:FTM session ends with 26 valid readings out of 31, Avg raw RTT: 49.218 nSec, Avg RSSI: -1
I (393564) ftm_station: Estimated RTT - 33 nSec, Estimated Distance - 5.07 meters
```
The final statement gives the average calculated RTT along with an estimated distance between the Station and the AP. This distance is measured by first adjusting the RTT with any physical analog delays and a calibration delta. Distances measured using RTT are not perfectly accurate, and are subjected to various errors like RF interference, multi-path, path loss, orientations etc.

View File

@ -1,2 +1,2 @@
idf_component_register(SRCS "ftm_station_main.c"
idf_component_register(SRCS "ftm_main.c"
INCLUDE_DIRS ".")

View File

@ -37,6 +37,7 @@ typedef struct {
struct arg_lit *mode;
struct arg_int *frm_count;
struct arg_int *burst_period;
struct arg_str *ssid;
struct arg_end *end;
} wifi_ftm_args_t;
@ -59,29 +60,8 @@ const int FTM_FAILURE_BIT = BIT1;
wifi_ftm_report_entry_t *g_ftm_report;
uint8_t g_ftm_report_num_entries;
static void scan_done_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
uint16_t sta_number = 0;
uint8_t i;
wifi_ap_record_t *ap_list_buffer;
esp_wifi_scan_get_ap_num(&sta_number);
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
if (ap_list_buffer == NULL) {
ESP_LOGE(TAG_STA, "Failed to malloc buffer to print scan results");
return;
}
if (esp_wifi_scan_get_ap_records(&sta_number, (wifi_ap_record_t *)ap_list_buffer) == ESP_OK) {
for (i = 0; i < sta_number; i++) {
ESP_LOGI(TAG_STA, "[%s][rssi=%d]""%s", ap_list_buffer[i].ssid, ap_list_buffer[i].rssi,
ap_list_buffer[i].ftm_responder ? "[FTM Responder]" : "");
}
}
free(ap_list_buffer);
ESP_LOGI(TAG_STA, "sta scan done");
}
uint16_t g_scan_ap_num;
wifi_ap_record_t *g_ap_list_buffer;
static void wifi_connected_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
@ -141,11 +121,6 @@ void initialise_wifi(void)
ESP_ERROR_CHECK( esp_event_loop_create_default() );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
WIFI_EVENT_SCAN_DONE,
&scan_done_handler,
NULL,
NULL));
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
WIFI_EVENT_STA_CONNECTED,
&wifi_connected_handler,
@ -209,13 +184,40 @@ static int wifi_cmd_sta(int argc, char **argv)
return 0;
}
static bool wifi_cmd_sta_scan(const char *ssid)
static bool wifi_perform_scan(const char *ssid, bool internal)
{
wifi_scan_config_t scan_config = { 0 };
scan_config.ssid = (uint8_t *) ssid;
uint8_t i;
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_scan_start(&scan_config, false) );
ESP_ERROR_CHECK( esp_wifi_scan_start(&scan_config, true) );
esp_wifi_scan_get_ap_num(&g_scan_ap_num);
if (g_scan_ap_num == 0) {
ESP_LOGI(TAG_STA, "No matching AP found");
return false;
}
if (g_ap_list_buffer) {
free(g_ap_list_buffer);
}
g_ap_list_buffer = malloc(g_scan_ap_num * sizeof(wifi_ap_record_t));
if (g_ap_list_buffer == NULL) {
ESP_LOGE(TAG_STA, "Failed to malloc buffer to print scan results");
return false;
}
if (esp_wifi_scan_get_ap_records(&g_scan_ap_num, (wifi_ap_record_t *)g_ap_list_buffer) == ESP_OK) {
if (!internal) {
for (i = 0; i < g_scan_ap_num; i++) {
ESP_LOGI(TAG_STA, "[%s][rssi=%d]""%s", g_ap_list_buffer[i].ssid, g_ap_list_buffer[i].rssi,
g_ap_list_buffer[i].ftm_responder ? "[FTM Responder]" : "");
}
}
}
ESP_LOGI(TAG_STA, "sta scan done");
return true;
}
@ -231,9 +233,9 @@ static int wifi_cmd_scan(int argc, char **argv)
ESP_LOGI(TAG_STA, "sta start to scan");
if ( scan_args.ssid->count == 1 ) {
wifi_cmd_sta_scan(scan_args.ssid->sval[0]);
wifi_perform_scan(scan_args.ssid->sval[0], false);
} else {
wifi_cmd_sta_scan(NULL);
wifi_perform_scan(NULL, false);
}
return 0;
}
@ -309,9 +311,45 @@ static int wifi_cmd_query(int argc, char **argv)
return 0;
}
wifi_ap_record_t *find_ftm_responder_ap(const char *ssid)
{
bool retry_scan = false;
uint8_t i;
if (!ssid)
return NULL;
retry:
if (!g_ap_list_buffer || (g_scan_ap_num == 0)) {
ESP_LOGI(TAG_STA, "Scanning for %s", ssid);
if (false == wifi_perform_scan(ssid, true)) {
return NULL;
}
}
for (i = 0; i < g_scan_ap_num; i++) {
if (strcmp((const char *)g_ap_list_buffer[i].ssid, ssid) == 0)
return &g_ap_list_buffer[i];
}
if (!retry_scan) {
retry_scan = true;
if (g_ap_list_buffer) {
free(g_ap_list_buffer);
g_ap_list_buffer = NULL;
}
goto retry;
}
ESP_LOGI(TAG_STA, "No matching AP found");
return NULL;
}
static int wifi_cmd_ftm(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &ftm_args);
wifi_ap_record_t *ap_record;
wifi_ftm_initiator_cfg_t ftmi_cfg = {
.frm_count = 32,
@ -327,6 +365,18 @@ static int wifi_cmd_ftm(int argc, char **argv)
goto ftm_start;
}
if (ftm_args.ssid->count == 1) {
ap_record = find_ftm_responder_ap(ftm_args.ssid->sval[0]);
if (ap_record) {
printf("Starting FTM with " MACSTR " on channel %d\n", MAC2STR(ap_record->bssid),
ap_record->primary);
memcpy(ftmi_cfg.resp_mac, ap_record->bssid, 6);
ftmi_cfg.channel = ap_record->primary;
} else {
return 0;
}
}
if (ftm_args.frm_count->count != 0) {
uint8_t count = ftm_args.frm_count->ival[0];
if (count != 0 && count != 16 && count != 24 &&
@ -354,7 +404,7 @@ ftm_start:
ftmi_cfg.frm_count, ftmi_cfg.burst_period * 100);
}
if (ESP_OK != esp_wifi_ftm_start_initiator(&ftmi_cfg)) {
if (ESP_OK != esp_wifi_ftm_initiate_session(&ftmi_cfg)) {
ESP_LOGE(TAG_STA, "Failed to start FTM session");
return 0;
}
@ -430,6 +480,7 @@ void register_wifi(void)
ESP_ERROR_CHECK( esp_console_cmd_register(&query_cmd) );
ftm_args.mode = arg_lit1("I", "ftm_initiator", "FTM Initiator mode");
ftm_args.ssid = arg_str0("s", "ssid", "SSID", "SSID of AP");
ftm_args.frm_count = arg_int0("c", "frm_count", "<0/16/24/32/64>", "FTM frames to be exchanged (0: No preference)");
ftm_args.burst_period = arg_int0("p", "burst_period", "<2-255 (x 100 mSec)>", "Periodicity of FTM bursts in 100's of miliseconds (0: No preference)");
ftm_args.end = arg_end(1);
@ -469,12 +520,11 @@ void app_main(void)
printf("\n ==========================================================\n");
printf(" | Steps to test FTM |\n");
printf(" | |\n");
printf(" | 1. Print 'help' to gain overview of commands |\n");
printf(" | 2. Use 'scan' command for AP that support FTM |\n");
printf(" | 1. Use 'help' to gain overview of commands |\n");
printf(" | 2. Use 'scan' command to search for external AP's |\n");
printf(" | OR |\n");
printf(" | 2. Start SoftAP on another device with 'ap' command |\n");
printf(" | 3. Setup connection with the AP using 'sta' command |\n");
printf(" | 4. Initiate FTM from Station using 'ftm -I' command |\n");
printf(" | 2. Start SoftAP on another device using 'ap' command |\n");
printf(" | 3. Start FTM with command 'ftm -I -s <SSID>' |\n");
printf(" | |\n");
printf(" ==========================================================\n\n");