wifi_provisioning : Added Wi-Fi Scan list feature to Provisioning Manager

List of changes in components/wifi_provisioning:
* Manager version is now v1.1
* .proto files and protocomm handler added for sending Wi-Fi scan command and receiving scan results
* Implemented handlers for wifi_scan protocomm endpoint
* Update manager context data structure to hold scan state and results
* scheme_softap now runs Wi-Fi in APSTA mode
* Wi-Fi is started in AP mode when provisioning is started. This is necessary for scan list to work
* Docs updates with information about new wifi_scan endpoint

List of changes in tools/esp_prov:
* Added functions for sending and receiving protobuf messages compatible with wifi_scan protocomm endpoint
* Added feature to display/refresh scan results and accept user selection at runtime
* New functions:
  * get_version() : only returns the protocol version string
  * has_capability() : check is a capability is present according to proto-ver response
* wifi_scan feature is provided only if the `wifi_scan` capability is present

Other changes:
* Replace recursive mutex with plain mutex
* assert on return value of mutex give / take calls
* replace all calls with macros ACQUIRE_LOCK and RELEASE_LOCK
* some checks added in scanning related private APIs
* free and nullify scanning context and state if service is stopped while ongoing scan
This commit is contained in:
Anurag Kar
2019-04-23 12:18:28 +05:30
committed by bot
parent 12f4541f19
commit 9c0ee28670
21 changed files with 3136 additions and 115 deletions

View File

@@ -21,6 +21,7 @@
#include <tcpip_adapter.h>
#include "wifi_provisioning/wifi_config.h"
#include "wifi_provisioning/wifi_scan.h"
#include "wifi_provisioning/manager.h"
#include "wifi_provisioning_priv.h"
@@ -134,13 +135,65 @@ static esp_err_t apply_config_handler(wifi_prov_ctx_t **ctx)
return ret;
}
wifi_prov_config_handlers_t get_wifi_prov_handlers(void)
esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr)
{
wifi_prov_config_handlers_t wifi_prov_handlers = {
.get_status_handler = get_status_handler,
.set_config_handler = set_config_handler,
.apply_config_handler = apply_config_handler,
.ctx = NULL
};
return wifi_prov_handlers;
if (!ptr) {
return ESP_ERR_INVALID_ARG;
}
ptr->get_status_handler = get_status_handler;
ptr->set_config_handler = set_config_handler;
ptr->apply_config_handler = apply_config_handler;
ptr->ctx = NULL;
return ESP_OK;
}
/*************************************************************************/
static esp_err_t scan_start(bool blocking, bool passive,
uint8_t group_channels, uint32_t period_ms,
wifi_prov_scan_ctx_t **ctx)
{
return wifi_prov_mgr_wifi_scan_start(blocking, passive, group_channels, period_ms);
}
static esp_err_t scan_status(bool *scan_finished,
uint16_t *result_count,
wifi_prov_scan_ctx_t **ctx)
{
*scan_finished = wifi_prov_mgr_wifi_scan_finished();
*result_count = wifi_prov_mgr_wifi_scan_result_count();
return ESP_OK;
}
static esp_err_t scan_result(uint16_t result_index,
wifi_prov_scan_result_t *result,
wifi_prov_scan_ctx_t **ctx)
{
const wifi_ap_record_t *record = wifi_prov_mgr_wifi_scan_result(result_index);
if (!record) {
return ESP_FAIL;
}
/* Compile time check ensures memory safety in case SSID length in
* record / result structure definition changes in future */
_Static_assert(sizeof(result->ssid) == sizeof(record->ssid),
"source and destination should be of same size");
memcpy(result->ssid, record->ssid, sizeof(record->ssid));
memcpy(result->bssid, record->bssid, sizeof(record->bssid));
result->channel = record->primary;
result->rssi = record->rssi;
result->auth = record->authmode;
return ESP_OK;
}
esp_err_t get_wifi_scan_handlers(wifi_prov_scan_handlers_t *ptr)
{
if (!ptr) {
return ESP_ERR_INVALID_ARG;
}
ptr->scan_start = scan_start;
ptr->scan_status = scan_status;
ptr->scan_result = scan_result;
ptr->ctx = NULL;
return ESP_OK;
}