diff --git a/.github/workflows/release_zips.yml b/.github/workflows/release_zips.yml index a88dd90128e8..ccce907041e8 100644 --- a/.github/workflows/release_zips.yml +++ b/.github/workflows/release_zips.yml @@ -10,8 +10,8 @@ jobs: name: Create release zip file runs-on: ubuntu-20.04 steps: - - name: Create a recursive clone source zip - uses: espressif/github-actions/release_zips@master + - name: Create a recursive clone source and stripped zip + uses: Jason2866/github-actions/release_zips@release_idf env: RELEASE_PROJECT_NAME: ESP-IDF GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/components/driver/dac/dac_continuous.c b/components/driver/dac/dac_continuous.c index 98bee776efd4..977a06d55e30 100644 --- a/components/driver/dac/dac_continuous.c +++ b/components/driver/dac/dac_continuous.c @@ -556,16 +556,17 @@ static esp_err_t s_dac_wait_to_load_dma_data(dac_continuous_handle_t handle, uin DAC_STAILQ_REMOVE(&handle->head, desc, lldesc_s, qe); } - static bool split_flag = false; + // TASMOTA: remove split because it does some harm and I'm not sure why it was there in the first place. No such code in 4.x + // static bool split_flag = false; uint8_t *dma_buf = (uint8_t *)desc->buf; - if (buf_size * DAC_16BIT_ALIGN_COEFF < 2 * handle->cfg.buf_size) { - if (!split_flag) { - buf_size >>= 1; - split_flag = true; - } else { - split_flag = false; - } - } + // if (buf_size * DAC_16BIT_ALIGN_COEFF < 2 * handle->cfg.buf_size) { + // if (!split_flag) { + // buf_size >>= 1; + // split_flag = true; + // } else { + // split_flag = false; + // } + // } size_t load_bytes = s_dac_load_data_into_buf(handle, dma_buf, handle->cfg.buf_size, buf, buf_size); lldesc_config(desc, LLDESC_HW_OWNED, 1, 0, load_bytes); desc->size = load_bytes; diff --git a/components/esp_eth/CMakeLists.txt b/components/esp_eth/CMakeLists.txt index 55f0fc093730..f64bf541f16a 100644 --- a/components/esp_eth/CMakeLists.txt +++ b/components/esp_eth/CMakeLists.txt @@ -32,7 +32,8 @@ if(CONFIG_ETH_ENABLED) "src/esp_eth_phy_ip101.c" "src/esp_eth_phy_ksz80xx.c" "src/esp_eth_phy_lan87xx.c" - "src/esp_eth_phy_rtl8201.c") + "src/esp_eth_phy_rtl8201.c" + "src/esp_eth_phy_jl1101.c") endif() if(CONFIG_ETH_SPI_ETHERNET_DM9051) diff --git a/components/esp_eth/include/esp_eth_phy.h b/components/esp_eth/include/esp_eth_phy.h index 07bcf8fb9307..ad62fc144daa 100644 --- a/components/esp_eth/include/esp_eth_phy.h +++ b/components/esp_eth/include/esp_eth_phy.h @@ -352,6 +352,17 @@ esp_eth_phy_t *esp_eth_phy_new_dp83848(const eth_phy_config_t *config); */ esp_eth_phy_t *esp_eth_phy_new_ksz80xx(const eth_phy_config_t *config); +/** +* @brief Create a PHY instance of JL1101 +* +* @param[in] config: configuration of PHY +* +* @return +* - instance: create PHY instance successfully +* - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config); + #if CONFIG_ETH_SPI_ETHERNET_DM9051 /** * @brief Create a PHY instance of DM9051 diff --git a/components/esp_eth/src/esp_eth_phy_jl1101.c b/components/esp_eth/src/esp_eth_phy_jl1101.c new file mode 100644 index 000000000000..512e5fe024f5 --- /dev/null +++ b/components/esp_eth/src/esp_eth_phy_jl1101.c @@ -0,0 +1,186 @@ +/* + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "esp_log.h" +#include "esp_check.h" +#include "esp_eth_phy_802_3.h" + +static const char *TAG = "jl1101"; + +/***************Vendor Specific Register***************/ + +/** + * @brief PSMR(Power Saving Mode Register) + * + */ +typedef union { + struct { + uint16_t reserved : 15; /* Reserved */ + uint16_t en_pwr_save : 1; /* Enable power saving mode */ + }; + uint16_t val; +} psmr_reg_t; + +/** + * @brief PSR(Page Select Register) + * + */ +typedef union { + struct { + uint16_t page_select : 8; /* Select register page, default is 0 */ + uint16_t reserved : 8; /* Reserved */ + }; + uint16_t val; +} psr_reg_t; +#define ETH_PHY_PSR_REG_ADDR (0x1F) + +typedef struct { + phy_802_3_t phy_802_3; +} phy_jl1101_t; + +static esp_err_t jl1101_page_select(phy_jl1101_t *jl1101, uint32_t page) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = jl1101->phy_802_3.eth; + psr_reg_t psr = { + .page_select = page + }; + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, jl1101->phy_802_3.addr, ETH_PHY_PSR_REG_ADDR, psr.val), err, TAG, "write PSR failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_update_link_duplex_speed(phy_jl1101_t *jl1101) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = jl1101->phy_802_3.eth; + uint32_t addr = jl1101->phy_802_3.addr; + eth_speed_t speed = ETH_SPEED_10M; + eth_duplex_t duplex = ETH_DUPLEX_HALF; + bmcr_reg_t bmcr; + bmsr_reg_t bmsr; + uint32_t peer_pause_ability = false; + anlpar_reg_t anlpar; + ESP_GOTO_ON_ERROR(jl1101_page_select(jl1101, 0), err, TAG, "select page 0 failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); + eth_link_t link = bmsr.link_status ? ETH_LINK_UP : ETH_LINK_DOWN; + /* check if link status changed */ + if (jl1101->phy_802_3.link_status != link) { + /* when link up, read negotiation result */ + if (link == ETH_LINK_UP) { + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + if (bmcr.speed_select) { + speed = ETH_SPEED_100M; + } else { + speed = ETH_SPEED_10M; + } + if (bmcr.duplex_mode) { + duplex = ETH_DUPLEX_FULL; + } else { + duplex = ETH_DUPLEX_HALF; + } + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_SPEED, (void *)speed), err, TAG, "change speed failed"); + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_DUPLEX, (void *)duplex), err, TAG, "change duplex failed"); + /* if we're in duplex mode, and peer has the flow control ability */ + if (duplex == ETH_DUPLEX_FULL && anlpar.symmetric_pause) { + peer_pause_ability = 1; + } else { + peer_pause_ability = 0; + } + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_PAUSE, (void *)peer_pause_ability), err, TAG, "change pause ability failed"); + } + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)link), err, TAG, "change link failed"); + jl1101->phy_802_3.link_status = link; + } + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_get_link(esp_eth_phy_t *phy) +{ + esp_err_t ret = ESP_OK; + phy_jl1101_t *jl1101 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_jl1101_t, phy_802_3); + /* Updata information about link, speed, duplex */ + ESP_GOTO_ON_ERROR(jl1101_update_link_duplex_speed(jl1101), err, TAG, "update link duplex speed failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + esp_eth_mediator_t *eth = phy_802_3->eth; + if (cmd == ESP_ETH_PHY_AUTONEGO_EN) { + bmcr_reg_t bmcr; + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + ESP_GOTO_ON_FALSE(bmcr.en_loopback == 0, ESP_ERR_INVALID_STATE, err, TAG, "Autonegotiation can't be enabled while in loopback operation"); + } + return esp_eth_phy_802_3_autonego_ctrl(phy_802_3, cmd, autonego_en_stat); +err: + return ret; +} + +static esp_err_t jl1101_loopback(esp_eth_phy_t *phy, bool enable) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + bool auto_nego_en; + ESP_GOTO_ON_ERROR(jl1101_autonego_ctrl(phy, ESP_ETH_PHY_AUTONEGO_G_STAT, &auto_nego_en), err, TAG, "get status of autonegotiation failed"); + ESP_GOTO_ON_FALSE(!(auto_nego_en && enable), ESP_ERR_INVALID_STATE, err, TAG, "Unable to set loopback while autonegotiation is enabled. Disable it to use loopback"); + return esp_eth_phy_802_3_loopback(phy_802_3, enable); +err: + return ret; +} + +static esp_err_t jl1101_init(esp_eth_phy_t *phy) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + + /* Basic PHY init */ + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_basic_phy_init(phy_802_3), err, TAG, "failed to init PHY"); + + /* Check PHY ID */ + uint32_t oui; + uint8_t model; + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_read_oui(phy_802_3, &oui), err, TAG, "read OUI failed"); + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_read_manufac_info(phy_802_3, &model, NULL), err, TAG, "read manufacturer's info failed"); + ESP_GOTO_ON_FALSE(oui == 0x24DF10 && model == 0x2, ESP_FAIL, err, TAG, "wrong chip ID"); + + return ESP_OK; +err: + return ret; +} + +esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config) +{ + esp_eth_phy_t *ret = NULL; + phy_jl1101_t *jl1101 = calloc(1, sizeof(phy_jl1101_t)); + ESP_GOTO_ON_FALSE(jl1101, NULL, err, TAG, "calloc jl1101 failed"); + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&jl1101->phy_802_3, config) == ESP_OK, + NULL, err, TAG, "configuration initialization of PHY 802.3 failed"); + + // redefine functions which need to be customized for sake of jl1101 + jl1101->phy_802_3.parent.init = jl1101_init; + jl1101->phy_802_3.parent.get_link = jl1101_get_link; + jl1101->phy_802_3.parent.autonego_ctrl = jl1101_autonego_ctrl; + jl1101->phy_802_3.parent.loopback = jl1101_loopback; + + return &jl1101->phy_802_3.parent; +err: + if (jl1101 != NULL) { + free(jl1101); + } + return ret; +} diff --git a/components/esp_hw_support/mac_addr.c b/components/esp_hw_support/mac_addr.c index a73f40e8e6e3..ffbe493ad0ce 100644 --- a/components/esp_hw_support/mac_addr.c +++ b/components/esp_hw_support/mac_addr.c @@ -286,6 +286,8 @@ static esp_err_t get_efuse_factory_mac(uint8_t *mac) uint32_t mac_low = ((uint32_t)mac[2] << 24) | ((uint32_t)mac[3] << 16) | ((uint32_t)mac[4] << 8) | mac[5]; if (((mac_high & 0xFFFF) == 0x18fe) && (mac_low >= 0x346a85c7) && (mac_low <= 0x346a85f8)) { return ESP_OK; + } else if (esp_efuse_get_pkg_ver() == 3) { + return ESP_OK; // override for Xiaomi SOC's and maybe others too } else { ESP_LOGE(TAG, "Base MAC address from BLK0 of EFUSE CRC error, efuse_crc = 0x%02x; calc_crc = 0x%02x", efuse_crc, calc_crc); #ifdef CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR diff --git a/components/esp_psram/esp32/esp_psram_impl_quad.c b/components/esp_psram/esp32/esp_psram_impl_quad.c index cac52cf9a95c..4a4f62ff66dc 100644 --- a/components/esp_psram/esp32/esp_psram_impl_quad.c +++ b/components/esp_psram/esp32/esp_psram_impl_quad.c @@ -866,7 +866,7 @@ esp_err_t IRAM_ATTR esp_psram_impl_enable(void) //psram init psram_io.psram_cs_io = D2WD_PSRAM_CS_IO; } else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 && ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 300)) { ESP_EARLY_LOGE(TAG, "This chip is ESP32-PICO-V3. It does not support PSRAM (disable it in Kconfig)"); - abort(); + return ESP_FAIL; } else if ((pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) || (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32U4WDH)) { ESP_EARLY_LOGI(TAG, "This chip is %s", (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) ? "ESP32-PICO" : "ESP32-U4WDH"); @@ -903,7 +903,7 @@ esp_err_t IRAM_ATTR esp_psram_impl_enable(void) //psram init psram_io.psram_cs_io = D0WDR2_V3_PSRAM_CS_IO; } else { ESP_EARLY_LOGE(TAG, "Not a valid or known package id: %d", pkg_ver); - abort(); + return ESP_FAIL; } s_psram_cs_io = psram_io.psram_cs_io; diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 86779183906e..5754189a00d8 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -281,7 +281,7 @@ menu "Wi-Fi" config ESP_WIFI_ENABLE_WPA3_SAE bool "Enable WPA3-Personal" default y - select ESP_WIFI_MBEDTLS_CRYPTO + depends on ESP_WIFI_MBEDTLS_CRYPTO help Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's. PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be @@ -465,16 +465,9 @@ menu "Wi-Fi" select MBEDTLS_ECP_C select MBEDTLS_ECDH_C select MBEDTLS_ECDSA_C - select MBEDTLS_CMAC_C - select MBEDTLS_ECP_DP_SECP256R1_ENABLED + select MBEDTLS_TLS_ENABLED help - Select this option to enable the use of MbedTLS crypto APIs. - The internal crypto support within the supplicant is limited - and may not suffice for all new security features, including WPA3. - - It is recommended to always keep this option enabled. Additionally, - note that MbedTLS can leverage hardware acceleration if available, - resulting in significantly faster cryptographic operations. + Select this option to use MbedTLS crypto APIs which utilize hardware acceleration. if ESP_WIFI_MBEDTLS_CRYPTO config ESP_WIFI_MBEDTLS_TLS_CLIENT @@ -501,7 +494,6 @@ menu "Wi-Fi" config ESP_WIFI_SUITE_B_192 bool "Enable NSA suite B support with 192 bit key" default n - depends on SOC_WIFI_GCMP_SUPPORT select ESP_WIFI_GCMP_SUPPORT select ESP_WIFI_GMAC_SUPPORT help diff --git a/components/soc/esp32c2/include/soc/soc.h b/components/soc/esp32c2/include/soc/soc.h index 5186fdb044bd..2afa1480f521 100644 --- a/components/soc/esp32c2/include/soc/soc.h +++ b/components/soc/esp32c2/include/soc/soc.h @@ -30,7 +30,7 @@ #define UART_FIFO_AHB_REG(i) (REG_UART_AHB_BASE(i) + 0x0) #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000) #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) -#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (0)) // only one GPSPI +#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (DR_REG_SPI0_BASE - ((i) * 0x1000))) // only one GPSPI #define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE + (i) * 0x14000 ) //Registers Operation {{ diff --git a/components/soc/esp32c3/include/soc/soc.h b/components/soc/esp32c3/include/soc/soc.h index bbe07ec4e4d1..2a4d3346bfec 100644 --- a/components/soc/esp32c3/include/soc/soc.h +++ b/components/soc/esp32c3/include/soc/soc.h @@ -23,7 +23,7 @@ #define REG_I2S_BASE(i) (DR_REG_I2S_BASE) // only one I2S on C3 #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000) #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) -#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (0)) // only one GPSPI +#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (DR_REG_SPI0_BASE - ((i) * 0x1000))) // only one GPSPI #define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE + (i) * 0x14000 ) //Registers Operation {{ diff --git a/components/soc/esp32c6/include/soc/soc.h b/components/soc/esp32c6/include/soc/soc.h index 94dd6ceb8ebe..594167bc536e 100644 --- a/components/soc/esp32c6/include/soc/soc.h +++ b/components/soc/esp32c6/include/soc/soc.h @@ -23,7 +23,7 @@ #define REG_I2S_BASE(i) (DR_REG_I2S_BASE) // only one I2S on C6 #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i) * 0x1000) // TIMERG0 and TIMERG1 #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE + (i) * 0x1000) // SPIMEM0 and SPIMEM1 -#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (0)) // only one GPSPI on C6 +#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (DR_REG_SPI0_BASE - ((i) * 0x1000))) // only one GPSPI on C6 #define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE) // only one I2C on C6 #define REG_MCPWM_BASE(i) (DR_REG_MCPWM_BASE) // only one MCPWM on C6 #define REG_TWAI_BASE(i) (DR_REG_TWAI0_BASE + (i) * 0x2000) // TWAI0 and TWAI1 diff --git a/components/soc/esp32h2/include/soc/soc.h b/components/soc/esp32h2/include/soc/soc.h index b45923bef82a..9be73fd0df85 100644 --- a/components/soc/esp32h2/include/soc/soc.h +++ b/components/soc/esp32h2/include/soc/soc.h @@ -23,7 +23,7 @@ #define REG_I2S_BASE(i) (DR_REG_I2S_BASE) // only one I2S on H2 #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000) #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE + (i) * 0x1000) -#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (0)) // only one GPSPI +#define REG_SPI_BASE(i) (DR_REG_SPI2_BASE + (i - 2) * 0x1000) // only one GPSPI #define REG_I2C_BASE(i) (DR_REG_I2C_EXT0_BASE + (i) * 0x1000) //Registers Operation {{ diff --git a/components/soc/esp32s2/include/soc/soc.h b/components/soc/esp32s2/include/soc/soc.h index 2439e12560e8..7c9b486b0ee3 100644 --- a/components/soc/esp32s2/include/soc/soc.h +++ b/components/soc/esp32s2/include/soc/soc.h @@ -25,7 +25,7 @@ #define REG_I2S_BASE( i ) (DR_REG_I2S_BASE) #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000) #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) -#define REG_SPI_BASE(i) (((i)>=2) ? (DR_REG_SPI2_BASE + (i-2) * 0x1000) : (0)) // GPSPI2 and GPSPI3 +#define REG_SPI_BASE(i) (DR_REG_SPI2_BASE + (((i)>3) ? (((i-2)* 0x1000) + 0x10000) : ((i - 2)* 0x1000 ))) // GPSPI2 and GPSPI3 #define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE + (i) * 0x14000 ) //Convenient way to replace the register ops when ulp riscv projects diff --git a/components/soc/esp32s3/include/soc/soc.h b/components/soc/esp32s3/include/soc/soc.h index d91136a8122b..b9a2af9e001d 100644 --- a/components/soc/esp32s3/include/soc/soc.h +++ b/components/soc/esp32s3/include/soc/soc.h @@ -34,7 +34,7 @@ #define REG_I2S_BASE( i ) (DR_REG_I2S_BASE + (i) * 0x1E000) #define REG_TIMG_BASE(i) (DR_REG_TIMERGROUP0_BASE + (i)*0x1000) #define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) -#define REG_SPI_BASE(i) (((i)>=2) ? (DR_REG_SPI2_BASE + (i-2) * 0x1000) : (0)) // GPSPI2 and GPSPI3 +#define REG_SPI_BASE(i) (((i)==2) ? (DR_REG_SPI2_BASE) : (DR_REG_SPI0_BASE - ((i) * 0x1000))) // GPSPI2 and GPSPI3 #define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE + (i) * 0x14000 ) //Convenient way to replace the register ops when ulp riscv projects diff --git a/components/wifi_provisioning/CMakeLists.txt b/components/wifi_provisioning/CMakeLists.txt deleted file mode 100644 index 96cfdd5665a7..000000000000 --- a/components/wifi_provisioning/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -idf_build_get_property(target IDF_TARGET) - -if(${target} STREQUAL "linux") - return() # This component is not supported by the POSIX/Linux simulator -endif() - -set(srcs "src/wifi_config.c" - "src/wifi_scan.c" - "src/wifi_ctrl.c" - "src/manager.c" - "src/handlers.c" - "src/scheme_console.c" - "proto-c/wifi_config.pb-c.c" - "proto-c/wifi_scan.pb-c.c" - "proto-c/wifi_ctrl.pb-c.c" - "proto-c/wifi_constants.pb-c.c") - -if(CONFIG_ESP_WIFI_SOFTAP_SUPPORT) - list(APPEND srcs "src/scheme_softap.c") -endif() - -if(CONFIG_BT_ENABLED) - if(CONFIG_BT_BLUEDROID_ENABLED OR CONFIG_BT_NIMBLE_ENABLED) - list(APPEND srcs - "src/scheme_ble.c") - endif() -endif() - -idf_component_register(SRCS "${srcs}" - INCLUDE_DIRS include - PRIV_INCLUDE_DIRS src proto-c - REQUIRES lwip protocomm - PRIV_REQUIRES protobuf-c bt json esp_timer esp_wifi) diff --git a/components/wifi_provisioning/Kconfig b/components/wifi_provisioning/Kconfig deleted file mode 100644 index 9403d0ee2303..000000000000 --- a/components/wifi_provisioning/Kconfig +++ /dev/null @@ -1,62 +0,0 @@ -menu "Wi-Fi Provisioning Manager" - - config WIFI_PROV_SCAN_MAX_ENTRIES - int "Max Wi-Fi Scan Result Entries" - default 16 - range 1 255 - help - This sets the maximum number of entries of Wi-Fi scan results that will be kept by the provisioning manager - - config WIFI_PROV_AUTOSTOP_TIMEOUT - int "Provisioning auto-stop timeout" - default 30 - range 5 600 - help - Time (in seconds) after which the Wi-Fi provisioning manager will auto-stop after connecting to - a Wi-Fi network successfully. - - config WIFI_PROV_BLE_BONDING - bool - prompt "Enable BLE bonding" - depends on BT_ENABLED - help - This option is applicable only when provisioning transport is BLE. - - config WIFI_PROV_BLE_SEC_CONN - bool - prompt "Enable BLE Secure connection flag" - depends on BT_NIMBLE_ENABLED - default y - help - Used to enable Secure connection support when provisioning transport is BLE. - - config WIFI_PROV_BLE_FORCE_ENCRYPTION - bool - prompt "Force Link Encryption during characteristic Read / Write" - help - Used to enforce link encryption when attempting to read / write characteristic - - config WIFI_PROV_KEEP_BLE_ON_AFTER_PROV - bool "Keep BT on after provisioning is done" - depends on BT_ENABLED - select ESP_PROTOCOMM_KEEP_BLE_ON_AFTER_BLE_STOP - - config WIFI_PROV_DISCONNECT_AFTER_PROV - bool "Terminate connection after provisioning is done" - depends on WIFI_PROV_KEEP_BLE_ON_AFTER_PROV - default y - select ESP_PROTOCOMM_DISCONNECT_AFTER_BLE_STOP - - choice WIFI_PROV_STA_SCAN_METHOD - bool "Wifi Provisioning Scan Method" - default WIFI_PROV_STA_ALL_CHANNEL_SCAN - config WIFI_PROV_STA_ALL_CHANNEL_SCAN - bool "All Channel Scan" - help - Scan will end after scanning the entire channel. This option is useful in Mesh WiFi Systems. - config WIFI_PROV_STA_FAST_SCAN - bool "Fast Scan" - help - Scan will end after an AP matching with the SSID has been detected. - endchoice -endmenu diff --git a/components/wifi_provisioning/include/wifi_provisioning/manager.h b/components/wifi_provisioning/include/wifi_provisioning/manager.h deleted file mode 100644 index 72c6d6d50b79..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/manager.h +++ /dev/null @@ -1,601 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include - -#include "esp_event.h" -#include "esp_wifi_types.h" -#include "wifi_provisioning/wifi_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ESP_EVENT_DECLARE_BASE(WIFI_PROV_EVENT); - -/** - * @brief Events generated by manager - * - * These events are generated in order of declaration and, for the - * stretch of time between initialization and de-initialization of - * the manager, each event is signaled only once - */ -typedef enum { - /** - * Emitted when the manager is initialized - */ - WIFI_PROV_INIT, - - /** - * Indicates that provisioning has started - */ - WIFI_PROV_START, - - /** - * Emitted when Wi-Fi AP credentials are received via `protocomm` - * endpoint `wifi_config`. The event data in this case is a pointer - * to the corresponding `wifi_sta_config_t` structure - */ - WIFI_PROV_CRED_RECV, - - /** - * Emitted when device fails to connect to the AP of which the - * credentials were received earlier on event `WIFI_PROV_CRED_RECV`. - * The event data in this case is a pointer to the disconnection - * reason code with type `wifi_prov_sta_fail_reason_t` - */ - WIFI_PROV_CRED_FAIL, - - /** - * Emitted when device successfully connects to the AP of which the - * credentials were received earlier on event `WIFI_PROV_CRED_RECV` - */ - WIFI_PROV_CRED_SUCCESS, - - /** - * Signals that provisioning service has stopped - */ - WIFI_PROV_END, - - /** - * Signals that manager has been de-initialized - */ - WIFI_PROV_DEINIT, -} wifi_prov_cb_event_t; - -typedef void (*wifi_prov_cb_func_t)(void *user_data, wifi_prov_cb_event_t event, void *event_data); - -/** - * @brief Event handler that is used by the manager while - * provisioning service is active - */ -typedef struct { - /** - * Callback function to be executed on provisioning events - */ - wifi_prov_cb_func_t event_cb; - - /** - * User context data to pass as parameter to callback function - */ - void *user_data; -} wifi_prov_event_handler_t; - -/** - * @brief Event handler can be set to none if not used - */ -#define WIFI_PROV_EVENT_HANDLER_NONE { \ - .event_cb = NULL, \ - .user_data = NULL \ -} - -/** - * @brief Structure for specifying the provisioning scheme to be - * followed by the manager - * - * @note Ready to use schemes are available: - * - wifi_prov_scheme_ble : for provisioning over BLE transport + GATT server - * - wifi_prov_scheme_softap : for provisioning over SoftAP transport + HTTP server - * - wifi_prov_scheme_console : for provisioning over Serial UART transport + Console (for debugging) - */ -typedef struct wifi_prov_scheme { - /** - * Function which is to be called by the manager when it is to - * start the provisioning service associated with a protocomm instance - * and a scheme specific configuration - */ - esp_err_t (*prov_start) (protocomm_t *pc, void *config); - - /** - * Function which is to be called by the manager to stop the - * provisioning service previously associated with a protocomm instance - */ - esp_err_t (*prov_stop) (protocomm_t *pc); - - /** - * Function which is to be called by the manager to generate - * a new configuration for the provisioning service, that is - * to be passed to prov_start() - */ - void *(*new_config) (void); - - /** - * Function which is to be called by the manager to delete a - * configuration generated using new_config() - */ - void (*delete_config) (void *config); - - /** - * Function which is to be called by the manager to set the - * service name and key values in the configuration structure - */ - esp_err_t (*set_config_service) (void *config, const char *service_name, const char *service_key); - - /** - * Function which is to be called by the manager to set a protocomm endpoint - * with an identifying name and UUID in the configuration structure - */ - esp_err_t (*set_config_endpoint) (void *config, const char *endpoint_name, uint16_t uuid); - - /** - * Sets mode of operation of Wi-Fi during provisioning - * This is set to : - * - WIFI_MODE_APSTA for SoftAP transport - * - WIFI_MODE_STA for BLE transport - */ - wifi_mode_t wifi_mode; -} wifi_prov_scheme_t; - -/** - * @brief Structure for specifying the manager configuration - */ -typedef struct { - /** - * Provisioning scheme to use. Following schemes are already available: - * - wifi_prov_scheme_ble : for provisioning over BLE transport + GATT server - * - wifi_prov_scheme_softap : for provisioning over SoftAP transport + HTTP server + mDNS (optional) - * - wifi_prov_scheme_console : for provisioning over Serial UART transport + Console (for debugging) - */ - wifi_prov_scheme_t scheme; - - /** - * Event handler required by the scheme for incorporating scheme specific - * behavior while provisioning manager is running. Various options may be - * provided by the scheme for setting this field. Use WIFI_PROV_EVENT_HANDLER_NONE - * when not used. When using scheme wifi_prov_scheme_ble, the following - * options are available: - * - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM - * - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE - * - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT - */ - wifi_prov_event_handler_t scheme_event_handler; - - /** - * Event handler that can be set for the purpose of incorporating application - * specific behavior. Use WIFI_PROV_EVENT_HANDLER_NONE when not used. - */ - wifi_prov_event_handler_t app_event_handler; -} wifi_prov_mgr_config_t; - -/** - * @brief Security modes supported by the Provisioning Manager. - * - * These are same as the security modes provided by protocomm - */ -typedef enum wifi_prov_security { -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0 - /** - * No security (plain-text communication) - */ - WIFI_PROV_SECURITY_0 = 0, -#endif -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1 - /** - * This secure communication mode consists of - * X25519 key exchange - * + proof of possession (pop) based authentication - * + AES-CTR encryption - */ - WIFI_PROV_SECURITY_1 = 1, -#endif -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2 - /** - * This secure communication mode consists of - * SRP6a based authentication and key exchange - * + AES-GCM encryption/decryption - */ - WIFI_PROV_SECURITY_2 = 2 -#endif -} wifi_prov_security_t; - -/** - * @brief Security 1 params structure - * This needs to be passed when using WIFI_PROV_SECURITY_1 - */ -typedef const char wifi_prov_security1_params_t; - -/** - * @brief Security 2 params structure - * This needs to be passed when using WIFI_PROV_SECURITY_2 - */ -typedef protocomm_security2_params_t wifi_prov_security2_params_t; - -/** - * @brief Initialize provisioning manager instance - * - * Configures the manager and allocates internal resources - * - * Configuration specifies the provisioning scheme (transport) - * and event handlers - * - * Event WIFI_PROV_INIT is emitted right after initialization - * is complete - * - * @param[in] config Configuration structure - * - * @return - * - ESP_OK : Success - * - ESP_FAIL : Fail - */ -esp_err_t wifi_prov_mgr_init(wifi_prov_mgr_config_t config); - -/** - * @brief Stop provisioning (if running) and release - * resource used by the manager - * - * Event WIFI_PROV_DEINIT is emitted right after de-initialization - * is finished - * - * If provisioning service is still active when this API is called, - * it first stops the service, hence emitting WIFI_PROV_END, and - * then performs the de-initialization - */ -void wifi_prov_mgr_deinit(void); - -/** - * @brief Checks if device is provisioned - * - * This checks if Wi-Fi credentials are present on the NVS - * - * The Wi-Fi credentials are assumed to be kept in the same - * NVS namespace as used by esp_wifi component - * - * If one were to call esp_wifi_set_config() directly instead - * of going through the provisioning process, this function will - * still yield true (i.e. device will be found to be provisioned) - * - * @note Calling wifi_prov_mgr_start_provisioning() automatically - * resets the provision state, irrespective of what the - * state was prior to making the call. - * - * @param[out] provisioned True if provisioned, else false - * - * @return - * - ESP_OK : Retrieved provision state successfully - * - ESP_FAIL : Wi-Fi not initialized - * - ESP_ERR_INVALID_ARG : Null argument supplied - */ -esp_err_t wifi_prov_mgr_is_provisioned(bool *provisioned); - -/** - * @brief Start provisioning service - * - * This starts the provisioning service according to the scheme - * configured at the time of initialization. For scheme : - * - wifi_prov_scheme_ble : This starts protocomm_ble, which internally initializes - * BLE transport and starts GATT server for handling - * provisioning requests - * - wifi_prov_scheme_softap : This activates SoftAP mode of Wi-Fi and starts - * protocomm_httpd, which internally starts an HTTP - * server for handling provisioning requests (If mDNS is - * active it also starts advertising service with type - * _esp_wifi_prov._tcp) - * - * Event WIFI_PROV_START is emitted right after provisioning starts without failure - * - * @note This API will start provisioning service even if device is found to be - * already provisioned, i.e. wifi_prov_mgr_is_provisioned() yields true - * - * @param[in] security Specify which protocomm security scheme to use : - * - WIFI_PROV_SECURITY_0 : For no security - * - WIFI_PROV_SECURITY_1 : x25519 secure handshake for session - * establishment followed by AES-CTR encryption of provisioning messages - * - WIFI_PROV_SECURITY_2: SRP6a based authentication and key exchange - * followed by AES-GCM encryption/decryption of provisioning messages - * @param[in] wifi_prov_sec_params - * Pointer to security params (NULL if not needed). - * This is not needed for protocomm security 0 - * This pointer should hold the struct of type - * wifi_prov_security1_params_t for protocomm security 1 - * and wifi_prov_security2_params_t for protocomm security 2 respectively. - * This pointer and its contents should be valid till the provisioning service is - * running and has not been stopped or de-inited. - * @param[in] service_name Unique name of the service. This translates to: - * - Wi-Fi SSID when provisioning mode is softAP - * - Device name when provisioning mode is BLE - * @param[in] service_key Key required by client to access the service (NULL if not needed). - * This translates to: - * - Wi-Fi password when provisioning mode is softAP - * - ignored when provisioning mode is BLE - * - * @return - * - ESP_OK : Provisioning started successfully - * - ESP_FAIL : Failed to start provisioning service - * - ESP_ERR_INVALID_STATE : Provisioning manager not initialized or already started - */ -esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const void *wifi_prov_sec_params, const char *service_name, const char *service_key); - -/** - * @brief Stop provisioning service - * - * If provisioning service is active, this API will initiate a process to stop - * the service and return. Once the service actually stops, the event WIFI_PROV_END - * will be emitted. - * - * If wifi_prov_mgr_deinit() is called without calling this API first, it will - * automatically stop the provisioning service and emit the WIFI_PROV_END, followed - * by WIFI_PROV_DEINIT, before returning. - * - * This API will generally be used along with wifi_prov_mgr_disable_auto_stop() - * in the scenario when the main application has registered its own endpoints, - * and wishes that the provisioning service is stopped only when some protocomm - * command from the client side application is received. - * - * Calling this API inside an endpoint handler, with sufficient cleanup_delay, - * will allow the response / acknowledgment to be sent successfully before the - * underlying protocomm service is stopped. - * - * Cleaup_delay is set when calling wifi_prov_mgr_disable_auto_stop(). - * If not specified, it defaults to 1000ms. - * - * For straightforward cases, using this API is usually not necessary as - * provisioning is stopped automatically once WIFI_PROV_CRED_SUCCESS is emitted. - * Stopping is delayed (maximum 30 seconds) thus allowing the client side - * application to query for Wi-Fi state, i.e. after receiving the first query - * and sending `Wi-Fi state connected` response the service is stopped immediately. - */ -void wifi_prov_mgr_stop_provisioning(void); - -/** - * @brief Wait for provisioning service to finish - * - * Calling this API will block until provisioning service is stopped - * i.e. till event WIFI_PROV_END is emitted. - * - * This will not block if provisioning is not started or not initialized. - */ -void wifi_prov_mgr_wait(void); - -/** - * @brief Disable auto stopping of provisioning service upon completion - * - * By default, once provisioning is complete, the provisioning service is automatically - * stopped, and all endpoints (along with those registered by main application) are - * deactivated. - * - * This API is useful in the case when main application wishes to close provisioning service - * only after it receives some protocomm command from the client side app. For example, after - * connecting to Wi-Fi, the device may want to connect to the cloud, and only once that is - * successfully, the device is said to be fully configured. But, then it is upto the main - * application to explicitly call wifi_prov_mgr_stop_provisioning() later when the device is - * fully configured and the provisioning service is no longer required. - * - * @note This must be called before executing wifi_prov_mgr_start_provisioning() - * - * @param[in] cleanup_delay Sets the delay after which the actual cleanup of transport related - * resources is done after a call to wifi_prov_mgr_stop_provisioning() - * returns. Minimum allowed value is 100ms. If not specified, this will - * default to 1000ms. - * - * @return - * - ESP_OK : Success - * - ESP_ERR_INVALID_STATE : Manager not initialized or - * provisioning service already started - */ -esp_err_t wifi_prov_mgr_disable_auto_stop(uint32_t cleanup_delay); - -/** - * @brief Set application version and capabilities in the JSON data returned by - * proto-ver endpoint - * - * This function can be called multiple times, to specify information about the various - * application specific services running on the device, identified by unique labels. - * - * The provisioning service itself registers an entry in the JSON data, by the label "prov", - * containing only provisioning service version and capabilities. Application services should - * use a label other than "prov" so as not to overwrite this. - * - * @note This must be called before executing wifi_prov_mgr_start_provisioning() - * - * @param[in] label String indicating the application name. - * - * @param[in] version String indicating the application version. - * There is no constraint on format. - * - * @param[in] capabilities Array of strings with capabilities. - * These could be used by the client side app to know - * the application registered endpoint capabilities - * - * @param[in] total_capabilities Size of capabilities array - * - * @return - * - ESP_OK : Success - * - ESP_ERR_INVALID_STATE : Manager not initialized or - * provisioning service already started - * - ESP_ERR_NO_MEM : Failed to allocate memory for version string - * - ESP_ERR_INVALID_ARG : Null argument - */ -esp_err_t wifi_prov_mgr_set_app_info(const char *label, const char *version, - const char**capabilities, size_t total_capabilities); - -/** - * @brief Create an additional endpoint and allocate internal resources for it - * - * This API is to be called by the application if it wants to create an additional - * endpoint. All additional endpoints will be assigned UUIDs starting from 0xFF54 - * and so on in the order of execution. - * - * protocomm handler for the created endpoint is to be registered later using - * wifi_prov_mgr_endpoint_register() after provisioning has started. - * - * @note This API can only be called BEFORE provisioning is started - * - * @note Additional endpoints can be used for configuring client provided - * parameters other than Wi-Fi credentials, that are necessary for the - * main application and hence must be set prior to starting the application - * - * @note After session establishment, the additional endpoints must be targeted - * first by the client side application before sending Wi-Fi configuration, - * because once Wi-Fi configuration finishes the provisioning service is - * stopped and hence all endpoints are unregistered - * - * @param[in] ep_name unique name of the endpoint - * - * @return - * - ESP_OK : Success - * - ESP_FAIL : Failure - */ -esp_err_t wifi_prov_mgr_endpoint_create(const char *ep_name); - -/** - * @brief Register a handler for the previously created endpoint - * - * This API can be called by the application to register a protocomm handler - * to any endpoint that was created using wifi_prov_mgr_endpoint_create(). - * - * @note This API can only be called AFTER provisioning has started - * - * @note Additional endpoints can be used for configuring client provided - * parameters other than Wi-Fi credentials, that are necessary for the - * main application and hence must be set prior to starting the application - * - * @note After session establishment, the additional endpoints must be targeted - * first by the client side application before sending Wi-Fi configuration, - * because once Wi-Fi configuration finishes the provisioning service is - * stopped and hence all endpoints are unregistered - * - * @param[in] ep_name Name of the endpoint - * @param[in] handler Endpoint handler function - * @param[in] user_ctx User data - * - * @return - * - ESP_OK : Success - * - ESP_FAIL : Failure - */ -esp_err_t wifi_prov_mgr_endpoint_register(const char *ep_name, - protocomm_req_handler_t handler, - void *user_ctx); - -/** - * @brief Unregister the handler for an endpoint - * - * This API can be called if the application wants to selectively - * unregister the handler of an endpoint while the provisioning - * is still in progress. - * - * All the endpoint handlers are unregistered automatically when - * the provisioning stops. - * - * @param[in] ep_name Name of the endpoint - */ -void wifi_prov_mgr_endpoint_unregister(const char *ep_name); - -/** - * @brief Get state of Wi-Fi Station during provisioning - * - * @param[out] state Pointer to wifi_prov_sta_state_t - * variable to be filled - * - * @return - * - ESP_OK : Successfully retrieved Wi-Fi state - * - ESP_FAIL : Provisioning app not running - */ -esp_err_t wifi_prov_mgr_get_wifi_state(wifi_prov_sta_state_t *state); - -/** - * @brief Get reason code in case of Wi-Fi station - * disconnection during provisioning - * -* @param[out] reason Pointer to wifi_prov_sta_fail_reason_t -* variable to be filled - * - * @return - * - ESP_OK : Successfully retrieved Wi-Fi disconnect reason - * - ESP_FAIL : Provisioning app not running - */ -esp_err_t wifi_prov_mgr_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t *reason); - -/** - * @brief Runs Wi-Fi as Station with the supplied configuration - * - * Configures the Wi-Fi station mode to connect to the AP with - * SSID and password specified in config structure and sets - * Wi-Fi to run as station. - * - * This is automatically called by provisioning service upon - * receiving new credentials. - * - * If credentials are to be supplied to the manager via a - * different mode other than through protocomm, then this - * API needs to be called. - * - * Event WIFI_PROV_CRED_RECV is emitted after credentials have - * been applied and Wi-Fi station started - * - * @param[in] wifi_cfg Pointer to Wi-Fi configuration structure - * - * @return - * - ESP_OK : Wi-Fi configured and started successfully - * - ESP_FAIL : Failed to set configuration - */ -esp_err_t wifi_prov_mgr_configure_sta(wifi_config_t *wifi_cfg); - -/** - * @brief Reset Wi-Fi provisioning config - * - * Calling this API will restore WiFi stack persistent settings to default values. - * - * @return - * - ESP_OK : Reset provisioning config successfully - * - ESP_FAIL : Failed to reset provisioning config - */ -esp_err_t wifi_prov_mgr_reset_provisioning(void); - -/** - * @brief Reset internal state machine and clear provisioned credentials. - * - * This API should be used to restart provisioning ONLY in the case - * of provisioning failures without rebooting the device. - * - * @return - * - ESP_OK : Reset provisioning state machine successfully - * - ESP_FAIL : Failed to reset provisioning state machine - * - ESP_ERR_INVALID_STATE : Manager not initialized - */ -esp_err_t wifi_prov_mgr_reset_sm_state_on_failure(void); - -/** - * @brief Reset internal state machine and clear provisioned credentials. - * - * This API can be used to restart provisioning ONLY in case the device is - * to be provisioned again for new credentials after a previous successful - * provisioning without rebooting the device. - * - * @note This API can be used only if provisioning auto-stop has been - * disabled using wifi_prov_mgr_disable_auto_stop() - * - * @return - * - ESP_OK : Reset provisioning state machine successfully - * - ESP_FAIL : Failed to reset provisioning state machine - * - ESP_ERR_INVALID_STATE : Manager not initialized - */ -esp_err_t wifi_prov_mgr_reset_sm_state_for_reprovision(void); - -#ifdef __cplusplus -} -#endif diff --git a/components/wifi_provisioning/include/wifi_provisioning/scheme_ble.h b/components/wifi_provisioning/include/wifi_provisioning/scheme_ble.h deleted file mode 100644 index fc19e16b171a..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/scheme_ble.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include -#include - -#include "wifi_provisioning/manager.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Scheme that can be used by manager for provisioning - * over BLE transport with GATT server - */ -extern const wifi_prov_scheme_t wifi_prov_scheme_ble; - -/* This scheme specific event handler is to be used when application - * doesn't require BT and BLE after provisioning has finished */ -#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM { \ - .event_cb = wifi_prov_scheme_ble_event_cb_free_btdm, \ - .user_data = NULL \ -} - -/* This scheme specific event handler is to be used when application - * doesn't require BLE to be active after provisioning has finished */ -#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE { \ - .event_cb = wifi_prov_scheme_ble_event_cb_free_ble, \ - .user_data = NULL \ -} - -/* This scheme specific event handler is to be used when application - * doesn't require BT to be active after provisioning has finished */ -#define WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT { \ - .event_cb = wifi_prov_scheme_ble_event_cb_free_bt, \ - .user_data = NULL \ -} - -void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event_t event, void *event_data); -void wifi_prov_scheme_ble_event_cb_free_ble (void *user_data, wifi_prov_cb_event_t event, void *event_data); -void wifi_prov_scheme_ble_event_cb_free_bt (void *user_data, wifi_prov_cb_event_t event, void *event_data); - -/** - * @brief Set the 128 bit GATT service UUID used for provisioning - * - * This API is used to override the default 128 bit provisioning - * service UUID, which is 0000ffff-0000-1000-8000-00805f9b34fb. - * - * This must be called before starting provisioning, i.e. before - * making a call to wifi_prov_mgr_start_provisioning(), otherwise - * the default UUID will be used. - * - * @note The data being pointed to by the argument must be valid - * atleast till provisioning is started. Upon start, the - * manager will store an internal copy of this UUID, and - * this data can be freed or invalidated afterwords. - * - * @param[in] uuid128 A custom 128 bit UUID - * - * @return - * - ESP_OK : Success - * - ESP_ERR_INVALID_ARG : Null argument - */ -esp_err_t wifi_prov_scheme_ble_set_service_uuid(uint8_t *uuid128); - -/** - * @brief Set manufacturer specific data in scan response - * - * This must be called before starting provisioning, i.e. before - * making a call to wifi_prov_mgr_start_provisioning(). - * - * @note It is important to understand that length of custom manufacturer - * data should be within limits. The manufacturer data goes into scan - * response along with BLE device name. By default, BLE device name - * length is of 11 Bytes, however it can vary as per application use - * case. So, one has to honour the scan response data size limits i.e. - * (mfg_data_len + 2) < 31 - (device_name_length + 2 ). If the - * mfg_data length exceeds this limit, the length will be truncated. - * - * @param[in] mfg_data Custom manufacturer data - * @param[in] mfg_data_len Manufacturer data length - * - * @return - * - ESP_OK : Success - * - ESP_ERR_INVALID_ARG : Null argument - */ -esp_err_t wifi_prov_scheme_ble_set_mfg_data(uint8_t *mfg_data, ssize_t mfg_data_len); - -#ifdef __cplusplus -} -#endif diff --git a/components/wifi_provisioning/include/wifi_provisioning/scheme_console.h b/components/wifi_provisioning/include/wifi_provisioning/scheme_console.h deleted file mode 100644 index 760fe3243a59..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/scheme_console.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include -#include - -#include "wifi_provisioning/manager.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Scheme that can be used by manager for provisioning - * over console (Serial UART) - */ -extern const wifi_prov_scheme_t wifi_prov_scheme_console; - -#ifdef __cplusplus -} -#endif diff --git a/components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h b/components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h deleted file mode 100644 index eda48be0f7e9..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include -#include - -#include "wifi_provisioning/manager.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Scheme that can be used by manager for provisioning - * over SoftAP transport with HTTP server - */ -extern const wifi_prov_scheme_t wifi_prov_scheme_softap; - -/** - * - * @brief Provide HTTPD Server handle externally. - * - * Useful in cases wherein applications need the webserver for some - * different operations, and do not want the wifi provisioning component - * to start/stop a new instance. - * - * @note This API should be called before wifi_prov_mgr_start_provisioning() - * - * @param[in] handle Handle to HTTPD server instance - */ -void wifi_prov_scheme_softap_set_httpd_handle(void *handle); -#ifdef __cplusplus -} -#endif diff --git a/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h deleted file mode 100644 index 6c9d11f5ab1d..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef _WIFI_PROV_CONFIG_H_ -#define _WIFI_PROV_CONFIG_H_ - -#include "esp_netif_ip_addr.h" -#include "esp_err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief WiFi STA status for conveying back to the provisioning master - */ -typedef enum { - WIFI_PROV_STA_CONNECTING, - WIFI_PROV_STA_CONNECTED, - WIFI_PROV_STA_DISCONNECTED -} wifi_prov_sta_state_t; - -/** - * @brief WiFi STA connection fail reason - */ -typedef enum { - WIFI_PROV_STA_AUTH_ERROR, - WIFI_PROV_STA_AP_NOT_FOUND -} wifi_prov_sta_fail_reason_t; - -/** - * @brief WiFi STA connected status information - */ -typedef struct { - /** - * IP Address received by station - */ - char ip_addr[IP4ADDR_STRLEN_MAX]; - - char bssid[6]; /*!< BSSID of the AP to which connection was estalished */ - char ssid[33]; /*!< SSID of the to which connection was estalished */ - uint8_t channel; /*!< Channel of the AP */ - uint8_t auth_mode; /*!< Authorization mode of the AP */ -} wifi_prov_sta_conn_info_t; - -/** - * @brief WiFi status data to be sent in response to `get_status` request from master - */ -typedef struct { - wifi_prov_sta_state_t wifi_state; /*!< WiFi state of the station */ - union { - /** - * Reason for disconnection (valid only when `wifi_state` is `WIFI_STATION_DISCONNECTED`) - */ - wifi_prov_sta_fail_reason_t fail_reason; - - /** - * Connection information (valid only when `wifi_state` is `WIFI_STATION_CONNECTED`) - */ - wifi_prov_sta_conn_info_t conn_info; - }; -} wifi_prov_config_get_data_t; - -/** - * @brief WiFi config data received by slave during `set_config` request from master - */ -typedef struct { - char ssid[33]; /*!< SSID of the AP to which the slave is to be connected */ - char password[64]; /*!< Password of the AP */ - char bssid[6]; /*!< BSSID of the AP */ - uint8_t channel; /*!< Channel of the AP */ -} wifi_prov_config_set_data_t; - -/** - * @brief Type of context data passed to each get/set/apply handler - * function set in `wifi_prov_config_handlers` structure. - * - * This is passed as an opaque pointer, thereby allowing it be defined - * later in application code as per requirements. - */ -typedef struct wifi_prov_ctx wifi_prov_ctx_t; - -/** - * @brief Internal handlers for receiving and responding to protocomm - * requests from master - * - * This is to be passed as priv_data for protocomm request handler - * (refer to `wifi_prov_config_data_handler()`) when calling `protocomm_add_endpoint()`. - */ -typedef struct wifi_prov_config_handlers { - /** - * Handler function called when connection status - * of the slave (in WiFi station mode) is requested - */ - esp_err_t (*get_status_handler)(wifi_prov_config_get_data_t *resp_data, - wifi_prov_ctx_t **ctx); - - /** - * Handler function called when WiFi connection configuration - * (eg. AP SSID, password, etc.) of the slave (in WiFi station mode) - * is to be set to user provided values - */ - esp_err_t (*set_config_handler)(const wifi_prov_config_set_data_t *req_data, - wifi_prov_ctx_t **ctx); - - /** - * Handler function for applying the configuration that was set in - * `set_config_handler`. After applying the station may get connected to - * the AP or may fail to connect. The slave must be ready to convey the - * updated connection status information when `get_status_handler` is - * invoked again by the master. - */ - esp_err_t (*apply_config_handler)(wifi_prov_ctx_t **ctx); - - /** - * Context pointer to be passed to above handler functions upon invocation - */ - wifi_prov_ctx_t *ctx; -} wifi_prov_config_handlers_t; - -/** - * @brief Handler for receiving and responding to requests from master - * - * This is to be registered as the `wifi_config` endpoint handler - * (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()` - */ -esp_err_t wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/wifi_provisioning/include/wifi_provisioning/wifi_scan.h b/components/wifi_provisioning/include/wifi_provisioning/wifi_scan.h deleted file mode 100644 index a4ebb7e57002..000000000000 --- a/components/wifi_provisioning/include/wifi_provisioning/wifi_scan.h +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _PROV_WIFI_SCAN_H_ -#define _PROV_WIFI_SCAN_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define WIFI_SSID_LEN sizeof(((wifi_ap_record_t *)0)->ssid) -#define WIFI_BSSID_LEN sizeof(((wifi_ap_record_t *)0)->bssid) - -/** - * @brief Type of context data passed to each get/set/apply handler - * function set in `wifi_prov_scan_handlers` structure. - * - * This is passed as an opaque pointer, thereby allowing it be defined - * later in application code as per requirements. - */ -typedef struct wifi_prov_scan_ctx wifi_prov_scan_ctx_t; - -/** - * @brief Structure of entries in the scan results list - */ -typedef struct { - /** - * SSID of Wi-Fi AP - */ - char ssid[WIFI_SSID_LEN]; - - /** - * BSSID of Wi-Fi AP - */ - char bssid[WIFI_BSSID_LEN]; - - /** - * Wi-Fi channel number - */ - uint8_t channel; - - /** - * Signal strength - */ - int rssi; - - /** - * Wi-Fi security mode - */ - uint8_t auth; -} wifi_prov_scan_result_t; - -/** - * @brief Internal handlers for receiving and responding to protocomm - * requests from client - * - * This is to be passed as priv_data for protocomm request handler - * (refer to `wifi_prov_scan_handler()`) when calling `protocomm_add_endpoint()`. - */ -typedef struct wifi_prov_scan_handlers { - /** - * Handler function called when scan start command is received - * with various scan parameters : - * - * blocking (input) - If true, the function should return only - * when the scanning is finished - * - * passive (input) - If true, scan is to be started in passive - * mode (this may be slower) instead of active mode - * - * group_channels (input) - This specifies whether to scan - * all channels in one go (when zero) or perform scanning of - * channels in groups, with 120ms delay between scanning of - * consecutive groups, and the value of this parameter sets the - * number of channels in each group. This is useful when transport - * mode is SoftAP, where scanning all channels in one go may not - * give the Wi-Fi driver enough time to send out beacons, and - * hence may cause disconnection with any connected stations. - * When scanning in groups, the manager will wait for atleast - * 120ms after completing scan on a group of channels, and thus - * allow the driver to send out the beacons. For example, given - * that the total number of Wi-Fi channels is 14, then setting - * group_channels to 4, will create 5 groups, with each group - * having 3 channels, except the last one which will have - * 14 % 3 = 2 channels. So, when scan is started, the first 3 - * channels will be scanned, followed by a 120ms delay, and then - * the next 3 channels, and so on, until all the 14 channels have - * been scanned. One may need to adjust this parameter as having - * only few channels in a group may slow down the overall scan - * time, while having too many may again cause disconnection. - * Usually a value of 4 should work for most cases. Note that - * for any other mode of transport, e.g. BLE, this can be safely - * set to 0, and hence achieve the fastest overall scanning time. - * - * period_ms (input) - Scan parameter specifying how long to - * wait on each channel (in milli-seconds) - */ - esp_err_t (*scan_start)(bool blocking, bool passive, - uint8_t group_channels, uint32_t period_ms, - wifi_prov_scan_ctx_t **ctx); - - /** - * Handler function called when scan status is requested. Status - * is given the parameters : - * - * scan_finished (output) - When scan has finished this returns true - * - * result_count (output) - This gives the total number of results - * obtained till now. If scan is yet happening this number will - * keep on updating - */ - esp_err_t (*scan_status)(bool *scan_finished, - uint16_t *result_count, - wifi_prov_scan_ctx_t **ctx); - - /** - * Handler function called when scan result is requested. Parameters : - * - * scan_result - For fetching scan results. This can be called even - * if scan is still on going - * - * start_index (input) - Starting index from where to fetch the - * entries from the results list - * - * count (input) - Number of entries to fetch from the starting index - * - * entries (output) - List of entries returned. Each entry consists - * of ssid, channel and rssi information - */ - esp_err_t (*scan_result)(uint16_t result_index, - wifi_prov_scan_result_t *result, - wifi_prov_scan_ctx_t **ctx); - - /** - * Context pointer to be passed to above handler functions upon invocation - */ - wifi_prov_scan_ctx_t *ctx; -} wifi_prov_scan_handlers_t; - -/** - * @brief Handler for sending on demand Wi-Fi scan results - * - * This is to be registered as the `prov-scan` endpoint handler - * (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()` - */ -esp_err_t wifi_prov_scan_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/wifi_provisioning/proto-c/wifi_config.pb-c.c b/components/wifi_provisioning/proto-c/wifi_config.pb-c.c deleted file mode 100644 index 0be6dcd86798..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_config.pb-c.c +++ /dev/null @@ -1,744 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_config.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "wifi_config.pb-c.h" -void cmd_get_status__init - (CmdGetStatus *message) -{ - static const CmdGetStatus init_value = CMD_GET_STATUS__INIT; - *message = init_value; -} -size_t cmd_get_status__get_packed_size - (const CmdGetStatus *message) -{ - assert(message->base.descriptor == &cmd_get_status__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_get_status__pack - (const CmdGetStatus *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_get_status__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_get_status__pack_to_buffer - (const CmdGetStatus *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_get_status__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdGetStatus * - cmd_get_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdGetStatus *) - protobuf_c_message_unpack (&cmd_get_status__descriptor, - allocator, len, data); -} -void cmd_get_status__free_unpacked - (CmdGetStatus *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_get_status__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_get_status__init - (RespGetStatus *message) -{ - static const RespGetStatus init_value = RESP_GET_STATUS__INIT; - *message = init_value; -} -size_t resp_get_status__get_packed_size - (const RespGetStatus *message) -{ - assert(message->base.descriptor == &resp_get_status__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_get_status__pack - (const RespGetStatus *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_get_status__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_get_status__pack_to_buffer - (const RespGetStatus *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_get_status__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespGetStatus * - resp_get_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespGetStatus *) - protobuf_c_message_unpack (&resp_get_status__descriptor, - allocator, len, data); -} -void resp_get_status__free_unpacked - (RespGetStatus *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_get_status__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void cmd_set_config__init - (CmdSetConfig *message) -{ - static const CmdSetConfig init_value = CMD_SET_CONFIG__INIT; - *message = init_value; -} -size_t cmd_set_config__get_packed_size - (const CmdSetConfig *message) -{ - assert(message->base.descriptor == &cmd_set_config__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_set_config__pack - (const CmdSetConfig *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_set_config__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_set_config__pack_to_buffer - (const CmdSetConfig *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_set_config__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdSetConfig * - cmd_set_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdSetConfig *) - protobuf_c_message_unpack (&cmd_set_config__descriptor, - allocator, len, data); -} -void cmd_set_config__free_unpacked - (CmdSetConfig *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_set_config__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_set_config__init - (RespSetConfig *message) -{ - static const RespSetConfig init_value = RESP_SET_CONFIG__INIT; - *message = init_value; -} -size_t resp_set_config__get_packed_size - (const RespSetConfig *message) -{ - assert(message->base.descriptor == &resp_set_config__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_set_config__pack - (const RespSetConfig *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_set_config__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_set_config__pack_to_buffer - (const RespSetConfig *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_set_config__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespSetConfig * - resp_set_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespSetConfig *) - protobuf_c_message_unpack (&resp_set_config__descriptor, - allocator, len, data); -} -void resp_set_config__free_unpacked - (RespSetConfig *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_set_config__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void cmd_apply_config__init - (CmdApplyConfig *message) -{ - static const CmdApplyConfig init_value = CMD_APPLY_CONFIG__INIT; - *message = init_value; -} -size_t cmd_apply_config__get_packed_size - (const CmdApplyConfig *message) -{ - assert(message->base.descriptor == &cmd_apply_config__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_apply_config__pack - (const CmdApplyConfig *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_apply_config__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_apply_config__pack_to_buffer - (const CmdApplyConfig *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_apply_config__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdApplyConfig * - cmd_apply_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdApplyConfig *) - protobuf_c_message_unpack (&cmd_apply_config__descriptor, - allocator, len, data); -} -void cmd_apply_config__free_unpacked - (CmdApplyConfig *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_apply_config__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_apply_config__init - (RespApplyConfig *message) -{ - static const RespApplyConfig init_value = RESP_APPLY_CONFIG__INIT; - *message = init_value; -} -size_t resp_apply_config__get_packed_size - (const RespApplyConfig *message) -{ - assert(message->base.descriptor == &resp_apply_config__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_apply_config__pack - (const RespApplyConfig *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_apply_config__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_apply_config__pack_to_buffer - (const RespApplyConfig *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_apply_config__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespApplyConfig * - resp_apply_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespApplyConfig *) - protobuf_c_message_unpack (&resp_apply_config__descriptor, - allocator, len, data); -} -void resp_apply_config__free_unpacked - (RespApplyConfig *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_apply_config__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void wi_fi_config_payload__init - (WiFiConfigPayload *message) -{ - static const WiFiConfigPayload init_value = WI_FI_CONFIG_PAYLOAD__INIT; - *message = init_value; -} -size_t wi_fi_config_payload__get_packed_size - (const WiFiConfigPayload *message) -{ - assert(message->base.descriptor == &wi_fi_config_payload__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t wi_fi_config_payload__pack - (const WiFiConfigPayload *message, - uint8_t *out) -{ - assert(message->base.descriptor == &wi_fi_config_payload__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t wi_fi_config_payload__pack_to_buffer - (const WiFiConfigPayload *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &wi_fi_config_payload__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -WiFiConfigPayload * - wi_fi_config_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (WiFiConfigPayload *) - protobuf_c_message_unpack (&wi_fi_config_payload__descriptor, - allocator, len, data); -} -void wi_fi_config_payload__free_unpacked - (WiFiConfigPayload *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &wi_fi_config_payload__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -#define cmd_get_status__field_descriptors NULL -#define cmd_get_status__field_indices_by_name NULL -#define cmd_get_status__number_ranges NULL -const ProtobufCMessageDescriptor cmd_get_status__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdGetStatus", - "CmdGetStatus", - "CmdGetStatus", - "", - sizeof(CmdGetStatus), - 0, - cmd_get_status__field_descriptors, - cmd_get_status__field_indices_by_name, - 0, cmd_get_status__number_ranges, - (ProtobufCMessageInit) cmd_get_status__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor resp_get_status__field_descriptors[4] = -{ - { - "status", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(RespGetStatus, status), - &status__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "sta_state", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(RespGetStatus, sta_state), - &wifi_station_state__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "fail_reason", - 10, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - offsetof(RespGetStatus, state_case), - offsetof(RespGetStatus, fail_reason), - &wifi_connect_failed_reason__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "connected", - 11, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(RespGetStatus, state_case), - offsetof(RespGetStatus, connected), - &wifi_connected_state__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned resp_get_status__field_indices_by_name[] = { - 3, /* field[3] = connected */ - 2, /* field[2] = fail_reason */ - 1, /* field[1] = sta_state */ - 0, /* field[0] = status */ -}; -static const ProtobufCIntRange resp_get_status__number_ranges[2 + 1] = -{ - { 1, 0 }, - { 10, 2 }, - { 0, 4 } -}; -const ProtobufCMessageDescriptor resp_get_status__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespGetStatus", - "RespGetStatus", - "RespGetStatus", - "", - sizeof(RespGetStatus), - 4, - resp_get_status__field_descriptors, - resp_get_status__field_indices_by_name, - 2, resp_get_status__number_ranges, - (ProtobufCMessageInit) resp_get_status__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor cmd_set_config__field_descriptors[4] = -{ - { - "ssid", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(CmdSetConfig, ssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "passphrase", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(CmdSetConfig, passphrase), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "bssid", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(CmdSetConfig, bssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "channel", - 4, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - offsetof(CmdSetConfig, channel), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned cmd_set_config__field_indices_by_name[] = { - 2, /* field[2] = bssid */ - 3, /* field[3] = channel */ - 1, /* field[1] = passphrase */ - 0, /* field[0] = ssid */ -}; -static const ProtobufCIntRange cmd_set_config__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 4 } -}; -const ProtobufCMessageDescriptor cmd_set_config__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdSetConfig", - "CmdSetConfig", - "CmdSetConfig", - "", - sizeof(CmdSetConfig), - 4, - cmd_set_config__field_descriptors, - cmd_set_config__field_indices_by_name, - 1, cmd_set_config__number_ranges, - (ProtobufCMessageInit) cmd_set_config__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor resp_set_config__field_descriptors[1] = -{ - { - "status", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(RespSetConfig, status), - &status__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned resp_set_config__field_indices_by_name[] = { - 0, /* field[0] = status */ -}; -static const ProtobufCIntRange resp_set_config__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 1 } -}; -const ProtobufCMessageDescriptor resp_set_config__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespSetConfig", - "RespSetConfig", - "RespSetConfig", - "", - sizeof(RespSetConfig), - 1, - resp_set_config__field_descriptors, - resp_set_config__field_indices_by_name, - 1, resp_set_config__number_ranges, - (ProtobufCMessageInit) resp_set_config__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define cmd_apply_config__field_descriptors NULL -#define cmd_apply_config__field_indices_by_name NULL -#define cmd_apply_config__number_ranges NULL -const ProtobufCMessageDescriptor cmd_apply_config__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdApplyConfig", - "CmdApplyConfig", - "CmdApplyConfig", - "", - sizeof(CmdApplyConfig), - 0, - cmd_apply_config__field_descriptors, - cmd_apply_config__field_indices_by_name, - 0, cmd_apply_config__number_ranges, - (ProtobufCMessageInit) cmd_apply_config__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor resp_apply_config__field_descriptors[1] = -{ - { - "status", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(RespApplyConfig, status), - &status__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned resp_apply_config__field_indices_by_name[] = { - 0, /* field[0] = status */ -}; -static const ProtobufCIntRange resp_apply_config__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 1 } -}; -const ProtobufCMessageDescriptor resp_apply_config__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespApplyConfig", - "RespApplyConfig", - "RespApplyConfig", - "", - sizeof(RespApplyConfig), - 1, - resp_apply_config__field_descriptors, - resp_apply_config__field_indices_by_name, - 1, resp_apply_config__number_ranges, - (ProtobufCMessageInit) resp_apply_config__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor wi_fi_config_payload__field_descriptors[7] = -{ - { - "msg", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiConfigPayload, msg), - &wi_fi_config_msg_type__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_get_status", - 10, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, cmd_get_status), - &cmd_get_status__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_get_status", - 11, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, resp_get_status), - &resp_get_status__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_set_config", - 12, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, cmd_set_config), - &cmd_set_config__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_set_config", - 13, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, resp_set_config), - &resp_set_config__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_apply_config", - 14, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, cmd_apply_config), - &cmd_apply_config__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_apply_config", - 15, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiConfigPayload, payload_case), - offsetof(WiFiConfigPayload, resp_apply_config), - &resp_apply_config__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned wi_fi_config_payload__field_indices_by_name[] = { - 5, /* field[5] = cmd_apply_config */ - 1, /* field[1] = cmd_get_status */ - 3, /* field[3] = cmd_set_config */ - 0, /* field[0] = msg */ - 6, /* field[6] = resp_apply_config */ - 2, /* field[2] = resp_get_status */ - 4, /* field[4] = resp_set_config */ -}; -static const ProtobufCIntRange wi_fi_config_payload__number_ranges[2 + 1] = -{ - { 1, 0 }, - { 10, 1 }, - { 0, 7 } -}; -const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "WiFiConfigPayload", - "WiFiConfigPayload", - "WiFiConfigPayload", - "", - sizeof(WiFiConfigPayload), - 7, - wi_fi_config_payload__field_descriptors, - wi_fi_config_payload__field_indices_by_name, - 2, wi_fi_config_payload__number_ranges, - (ProtobufCMessageInit) wi_fi_config_payload__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue wi_fi_config_msg_type__enum_values_by_number[6] = -{ - { "TypeCmdGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus", 0 }, - { "TypeRespGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus", 1 }, - { "TypeCmdSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig", 2 }, - { "TypeRespSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig", 3 }, - { "TypeCmdApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig", 4 }, - { "TypeRespApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig", 5 }, -}; -static const ProtobufCIntRange wi_fi_config_msg_type__value_ranges[] = { -{0, 0},{0, 6} -}; -static const ProtobufCEnumValueIndex wi_fi_config_msg_type__enum_values_by_name[6] = -{ - { "TypeCmdApplyConfig", 4 }, - { "TypeCmdGetStatus", 0 }, - { "TypeCmdSetConfig", 2 }, - { "TypeRespApplyConfig", 5 }, - { "TypeRespGetStatus", 1 }, - { "TypeRespSetConfig", 3 }, -}; -const ProtobufCEnumDescriptor wi_fi_config_msg_type__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WiFiConfigMsgType", - "WiFiConfigMsgType", - "WiFiConfigMsgType", - "", - 6, - wi_fi_config_msg_type__enum_values_by_number, - 6, - wi_fi_config_msg_type__enum_values_by_name, - 1, - wi_fi_config_msg_type__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; diff --git a/components/wifi_provisioning/proto-c/wifi_config.pb-c.h b/components/wifi_provisioning/proto-c/wifi_config.pb-c.h deleted file mode 100644 index 3e293f23be03..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_config.pb-c.h +++ /dev/null @@ -1,321 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_config.proto */ - -#ifndef PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED -#define PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - -#include "constants.pb-c.h" -#include "wifi_constants.pb-c.h" - -typedef struct CmdGetStatus CmdGetStatus; -typedef struct RespGetStatus RespGetStatus; -typedef struct CmdSetConfig CmdSetConfig; -typedef struct RespSetConfig RespSetConfig; -typedef struct CmdApplyConfig CmdApplyConfig; -typedef struct RespApplyConfig RespApplyConfig; -typedef struct WiFiConfigPayload WiFiConfigPayload; - - -/* --- enums --- */ - -typedef enum _WiFiConfigMsgType { - WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus = 0, - WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus = 1, - WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig = 2, - WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig = 3, - WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig = 4, - WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig = 5 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_MSG_TYPE) -} WiFiConfigMsgType; - -/* --- messages --- */ - -struct CmdGetStatus -{ - ProtobufCMessage base; -}; -#define CMD_GET_STATUS__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_get_status__descriptor) \ - } - - -typedef enum { - RESP_GET_STATUS__STATE__NOT_SET = 0, - RESP_GET_STATUS__STATE_FAIL_REASON = 10, - RESP_GET_STATUS__STATE_CONNECTED = 11 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(RESP_GET_STATUS__STATE__CASE) -} RespGetStatus__StateCase; - -struct RespGetStatus -{ - ProtobufCMessage base; - Status status; - WifiStationState sta_state; - RespGetStatus__StateCase state_case; - union { - WifiConnectFailedReason fail_reason; - WifiConnectedState *connected; - }; -}; -#define RESP_GET_STATUS__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_get_status__descriptor) \ - , STATUS__Success, WIFI_STATION_STATE__Connected, RESP_GET_STATUS__STATE__NOT_SET, {0} } - - -struct CmdSetConfig -{ - ProtobufCMessage base; - ProtobufCBinaryData ssid; - ProtobufCBinaryData passphrase; - ProtobufCBinaryData bssid; - int32_t channel; -}; -#define CMD_SET_CONFIG__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_set_config__descriptor) \ - , {0,NULL}, {0,NULL}, {0,NULL}, 0 } - - -struct RespSetConfig -{ - ProtobufCMessage base; - Status status; -}; -#define RESP_SET_CONFIG__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_set_config__descriptor) \ - , STATUS__Success } - - -struct CmdApplyConfig -{ - ProtobufCMessage base; -}; -#define CMD_APPLY_CONFIG__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_apply_config__descriptor) \ - } - - -struct RespApplyConfig -{ - ProtobufCMessage base; - Status status; -}; -#define RESP_APPLY_CONFIG__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_apply_config__descriptor) \ - , STATUS__Success } - - -typedef enum { - WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET = 0, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_STATUS = 10, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS = 11, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_CONFIG = 12, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG = 13, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_APPLY_CONFIG = 14, - WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG = 15 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_PAYLOAD__PAYLOAD__CASE) -} WiFiConfigPayload__PayloadCase; - -struct WiFiConfigPayload -{ - ProtobufCMessage base; - WiFiConfigMsgType msg; - WiFiConfigPayload__PayloadCase payload_case; - union { - CmdGetStatus *cmd_get_status; - RespGetStatus *resp_get_status; - CmdSetConfig *cmd_set_config; - RespSetConfig *resp_set_config; - CmdApplyConfig *cmd_apply_config; - RespApplyConfig *resp_apply_config; - }; -}; -#define WI_FI_CONFIG_PAYLOAD__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&wi_fi_config_payload__descriptor) \ - , WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus, WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET, {0} } - - -/* CmdGetStatus methods */ -void cmd_get_status__init - (CmdGetStatus *message); -size_t cmd_get_status__get_packed_size - (const CmdGetStatus *message); -size_t cmd_get_status__pack - (const CmdGetStatus *message, - uint8_t *out); -size_t cmd_get_status__pack_to_buffer - (const CmdGetStatus *message, - ProtobufCBuffer *buffer); -CmdGetStatus * - cmd_get_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_get_status__free_unpacked - (CmdGetStatus *message, - ProtobufCAllocator *allocator); -/* RespGetStatus methods */ -void resp_get_status__init - (RespGetStatus *message); -size_t resp_get_status__get_packed_size - (const RespGetStatus *message); -size_t resp_get_status__pack - (const RespGetStatus *message, - uint8_t *out); -size_t resp_get_status__pack_to_buffer - (const RespGetStatus *message, - ProtobufCBuffer *buffer); -RespGetStatus * - resp_get_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_get_status__free_unpacked - (RespGetStatus *message, - ProtobufCAllocator *allocator); -/* CmdSetConfig methods */ -void cmd_set_config__init - (CmdSetConfig *message); -size_t cmd_set_config__get_packed_size - (const CmdSetConfig *message); -size_t cmd_set_config__pack - (const CmdSetConfig *message, - uint8_t *out); -size_t cmd_set_config__pack_to_buffer - (const CmdSetConfig *message, - ProtobufCBuffer *buffer); -CmdSetConfig * - cmd_set_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_set_config__free_unpacked - (CmdSetConfig *message, - ProtobufCAllocator *allocator); -/* RespSetConfig methods */ -void resp_set_config__init - (RespSetConfig *message); -size_t resp_set_config__get_packed_size - (const RespSetConfig *message); -size_t resp_set_config__pack - (const RespSetConfig *message, - uint8_t *out); -size_t resp_set_config__pack_to_buffer - (const RespSetConfig *message, - ProtobufCBuffer *buffer); -RespSetConfig * - resp_set_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_set_config__free_unpacked - (RespSetConfig *message, - ProtobufCAllocator *allocator); -/* CmdApplyConfig methods */ -void cmd_apply_config__init - (CmdApplyConfig *message); -size_t cmd_apply_config__get_packed_size - (const CmdApplyConfig *message); -size_t cmd_apply_config__pack - (const CmdApplyConfig *message, - uint8_t *out); -size_t cmd_apply_config__pack_to_buffer - (const CmdApplyConfig *message, - ProtobufCBuffer *buffer); -CmdApplyConfig * - cmd_apply_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_apply_config__free_unpacked - (CmdApplyConfig *message, - ProtobufCAllocator *allocator); -/* RespApplyConfig methods */ -void resp_apply_config__init - (RespApplyConfig *message); -size_t resp_apply_config__get_packed_size - (const RespApplyConfig *message); -size_t resp_apply_config__pack - (const RespApplyConfig *message, - uint8_t *out); -size_t resp_apply_config__pack_to_buffer - (const RespApplyConfig *message, - ProtobufCBuffer *buffer); -RespApplyConfig * - resp_apply_config__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_apply_config__free_unpacked - (RespApplyConfig *message, - ProtobufCAllocator *allocator); -/* WiFiConfigPayload methods */ -void wi_fi_config_payload__init - (WiFiConfigPayload *message); -size_t wi_fi_config_payload__get_packed_size - (const WiFiConfigPayload *message); -size_t wi_fi_config_payload__pack - (const WiFiConfigPayload *message, - uint8_t *out); -size_t wi_fi_config_payload__pack_to_buffer - (const WiFiConfigPayload *message, - ProtobufCBuffer *buffer); -WiFiConfigPayload * - wi_fi_config_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void wi_fi_config_payload__free_unpacked - (WiFiConfigPayload *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*CmdGetStatus_Closure) - (const CmdGetStatus *message, - void *closure_data); -typedef void (*RespGetStatus_Closure) - (const RespGetStatus *message, - void *closure_data); -typedef void (*CmdSetConfig_Closure) - (const CmdSetConfig *message, - void *closure_data); -typedef void (*RespSetConfig_Closure) - (const RespSetConfig *message, - void *closure_data); -typedef void (*CmdApplyConfig_Closure) - (const CmdApplyConfig *message, - void *closure_data); -typedef void (*RespApplyConfig_Closure) - (const RespApplyConfig *message, - void *closure_data); -typedef void (*WiFiConfigPayload_Closure) - (const WiFiConfigPayload *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor wi_fi_config_msg_type__descriptor; -extern const ProtobufCMessageDescriptor cmd_get_status__descriptor; -extern const ProtobufCMessageDescriptor resp_get_status__descriptor; -extern const ProtobufCMessageDescriptor cmd_set_config__descriptor; -extern const ProtobufCMessageDescriptor resp_set_config__descriptor; -extern const ProtobufCMessageDescriptor cmd_apply_config__descriptor; -extern const ProtobufCMessageDescriptor resp_apply_config__descriptor; -extern const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED */ diff --git a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c b/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c deleted file mode 100644 index aec0f4182041..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c +++ /dev/null @@ -1,244 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_constants.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "wifi_constants.pb-c.h" -void wifi_connected_state__init - (WifiConnectedState *message) -{ - static const WifiConnectedState init_value = WIFI_CONNECTED_STATE__INIT; - *message = init_value; -} -size_t wifi_connected_state__get_packed_size - (const WifiConnectedState *message) -{ - assert(message->base.descriptor == &wifi_connected_state__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t wifi_connected_state__pack - (const WifiConnectedState *message, - uint8_t *out) -{ - assert(message->base.descriptor == &wifi_connected_state__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t wifi_connected_state__pack_to_buffer - (const WifiConnectedState *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &wifi_connected_state__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -WifiConnectedState * - wifi_connected_state__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (WifiConnectedState *) - protobuf_c_message_unpack (&wifi_connected_state__descriptor, - allocator, len, data); -} -void wifi_connected_state__free_unpacked - (WifiConnectedState *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &wifi_connected_state__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -static const ProtobufCFieldDescriptor wifi_connected_state__field_descriptors[5] = -{ - { - "ip4_addr", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(WifiConnectedState, ip4_addr), - NULL, - &protobuf_c_empty_string, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "auth_mode", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WifiConnectedState, auth_mode), - &wifi_auth_mode__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "ssid", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(WifiConnectedState, ssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "bssid", - 4, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(WifiConnectedState, bssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "channel", - 5, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - offsetof(WifiConnectedState, channel), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned wifi_connected_state__field_indices_by_name[] = { - 1, /* field[1] = auth_mode */ - 3, /* field[3] = bssid */ - 4, /* field[4] = channel */ - 0, /* field[0] = ip4_addr */ - 2, /* field[2] = ssid */ -}; -static const ProtobufCIntRange wifi_connected_state__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 5 } -}; -const ProtobufCMessageDescriptor wifi_connected_state__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "WifiConnectedState", - "WifiConnectedState", - "WifiConnectedState", - "", - sizeof(WifiConnectedState), - 5, - wifi_connected_state__field_descriptors, - wifi_connected_state__field_indices_by_name, - 1, wifi_connected_state__number_ranges, - (ProtobufCMessageInit) wifi_connected_state__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue wifi_station_state__enum_values_by_number[4] = -{ - { "Connected", "WIFI_STATION_STATE__Connected", 0 }, - { "Connecting", "WIFI_STATION_STATE__Connecting", 1 }, - { "Disconnected", "WIFI_STATION_STATE__Disconnected", 2 }, - { "ConnectionFailed", "WIFI_STATION_STATE__ConnectionFailed", 3 }, -}; -static const ProtobufCIntRange wifi_station_state__value_ranges[] = { -{0, 0},{0, 4} -}; -static const ProtobufCEnumValueIndex wifi_station_state__enum_values_by_name[4] = -{ - { "Connected", 0 }, - { "Connecting", 1 }, - { "ConnectionFailed", 3 }, - { "Disconnected", 2 }, -}; -const ProtobufCEnumDescriptor wifi_station_state__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WifiStationState", - "WifiStationState", - "WifiStationState", - "", - 4, - wifi_station_state__enum_values_by_number, - 4, - wifi_station_state__enum_values_by_name, - 1, - wifi_station_state__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; -static const ProtobufCEnumValue wifi_connect_failed_reason__enum_values_by_number[2] = -{ - { "AuthError", "WIFI_CONNECT_FAILED_REASON__AuthError", 0 }, - { "NetworkNotFound", "WIFI_CONNECT_FAILED_REASON__NetworkNotFound", 1 }, -}; -static const ProtobufCIntRange wifi_connect_failed_reason__value_ranges[] = { -{0, 0},{0, 2} -}; -static const ProtobufCEnumValueIndex wifi_connect_failed_reason__enum_values_by_name[2] = -{ - { "AuthError", 0 }, - { "NetworkNotFound", 1 }, -}; -const ProtobufCEnumDescriptor wifi_connect_failed_reason__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WifiConnectFailedReason", - "WifiConnectFailedReason", - "WifiConnectFailedReason", - "", - 2, - wifi_connect_failed_reason__enum_values_by_number, - 2, - wifi_connect_failed_reason__enum_values_by_name, - 1, - wifi_connect_failed_reason__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; -static const ProtobufCEnumValue wifi_auth_mode__enum_values_by_number[8] = -{ - { "Open", "WIFI_AUTH_MODE__Open", 0 }, - { "WEP", "WIFI_AUTH_MODE__WEP", 1 }, - { "WPA_PSK", "WIFI_AUTH_MODE__WPA_PSK", 2 }, - { "WPA2_PSK", "WIFI_AUTH_MODE__WPA2_PSK", 3 }, - { "WPA_WPA2_PSK", "WIFI_AUTH_MODE__WPA_WPA2_PSK", 4 }, - { "WPA2_ENTERPRISE", "WIFI_AUTH_MODE__WPA2_ENTERPRISE", 5 }, - { "WPA3_PSK", "WIFI_AUTH_MODE__WPA3_PSK", 6 }, - { "WPA2_WPA3_PSK", "WIFI_AUTH_MODE__WPA2_WPA3_PSK", 7 }, -}; -static const ProtobufCIntRange wifi_auth_mode__value_ranges[] = { -{0, 0},{0, 8} -}; -static const ProtobufCEnumValueIndex wifi_auth_mode__enum_values_by_name[8] = -{ - { "Open", 0 }, - { "WEP", 1 }, - { "WPA2_ENTERPRISE", 5 }, - { "WPA2_PSK", 3 }, - { "WPA2_WPA3_PSK", 7 }, - { "WPA3_PSK", 6 }, - { "WPA_PSK", 2 }, - { "WPA_WPA2_PSK", 4 }, -}; -const ProtobufCEnumDescriptor wifi_auth_mode__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WifiAuthMode", - "WifiAuthMode", - "WifiAuthMode", - "", - 8, - wifi_auth_mode__enum_values_by_number, - 8, - wifi_auth_mode__enum_values_by_name, - 1, - wifi_auth_mode__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; diff --git a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.h b/components/wifi_provisioning/proto-c/wifi_constants.pb-c.h deleted file mode 100644 index abebe2956b1d..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.h +++ /dev/null @@ -1,101 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_constants.proto */ - -#ifndef PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED -#define PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - - -typedef struct WifiConnectedState WifiConnectedState; - - -/* --- enums --- */ - -typedef enum _WifiStationState { - WIFI_STATION_STATE__Connected = 0, - WIFI_STATION_STATE__Connecting = 1, - WIFI_STATION_STATE__Disconnected = 2, - WIFI_STATION_STATE__ConnectionFailed = 3 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_STATION_STATE) -} WifiStationState; -typedef enum _WifiConnectFailedReason { - WIFI_CONNECT_FAILED_REASON__AuthError = 0, - WIFI_CONNECT_FAILED_REASON__NetworkNotFound = 1 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_CONNECT_FAILED_REASON) -} WifiConnectFailedReason; -typedef enum _WifiAuthMode { - WIFI_AUTH_MODE__Open = 0, - WIFI_AUTH_MODE__WEP = 1, - WIFI_AUTH_MODE__WPA_PSK = 2, - WIFI_AUTH_MODE__WPA2_PSK = 3, - WIFI_AUTH_MODE__WPA_WPA2_PSK = 4, - WIFI_AUTH_MODE__WPA2_ENTERPRISE = 5, - WIFI_AUTH_MODE__WPA3_PSK = 6, - WIFI_AUTH_MODE__WPA2_WPA3_PSK = 7 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_AUTH_MODE) -} WifiAuthMode; - -/* --- messages --- */ - -struct WifiConnectedState -{ - ProtobufCMessage base; - char *ip4_addr; - WifiAuthMode auth_mode; - ProtobufCBinaryData ssid; - ProtobufCBinaryData bssid; - int32_t channel; -}; -#define WIFI_CONNECTED_STATE__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&wifi_connected_state__descriptor) \ - , (char *)protobuf_c_empty_string, WIFI_AUTH_MODE__Open, {0,NULL}, {0,NULL}, 0 } - - -/* WifiConnectedState methods */ -void wifi_connected_state__init - (WifiConnectedState *message); -size_t wifi_connected_state__get_packed_size - (const WifiConnectedState *message); -size_t wifi_connected_state__pack - (const WifiConnectedState *message, - uint8_t *out); -size_t wifi_connected_state__pack_to_buffer - (const WifiConnectedState *message, - ProtobufCBuffer *buffer); -WifiConnectedState * - wifi_connected_state__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void wifi_connected_state__free_unpacked - (WifiConnectedState *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*WifiConnectedState_Closure) - (const WifiConnectedState *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor wifi_station_state__descriptor; -extern const ProtobufCEnumDescriptor wifi_connect_failed_reason__descriptor; -extern const ProtobufCEnumDescriptor wifi_auth_mode__descriptor; -extern const ProtobufCMessageDescriptor wifi_connected_state__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED */ diff --git a/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.c b/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.c deleted file mode 100644 index a1a0fbf84aa3..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.c +++ /dev/null @@ -1,444 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_ctrl.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "wifi_ctrl.pb-c.h" -void cmd_ctrl_reset__init - (CmdCtrlReset *message) -{ - static const CmdCtrlReset init_value = CMD_CTRL_RESET__INIT; - *message = init_value; -} -size_t cmd_ctrl_reset__get_packed_size - (const CmdCtrlReset *message) -{ - assert(message->base.descriptor == &cmd_ctrl_reset__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_ctrl_reset__pack - (const CmdCtrlReset *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_ctrl_reset__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_ctrl_reset__pack_to_buffer - (const CmdCtrlReset *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_ctrl_reset__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdCtrlReset * - cmd_ctrl_reset__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdCtrlReset *) - protobuf_c_message_unpack (&cmd_ctrl_reset__descriptor, - allocator, len, data); -} -void cmd_ctrl_reset__free_unpacked - (CmdCtrlReset *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_ctrl_reset__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_ctrl_reset__init - (RespCtrlReset *message) -{ - static const RespCtrlReset init_value = RESP_CTRL_RESET__INIT; - *message = init_value; -} -size_t resp_ctrl_reset__get_packed_size - (const RespCtrlReset *message) -{ - assert(message->base.descriptor == &resp_ctrl_reset__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_ctrl_reset__pack - (const RespCtrlReset *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_ctrl_reset__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_ctrl_reset__pack_to_buffer - (const RespCtrlReset *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_ctrl_reset__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespCtrlReset * - resp_ctrl_reset__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespCtrlReset *) - protobuf_c_message_unpack (&resp_ctrl_reset__descriptor, - allocator, len, data); -} -void resp_ctrl_reset__free_unpacked - (RespCtrlReset *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_ctrl_reset__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void cmd_ctrl_reprov__init - (CmdCtrlReprov *message) -{ - static const CmdCtrlReprov init_value = CMD_CTRL_REPROV__INIT; - *message = init_value; -} -size_t cmd_ctrl_reprov__get_packed_size - (const CmdCtrlReprov *message) -{ - assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_ctrl_reprov__pack - (const CmdCtrlReprov *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_ctrl_reprov__pack_to_buffer - (const CmdCtrlReprov *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdCtrlReprov * - cmd_ctrl_reprov__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdCtrlReprov *) - protobuf_c_message_unpack (&cmd_ctrl_reprov__descriptor, - allocator, len, data); -} -void cmd_ctrl_reprov__free_unpacked - (CmdCtrlReprov *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_ctrl_reprov__init - (RespCtrlReprov *message) -{ - static const RespCtrlReprov init_value = RESP_CTRL_REPROV__INIT; - *message = init_value; -} -size_t resp_ctrl_reprov__get_packed_size - (const RespCtrlReprov *message) -{ - assert(message->base.descriptor == &resp_ctrl_reprov__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_ctrl_reprov__pack - (const RespCtrlReprov *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_ctrl_reprov__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_ctrl_reprov__pack_to_buffer - (const RespCtrlReprov *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_ctrl_reprov__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespCtrlReprov * - resp_ctrl_reprov__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespCtrlReprov *) - protobuf_c_message_unpack (&resp_ctrl_reprov__descriptor, - allocator, len, data); -} -void resp_ctrl_reprov__free_unpacked - (RespCtrlReprov *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_ctrl_reprov__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void wi_fi_ctrl_payload__init - (WiFiCtrlPayload *message) -{ - static const WiFiCtrlPayload init_value = WI_FI_CTRL_PAYLOAD__INIT; - *message = init_value; -} -size_t wi_fi_ctrl_payload__get_packed_size - (const WiFiCtrlPayload *message) -{ - assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t wi_fi_ctrl_payload__pack - (const WiFiCtrlPayload *message, - uint8_t *out) -{ - assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t wi_fi_ctrl_payload__pack_to_buffer - (const WiFiCtrlPayload *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -WiFiCtrlPayload * - wi_fi_ctrl_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (WiFiCtrlPayload *) - protobuf_c_message_unpack (&wi_fi_ctrl_payload__descriptor, - allocator, len, data); -} -void wi_fi_ctrl_payload__free_unpacked - (WiFiCtrlPayload *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &wi_fi_ctrl_payload__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -#define cmd_ctrl_reset__field_descriptors NULL -#define cmd_ctrl_reset__field_indices_by_name NULL -#define cmd_ctrl_reset__number_ranges NULL -const ProtobufCMessageDescriptor cmd_ctrl_reset__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdCtrlReset", - "CmdCtrlReset", - "CmdCtrlReset", - "", - sizeof(CmdCtrlReset), - 0, - cmd_ctrl_reset__field_descriptors, - cmd_ctrl_reset__field_indices_by_name, - 0, cmd_ctrl_reset__number_ranges, - (ProtobufCMessageInit) cmd_ctrl_reset__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define resp_ctrl_reset__field_descriptors NULL -#define resp_ctrl_reset__field_indices_by_name NULL -#define resp_ctrl_reset__number_ranges NULL -const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespCtrlReset", - "RespCtrlReset", - "RespCtrlReset", - "", - sizeof(RespCtrlReset), - 0, - resp_ctrl_reset__field_descriptors, - resp_ctrl_reset__field_indices_by_name, - 0, resp_ctrl_reset__number_ranges, - (ProtobufCMessageInit) resp_ctrl_reset__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define cmd_ctrl_reprov__field_descriptors NULL -#define cmd_ctrl_reprov__field_indices_by_name NULL -#define cmd_ctrl_reprov__number_ranges NULL -const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdCtrlReprov", - "CmdCtrlReprov", - "CmdCtrlReprov", - "", - sizeof(CmdCtrlReprov), - 0, - cmd_ctrl_reprov__field_descriptors, - cmd_ctrl_reprov__field_indices_by_name, - 0, cmd_ctrl_reprov__number_ranges, - (ProtobufCMessageInit) cmd_ctrl_reprov__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define resp_ctrl_reprov__field_descriptors NULL -#define resp_ctrl_reprov__field_indices_by_name NULL -#define resp_ctrl_reprov__number_ranges NULL -const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespCtrlReprov", - "RespCtrlReprov", - "RespCtrlReprov", - "", - sizeof(RespCtrlReprov), - 0, - resp_ctrl_reprov__field_descriptors, - resp_ctrl_reprov__field_indices_by_name, - 0, resp_ctrl_reprov__number_ranges, - (ProtobufCMessageInit) resp_ctrl_reprov__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor wi_fi_ctrl_payload__field_descriptors[6] = -{ - { - "msg", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiCtrlPayload, msg), - &wi_fi_ctrl_msg_type__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "status", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiCtrlPayload, status), - &status__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_ctrl_reset", - 11, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiCtrlPayload, payload_case), - offsetof(WiFiCtrlPayload, cmd_ctrl_reset), - &cmd_ctrl_reset__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_ctrl_reset", - 12, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiCtrlPayload, payload_case), - offsetof(WiFiCtrlPayload, resp_ctrl_reset), - &resp_ctrl_reset__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_ctrl_reprov", - 13, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiCtrlPayload, payload_case), - offsetof(WiFiCtrlPayload, cmd_ctrl_reprov), - &cmd_ctrl_reprov__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_ctrl_reprov", - 14, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiCtrlPayload, payload_case), - offsetof(WiFiCtrlPayload, resp_ctrl_reprov), - &resp_ctrl_reprov__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned wi_fi_ctrl_payload__field_indices_by_name[] = { - 4, /* field[4] = cmd_ctrl_reprov */ - 2, /* field[2] = cmd_ctrl_reset */ - 0, /* field[0] = msg */ - 5, /* field[5] = resp_ctrl_reprov */ - 3, /* field[3] = resp_ctrl_reset */ - 1, /* field[1] = status */ -}; -static const ProtobufCIntRange wi_fi_ctrl_payload__number_ranges[2 + 1] = -{ - { 1, 0 }, - { 11, 2 }, - { 0, 6 } -}; -const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "WiFiCtrlPayload", - "WiFiCtrlPayload", - "WiFiCtrlPayload", - "", - sizeof(WiFiCtrlPayload), - 6, - wi_fi_ctrl_payload__field_descriptors, - wi_fi_ctrl_payload__field_indices_by_name, - 2, wi_fi_ctrl_payload__number_ranges, - (ProtobufCMessageInit) wi_fi_ctrl_payload__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue wi_fi_ctrl_msg_type__enum_values_by_number[5] = -{ - { "TypeCtrlReserved", "WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved", 0 }, - { "TypeCmdCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset", 1 }, - { "TypeRespCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset", 2 }, - { "TypeCmdCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov", 3 }, - { "TypeRespCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov", 4 }, -}; -static const ProtobufCIntRange wi_fi_ctrl_msg_type__value_ranges[] = { -{0, 0},{0, 5} -}; -static const ProtobufCEnumValueIndex wi_fi_ctrl_msg_type__enum_values_by_name[5] = -{ - { "TypeCmdCtrlReprov", 3 }, - { "TypeCmdCtrlReset", 1 }, - { "TypeCtrlReserved", 0 }, - { "TypeRespCtrlReprov", 4 }, - { "TypeRespCtrlReset", 2 }, -}; -const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WiFiCtrlMsgType", - "WiFiCtrlMsgType", - "WiFiCtrlMsgType", - "", - 5, - wi_fi_ctrl_msg_type__enum_values_by_number, - 5, - wi_fi_ctrl_msg_type__enum_values_by_name, - 1, - wi_fi_ctrl_msg_type__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; diff --git a/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.h b/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.h deleted file mode 100644 index 2291bf31c8f5..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_ctrl.pb-c.h +++ /dev/null @@ -1,230 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_ctrl.proto */ - -#ifndef PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED -#define PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - -#include "constants.pb-c.h" - -typedef struct CmdCtrlReset CmdCtrlReset; -typedef struct RespCtrlReset RespCtrlReset; -typedef struct CmdCtrlReprov CmdCtrlReprov; -typedef struct RespCtrlReprov RespCtrlReprov; -typedef struct WiFiCtrlPayload WiFiCtrlPayload; - - -/* --- enums --- */ - -typedef enum _WiFiCtrlMsgType { - WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved = 0, - WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset = 1, - WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset = 2, - WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov = 3, - WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov = 4 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_MSG_TYPE) -} WiFiCtrlMsgType; - -/* --- messages --- */ - -struct CmdCtrlReset -{ - ProtobufCMessage base; -}; -#define CMD_CTRL_RESET__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_ctrl_reset__descriptor) \ - } - - -struct RespCtrlReset -{ - ProtobufCMessage base; -}; -#define RESP_CTRL_RESET__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_ctrl_reset__descriptor) \ - } - - -struct CmdCtrlReprov -{ - ProtobufCMessage base; -}; -#define CMD_CTRL_REPROV__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_ctrl_reprov__descriptor) \ - } - - -struct RespCtrlReprov -{ - ProtobufCMessage base; -}; -#define RESP_CTRL_REPROV__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_ctrl_reprov__descriptor) \ - } - - -typedef enum { - WI_FI_CTRL_PAYLOAD__PAYLOAD__NOT_SET = 0, - WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_RESET = 11, - WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET = 12, - WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_REPROV = 13, - WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV = 14 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_PAYLOAD__PAYLOAD__CASE) -} WiFiCtrlPayload__PayloadCase; - -struct WiFiCtrlPayload -{ - ProtobufCMessage base; - WiFiCtrlMsgType msg; - Status status; - WiFiCtrlPayload__PayloadCase payload_case; - union { - CmdCtrlReset *cmd_ctrl_reset; - RespCtrlReset *resp_ctrl_reset; - CmdCtrlReprov *cmd_ctrl_reprov; - RespCtrlReprov *resp_ctrl_reprov; - }; -}; -#define WI_FI_CTRL_PAYLOAD__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&wi_fi_ctrl_payload__descriptor) \ - , WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved, STATUS__Success, WI_FI_CTRL_PAYLOAD__PAYLOAD__NOT_SET, {0} } - - -/* CmdCtrlReset methods */ -void cmd_ctrl_reset__init - (CmdCtrlReset *message); -size_t cmd_ctrl_reset__get_packed_size - (const CmdCtrlReset *message); -size_t cmd_ctrl_reset__pack - (const CmdCtrlReset *message, - uint8_t *out); -size_t cmd_ctrl_reset__pack_to_buffer - (const CmdCtrlReset *message, - ProtobufCBuffer *buffer); -CmdCtrlReset * - cmd_ctrl_reset__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_ctrl_reset__free_unpacked - (CmdCtrlReset *message, - ProtobufCAllocator *allocator); -/* RespCtrlReset methods */ -void resp_ctrl_reset__init - (RespCtrlReset *message); -size_t resp_ctrl_reset__get_packed_size - (const RespCtrlReset *message); -size_t resp_ctrl_reset__pack - (const RespCtrlReset *message, - uint8_t *out); -size_t resp_ctrl_reset__pack_to_buffer - (const RespCtrlReset *message, - ProtobufCBuffer *buffer); -RespCtrlReset * - resp_ctrl_reset__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_ctrl_reset__free_unpacked - (RespCtrlReset *message, - ProtobufCAllocator *allocator); -/* CmdCtrlReprov methods */ -void cmd_ctrl_reprov__init - (CmdCtrlReprov *message); -size_t cmd_ctrl_reprov__get_packed_size - (const CmdCtrlReprov *message); -size_t cmd_ctrl_reprov__pack - (const CmdCtrlReprov *message, - uint8_t *out); -size_t cmd_ctrl_reprov__pack_to_buffer - (const CmdCtrlReprov *message, - ProtobufCBuffer *buffer); -CmdCtrlReprov * - cmd_ctrl_reprov__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_ctrl_reprov__free_unpacked - (CmdCtrlReprov *message, - ProtobufCAllocator *allocator); -/* RespCtrlReprov methods */ -void resp_ctrl_reprov__init - (RespCtrlReprov *message); -size_t resp_ctrl_reprov__get_packed_size - (const RespCtrlReprov *message); -size_t resp_ctrl_reprov__pack - (const RespCtrlReprov *message, - uint8_t *out); -size_t resp_ctrl_reprov__pack_to_buffer - (const RespCtrlReprov *message, - ProtobufCBuffer *buffer); -RespCtrlReprov * - resp_ctrl_reprov__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_ctrl_reprov__free_unpacked - (RespCtrlReprov *message, - ProtobufCAllocator *allocator); -/* WiFiCtrlPayload methods */ -void wi_fi_ctrl_payload__init - (WiFiCtrlPayload *message); -size_t wi_fi_ctrl_payload__get_packed_size - (const WiFiCtrlPayload *message); -size_t wi_fi_ctrl_payload__pack - (const WiFiCtrlPayload *message, - uint8_t *out); -size_t wi_fi_ctrl_payload__pack_to_buffer - (const WiFiCtrlPayload *message, - ProtobufCBuffer *buffer); -WiFiCtrlPayload * - wi_fi_ctrl_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void wi_fi_ctrl_payload__free_unpacked - (WiFiCtrlPayload *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*CmdCtrlReset_Closure) - (const CmdCtrlReset *message, - void *closure_data); -typedef void (*RespCtrlReset_Closure) - (const RespCtrlReset *message, - void *closure_data); -typedef void (*CmdCtrlReprov_Closure) - (const CmdCtrlReprov *message, - void *closure_data); -typedef void (*RespCtrlReprov_Closure) - (const RespCtrlReprov *message, - void *closure_data); -typedef void (*WiFiCtrlPayload_Closure) - (const WiFiCtrlPayload *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor; -extern const ProtobufCMessageDescriptor cmd_ctrl_reset__descriptor; -extern const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor; -extern const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor; -extern const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor; -extern const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_wifi_5fctrl_2eproto__INCLUDED */ diff --git a/components/wifi_provisioning/proto-c/wifi_scan.pb-c.c b/components/wifi_provisioning/proto-c/wifi_scan.pb-c.c deleted file mode 100644 index 4cf5b5dc3b1f..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_scan.pb-c.c +++ /dev/null @@ -1,878 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_scan.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "wifi_scan.pb-c.h" -void cmd_scan_start__init - (CmdScanStart *message) -{ - static const CmdScanStart init_value = CMD_SCAN_START__INIT; - *message = init_value; -} -size_t cmd_scan_start__get_packed_size - (const CmdScanStart *message) -{ - assert(message->base.descriptor == &cmd_scan_start__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_scan_start__pack - (const CmdScanStart *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_scan_start__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_scan_start__pack_to_buffer - (const CmdScanStart *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_scan_start__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdScanStart * - cmd_scan_start__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdScanStart *) - protobuf_c_message_unpack (&cmd_scan_start__descriptor, - allocator, len, data); -} -void cmd_scan_start__free_unpacked - (CmdScanStart *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_scan_start__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_scan_start__init - (RespScanStart *message) -{ - static const RespScanStart init_value = RESP_SCAN_START__INIT; - *message = init_value; -} -size_t resp_scan_start__get_packed_size - (const RespScanStart *message) -{ - assert(message->base.descriptor == &resp_scan_start__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_scan_start__pack - (const RespScanStart *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_scan_start__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_scan_start__pack_to_buffer - (const RespScanStart *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_scan_start__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespScanStart * - resp_scan_start__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespScanStart *) - protobuf_c_message_unpack (&resp_scan_start__descriptor, - allocator, len, data); -} -void resp_scan_start__free_unpacked - (RespScanStart *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_scan_start__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void cmd_scan_status__init - (CmdScanStatus *message) -{ - static const CmdScanStatus init_value = CMD_SCAN_STATUS__INIT; - *message = init_value; -} -size_t cmd_scan_status__get_packed_size - (const CmdScanStatus *message) -{ - assert(message->base.descriptor == &cmd_scan_status__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_scan_status__pack - (const CmdScanStatus *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_scan_status__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_scan_status__pack_to_buffer - (const CmdScanStatus *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_scan_status__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdScanStatus * - cmd_scan_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdScanStatus *) - protobuf_c_message_unpack (&cmd_scan_status__descriptor, - allocator, len, data); -} -void cmd_scan_status__free_unpacked - (CmdScanStatus *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_scan_status__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_scan_status__init - (RespScanStatus *message) -{ - static const RespScanStatus init_value = RESP_SCAN_STATUS__INIT; - *message = init_value; -} -size_t resp_scan_status__get_packed_size - (const RespScanStatus *message) -{ - assert(message->base.descriptor == &resp_scan_status__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_scan_status__pack - (const RespScanStatus *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_scan_status__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_scan_status__pack_to_buffer - (const RespScanStatus *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_scan_status__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespScanStatus * - resp_scan_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespScanStatus *) - protobuf_c_message_unpack (&resp_scan_status__descriptor, - allocator, len, data); -} -void resp_scan_status__free_unpacked - (RespScanStatus *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_scan_status__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void cmd_scan_result__init - (CmdScanResult *message) -{ - static const CmdScanResult init_value = CMD_SCAN_RESULT__INIT; - *message = init_value; -} -size_t cmd_scan_result__get_packed_size - (const CmdScanResult *message) -{ - assert(message->base.descriptor == &cmd_scan_result__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t cmd_scan_result__pack - (const CmdScanResult *message, - uint8_t *out) -{ - assert(message->base.descriptor == &cmd_scan_result__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t cmd_scan_result__pack_to_buffer - (const CmdScanResult *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &cmd_scan_result__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -CmdScanResult * - cmd_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (CmdScanResult *) - protobuf_c_message_unpack (&cmd_scan_result__descriptor, - allocator, len, data); -} -void cmd_scan_result__free_unpacked - (CmdScanResult *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &cmd_scan_result__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void wi_fi_scan_result__init - (WiFiScanResult *message) -{ - static const WiFiScanResult init_value = WI_FI_SCAN_RESULT__INIT; - *message = init_value; -} -size_t wi_fi_scan_result__get_packed_size - (const WiFiScanResult *message) -{ - assert(message->base.descriptor == &wi_fi_scan_result__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t wi_fi_scan_result__pack - (const WiFiScanResult *message, - uint8_t *out) -{ - assert(message->base.descriptor == &wi_fi_scan_result__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t wi_fi_scan_result__pack_to_buffer - (const WiFiScanResult *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &wi_fi_scan_result__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -WiFiScanResult * - wi_fi_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (WiFiScanResult *) - protobuf_c_message_unpack (&wi_fi_scan_result__descriptor, - allocator, len, data); -} -void wi_fi_scan_result__free_unpacked - (WiFiScanResult *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &wi_fi_scan_result__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void resp_scan_result__init - (RespScanResult *message) -{ - static const RespScanResult init_value = RESP_SCAN_RESULT__INIT; - *message = init_value; -} -size_t resp_scan_result__get_packed_size - (const RespScanResult *message) -{ - assert(message->base.descriptor == &resp_scan_result__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t resp_scan_result__pack - (const RespScanResult *message, - uint8_t *out) -{ - assert(message->base.descriptor == &resp_scan_result__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t resp_scan_result__pack_to_buffer - (const RespScanResult *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &resp_scan_result__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -RespScanResult * - resp_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (RespScanResult *) - protobuf_c_message_unpack (&resp_scan_result__descriptor, - allocator, len, data); -} -void resp_scan_result__free_unpacked - (RespScanResult *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &resp_scan_result__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void wi_fi_scan_payload__init - (WiFiScanPayload *message) -{ - static const WiFiScanPayload init_value = WI_FI_SCAN_PAYLOAD__INIT; - *message = init_value; -} -size_t wi_fi_scan_payload__get_packed_size - (const WiFiScanPayload *message) -{ - assert(message->base.descriptor == &wi_fi_scan_payload__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t wi_fi_scan_payload__pack - (const WiFiScanPayload *message, - uint8_t *out) -{ - assert(message->base.descriptor == &wi_fi_scan_payload__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t wi_fi_scan_payload__pack_to_buffer - (const WiFiScanPayload *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &wi_fi_scan_payload__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -WiFiScanPayload * - wi_fi_scan_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (WiFiScanPayload *) - protobuf_c_message_unpack (&wi_fi_scan_payload__descriptor, - allocator, len, data); -} -void wi_fi_scan_payload__free_unpacked - (WiFiScanPayload *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &wi_fi_scan_payload__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -static const ProtobufCFieldDescriptor cmd_scan_start__field_descriptors[4] = -{ - { - "blocking", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BOOL, - 0, /* quantifier_offset */ - offsetof(CmdScanStart, blocking), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "passive", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BOOL, - 0, /* quantifier_offset */ - offsetof(CmdScanStart, passive), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "group_channels", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(CmdScanStart, group_channels), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "period_ms", - 4, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(CmdScanStart, period_ms), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned cmd_scan_start__field_indices_by_name[] = { - 0, /* field[0] = blocking */ - 2, /* field[2] = group_channels */ - 1, /* field[1] = passive */ - 3, /* field[3] = period_ms */ -}; -static const ProtobufCIntRange cmd_scan_start__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 4 } -}; -const ProtobufCMessageDescriptor cmd_scan_start__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdScanStart", - "CmdScanStart", - "CmdScanStart", - "", - sizeof(CmdScanStart), - 4, - cmd_scan_start__field_descriptors, - cmd_scan_start__field_indices_by_name, - 1, cmd_scan_start__number_ranges, - (ProtobufCMessageInit) cmd_scan_start__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define resp_scan_start__field_descriptors NULL -#define resp_scan_start__field_indices_by_name NULL -#define resp_scan_start__number_ranges NULL -const ProtobufCMessageDescriptor resp_scan_start__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespScanStart", - "RespScanStart", - "RespScanStart", - "", - sizeof(RespScanStart), - 0, - resp_scan_start__field_descriptors, - resp_scan_start__field_indices_by_name, - 0, resp_scan_start__number_ranges, - (ProtobufCMessageInit) resp_scan_start__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define cmd_scan_status__field_descriptors NULL -#define cmd_scan_status__field_indices_by_name NULL -#define cmd_scan_status__number_ranges NULL -const ProtobufCMessageDescriptor cmd_scan_status__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdScanStatus", - "CmdScanStatus", - "CmdScanStatus", - "", - sizeof(CmdScanStatus), - 0, - cmd_scan_status__field_descriptors, - cmd_scan_status__field_indices_by_name, - 0, cmd_scan_status__number_ranges, - (ProtobufCMessageInit) cmd_scan_status__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor resp_scan_status__field_descriptors[2] = -{ - { - "scan_finished", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BOOL, - 0, /* quantifier_offset */ - offsetof(RespScanStatus, scan_finished), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "result_count", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(RespScanStatus, result_count), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned resp_scan_status__field_indices_by_name[] = { - 1, /* field[1] = result_count */ - 0, /* field[0] = scan_finished */ -}; -static const ProtobufCIntRange resp_scan_status__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 2 } -}; -const ProtobufCMessageDescriptor resp_scan_status__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespScanStatus", - "RespScanStatus", - "RespScanStatus", - "", - sizeof(RespScanStatus), - 2, - resp_scan_status__field_descriptors, - resp_scan_status__field_indices_by_name, - 1, resp_scan_status__number_ranges, - (ProtobufCMessageInit) resp_scan_status__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor cmd_scan_result__field_descriptors[2] = -{ - { - "start_index", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(CmdScanResult, start_index), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "count", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(CmdScanResult, count), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned cmd_scan_result__field_indices_by_name[] = { - 1, /* field[1] = count */ - 0, /* field[0] = start_index */ -}; -static const ProtobufCIntRange cmd_scan_result__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 2 } -}; -const ProtobufCMessageDescriptor cmd_scan_result__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "CmdScanResult", - "CmdScanResult", - "CmdScanResult", - "", - sizeof(CmdScanResult), - 2, - cmd_scan_result__field_descriptors, - cmd_scan_result__field_indices_by_name, - 1, cmd_scan_result__number_ranges, - (ProtobufCMessageInit) cmd_scan_result__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor wi_fi_scan_result__field_descriptors[5] = -{ - { - "ssid", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(WiFiScanResult, ssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "channel", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(WiFiScanResult, channel), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "rssi", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - offsetof(WiFiScanResult, rssi), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "bssid", - 4, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(WiFiScanResult, bssid), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "auth", - 5, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiScanResult, auth), - &wifi_auth_mode__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned wi_fi_scan_result__field_indices_by_name[] = { - 4, /* field[4] = auth */ - 3, /* field[3] = bssid */ - 1, /* field[1] = channel */ - 2, /* field[2] = rssi */ - 0, /* field[0] = ssid */ -}; -static const ProtobufCIntRange wi_fi_scan_result__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 5 } -}; -const ProtobufCMessageDescriptor wi_fi_scan_result__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "WiFiScanResult", - "WiFiScanResult", - "WiFiScanResult", - "", - sizeof(WiFiScanResult), - 5, - wi_fi_scan_result__field_descriptors, - wi_fi_scan_result__field_indices_by_name, - 1, wi_fi_scan_result__number_ranges, - (ProtobufCMessageInit) wi_fi_scan_result__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor resp_scan_result__field_descriptors[1] = -{ - { - "entries", - 1, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(RespScanResult, n_entries), - offsetof(RespScanResult, entries), - &wi_fi_scan_result__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned resp_scan_result__field_indices_by_name[] = { - 0, /* field[0] = entries */ -}; -static const ProtobufCIntRange resp_scan_result__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 1 } -}; -const ProtobufCMessageDescriptor resp_scan_result__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "RespScanResult", - "RespScanResult", - "RespScanResult", - "", - sizeof(RespScanResult), - 1, - resp_scan_result__field_descriptors, - resp_scan_result__field_indices_by_name, - 1, resp_scan_result__number_ranges, - (ProtobufCMessageInit) resp_scan_result__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor wi_fi_scan_payload__field_descriptors[8] = -{ - { - "msg", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiScanPayload, msg), - &wi_fi_scan_msg_type__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "status", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(WiFiScanPayload, status), - &status__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_scan_start", - 10, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, cmd_scan_start), - &cmd_scan_start__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_scan_start", - 11, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, resp_scan_start), - &resp_scan_start__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_scan_status", - 12, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, cmd_scan_status), - &cmd_scan_status__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_scan_status", - 13, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, resp_scan_status), - &resp_scan_status__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "cmd_scan_result", - 14, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, cmd_scan_result), - &cmd_scan_result__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "resp_scan_result", - 15, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(WiFiScanPayload, payload_case), - offsetof(WiFiScanPayload, resp_scan_result), - &resp_scan_result__descriptor, - NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned wi_fi_scan_payload__field_indices_by_name[] = { - 6, /* field[6] = cmd_scan_result */ - 2, /* field[2] = cmd_scan_start */ - 4, /* field[4] = cmd_scan_status */ - 0, /* field[0] = msg */ - 7, /* field[7] = resp_scan_result */ - 3, /* field[3] = resp_scan_start */ - 5, /* field[5] = resp_scan_status */ - 1, /* field[1] = status */ -}; -static const ProtobufCIntRange wi_fi_scan_payload__number_ranges[2 + 1] = -{ - { 1, 0 }, - { 10, 2 }, - { 0, 8 } -}; -const ProtobufCMessageDescriptor wi_fi_scan_payload__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "WiFiScanPayload", - "WiFiScanPayload", - "WiFiScanPayload", - "", - sizeof(WiFiScanPayload), - 8, - wi_fi_scan_payload__field_descriptors, - wi_fi_scan_payload__field_indices_by_name, - 2, wi_fi_scan_payload__number_ranges, - (ProtobufCMessageInit) wi_fi_scan_payload__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue wi_fi_scan_msg_type__enum_values_by_number[6] = -{ - { "TypeCmdScanStart", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart", 0 }, - { "TypeRespScanStart", "WI_FI_SCAN_MSG_TYPE__TypeRespScanStart", 1 }, - { "TypeCmdScanStatus", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus", 2 }, - { "TypeRespScanStatus", "WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus", 3 }, - { "TypeCmdScanResult", "WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult", 4 }, - { "TypeRespScanResult", "WI_FI_SCAN_MSG_TYPE__TypeRespScanResult", 5 }, -}; -static const ProtobufCIntRange wi_fi_scan_msg_type__value_ranges[] = { -{0, 0},{0, 6} -}; -static const ProtobufCEnumValueIndex wi_fi_scan_msg_type__enum_values_by_name[6] = -{ - { "TypeCmdScanResult", 4 }, - { "TypeCmdScanStart", 0 }, - { "TypeCmdScanStatus", 2 }, - { "TypeRespScanResult", 5 }, - { "TypeRespScanStart", 1 }, - { "TypeRespScanStatus", 3 }, -}; -const ProtobufCEnumDescriptor wi_fi_scan_msg_type__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "WiFiScanMsgType", - "WiFiScanMsgType", - "WiFiScanMsgType", - "", - 6, - wi_fi_scan_msg_type__enum_values_by_number, - 6, - wi_fi_scan_msg_type__enum_values_by_name, - 1, - wi_fi_scan_msg_type__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; diff --git a/components/wifi_provisioning/proto-c/wifi_scan.pb-c.h b/components/wifi_provisioning/proto-c/wifi_scan.pb-c.h deleted file mode 100644 index dc3975590da5..000000000000 --- a/components/wifi_provisioning/proto-c/wifi_scan.pb-c.h +++ /dev/null @@ -1,350 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: wifi_scan.proto */ - -#ifndef PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED -#define PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - -#include "constants.pb-c.h" -#include "wifi_constants.pb-c.h" - -typedef struct CmdScanStart CmdScanStart; -typedef struct RespScanStart RespScanStart; -typedef struct CmdScanStatus CmdScanStatus; -typedef struct RespScanStatus RespScanStatus; -typedef struct CmdScanResult CmdScanResult; -typedef struct WiFiScanResult WiFiScanResult; -typedef struct RespScanResult RespScanResult; -typedef struct WiFiScanPayload WiFiScanPayload; - - -/* --- enums --- */ - -typedef enum _WiFiScanMsgType { - WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart = 0, - WI_FI_SCAN_MSG_TYPE__TypeRespScanStart = 1, - WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus = 2, - WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus = 3, - WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult = 4, - WI_FI_SCAN_MSG_TYPE__TypeRespScanResult = 5 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_SCAN_MSG_TYPE) -} WiFiScanMsgType; - -/* --- messages --- */ - -struct CmdScanStart -{ - ProtobufCMessage base; - protobuf_c_boolean blocking; - protobuf_c_boolean passive; - uint32_t group_channels; - uint32_t period_ms; -}; -#define CMD_SCAN_START__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_scan_start__descriptor) \ - , 0, 0, 0, 0 } - - -struct RespScanStart -{ - ProtobufCMessage base; -}; -#define RESP_SCAN_START__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_scan_start__descriptor) \ - } - - -struct CmdScanStatus -{ - ProtobufCMessage base; -}; -#define CMD_SCAN_STATUS__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_scan_status__descriptor) \ - } - - -struct RespScanStatus -{ - ProtobufCMessage base; - protobuf_c_boolean scan_finished; - uint32_t result_count; -}; -#define RESP_SCAN_STATUS__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_scan_status__descriptor) \ - , 0, 0 } - - -struct CmdScanResult -{ - ProtobufCMessage base; - uint32_t start_index; - uint32_t count; -}; -#define CMD_SCAN_RESULT__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&cmd_scan_result__descriptor) \ - , 0, 0 } - - -struct WiFiScanResult -{ - ProtobufCMessage base; - ProtobufCBinaryData ssid; - uint32_t channel; - int32_t rssi; - ProtobufCBinaryData bssid; - WifiAuthMode auth; -}; -#define WI_FI_SCAN_RESULT__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&wi_fi_scan_result__descriptor) \ - , {0,NULL}, 0, 0, {0,NULL}, WIFI_AUTH_MODE__Open } - - -struct RespScanResult -{ - ProtobufCMessage base; - size_t n_entries; - WiFiScanResult **entries; -}; -#define RESP_SCAN_RESULT__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&resp_scan_result__descriptor) \ - , 0,NULL } - - -typedef enum { - WI_FI_SCAN_PAYLOAD__PAYLOAD__NOT_SET = 0, - WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_START = 10, - WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_START = 11, - WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_STATUS = 12, - WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_STATUS = 13, - WI_FI_SCAN_PAYLOAD__PAYLOAD_CMD_SCAN_RESULT = 14, - WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_RESULT = 15 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_SCAN_PAYLOAD__PAYLOAD__CASE) -} WiFiScanPayload__PayloadCase; - -struct WiFiScanPayload -{ - ProtobufCMessage base; - WiFiScanMsgType msg; - Status status; - WiFiScanPayload__PayloadCase payload_case; - union { - CmdScanStart *cmd_scan_start; - RespScanStart *resp_scan_start; - CmdScanStatus *cmd_scan_status; - RespScanStatus *resp_scan_status; - CmdScanResult *cmd_scan_result; - RespScanResult *resp_scan_result; - }; -}; -#define WI_FI_SCAN_PAYLOAD__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&wi_fi_scan_payload__descriptor) \ - , WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart, STATUS__Success, WI_FI_SCAN_PAYLOAD__PAYLOAD__NOT_SET, {0} } - - -/* CmdScanStart methods */ -void cmd_scan_start__init - (CmdScanStart *message); -size_t cmd_scan_start__get_packed_size - (const CmdScanStart *message); -size_t cmd_scan_start__pack - (const CmdScanStart *message, - uint8_t *out); -size_t cmd_scan_start__pack_to_buffer - (const CmdScanStart *message, - ProtobufCBuffer *buffer); -CmdScanStart * - cmd_scan_start__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_scan_start__free_unpacked - (CmdScanStart *message, - ProtobufCAllocator *allocator); -/* RespScanStart methods */ -void resp_scan_start__init - (RespScanStart *message); -size_t resp_scan_start__get_packed_size - (const RespScanStart *message); -size_t resp_scan_start__pack - (const RespScanStart *message, - uint8_t *out); -size_t resp_scan_start__pack_to_buffer - (const RespScanStart *message, - ProtobufCBuffer *buffer); -RespScanStart * - resp_scan_start__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_scan_start__free_unpacked - (RespScanStart *message, - ProtobufCAllocator *allocator); -/* CmdScanStatus methods */ -void cmd_scan_status__init - (CmdScanStatus *message); -size_t cmd_scan_status__get_packed_size - (const CmdScanStatus *message); -size_t cmd_scan_status__pack - (const CmdScanStatus *message, - uint8_t *out); -size_t cmd_scan_status__pack_to_buffer - (const CmdScanStatus *message, - ProtobufCBuffer *buffer); -CmdScanStatus * - cmd_scan_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_scan_status__free_unpacked - (CmdScanStatus *message, - ProtobufCAllocator *allocator); -/* RespScanStatus methods */ -void resp_scan_status__init - (RespScanStatus *message); -size_t resp_scan_status__get_packed_size - (const RespScanStatus *message); -size_t resp_scan_status__pack - (const RespScanStatus *message, - uint8_t *out); -size_t resp_scan_status__pack_to_buffer - (const RespScanStatus *message, - ProtobufCBuffer *buffer); -RespScanStatus * - resp_scan_status__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_scan_status__free_unpacked - (RespScanStatus *message, - ProtobufCAllocator *allocator); -/* CmdScanResult methods */ -void cmd_scan_result__init - (CmdScanResult *message); -size_t cmd_scan_result__get_packed_size - (const CmdScanResult *message); -size_t cmd_scan_result__pack - (const CmdScanResult *message, - uint8_t *out); -size_t cmd_scan_result__pack_to_buffer - (const CmdScanResult *message, - ProtobufCBuffer *buffer); -CmdScanResult * - cmd_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void cmd_scan_result__free_unpacked - (CmdScanResult *message, - ProtobufCAllocator *allocator); -/* WiFiScanResult methods */ -void wi_fi_scan_result__init - (WiFiScanResult *message); -size_t wi_fi_scan_result__get_packed_size - (const WiFiScanResult *message); -size_t wi_fi_scan_result__pack - (const WiFiScanResult *message, - uint8_t *out); -size_t wi_fi_scan_result__pack_to_buffer - (const WiFiScanResult *message, - ProtobufCBuffer *buffer); -WiFiScanResult * - wi_fi_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void wi_fi_scan_result__free_unpacked - (WiFiScanResult *message, - ProtobufCAllocator *allocator); -/* RespScanResult methods */ -void resp_scan_result__init - (RespScanResult *message); -size_t resp_scan_result__get_packed_size - (const RespScanResult *message); -size_t resp_scan_result__pack - (const RespScanResult *message, - uint8_t *out); -size_t resp_scan_result__pack_to_buffer - (const RespScanResult *message, - ProtobufCBuffer *buffer); -RespScanResult * - resp_scan_result__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void resp_scan_result__free_unpacked - (RespScanResult *message, - ProtobufCAllocator *allocator); -/* WiFiScanPayload methods */ -void wi_fi_scan_payload__init - (WiFiScanPayload *message); -size_t wi_fi_scan_payload__get_packed_size - (const WiFiScanPayload *message); -size_t wi_fi_scan_payload__pack - (const WiFiScanPayload *message, - uint8_t *out); -size_t wi_fi_scan_payload__pack_to_buffer - (const WiFiScanPayload *message, - ProtobufCBuffer *buffer); -WiFiScanPayload * - wi_fi_scan_payload__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void wi_fi_scan_payload__free_unpacked - (WiFiScanPayload *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*CmdScanStart_Closure) - (const CmdScanStart *message, - void *closure_data); -typedef void (*RespScanStart_Closure) - (const RespScanStart *message, - void *closure_data); -typedef void (*CmdScanStatus_Closure) - (const CmdScanStatus *message, - void *closure_data); -typedef void (*RespScanStatus_Closure) - (const RespScanStatus *message, - void *closure_data); -typedef void (*CmdScanResult_Closure) - (const CmdScanResult *message, - void *closure_data); -typedef void (*WiFiScanResult_Closure) - (const WiFiScanResult *message, - void *closure_data); -typedef void (*RespScanResult_Closure) - (const RespScanResult *message, - void *closure_data); -typedef void (*WiFiScanPayload_Closure) - (const WiFiScanPayload *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor wi_fi_scan_msg_type__descriptor; -extern const ProtobufCMessageDescriptor cmd_scan_start__descriptor; -extern const ProtobufCMessageDescriptor resp_scan_start__descriptor; -extern const ProtobufCMessageDescriptor cmd_scan_status__descriptor; -extern const ProtobufCMessageDescriptor resp_scan_status__descriptor; -extern const ProtobufCMessageDescriptor cmd_scan_result__descriptor; -extern const ProtobufCMessageDescriptor wi_fi_scan_result__descriptor; -extern const ProtobufCMessageDescriptor resp_scan_result__descriptor; -extern const ProtobufCMessageDescriptor wi_fi_scan_payload__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_wifi_5fscan_2eproto__INCLUDED */ diff --git a/components/wifi_provisioning/proto/CMakeLists.txt b/components/wifi_provisioning/proto/CMakeLists.txt deleted file mode 100644 index 08e6980b5447..000000000000 --- a/components/wifi_provisioning/proto/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -set(PROTO_COMPILER "protoc") -set(PROTO_C_COMPILER "protoc-c") -set(C_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../proto-c") -set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python") -set(PROTOCOMM_INCL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../protocomm/proto") - -set(PROTO_SRCS "wifi_constants.proto" - "wifi_config.proto" - "wifi_scan.proto") - -add_custom_target(c_proto - COMMAND ${PROTO_C_COMPILER} --c_out=${C_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} - VERBATIM - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - ) - -add_custom_target(python_proto - COMMAND ${PROTO_COMPILER} --python_out=${PY_OUT_PATH} -I . -I ${PROTOCOMM_INCL_PATH} ${PROTO_SRCS} - VERBATIM - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - ) - -add_custom_target(proto ALL - DEPENDS c_proto python_proto - VERBATIM - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - ) diff --git a/components/wifi_provisioning/proto/README.md b/components/wifi_provisioning/proto/README.md deleted file mode 100644 index 68f9be20583a..000000000000 --- a/components/wifi_provisioning/proto/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Protobuf files for defining Wi-Fi provisioning packet structures - -`wifi_provisioning` uses Google Protobuf for language, transport and architecture agnostic protocol communication. These proto files define the protocomm packet structure, separated across multiple files: -* wifi_contants.proto - Defines the various enums for indicating state of Wi-Fi (connected / disconnect / connecting), diconnect reasons, auth modes, etc. -* wifi_config.proto - Defines Wi-Fi configuration structures and commands for setting credentials (SSID, passphrase, BSSID), applying credentials and getting connection state. -* wifi_scan.proto - Defines Wi-Fi scan commands and result structures - -Note : These proto files are not automatically compiled during the build process. - -# Compilation - -Compilation requires protoc (Protobuf Compiler) and protoc-c (Protobuf C Compiler) installed. Since the generated files are to remain the same, as long as the proto files are not modified, therefore the generated files are already available under `components/wifi_provisioning/proto-c` and `components/wifi_provisioning/python` directories, and thus running cmake / make (and installing the Protobuf compilers) is optional. - -If using `cmake` follow the below steps. If using `make`, jump to Step 2 directly. - -## Step 1 (Only for cmake) - -When using cmake, first create a build directory and call cmake from inside: - -``` -mkdir build -cd build -cmake .. -``` - -## Step 2 - -Simply run `make` to generate the respective C and Python files. The newly created files will overwrite those under `components/wifi_provisioning/proto-c` and `components/wifi_provisioning/python` diff --git a/components/wifi_provisioning/proto/makefile b/components/wifi_provisioning/proto/makefile deleted file mode 100644 index 585e42267bab..000000000000 --- a/components/wifi_provisioning/proto/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: c_proto python_proto - -c_proto: *.proto - @protoc-c --c_out=../proto-c/ -I . -I ../../protocomm/proto/ *.proto - -python_proto: *.proto - @protoc --python_out=../python/ -I . -I ../../protocomm/proto/ *.proto diff --git a/components/wifi_provisioning/proto/wifi_config.proto b/components/wifi_provisioning/proto/wifi_config.proto deleted file mode 100644 index e273dc8e552c..000000000000 --- a/components/wifi_provisioning/proto/wifi_config.proto +++ /dev/null @@ -1,57 +0,0 @@ -syntax = "proto3"; - -import "constants.proto"; -import "wifi_constants.proto"; - -message CmdGetStatus { - -} - -message RespGetStatus { - Status status = 1; - WifiStationState sta_state = 2; - oneof state { - WifiConnectFailedReason fail_reason = 10; - WifiConnectedState connected = 11; - } -} - -message CmdSetConfig { - bytes ssid = 1; - bytes passphrase = 2; - bytes bssid = 3; - int32 channel = 4; -} - -message RespSetConfig { - Status status = 1; -} - -message CmdApplyConfig { - -} - -message RespApplyConfig { - Status status = 1; -} - -enum WiFiConfigMsgType { - TypeCmdGetStatus = 0; - TypeRespGetStatus = 1; - TypeCmdSetConfig = 2; - TypeRespSetConfig = 3; - TypeCmdApplyConfig = 4; - TypeRespApplyConfig = 5; -} - -message WiFiConfigPayload { - WiFiConfigMsgType msg = 1; - oneof payload { - CmdGetStatus cmd_get_status = 10; - RespGetStatus resp_get_status = 11; - CmdSetConfig cmd_set_config = 12; - RespSetConfig resp_set_config = 13; - CmdApplyConfig cmd_apply_config = 14; - RespApplyConfig resp_apply_config = 15; - } -} diff --git a/components/wifi_provisioning/proto/wifi_constants.proto b/components/wifi_provisioning/proto/wifi_constants.proto deleted file mode 100644 index 8134b2ed7013..000000000000 --- a/components/wifi_provisioning/proto/wifi_constants.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; - -enum WifiStationState { - Connected = 0; - Connecting = 1; - Disconnected = 2; - ConnectionFailed = 3; -} - -enum WifiConnectFailedReason { - AuthError = 0; - NetworkNotFound = 1; -} - -enum WifiAuthMode { - Open = 0; - WEP = 1; - WPA_PSK = 2; - WPA2_PSK = 3; - WPA_WPA2_PSK = 4; - WPA2_ENTERPRISE = 5; - WPA3_PSK = 6; - WPA2_WPA3_PSK = 7; -} - -message WifiConnectedState { - string ip4_addr = 1; - WifiAuthMode auth_mode = 2; - bytes ssid = 3; - bytes bssid = 4; - int32 channel = 5; -} diff --git a/components/wifi_provisioning/proto/wifi_ctrl.proto b/components/wifi_provisioning/proto/wifi_ctrl.proto deleted file mode 100644 index a2f8c7e253a6..000000000000 --- a/components/wifi_provisioning/proto/wifi_ctrl.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; - -import "constants.proto"; - -message CmdCtrlReset { - -} - -message RespCtrlReset { - -} - -message CmdCtrlReprov { - -} - -message RespCtrlReprov{ - -} - -enum WiFiCtrlMsgType { - TypeCtrlReserved = 0; - TypeCmdCtrlReset = 1; - TypeRespCtrlReset = 2; - TypeCmdCtrlReprov = 3; - TypeRespCtrlReprov = 4; -} - -message WiFiCtrlPayload { - WiFiCtrlMsgType msg = 1; - Status status = 2; - oneof payload { - CmdCtrlReset cmd_ctrl_reset = 11; - RespCtrlReset resp_ctrl_reset = 12; - CmdCtrlReprov cmd_ctrl_reprov = 13; - RespCtrlReprov resp_ctrl_reprov = 14; - } -} diff --git a/components/wifi_provisioning/proto/wifi_scan.proto b/components/wifi_provisioning/proto/wifi_scan.proto deleted file mode 100644 index ea240f20f72e..000000000000 --- a/components/wifi_provisioning/proto/wifi_scan.proto +++ /dev/null @@ -1,63 +0,0 @@ -syntax = "proto3"; - -import "constants.proto"; -import "wifi_constants.proto"; - -message CmdScanStart { - bool blocking = 1; - bool passive = 2; - uint32 group_channels = 3; - uint32 period_ms = 4; -} - -message RespScanStart { - -} - -message CmdScanStatus { - -} - -message RespScanStatus { - bool scan_finished = 1; - uint32 result_count = 2; -} - -message CmdScanResult { - uint32 start_index = 1; - uint32 count = 2; -} - -message WiFiScanResult { - bytes ssid = 1; - uint32 channel = 2; - int32 rssi = 3; - bytes bssid = 4; - WifiAuthMode auth = 5; -} - -message RespScanResult { - repeated WiFiScanResult entries = 1; -} - -enum WiFiScanMsgType { - TypeCmdScanStart = 0; - TypeRespScanStart = 1; - TypeCmdScanStatus = 2; - TypeRespScanStatus = 3; - TypeCmdScanResult = 4; - TypeRespScanResult = 5; -} - -message WiFiScanPayload { - WiFiScanMsgType msg = 1; - Status status = 2; - oneof payload { - CmdScanStart cmd_scan_start = 10; - RespScanStart resp_scan_start = 11; - CmdScanStatus cmd_scan_status = 12; - RespScanStatus resp_scan_status = 13; - CmdScanResult cmd_scan_result = 14; - RespScanResult resp_scan_result = 15; - } -} diff --git a/components/wifi_provisioning/python/wifi_config_pb2.py b/components/wifi_provisioning/python/wifi_config_pb2.py deleted file mode 100644 index 3d48ecfb7eb4..000000000000 --- a/components/wifi_provisioning/python/wifi_config_pb2.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: wifi_config.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -import constants_pb2 as constants__pb2 -import wifi_constants_pb2 as wifi__constants__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11wifi_config.proto\x1a\x0f\x63onstants.proto\x1a\x14wifi_constants.proto\"\x0e\n\x0c\x43mdGetStatus\"\xb2\x01\n\rRespGetStatus\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\x12$\n\tsta_state\x18\x02 \x01(\x0e\x32\x11.WifiStationState\x12/\n\x0b\x66\x61il_reason\x18\n \x01(\x0e\x32\x18.WifiConnectFailedReasonH\x00\x12(\n\tconnected\x18\x0b \x01(\x0b\x32\x13.WifiConnectedStateH\x00\x42\x07\n\x05state\"P\n\x0c\x43mdSetConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x12\n\npassphrase\x18\x02 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x03 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x04 \x01(\x05\"(\n\rRespSetConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\x10\n\x0e\x43mdApplyConfig\"*\n\x0fRespApplyConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\xc3\x02\n\x11WiFiConfigPayload\x12\x1f\n\x03msg\x18\x01 \x01(\x0e\x32\x12.WiFiConfigMsgType\x12\'\n\x0e\x63md_get_status\x18\n \x01(\x0b\x32\r.CmdGetStatusH\x00\x12)\n\x0fresp_get_status\x18\x0b \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12\'\n\x0e\x63md_set_config\x18\x0c \x01(\x0b\x32\r.CmdSetConfigH\x00\x12)\n\x0fresp_set_config\x18\r \x01(\x0b\x32\x0e.RespSetConfigH\x00\x12+\n\x10\x63md_apply_config\x18\x0e \x01(\x0b\x32\x0f.CmdApplyConfigH\x00\x12-\n\x11resp_apply_config\x18\x0f \x01(\x0b\x32\x10.RespApplyConfigH\x00\x42\t\n\x07payload*\x9e\x01\n\x11WiFiConfigMsgType\x12\x14\n\x10TypeCmdGetStatus\x10\x00\x12\x15\n\x11TypeRespGetStatus\x10\x01\x12\x14\n\x10TypeCmdSetConfig\x10\x02\x12\x15\n\x11TypeRespSetConfig\x10\x03\x12\x16\n\x12TypeCmdApplyConfig\x10\x04\x12\x17\n\x13TypeRespApplyConfig\x10\x05\x62\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_config_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _WIFICONFIGMSGTYPE._serialized_start=770 - _WIFICONFIGMSGTYPE._serialized_end=928 - _CMDGETSTATUS._serialized_start=60 - _CMDGETSTATUS._serialized_end=74 - _RESPGETSTATUS._serialized_start=77 - _RESPGETSTATUS._serialized_end=255 - _CMDSETCONFIG._serialized_start=257 - _CMDSETCONFIG._serialized_end=337 - _RESPSETCONFIG._serialized_start=339 - _RESPSETCONFIG._serialized_end=379 - _CMDAPPLYCONFIG._serialized_start=381 - _CMDAPPLYCONFIG._serialized_end=397 - _RESPAPPLYCONFIG._serialized_start=399 - _RESPAPPLYCONFIG._serialized_end=441 - _WIFICONFIGPAYLOAD._serialized_start=444 - _WIFICONFIGPAYLOAD._serialized_end=767 -# @@protoc_insertion_point(module_scope) diff --git a/components/wifi_provisioning/python/wifi_constants_pb2.py b/components/wifi_provisioning/python/wifi_constants_pb2.py deleted file mode 100644 index 3165650d940e..000000000000 --- a/components/wifi_provisioning/python/wifi_constants_pb2.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: wifi_constants.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14wifi_constants.proto\"v\n\x12WifiConnectedState\x12\x10\n\x08ip4_addr\x18\x01 \x01(\t\x12 \n\tauth_mode\x18\x02 \x01(\x0e\x32\r.WifiAuthMode\x12\x0c\n\x04ssid\x18\x03 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x05 \x01(\x05*Y\n\x10WifiStationState\x12\r\n\tConnected\x10\x00\x12\x0e\n\nConnecting\x10\x01\x12\x10\n\x0c\x44isconnected\x10\x02\x12\x14\n\x10\x43onnectionFailed\x10\x03*=\n\x17WifiConnectFailedReason\x12\r\n\tAuthError\x10\x00\x12\x13\n\x0fNetworkNotFound\x10\x01*\x84\x01\n\x0cWifiAuthMode\x12\x08\n\x04Open\x10\x00\x12\x07\n\x03WEP\x10\x01\x12\x0b\n\x07WPA_PSK\x10\x02\x12\x0c\n\x08WPA2_PSK\x10\x03\x12\x10\n\x0cWPA_WPA2_PSK\x10\x04\x12\x13\n\x0fWPA2_ENTERPRISE\x10\x05\x12\x0c\n\x08WPA3_PSK\x10\x06\x12\x11\n\rWPA2_WPA3_PSK\x10\x07\x62\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_constants_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _WIFISTATIONSTATE._serialized_start=144 - _WIFISTATIONSTATE._serialized_end=233 - _WIFICONNECTFAILEDREASON._serialized_start=235 - _WIFICONNECTFAILEDREASON._serialized_end=296 - _WIFIAUTHMODE._serialized_start=299 - _WIFIAUTHMODE._serialized_end=431 - _WIFICONNECTEDSTATE._serialized_start=24 - _WIFICONNECTEDSTATE._serialized_end=142 -# @@protoc_insertion_point(module_scope) diff --git a/components/wifi_provisioning/python/wifi_ctrl_pb2.py b/components/wifi_provisioning/python/wifi_ctrl_pb2.py deleted file mode 100644 index 1057164e9ad1..000000000000 --- a/components/wifi_provisioning/python/wifi_ctrl_pb2.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: wifi_ctrl.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -import constants_pb2 as constants__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_ctrl.proto\x1a\x0f\x63onstants.proto\"\x0e\n\x0c\x43mdCtrlReset\"\x0f\n\rRespCtrlReset\"\x0f\n\rCmdCtrlReprov\"\x10\n\x0eRespCtrlReprov\"\x80\x02\n\x0fWiFiCtrlPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiCtrlMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_ctrl_reset\x18\x0b \x01(\x0b\x32\r.CmdCtrlResetH\x00\x12)\n\x0fresp_ctrl_reset\x18\x0c \x01(\x0b\x32\x0e.RespCtrlResetH\x00\x12)\n\x0f\x63md_ctrl_reprov\x18\r \x01(\x0b\x32\x0e.CmdCtrlReprovH\x00\x12+\n\x10resp_ctrl_reprov\x18\x0e \x01(\x0b\x32\x0f.RespCtrlReprovH\x00\x42\t\n\x07payload*\x83\x01\n\x0fWiFiCtrlMsgType\x12\x14\n\x10TypeCtrlReserved\x10\x00\x12\x14\n\x10TypeCmdCtrlReset\x10\x01\x12\x15\n\x11TypeRespCtrlReset\x10\x02\x12\x15\n\x11TypeCmdCtrlReprov\x10\x03\x12\x16\n\x12TypeRespCtrlReprov\x10\x04\x62\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_ctrl_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _WIFICTRLMSGTYPE._serialized_start=364 - _WIFICTRLMSGTYPE._serialized_end=495 - _CMDCTRLRESET._serialized_start=36 - _CMDCTRLRESET._serialized_end=50 - _RESPCTRLRESET._serialized_start=52 - _RESPCTRLRESET._serialized_end=67 - _CMDCTRLREPROV._serialized_start=69 - _CMDCTRLREPROV._serialized_end=84 - _RESPCTRLREPROV._serialized_start=86 - _RESPCTRLREPROV._serialized_end=102 - _WIFICTRLPAYLOAD._serialized_start=105 - _WIFICTRLPAYLOAD._serialized_end=361 -# @@protoc_insertion_point(module_scope) diff --git a/components/wifi_provisioning/python/wifi_scan_pb2.py b/components/wifi_provisioning/python/wifi_scan_pb2.py deleted file mode 100644 index aaf69c60f2ae..000000000000 --- a/components/wifi_provisioning/python/wifi_scan_pb2.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: wifi_scan.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -import constants_pb2 as constants__pb2 -import wifi_constants_pb2 as wifi__constants__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_scan.proto\x1a\x0f\x63onstants.proto\x1a\x14wifi_constants.proto\"\\\n\x0c\x43mdScanStart\x12\x10\n\x08\x62locking\x18\x01 \x01(\x08\x12\x0f\n\x07passive\x18\x02 \x01(\x08\x12\x16\n\x0egroup_channels\x18\x03 \x01(\r\x12\x11\n\tperiod_ms\x18\x04 \x01(\r\"\x0f\n\rRespScanStart\"\x0f\n\rCmdScanStatus\"=\n\x0eRespScanStatus\x12\x15\n\rscan_finished\x18\x01 \x01(\x08\x12\x14\n\x0cresult_count\x18\x02 \x01(\r\"3\n\rCmdScanResult\x12\x13\n\x0bstart_index\x18\x01 \x01(\r\x12\r\n\x05\x63ount\x18\x02 \x01(\r\"i\n\x0eWiFiScanResult\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x02 \x01(\r\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x1b\n\x04\x61uth\x18\x05 \x01(\x0e\x32\r.WifiAuthMode\"2\n\x0eRespScanResult\x12 \n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x0f.WiFiScanResult\"\xd8\x02\n\x0fWiFiScanPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiScanMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_scan_start\x18\n \x01(\x0b\x32\r.CmdScanStartH\x00\x12)\n\x0fresp_scan_start\x18\x0b \x01(\x0b\x32\x0e.RespScanStartH\x00\x12)\n\x0f\x63md_scan_status\x18\x0c \x01(\x0b\x32\x0e.CmdScanStatusH\x00\x12+\n\x10resp_scan_status\x18\r \x01(\x0b\x32\x0f.RespScanStatusH\x00\x12)\n\x0f\x63md_scan_result\x18\x0e \x01(\x0b\x32\x0e.CmdScanResultH\x00\x12+\n\x10resp_scan_result\x18\x0f \x01(\x0b\x32\x0f.RespScanResultH\x00\x42\t\n\x07payload*\x9c\x01\n\x0fWiFiScanMsgType\x12\x14\n\x10TypeCmdScanStart\x10\x00\x12\x15\n\x11TypeRespScanStart\x10\x01\x12\x15\n\x11TypeCmdScanStatus\x10\x02\x12\x16\n\x12TypeRespScanStatus\x10\x03\x12\x15\n\x11TypeCmdScanResult\x10\x04\x12\x16\n\x12TypeRespScanResult\x10\x05\x62\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_scan_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _WIFISCANMSGTYPE._serialized_start=809 - _WIFISCANMSGTYPE._serialized_end=965 - _CMDSCANSTART._serialized_start=58 - _CMDSCANSTART._serialized_end=150 - _RESPSCANSTART._serialized_start=152 - _RESPSCANSTART._serialized_end=167 - _CMDSCANSTATUS._serialized_start=169 - _CMDSCANSTATUS._serialized_end=184 - _RESPSCANSTATUS._serialized_start=186 - _RESPSCANSTATUS._serialized_end=247 - _CMDSCANRESULT._serialized_start=249 - _CMDSCANRESULT._serialized_end=300 - _WIFISCANRESULT._serialized_start=302 - _WIFISCANRESULT._serialized_end=407 - _RESPSCANRESULT._serialized_start=409 - _RESPSCANRESULT._serialized_end=459 - _WIFISCANPAYLOAD._serialized_start=462 - _WIFISCANPAYLOAD._serialized_end=806 -# @@protoc_insertion_point(module_scope) diff --git a/components/wifi_provisioning/src/handlers.c b/components/wifi_provisioning/src/handlers.c deleted file mode 100644 index a3baaf243eb4..000000000000 --- a/components/wifi_provisioning/src/handlers.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -#include -#include - -#include "wifi_provisioning/wifi_config.h" -#include "wifi_provisioning/wifi_scan.h" -#include "wifi_ctrl.h" -#include "wifi_provisioning/manager.h" -#include "wifi_provisioning_priv.h" - -static const char *TAG = "wifi_prov_handlers"; - -/* Provide definition of wifi_prov_ctx_t */ -struct wifi_prov_ctx { - wifi_config_t wifi_cfg; -}; - -static wifi_config_t *get_config(wifi_prov_ctx_t **ctx) -{ - return (*ctx ? & (*ctx)->wifi_cfg : NULL); -} - -static wifi_config_t *new_config(wifi_prov_ctx_t **ctx) -{ - free(*ctx); - (*ctx) = (wifi_prov_ctx_t *) calloc(1, sizeof(wifi_prov_ctx_t)); - return get_config(ctx); -} - -static void free_config(wifi_prov_ctx_t **ctx) -{ - free(*ctx); - *ctx = NULL; -} - -static esp_err_t get_status_handler(wifi_prov_config_get_data_t *resp_data, wifi_prov_ctx_t **ctx) -{ - /* Initialize to zero */ - memset(resp_data, 0, sizeof(wifi_prov_config_get_data_t)); - - if (wifi_prov_mgr_get_wifi_state(&resp_data->wifi_state) != ESP_OK) { - ESP_LOGW(TAG, "Wi-Fi provisioning manager not running"); - return ESP_ERR_INVALID_STATE; - } - - if (resp_data->wifi_state == WIFI_PROV_STA_CONNECTED) { - ESP_LOGD(TAG, "Got state : connected"); - - /* IP Addr assigned to STA */ - esp_netif_ip_info_t ip_info; - esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip_info); - esp_ip4addr_ntoa(&ip_info.ip, resp_data->conn_info.ip_addr, sizeof(resp_data->conn_info.ip_addr)); - - - /* AP information to which STA is connected */ - wifi_ap_record_t ap_info; - esp_wifi_sta_get_ap_info(&ap_info); - memcpy(resp_data->conn_info.bssid, (char *)ap_info.bssid, sizeof(ap_info.bssid)); - memcpy(resp_data->conn_info.ssid, (char *)ap_info.ssid, sizeof(ap_info.ssid)); - resp_data->conn_info.channel = ap_info.primary; - resp_data->conn_info.auth_mode = ap_info.authmode; - - /* Tell manager to stop provisioning service */ - wifi_prov_mgr_done(); - } else if (resp_data->wifi_state == WIFI_PROV_STA_DISCONNECTED) { - ESP_LOGD(TAG, "Got state : disconnected"); - - /* If disconnected, convey reason */ - wifi_prov_mgr_get_wifi_disconnect_reason(&resp_data->fail_reason); - } else { - ESP_LOGD(TAG, "Got state : connecting"); - } - return ESP_OK; -} - -static esp_err_t set_config_handler(const wifi_prov_config_set_data_t *req_data, wifi_prov_ctx_t **ctx) -{ - wifi_config_t *wifi_cfg = get_config(ctx); - if (wifi_cfg) { - free_config(ctx); - } - - wifi_cfg = new_config(ctx); - if (!wifi_cfg) { - ESP_LOGE(TAG, "Unable to allocate Wi-Fi config"); - return ESP_ERR_NO_MEM; - } - - ESP_LOGD(TAG, "Wi-Fi Credentials Received"); - - /* Using memcpy allows the max SSID length to be 32 bytes (as per 802.11 standard). - * But this doesn't guarantee that the saved SSID will be null terminated, because - * wifi_cfg->sta.ssid is also 32 bytes long (without extra 1 byte for null character). - * Although, this is not a matter for concern because esp_wifi library reads the SSID - * upto 32 bytes in absence of null termination */ - const size_t ssid_len = strnlen(req_data->ssid, sizeof(wifi_cfg->sta.ssid)); - /* Ensure SSID less than 32 bytes is null terminated */ - memset(wifi_cfg->sta.ssid, 0, sizeof(wifi_cfg->sta.ssid)); - memcpy(wifi_cfg->sta.ssid, req_data->ssid, ssid_len); - - /* Using strlcpy allows both max passphrase length (63 bytes) and ensures null termination - * because size of wifi_cfg->sta.password is 64 bytes (1 extra byte for null character) */ - strlcpy((char *) wifi_cfg->sta.password, req_data->password, sizeof(wifi_cfg->sta.password)); - -#ifdef CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN - wifi_cfg->sta.scan_method = WIFI_ALL_CHANNEL_SCAN; -#else /* CONFIG_WIFI_PROV_STA_FAST_SCAN */ - wifi_cfg->sta.scan_method = WIFI_FAST_SCAN; -#endif - - return ESP_OK; -} - -static esp_err_t apply_config_handler(wifi_prov_ctx_t **ctx) -{ - wifi_config_t *wifi_cfg = get_config(ctx); - if (!wifi_cfg) { - ESP_LOGE(TAG, "Wi-Fi config not set"); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t ret = wifi_prov_mgr_configure_sta(wifi_cfg); - if (ret == ESP_OK) { - ESP_LOGD(TAG, "Wi-Fi Credentials Applied"); - } else { - ESP_LOGE(TAG, "Failed to apply Wi-Fi Credentials"); - } - - free_config(ctx); - return ret; -} - -esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr) -{ - 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; -} - -/*************************************************************************/ - -static esp_err_t ctrl_reset(void) -{ - return wifi_prov_mgr_reset_sm_state_on_failure(); -} - -static esp_err_t ctrl_reprov(void) -{ - return wifi_prov_mgr_reset_sm_state_for_reprovision(); -} - -esp_err_t get_wifi_ctrl_handlers(wifi_ctrl_handlers_t *ptr) -{ - if (!ptr) { - return ESP_ERR_INVALID_ARG; - } - ptr->ctrl_reset = ctrl_reset; - ptr->ctrl_reprov = ctrl_reprov; - return ESP_OK; -} diff --git a/components/wifi_provisioning/src/manager.c b/components/wifi_provisioning/src/manager.c deleted file mode 100644 index d2d440f15266..000000000000 --- a/components/wifi_provisioning/src/manager.c +++ /dev/null @@ -1,1788 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "wifi_provisioning_priv.h" - -#define WIFI_PROV_MGR_VERSION "v1.1" -#define WIFI_PROV_STORAGE_BIT BIT0 -#define WIFI_PROV_SETTING_BIT BIT1 -#define MAX_SCAN_RESULTS CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES - -#define ACQUIRE_LOCK(mux) assert(xSemaphoreTake(mux, portMAX_DELAY) == pdTRUE) -#define RELEASE_LOCK(mux) assert(xSemaphoreGive(mux) == pdTRUE) - -static const char *TAG = "wifi_prov_mgr"; - -ESP_EVENT_DEFINE_BASE(WIFI_PROV_EVENT); -ESP_EVENT_DEFINE_BASE(WIFI_PROV_MGR_PVT_EVENT); - -typedef enum { - WIFI_PROV_STATE_IDLE, - WIFI_PROV_STATE_STARTING, - WIFI_PROV_STATE_STARTED, - WIFI_PROV_STATE_CRED_RECV, - WIFI_PROV_STATE_FAIL, - WIFI_PROV_STATE_SUCCESS, - WIFI_PROV_STATE_STOPPING -} wifi_prov_mgr_state_t; - -typedef enum { - WIFI_PROV_MGR_STOP, -} wifi_prov_mgr_pvt_event_t; - -/** - * @brief Structure for storing capabilities supported by - * the provisioning service - */ -struct wifi_prov_capabilities { - /* Security 0 is used */ - bool no_sec; - - /* Proof of Possession is not required for establishing session */ - bool no_pop; - - /* Provisioning doesn't stop on it's own after receiving Wi-Fi credentials - * instead application has to explicitly call wifi_prov_mgr_stop_provisioning() */ - bool no_auto_stop; -}; - -/** - * @brief Structure for storing miscellaneous information about - * provisioning service that will be conveyed to clients - */ -struct wifi_prov_info { - const char *version; - struct wifi_prov_capabilities capabilities; -}; - -/** - * @brief Context data for provisioning manager - */ -struct wifi_prov_mgr_ctx { - /* Provisioning manager configuration */ - wifi_prov_mgr_config_t mgr_config; - - /* State of the provisioning service */ - wifi_prov_mgr_state_t prov_state; - - /* Provisioning scheme configuration */ - void *prov_scheme_config; - - /* Protocomm handle */ - protocomm_t *pc; - - /* Type of security to use with protocomm */ - int security; - - /* Pointer to security params */ - const void* protocomm_sec_params; - - /* Handle for Provisioning Auto Stop timer */ - esp_timer_handle_t autostop_timer; - - /* Handle for delayed Wi-Fi connection timer */ - esp_timer_handle_t wifi_connect_timer; - - /* Handle for delayed cleanup timer */ - esp_timer_handle_t cleanup_delay_timer; - - /* State of Wi-Fi Station */ - wifi_prov_sta_state_t wifi_state; - - /* Code for Wi-Fi station disconnection (if disconnected) */ - wifi_prov_sta_fail_reason_t wifi_disconnect_reason; - - /* Protocomm handlers for Wi-Fi configuration endpoint */ - wifi_prov_config_handlers_t *wifi_prov_handlers; - - /* Protocomm handlers for Wi-Fi scan endpoint */ - wifi_prov_scan_handlers_t *wifi_scan_handlers; - - /* Protocomm handlers for Wi-Fi ctrl endpoint */ - wifi_ctrl_handlers_t *wifi_ctrl_handlers; - - /* Count of used endpoint UUIDs */ - unsigned int endpoint_uuid_used; - - /* Provisioning service information */ - struct wifi_prov_info mgr_info; - - /* Application related information in JSON format */ - cJSON *app_info_json; - - /* Delay after which resources will be cleaned up asynchronously - * upon execution of wifi_prov_mgr_stop_provisioning() */ - uint32_t cleanup_delay; - - /* Wi-Fi scan parameters and state variables */ - bool scanning; - uint8_t channels_per_group; - uint16_t curr_channel; - uint16_t ap_list_len[14]; // 14 entries corresponding to each channel - wifi_ap_record_t *ap_list[14]; - wifi_ap_record_t *ap_list_sorted[MAX_SCAN_RESULTS]; - wifi_scan_config_t scan_cfg; -}; - -/* Mutex to lock/unlock access to provisioning singleton - * context data. This is allocated only once on first init - * and never deleted as wifi_prov_mgr is a singleton */ -static SemaphoreHandle_t prov_ctx_lock = NULL; - -/* Pointer to provisioning context data */ -static struct wifi_prov_mgr_ctx *prov_ctx; - -/* This executes registered app_event_callback for a particular event - * - * NOTE : By the time this fucntion returns, it is possible that - * the manager got de-initialized due to a call to wifi_prov_mgr_deinit() - * either inside the event callbacks or from another thread. Therefore - * post execution of execute_event_cb(), the validity of prov_ctx must - * always be checked. A cleaner way, to avoid this pitfall safely, would - * be to limit the usage of this function to only public APIs, and that - * too at the very end, just before returning. - * - * NOTE: This function should be called only after ensuring that the - * context is valid and the control mutex is locked. */ -static void execute_event_cb(wifi_prov_cb_event_t event_id, void *event_data, size_t event_data_size) -{ - ESP_LOGD(TAG, "execute_event_cb : %d", event_id); - - if (prov_ctx) { - wifi_prov_cb_func_t app_cb = prov_ctx->mgr_config.app_event_handler.event_cb; - void *app_data = prov_ctx->mgr_config.app_event_handler.user_data; - - wifi_prov_cb_func_t scheme_cb = prov_ctx->mgr_config.scheme_event_handler.event_cb; - void *scheme_data = prov_ctx->mgr_config.scheme_event_handler.user_data; - - /* Release the mutex before executing the callbacks. This is done so that - * wifi_prov_mgr_event_handler() doesn't stay blocked for the duration */ - RELEASE_LOCK(prov_ctx_lock); - - if (scheme_cb) { - /* Call scheme specific event handler */ - scheme_cb(scheme_data, event_id, event_data); - } - - if (app_cb) { - /* Call application specific event handler */ - app_cb(app_data, event_id, event_data); - } - - if (esp_event_post(WIFI_PROV_EVENT, event_id, - event_data, event_data_size, - portMAX_DELAY) != ESP_OK) { - ESP_LOGE(TAG, "Failed to post event %d to default event loop", event_id); - } - - ACQUIRE_LOCK(prov_ctx_lock); - } -} - -esp_err_t wifi_prov_mgr_set_app_info(const char *label, const char *version, - const char**capabilities, size_t total_capabilities) -{ - if (!label || !version || !capabilities) { - return ESP_ERR_INVALID_ARG; - } - - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t ret = ESP_FAIL; - ACQUIRE_LOCK(prov_ctx_lock); - - if (prov_ctx && prov_ctx->prov_state == WIFI_PROV_STATE_IDLE) { - if (!prov_ctx->app_info_json) { - prov_ctx->app_info_json = cJSON_CreateObject(); - } - - cJSON *new_entry_json = cJSON_CreateObject(); - cJSON *capabilities_json = cJSON_CreateArray(); - cJSON_AddItemToObject(prov_ctx->app_info_json, label, new_entry_json); - - /* Version ("ver") */ - cJSON_AddStringToObject(new_entry_json, "ver", version); - - /* List of capabilities ("cap") */ - cJSON_AddItemToObject(new_entry_json, "cap", capabilities_json); - for (unsigned int i = 0; i < total_capabilities; i++) { - if (capabilities[i]) { - cJSON_AddItemToArray(capabilities_json, cJSON_CreateString(capabilities[i])); - } - } - ret = ESP_OK; - } else { - ret = ESP_ERR_INVALID_STATE; - } - - RELEASE_LOCK(prov_ctx_lock); - return ret; -} - -static cJSON* wifi_prov_get_info_json(void) -{ - cJSON *full_info_json = prov_ctx->app_info_json ? - cJSON_Duplicate(prov_ctx->app_info_json, 1) : cJSON_CreateObject(); - cJSON *prov_info_json = cJSON_CreateObject(); - cJSON *prov_capabilities = cJSON_CreateArray(); - - /* Use label "prov" to indicate provisioning related information */ - cJSON_AddItemToObject(full_info_json, "prov", prov_info_json); - - /* Version field */ - cJSON_AddStringToObject(prov_info_json, "ver", prov_ctx->mgr_info.version); - - cJSON_AddNumberToObject(prov_info_json, "sec_ver", prov_ctx->security); - /* Capabilities field */ - cJSON_AddItemToObject(prov_info_json, "cap", prov_capabilities); - - /* If Security / Proof of Possession is not used, indicate in capabilities */ - if (prov_ctx->mgr_info.capabilities.no_sec) { - cJSON_AddItemToArray(prov_capabilities, cJSON_CreateString("no_sec")); - } else if (prov_ctx->mgr_info.capabilities.no_pop) { - cJSON_AddItemToArray(prov_capabilities, cJSON_CreateString("no_pop")); - } - - /* Indicate capability for performing Wi-Fi scan */ - cJSON_AddItemToArray(prov_capabilities, cJSON_CreateString("wifi_scan")); - return full_info_json; -} - -/* Declare the internal event handler */ -static void wifi_prov_mgr_event_handler_internal(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data); - -static esp_err_t wifi_prov_mgr_start_service(const char *service_name, const char *service_key) -{ - const wifi_prov_scheme_t *scheme = &prov_ctx->mgr_config.scheme; - esp_err_t ret; - - /* Create new protocomm instance */ - prov_ctx->pc = protocomm_new(); - if (prov_ctx->pc == NULL) { - ESP_LOGE(TAG, "Failed to create new protocomm instance"); - return ESP_FAIL; - } - - ret = scheme->set_config_service(prov_ctx->prov_scheme_config, service_name, service_key); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to configure service"); - protocomm_delete(prov_ctx->pc); - return ret; - } - - /* Start provisioning */ - ret = scheme->prov_start(prov_ctx->pc, prov_ctx->prov_scheme_config); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to start service"); - protocomm_delete(prov_ctx->pc); - return ret; - } - - /* Set version information / capabilities of provisioning service and application */ - cJSON *version_json = wifi_prov_get_info_json(); - char *version_str = cJSON_Print(version_json); - ret = protocomm_set_version(prov_ctx->pc, "proto-ver", version_str); - free(version_str); - cJSON_Delete(version_json); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set version endpoint"); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - /* Set protocomm security type for endpoint */ - if (prov_ctx->security == 0) { -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0 - ret = protocomm_set_security(prov_ctx->pc, "prov-session", - &protocomm_security0, NULL); -#else - // Enable SECURITY_VERSION_0 in Protocomm configuration menu - return ESP_ERR_NOT_SUPPORTED; -#endif - } else if (prov_ctx->security == 1) { -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1 - ret = protocomm_set_security(prov_ctx->pc, "prov-session", - &protocomm_security1, prov_ctx->protocomm_sec_params); -#else - // Enable SECURITY_VERSION_1 in Protocomm configuration menu - return ESP_ERR_NOT_SUPPORTED; -#endif - } else if (prov_ctx->security == 2) { -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2 - ret = protocomm_set_security(prov_ctx->pc, "prov-session", - &protocomm_security2, prov_ctx->protocomm_sec_params); -#else - // Enable SECURITY_VERSION_2 in Protocomm configuration menu - return ESP_ERR_NOT_SUPPORTED; -#endif - } else { - ESP_LOGE(TAG, "Unsupported protocomm security version %d", prov_ctx->security); - ret = ESP_ERR_INVALID_ARG; - } - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set security endpoint"); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - prov_ctx->wifi_prov_handlers = malloc(sizeof(wifi_prov_config_handlers_t)); - ret = get_wifi_prov_handlers(prov_ctx->wifi_prov_handlers); - if (ret != ESP_OK) { - ESP_LOGD(TAG, "Failed to allocate memory for provisioning handlers"); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ESP_ERR_NO_MEM; - } - - /* Add protocomm endpoint for Wi-Fi station configuration */ - ret = protocomm_add_endpoint(prov_ctx->pc, "prov-config", - wifi_prov_config_data_handler, - prov_ctx->wifi_prov_handlers); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set provisioning endpoint"); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - prov_ctx->wifi_scan_handlers = malloc(sizeof(wifi_prov_scan_handlers_t)); - ret = get_wifi_scan_handlers(prov_ctx->wifi_scan_handlers); - if (ret != ESP_OK) { - ESP_LOGD(TAG, "Failed to allocate memory for Wi-Fi scan handlers"); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ESP_ERR_NO_MEM; - } - - /* Add endpoint for scanning Wi-Fi APs and sending scan list */ - ret = protocomm_add_endpoint(prov_ctx->pc, "prov-scan", - wifi_prov_scan_handler, - prov_ctx->wifi_scan_handlers); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi scan endpoint"); - free(prov_ctx->wifi_scan_handlers); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - prov_ctx->wifi_ctrl_handlers = malloc(sizeof(wifi_ctrl_handlers_t)); - ret = get_wifi_ctrl_handlers(prov_ctx->wifi_ctrl_handlers); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to allocate memory for Wi-Fi ctrl handlers"); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ESP_ERR_NO_MEM; - } - - /* Add endpoint for controlling state of Wi-Fi station */ - ret = protocomm_add_endpoint(prov_ctx->pc, "prov-ctrl", - wifi_ctrl_handler, - prov_ctx->wifi_ctrl_handlers); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi ctrl endpoint"); - free(prov_ctx->wifi_ctrl_handlers); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - /* Register global event handler */ - ret = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, - wifi_prov_mgr_event_handler_internal, NULL); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to register WiFi event handler"); - free(prov_ctx->wifi_scan_handlers); - free(prov_ctx->wifi_ctrl_handlers); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - ret = esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, - wifi_prov_mgr_event_handler_internal, NULL); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to register IP event handler"); - esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, - wifi_prov_mgr_event_handler_internal); - free(prov_ctx->wifi_scan_handlers); - free(prov_ctx->wifi_ctrl_handlers); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - ret = esp_event_handler_register(WIFI_PROV_MGR_PVT_EVENT, WIFI_PROV_MGR_STOP, - wifi_prov_mgr_event_handler_internal, NULL); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to register provisioning event handler"); - esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, - wifi_prov_mgr_event_handler_internal); - esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, - wifi_prov_mgr_event_handler_internal); - free(prov_ctx->wifi_scan_handlers); - free(prov_ctx->wifi_ctrl_handlers); - free(prov_ctx->wifi_prov_handlers); - scheme->prov_stop(prov_ctx->pc); - protocomm_delete(prov_ctx->pc); - return ret; - } - - - ESP_LOGI(TAG, "Provisioning started with service name : %s ", - service_name ? service_name : ""); - return ESP_OK; -} - -esp_err_t wifi_prov_mgr_endpoint_create(const char *ep_name) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t err = ESP_FAIL; - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx && - prov_ctx->prov_state == WIFI_PROV_STATE_IDLE) { - err = prov_ctx->mgr_config.scheme.set_config_endpoint( - prov_ctx->prov_scheme_config, ep_name, - prov_ctx->endpoint_uuid_used + 1); - } - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to create additional endpoint"); - } else { - prov_ctx->endpoint_uuid_used++; - } - RELEASE_LOCK(prov_ctx_lock); - return err; -} - -esp_err_t wifi_prov_mgr_endpoint_register(const char *ep_name, protocomm_req_handler_t handler, void *user_ctx) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t err = ESP_FAIL; - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx && - prov_ctx->prov_state > WIFI_PROV_STATE_STARTING && - prov_ctx->prov_state < WIFI_PROV_STATE_STOPPING) { - err = protocomm_add_endpoint(prov_ctx->pc, ep_name, handler, user_ctx); - } - RELEASE_LOCK(prov_ctx_lock); - - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to register handler for endpoint"); - } - return err; -} - -void wifi_prov_mgr_endpoint_unregister(const char *ep_name) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx && - prov_ctx->prov_state > WIFI_PROV_STATE_STARTING && - prov_ctx->prov_state < WIFI_PROV_STATE_STOPPING) { - protocomm_remove_endpoint(prov_ctx->pc, ep_name); - } - RELEASE_LOCK(prov_ctx_lock); -} - -static void prov_stop_and_notify(bool is_async) -{ - esp_event_handler_unregister(WIFI_PROV_MGR_PVT_EVENT, WIFI_PROV_MGR_STOP, - wifi_prov_mgr_event_handler_internal); - - if (prov_ctx->cleanup_delay_timer) { - esp_timer_stop(prov_ctx->cleanup_delay_timer); - esp_timer_delete(prov_ctx->cleanup_delay_timer); - prov_ctx->cleanup_delay_timer = NULL; - } - - wifi_prov_cb_func_t app_cb = prov_ctx->mgr_config.app_event_handler.event_cb; - void *app_data = prov_ctx->mgr_config.app_event_handler.user_data; - - wifi_prov_cb_func_t scheme_cb = prov_ctx->mgr_config.scheme_event_handler.event_cb; - void *scheme_data = prov_ctx->mgr_config.scheme_event_handler.user_data; - - /* This delay is so that the client side app is notified first - * and then the provisioning is stopped. Generally 1000ms is enough. */ - if (!is_async) - { - uint32_t cleanup_delay = prov_ctx->cleanup_delay > 100 ? prov_ctx->cleanup_delay : 100; - vTaskDelay(cleanup_delay / portTICK_PERIOD_MS); - } - - /* All the extra application added endpoints are also - * removed automatically when prov_stop is called */ - prov_ctx->mgr_config.scheme.prov_stop(prov_ctx->pc); - - /* Delete protocomm instance */ - protocomm_delete(prov_ctx->pc); - prov_ctx->pc = NULL; - - /* Free provisioning handlers */ - free(prov_ctx->wifi_prov_handlers->ctx); - free(prov_ctx->wifi_prov_handlers); - prov_ctx->wifi_prov_handlers = NULL; - - free(prov_ctx->wifi_scan_handlers->ctx); - free(prov_ctx->wifi_scan_handlers); - prov_ctx->wifi_scan_handlers = NULL; - - free(prov_ctx->wifi_ctrl_handlers); - prov_ctx->wifi_ctrl_handlers = NULL; - - /* Switch device to Wi-Fi STA mode irrespective of - * whether provisioning was completed or not */ - esp_wifi_set_mode(WIFI_MODE_STA); - ESP_LOGI(TAG, "Provisioning stopped"); - - if (is_async) { - /* NOTE: While calling this API in an async fashion, - * the context lock prov_ctx_lock has already been taken - */ - prov_ctx->prov_state = WIFI_PROV_STATE_IDLE; - - ESP_LOGD(TAG, "execute_event_cb : %d", WIFI_PROV_END); - if (scheme_cb) { - scheme_cb(scheme_data, WIFI_PROV_END, NULL); - } - if (app_cb) { - app_cb(app_data, WIFI_PROV_END, NULL); - } - if (esp_event_post(WIFI_PROV_EVENT, WIFI_PROV_END, NULL, 0, portMAX_DELAY) != ESP_OK) { - ESP_LOGE(TAG, "Failed to post event WIFI_PROV_END"); - } - } -} - -/* This will do one of these: - * 1) if blocking is false, start a cleanup timer for stopping the provisioning service (returns true) - * 2) if blocking is true, stop provisioning service immediately (returns true) - * 3) if service was already in the process of termination, in blocking mode this will - * wait till the service is stopped (returns false) - * 4) if service was not running, this will return immediately (returns false) - * - * NOTE: This function should be called only after ensuring that the context - * is valid and the control mutex is locked - * - * NOTE: When blocking mode is selected, the event callbacks are not executed. - * This help with de-initialization. - */ -static bool wifi_prov_mgr_stop_service(bool blocking) -{ - if (blocking) { - /* Wait for any ongoing calls to wifi_prov_mgr_start_service() or - * wifi_prov_mgr_stop_service() from another thread to finish */ - while (prov_ctx && ( - prov_ctx->prov_state == WIFI_PROV_STATE_STARTING || - prov_ctx->prov_state == WIFI_PROV_STATE_STOPPING)) { - RELEASE_LOCK(prov_ctx_lock); - vTaskDelay(100 / portTICK_PERIOD_MS); - ACQUIRE_LOCK(prov_ctx_lock); - } - } else { - /* Wait for any ongoing call to wifi_prov_mgr_start_service() - * from another thread to finish */ - while (prov_ctx && - prov_ctx->prov_state == WIFI_PROV_STATE_STARTING) { - RELEASE_LOCK(prov_ctx_lock); - vTaskDelay(100 / portTICK_PERIOD_MS); - ACQUIRE_LOCK(prov_ctx_lock); - } - - if (prov_ctx && prov_ctx->prov_state == WIFI_PROV_STATE_STOPPING) { - ESP_LOGD(TAG, "Provisioning is already stopping"); - return false; - } - } - - if (!prov_ctx || prov_ctx->prov_state == WIFI_PROV_STATE_IDLE) { - ESP_LOGD(TAG, "Provisioning not running"); - return false; - } - - /* Timers not needed anymore */ - if (prov_ctx->autostop_timer) { - esp_timer_stop(prov_ctx->autostop_timer); - esp_timer_delete(prov_ctx->autostop_timer); - prov_ctx->autostop_timer = NULL; - } - - if (prov_ctx->wifi_connect_timer) { - esp_timer_stop(prov_ctx->wifi_connect_timer); - esp_timer_delete(prov_ctx->wifi_connect_timer); - prov_ctx->wifi_connect_timer = NULL; - } - - ESP_LOGD(TAG, "Stopping provisioning"); - prov_ctx->prov_state = WIFI_PROV_STATE_STOPPING; - - /* Free proof of possession */ - if (prov_ctx->protocomm_sec_params) { - if (prov_ctx->security == 1) { - // In case of security 1 we keep an internal copy of "pop". - // Hence free it at this point - uint8_t *pop = (uint8_t *)((protocomm_security1_params_t *) prov_ctx->protocomm_sec_params)->data; - free(pop); - } - prov_ctx->protocomm_sec_params = NULL; - } - - /* Delete all scan results */ - for (uint16_t channel = 0; channel < 14; channel++) { - free(prov_ctx->ap_list[channel]); - prov_ctx->ap_list[channel] = NULL; - } - prov_ctx->scanning = false; - for (uint8_t i = 0; i < MAX_SCAN_RESULTS; i++) { - prov_ctx->ap_list_sorted[i] = NULL; - } - - /* Remove event handler */ - esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, - wifi_prov_mgr_event_handler_internal); - esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, - wifi_prov_mgr_event_handler_internal); - - if (blocking) { - /* Run the cleanup without launching a separate task. Also the - * WIFI_PROV_END event is not emitted in this case */ - RELEASE_LOCK(prov_ctx_lock); - prov_stop_and_notify(false); - ACQUIRE_LOCK(prov_ctx_lock); - prov_ctx->prov_state = WIFI_PROV_STATE_IDLE; - } else { - /* Launch cleanup timer to perform the cleanup asynchronously. - * It is important to do this asynchronously because, there are - * situations in which the transport level resources have to be - * released - some duration after - returning from a call to - * wifi_prov_mgr_stop_provisioning(), like when it is called - * inside a protocomm handler */ - uint64_t cleanup_delay_ms = prov_ctx->cleanup_delay > 100 ? prov_ctx->cleanup_delay : 100; - esp_timer_start_once(prov_ctx->cleanup_delay_timer, cleanup_delay_ms * 1000U); - ESP_LOGD(TAG, "Provisioning scheduled for stopping"); - } - return true; -} - -/* Task spawned by timer callback */ -static void stop_prov_timer_cb(void *arg) -{ - wifi_prov_mgr_stop_provisioning(); -} - -static void cleanup_delay_timer_cb(void *arg) -{ - esp_err_t ret = esp_event_post(WIFI_PROV_MGR_PVT_EVENT, WIFI_PROV_MGR_STOP, NULL, 0, pdMS_TO_TICKS(100)); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to post WIFI_PROV_MGR_STOP event! %d %s", ret, esp_err_to_name(ret)); - } -} - -esp_err_t wifi_prov_mgr_disable_auto_stop(uint32_t cleanup_delay) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t ret = ESP_FAIL; - ACQUIRE_LOCK(prov_ctx_lock); - - if (prov_ctx && prov_ctx->prov_state == WIFI_PROV_STATE_IDLE) { - prov_ctx->mgr_info.capabilities.no_auto_stop = true; - prov_ctx->cleanup_delay = cleanup_delay; - ret = ESP_OK; - } else { - ret = ESP_ERR_INVALID_STATE; - } - - RELEASE_LOCK(prov_ctx_lock); - return ret; -} - -/* Call this if provisioning is completed before the timeout occurs */ -esp_err_t wifi_prov_mgr_done(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - bool auto_stop_enabled = false; - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx && !prov_ctx->mgr_info.capabilities.no_auto_stop) { - auto_stop_enabled = true; - } - RELEASE_LOCK(prov_ctx_lock); - - /* Stop provisioning if auto stop is enabled */ - if (auto_stop_enabled) { - wifi_prov_mgr_stop_provisioning(); - } - return ESP_OK; -} - -static esp_err_t update_wifi_scan_results(void) -{ - if (!prov_ctx->scanning) { - return ESP_ERR_INVALID_STATE; - } - ESP_LOGD(TAG, "Scan finished"); - - esp_err_t ret = ESP_FAIL; - uint16_t count = 0; - uint16_t curr_channel = prov_ctx->curr_channel; - - if (prov_ctx->ap_list[curr_channel]) { - free(prov_ctx->ap_list[curr_channel]); - prov_ctx->ap_list[curr_channel] = NULL; - prov_ctx->ap_list_len[curr_channel] = 0; - } - - if (esp_wifi_scan_get_ap_num(&count) != ESP_OK) { - ESP_LOGE(TAG, "Failed to get count of scanned APs"); - goto exit; - } - - if (!count) { - ESP_LOGD(TAG, "Scan result empty"); - ret = ESP_OK; - goto exit; - } - - uint16_t get_count = MIN(count, MAX_SCAN_RESULTS); - prov_ctx->ap_list[curr_channel] = (wifi_ap_record_t *) calloc(get_count, sizeof(wifi_ap_record_t)); - if (!prov_ctx->ap_list[curr_channel]) { - ESP_LOGE(TAG, "Failed to allocate memory for AP list"); - esp_wifi_clear_ap_list(); - goto exit; - } - if (esp_wifi_scan_get_ap_records(&get_count, prov_ctx->ap_list[curr_channel]) != ESP_OK) { - ESP_LOGE(TAG, "Failed to get scanned AP records"); - goto exit; - } - prov_ctx->ap_list_len[curr_channel] = get_count; - - if (prov_ctx->channels_per_group) { - ESP_LOGD(TAG, "Scan results for channel %d :", curr_channel); - } else { - ESP_LOGD(TAG, "Scan results :"); - } - ESP_LOGD(TAG, "\tS.N. %-32s %-12s %s %s", "SSID", "BSSID", "RSSI", "AUTH"); - for (uint8_t i = 0; i < prov_ctx->ap_list_len[curr_channel]; i++) { - ESP_LOGD(TAG, "\t[%2d] %-32s %02x%02x%02x%02x%02x%02x %4d %4d", i, - prov_ctx->ap_list[curr_channel][i].ssid, - prov_ctx->ap_list[curr_channel][i].bssid[0], - prov_ctx->ap_list[curr_channel][i].bssid[1], - prov_ctx->ap_list[curr_channel][i].bssid[2], - prov_ctx->ap_list[curr_channel][i].bssid[3], - prov_ctx->ap_list[curr_channel][i].bssid[4], - prov_ctx->ap_list[curr_channel][i].bssid[5], - prov_ctx->ap_list[curr_channel][i].rssi, - prov_ctx->ap_list[curr_channel][i].authmode); - } - - /* Store results in sorted list */ - { - int rc = get_count; - int is = MAX_SCAN_RESULTS - rc - 1; - while (rc > 0 && is >= 0) { - if (prov_ctx->ap_list_sorted[is]) { - if (prov_ctx->ap_list_sorted[is]->rssi > prov_ctx->ap_list[curr_channel][rc - 1].rssi) { - prov_ctx->ap_list_sorted[is + rc] = &prov_ctx->ap_list[curr_channel][rc - 1]; - rc--; - continue; - } - prov_ctx->ap_list_sorted[is + rc] = prov_ctx->ap_list_sorted[is]; - } - is--; - } - while (rc > 0) { - prov_ctx->ap_list_sorted[rc - 1] = &prov_ctx->ap_list[curr_channel][rc - 1]; - rc--; - } - } - - ret = ESP_OK; - exit: - - if (!prov_ctx->channels_per_group) { - /* All channel scan was performed - * so nothing more to do */ - prov_ctx->scanning = false; - goto final; - } - - curr_channel = prov_ctx->curr_channel = (prov_ctx->curr_channel + 1) % 14; - if (ret != ESP_OK || curr_channel == 0) { - prov_ctx->scanning = false; - goto final; - } - - if ((curr_channel % prov_ctx->channels_per_group) == 0) { - vTaskDelay(120 / portTICK_PERIOD_MS); - } - - ESP_LOGD(TAG, "Scan starting on channel %u...", curr_channel); - prov_ctx->scan_cfg.channel = curr_channel; - ret = esp_wifi_scan_start(&prov_ctx->scan_cfg, false); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to start scan"); - prov_ctx->scanning = false; - goto final; - } - ESP_LOGD(TAG, "Scan started"); - - final: - - return ret; -} - -static void wifi_prov_mgr_event_handler_internal( - void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return; - } - - ACQUIRE_LOCK(prov_ctx_lock); - - /* If pointer to provisioning application data is NULL - * then provisioning manager is not running, therefore - * return with error to allow the global handler to act */ - if (!prov_ctx) { - RELEASE_LOCK(prov_ctx_lock); - return; - } - - /* If scan completed then update scan result */ - if (prov_ctx->prov_state == WIFI_PROV_STATE_STARTED && - event_base == WIFI_EVENT && - event_id == WIFI_EVENT_SCAN_DONE) { - update_wifi_scan_results(); - } - - /* Only handle events when credential is received and - * Wi-Fi STA is yet to complete trying the connection */ - if (prov_ctx->prov_state < WIFI_PROV_STATE_CRED_RECV) { - RELEASE_LOCK(prov_ctx_lock); - return; - } - - if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { - ESP_LOGI(TAG, "STA Start"); - /* Once configuration is received through protocomm, - * device is started as station. Once station starts, - * wait for connection to establish with configured - * host SSID and password */ - prov_ctx->wifi_state = WIFI_PROV_STA_CONNECTING; - } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { - ESP_LOGI(TAG, "STA Got IP"); - /* Station got IP. That means configuration is successful. */ - prov_ctx->wifi_state = WIFI_PROV_STA_CONNECTED; - prov_ctx->prov_state = WIFI_PROV_STATE_SUCCESS; - - /* If auto stop is enabled (default), schedule timer to - * stop provisioning after configured timeout. */ - if (!prov_ctx->mgr_info.capabilities.no_auto_stop) { - ESP_LOGD(TAG, "Starting %d sec timer for stop_prov_timer_cb()", - CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT); - esp_timer_start_once(prov_ctx->autostop_timer, CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT * 1000000U); - } - - /* Execute user registered callback handler */ - execute_event_cb(WIFI_PROV_CRED_SUCCESS, NULL, 0); - } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { - ESP_LOGE(TAG, "STA Disconnected"); - /* Station couldn't connect to configured host SSID */ - prov_ctx->wifi_state = WIFI_PROV_STA_DISCONNECTED; - - wifi_event_sta_disconnected_t* disconnected = (wifi_event_sta_disconnected_t*) event_data; - ESP_LOGE(TAG, "Disconnect reason : %d", disconnected->reason); - - /* Set code corresponding to the reason for disconnection */ - switch (disconnected->reason) { - case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: - case WIFI_REASON_AUTH_FAIL: - case WIFI_REASON_HANDSHAKE_TIMEOUT: - case WIFI_REASON_MIC_FAILURE: - ESP_LOGE(TAG, "STA Auth Error"); - prov_ctx->wifi_disconnect_reason = WIFI_PROV_STA_AUTH_ERROR; - break; - case WIFI_REASON_NO_AP_FOUND: - ESP_LOGE(TAG, "STA AP Not found"); - prov_ctx->wifi_disconnect_reason = WIFI_PROV_STA_AP_NOT_FOUND; - break; - default: - /* If none of the expected reasons, - * retry connecting to host SSID */ - prov_ctx->wifi_state = WIFI_PROV_STA_CONNECTING; - esp_wifi_connect(); - } - - /* In case of disconnection, update state of service and - * run the event handler with disconnection reason as data */ - if (prov_ctx->wifi_state == WIFI_PROV_STA_DISCONNECTED) { - prov_ctx->prov_state = WIFI_PROV_STATE_FAIL; - wifi_prov_sta_fail_reason_t reason = prov_ctx->wifi_disconnect_reason; - /* Execute user registered callback handler */ - execute_event_cb(WIFI_PROV_CRED_FAIL, (void *)&reason, sizeof(reason)); - } - } else if (event_base == WIFI_PROV_MGR_PVT_EVENT && event_id == WIFI_PROV_MGR_STOP) { - prov_stop_and_notify(true); - } - - RELEASE_LOCK(prov_ctx_lock); -} - -esp_err_t wifi_prov_mgr_wifi_scan_start(bool blocking, bool passive, - uint8_t group_channels, uint32_t period_ms) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - ACQUIRE_LOCK(prov_ctx_lock); - - if (!prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_ERR_INVALID_STATE; - } - - if (prov_ctx->scanning) { - ESP_LOGD(TAG, "Scan already running"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_OK; - } - - /* Clear sorted list for new entries */ - for (uint8_t i = 0; i < MAX_SCAN_RESULTS; i++) { - prov_ctx->ap_list_sorted[i] = NULL; - } - - if (passive) { - prov_ctx->scan_cfg.scan_type = WIFI_SCAN_TYPE_PASSIVE; -/* We do not recommend scan configuration modification in Wi-Fi and BT coexistence mode */ -#if !CONFIG_BT_ENABLED - prov_ctx->scan_cfg.scan_time.passive = period_ms; -#endif - } else { - prov_ctx->scan_cfg.scan_type = WIFI_SCAN_TYPE_ACTIVE; -/* We do not recommend scan configuration modification in Wi-Fi and BT coexistence mode */ -#if !CONFIG_BT_ENABLED - prov_ctx->scan_cfg.scan_time.active.min = period_ms; - prov_ctx->scan_cfg.scan_time.active.max = period_ms; -#endif - } - prov_ctx->channels_per_group = group_channels; - - if (prov_ctx->channels_per_group) { - ESP_LOGD(TAG, "Scan starting on channel 1..."); - prov_ctx->scan_cfg.channel = 1; - } else { - ESP_LOGD(TAG, "Scan starting..."); - prov_ctx->scan_cfg.channel = 0; - } - - if (esp_wifi_scan_start(&prov_ctx->scan_cfg, false) != ESP_OK) { - ESP_LOGE(TAG, "Failed to start scan"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - ESP_LOGD(TAG, "Scan started"); - prov_ctx->scanning = true; - prov_ctx->curr_channel = prov_ctx->scan_cfg.channel; - RELEASE_LOCK(prov_ctx_lock); - - /* If scan is to be non-blocking, return immediately */ - if (!blocking) { - return ESP_OK; - } - - /* Loop till scan is complete */ - bool scanning = true; - while (scanning) { - ACQUIRE_LOCK(prov_ctx_lock); - scanning = (prov_ctx && prov_ctx->scanning); - RELEASE_LOCK(prov_ctx_lock); - - /* 120ms delay is sufficient for Wi-Fi beacons to be sent */ - vTaskDelay(120 / portTICK_PERIOD_MS); - } - return ESP_OK; -} - -bool wifi_prov_mgr_wifi_scan_finished(void) -{ - bool scan_finished = true; - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return scan_finished; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (!prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - RELEASE_LOCK(prov_ctx_lock); - return scan_finished; - } - - scan_finished = !prov_ctx->scanning; - RELEASE_LOCK(prov_ctx_lock); - return scan_finished; -} - -uint16_t wifi_prov_mgr_wifi_scan_result_count(void) -{ - uint16_t rval = 0; - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return rval; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (!prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - RELEASE_LOCK(prov_ctx_lock); - return rval; - } - - while (rval < MAX_SCAN_RESULTS) { - if (!prov_ctx->ap_list_sorted[rval]) { - break; - } - rval++; - } - RELEASE_LOCK(prov_ctx_lock); - return rval; -} - -const wifi_ap_record_t *wifi_prov_mgr_wifi_scan_result(uint16_t index) -{ - const wifi_ap_record_t *rval = NULL; - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return rval; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (!prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - RELEASE_LOCK(prov_ctx_lock); - return rval; - } - - if (index < MAX_SCAN_RESULTS) { - rval = prov_ctx->ap_list_sorted[index]; - } - RELEASE_LOCK(prov_ctx_lock); - return rval; -} - -esp_err_t wifi_prov_mgr_get_wifi_state(wifi_prov_sta_state_t *state) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx == NULL || state == NULL) { - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - *state = prov_ctx->wifi_state; - RELEASE_LOCK(prov_ctx_lock); - return ESP_OK; -} - -esp_err_t wifi_prov_mgr_get_wifi_disconnect_reason(wifi_prov_sta_fail_reason_t *reason) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx == NULL || reason == NULL) { - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - if (prov_ctx->wifi_state != WIFI_PROV_STA_DISCONNECTED) { - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - *reason = prov_ctx->wifi_disconnect_reason; - RELEASE_LOCK(prov_ctx_lock); - return ESP_OK; -} - -static void debug_print_wifi_credentials(wifi_sta_config_t sta, const char* pretext) -{ - size_t passlen = strlen((const char*) sta.password); - ESP_LOGD(TAG, "%s Wi-Fi SSID : %.*s", pretext, - strnlen((const char *) sta.ssid, sizeof(sta.ssid)), (const char *) sta.ssid); - - if (passlen) { - /* Mask password partially if longer than 3, else mask it completely */ - memset(sta.password + (passlen > 3), '*', passlen - 2*(passlen > 3)); - ESP_LOGD(TAG, "%s Wi-Fi Password : %s", pretext, (const char *) sta.password); - } -} - -esp_err_t wifi_prov_mgr_is_provisioned(bool *provisioned) -{ - if (!provisioned) { - return ESP_ERR_INVALID_ARG; - } - - *provisioned = false; - - /* Get Wi-Fi Station configuration */ - wifi_config_t wifi_cfg; - if (esp_wifi_get_config(WIFI_IF_STA, &wifi_cfg) != ESP_OK) { - return ESP_FAIL; - } - - if (strlen((const char *) wifi_cfg.sta.ssid)) { - *provisioned = true; - debug_print_wifi_credentials(wifi_cfg.sta, "Found"); - } - return ESP_OK; -} - -static void wifi_connect_timer_cb(void *arg) -{ - if (esp_wifi_connect() != ESP_OK) { - ESP_LOGE(TAG, "Failed to connect Wi-Fi"); - } -} - -esp_err_t wifi_prov_mgr_configure_sta(wifi_config_t *wifi_cfg) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (!prov_ctx) { - ESP_LOGE(TAG, "Invalid state of Provisioning app"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - if (prov_ctx->prov_state >= WIFI_PROV_STATE_CRED_RECV) { - ESP_LOGE(TAG, "Wi-Fi credentials already received by provisioning app"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - debug_print_wifi_credentials(wifi_cfg->sta, "Received"); - - /* Configure Wi-Fi as both AP and/or Station */ - if (esp_wifi_set_mode(prov_ctx->mgr_config.scheme.wifi_mode) != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi mode"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - /* Don't release mutex yet as it is possible that right after - * esp_wifi_connect() is called below, the related Wi-Fi event - * happens even before manager state is updated in the next - * few lines causing the internal event handler to miss */ - - /* Set Wi-Fi storage again to flash to keep the newly - * provided credentials on NVS */ - if (esp_wifi_set_storage(WIFI_STORAGE_FLASH) != ESP_OK) { - ESP_LOGE(TAG, "Failed to set storage Wi-Fi"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - /* Configure Wi-Fi station with host credentials - * provided during provisioning */ - if (esp_wifi_set_config(WIFI_IF_STA, wifi_cfg) != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi configuration"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - /* Connect to AP after one second so that the response can - * be sent to the client successfully, before a channel change happens*/ - if (esp_timer_start_once(prov_ctx->wifi_connect_timer, 1000 * 1000U) != ESP_OK) { - ESP_LOGE(TAG, "Failed to start Wi-Fi connect timer"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_FAIL; - } - - /* Reset Wi-Fi station state for provisioning app */ - prov_ctx->wifi_state = WIFI_PROV_STA_CONNECTING; - prov_ctx->prov_state = WIFI_PROV_STATE_CRED_RECV; - /* Execute user registered callback handler */ - execute_event_cb(WIFI_PROV_CRED_RECV, (void *)&wifi_cfg->sta, sizeof(wifi_cfg->sta)); - RELEASE_LOCK(prov_ctx_lock); - - return ESP_OK; -} - -esp_err_t wifi_prov_mgr_init(wifi_prov_mgr_config_t config) -{ - if (!prov_ctx_lock) { - /* Create mutex if this is the first time init is being called. - * This is created only once and never deleted because if some - * other thread is trying to take this mutex while it is being - * deleted from another thread then the reference may become - * invalid and cause exception */ - prov_ctx_lock = xSemaphoreCreateMutex(); - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Failed to create mutex"); - return ESP_ERR_NO_MEM; - } - } - - void *fn_ptrs[] = { - config.scheme.prov_stop, - config.scheme.prov_start, - config.scheme.new_config, - config.scheme.delete_config, - config.scheme.set_config_service, - config.scheme.set_config_endpoint - }; - - /* All function pointers in the scheme structure must be non-null */ - for (size_t i = 0; i < sizeof(fn_ptrs)/sizeof(fn_ptrs[0]); i++) { - if (!fn_ptrs[i]) { - return ESP_ERR_INVALID_ARG; - } - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager already initialized"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_ERR_INVALID_STATE; - } - - /* Allocate memory for provisioning app data */ - prov_ctx = (struct wifi_prov_mgr_ctx *) calloc(1, sizeof(struct wifi_prov_mgr_ctx)); - if (!prov_ctx) { - ESP_LOGE(TAG, "Error allocating memory for singleton instance"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_ERR_NO_MEM; - } - - prov_ctx->mgr_config = config; - prov_ctx->prov_state = WIFI_PROV_STATE_IDLE; - prov_ctx->mgr_info.version = WIFI_PROV_MGR_VERSION; - - /* Allocate memory for provisioning scheme configuration */ - const wifi_prov_scheme_t *scheme = &prov_ctx->mgr_config.scheme; - esp_err_t ret = ESP_OK; - prov_ctx->prov_scheme_config = scheme->new_config(); - if (!prov_ctx->prov_scheme_config) { - ESP_LOGE(TAG, "failed to allocate provisioning scheme configuration"); - ret = ESP_ERR_NO_MEM; - goto exit; - } - - ret = scheme->set_config_endpoint(prov_ctx->prov_scheme_config, "prov-ctrl", 0xFF4F); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "failed to configure Wi-Fi state control endpoint"); - goto exit; - } - - ret = scheme->set_config_endpoint(prov_ctx->prov_scheme_config, "prov-scan", 0xFF50); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "failed to configure Wi-Fi scanning endpoint"); - goto exit; - } - - ret = scheme->set_config_endpoint(prov_ctx->prov_scheme_config, "prov-session", 0xFF51); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "failed to configure security endpoint"); - goto exit; - } - - ret = scheme->set_config_endpoint(prov_ctx->prov_scheme_config, "prov-config", 0xFF52); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "failed to configure Wi-Fi configuration endpoint"); - goto exit; - } - - ret = scheme->set_config_endpoint(prov_ctx->prov_scheme_config, "proto-ver", 0xFF53); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "failed to configure version endpoint"); - goto exit; - } - - /* Application specific custom endpoints will be assigned - * incremental UUIDs starting after this value */ - prov_ctx->endpoint_uuid_used = 0xFF53; - - /* This delay is so that the client side app is notified first - * and then the provisioning is stopped. Default is 1000ms. */ - prov_ctx->cleanup_delay = 1000; - -exit: - if (ret != ESP_OK) { - if (prov_ctx->prov_scheme_config) { - config.scheme.delete_config(prov_ctx->prov_scheme_config); - } - free(prov_ctx); - } else { - execute_event_cb(WIFI_PROV_INIT, NULL, 0); - } - RELEASE_LOCK(prov_ctx_lock); - return ret; -} - -void wifi_prov_mgr_wait(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return; - } - - while (1) { - ACQUIRE_LOCK(prov_ctx_lock); - if (prov_ctx && - prov_ctx->prov_state != WIFI_PROV_STATE_IDLE) { - RELEASE_LOCK(prov_ctx_lock); - vTaskDelay(1000 / portTICK_PERIOD_MS); - continue; - } - break; - } - RELEASE_LOCK(prov_ctx_lock); -} - -void wifi_prov_mgr_deinit(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return; - } - - ACQUIRE_LOCK(prov_ctx_lock); - - /* This will do one of these: - * 1) if found running, stop the provisioning service (returns true) - * 2) if service was already in the process of termination, this will - * wait till the service is stopped (returns false) - * 3) if service was not running, this will return immediately (returns false) - */ - bool service_was_running = wifi_prov_mgr_stop_service(1); - - /* If service was not running, its also possible that manager - * was not even initialized */ - if (!service_was_running && !prov_ctx) { - ESP_LOGD(TAG, "Manager already de-initialized"); - RELEASE_LOCK(prov_ctx_lock); - vSemaphoreDelete(prov_ctx_lock); - prov_ctx_lock = NULL; - return; - } - - if (prov_ctx->app_info_json) { - cJSON_Delete(prov_ctx->app_info_json); - } - - if (prov_ctx->prov_scheme_config) { - prov_ctx->mgr_config.scheme.delete_config(prov_ctx->prov_scheme_config); - } - - /* Extract the callbacks to be called post deinit */ - wifi_prov_cb_func_t app_cb = prov_ctx->mgr_config.app_event_handler.event_cb; - void *app_data = prov_ctx->mgr_config.app_event_handler.user_data; - - wifi_prov_cb_func_t scheme_cb = prov_ctx->mgr_config.scheme_event_handler.event_cb; - void *scheme_data = prov_ctx->mgr_config.scheme_event_handler.user_data; - - /* Free manager context */ - free(prov_ctx); - prov_ctx = NULL; - RELEASE_LOCK(prov_ctx_lock); - - /* If a running service was also stopped during de-initialization - * then WIFI_PROV_END event also needs to be emitted before deinit */ - if (service_was_running) { - ESP_LOGD(TAG, "execute_event_cb : %d", WIFI_PROV_END); - if (scheme_cb) { - scheme_cb(scheme_data, WIFI_PROV_END, NULL); - } - if (app_cb) { - app_cb(app_data, WIFI_PROV_END, NULL); - } - if (esp_event_post(WIFI_PROV_EVENT, WIFI_PROV_END, NULL, 0, portMAX_DELAY) != ESP_OK) { - ESP_LOGE(TAG, "Failed to post event WIFI_PROV_END"); - } - } - - ESP_LOGD(TAG, "execute_event_cb : %d", WIFI_PROV_DEINIT); - - /* Execute deinit event callbacks */ - if (scheme_cb) { - scheme_cb(scheme_data, WIFI_PROV_DEINIT, NULL); - } - if (app_cb) { - app_cb(app_data, WIFI_PROV_DEINIT, NULL); - } - if (esp_event_post(WIFI_PROV_EVENT, WIFI_PROV_DEINIT, NULL, 0, portMAX_DELAY) != ESP_OK) { - ESP_LOGE(TAG, "Failed to post event WIFI_PROV_DEINIT"); - } - - vSemaphoreDelete(prov_ctx_lock); - prov_ctx_lock = NULL; -} - -esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const void *wifi_prov_sec_params, - const char *service_name, const char *service_key) -{ - uint8_t restore_wifi_flag = 0; - - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - if (!prov_ctx) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_ERR_INVALID_STATE; - } - - if (prov_ctx->prov_state != WIFI_PROV_STATE_IDLE) { - ESP_LOGE(TAG, "Provisioning service already started"); - RELEASE_LOCK(prov_ctx_lock); - return ESP_ERR_INVALID_STATE; - } - - esp_err_t ret = ESP_OK; - /* Update state so that parallel call to wifi_prov_mgr_start_provisioning() - * or wifi_prov_mgr_stop_provisioning() or wifi_prov_mgr_deinit() from another - * thread doesn't interfere with this process */ - prov_ctx->prov_state = WIFI_PROV_STATE_STARTING; - - /* Start Wi-Fi in Station Mode. - * This is necessary for scanning to work */ - ret = esp_wifi_set_mode(WIFI_MODE_STA); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi mode to STA"); - goto err; - } - ret = esp_wifi_start(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to start Wi-Fi"); - goto err; - } - - /* Change Wi-Fi storage to RAM temporarily and erase any old - * credentials in RAM(i.e. without erasing the copy on NVS). Also - * call disconnect to make sure device doesn't remain connected - * to the AP whose credentials were present earlier */ - wifi_config_t wifi_cfg_empty, wifi_cfg_old; - memset(&wifi_cfg_empty, 0, sizeof(wifi_config_t)); - esp_wifi_get_config(WIFI_IF_STA, &wifi_cfg_old); - ret = esp_wifi_set_storage(WIFI_STORAGE_RAM); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi storage to RAM"); - goto err; - } - - /* WiFi storage needs to be restored before exiting this API */ - restore_wifi_flag |= WIFI_PROV_STORAGE_BIT; - /* Erase Wi-Fi credentials in RAM, when call disconnect and user code - * receive WIFI_EVENT_STA_DISCONNECTED and maybe call esp_wifi_connect, at - * this time Wi-Fi will have no configuration to connect */ - ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg_empty); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set empty Wi-Fi credentials"); - goto err; - } - /* WiFi settings needs to be restored if provisioning error before exiting this API */ - restore_wifi_flag |= WIFI_PROV_SETTING_BIT; - - ret = esp_wifi_disconnect(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to disconnect"); - goto err; - } - -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0 - /* Initialize app data */ - if (security == WIFI_PROV_SECURITY_0) { - prov_ctx->mgr_info.capabilities.no_sec = true; - } -#endif -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1 - if (security == WIFI_PROV_SECURITY_1) { - if (wifi_prov_sec_params) { - static protocomm_security1_params_t sec1_params; - // Generate internal copy of "pop", that shall be freed at the end - char *pop = strdup(wifi_prov_sec_params); - if (pop == NULL) { - ESP_LOGE(TAG, "Failed to allocate memory for pop"); - ret = ESP_ERR_NO_MEM; - goto err; - } - sec1_params.data = (const uint8_t *)pop; - sec1_params.len = strlen(pop); - prov_ctx->protocomm_sec_params = (const void *) &sec1_params; - } else { - prov_ctx->mgr_info.capabilities.no_pop = true; - } - } -#endif -#ifdef CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2 - if (security == WIFI_PROV_SECURITY_2) { - if (wifi_prov_sec_params) { - prov_ctx->protocomm_sec_params = wifi_prov_sec_params; - } - } -#endif - prov_ctx->security = security; - - - esp_timer_create_args_t wifi_connect_timer_conf = { - .callback = wifi_connect_timer_cb, - .arg = NULL, - .dispatch_method = ESP_TIMER_TASK, - .name = "wifi_prov_connect_tm" - }; - ret = esp_timer_create(&wifi_connect_timer_conf, &prov_ctx->wifi_connect_timer); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to create Wi-Fi connect timer"); - goto err; - } - - /* If auto stop on completion is enabled (default) create the stopping timer */ - if (!prov_ctx->mgr_info.capabilities.no_auto_stop) { - /* Create timer object as a member of app data */ - esp_timer_create_args_t autostop_timer_conf = { - .callback = stop_prov_timer_cb, - .arg = NULL, - .dispatch_method = ESP_TIMER_TASK, - .name = "wifi_prov_autostop_tm" - }; - ret = esp_timer_create(&autostop_timer_conf, &prov_ctx->autostop_timer); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to create auto-stop timer"); - esp_timer_delete(prov_ctx->wifi_connect_timer); - goto err; - } - } - - esp_timer_create_args_t cleanup_delay_timer = { - .callback = cleanup_delay_timer_cb, - .arg = NULL, - .dispatch_method = ESP_TIMER_TASK, - .name = "cleanup_delay_tm" - }; - ret = esp_timer_create(&cleanup_delay_timer, &prov_ctx->cleanup_delay_timer); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to create cleanup delay timer"); - esp_timer_delete(prov_ctx->wifi_connect_timer); - esp_timer_delete(prov_ctx->autostop_timer); - goto err; - } - - - /* System APIs for BLE / Wi-Fi will be called inside wifi_prov_mgr_start_service(), - * which may trigger system level events. Hence, releasing the context lock will - * ensure that wifi_prov_mgr_event_handler() doesn't block the global event_loop - * handler when system events need to be handled */ - RELEASE_LOCK(prov_ctx_lock); - - /* Start provisioning service */ - ret = wifi_prov_mgr_start_service(service_name, service_key); - if (ret != ESP_OK) { - esp_timer_delete(prov_ctx->autostop_timer); - esp_timer_delete(prov_ctx->wifi_connect_timer); - esp_timer_delete(prov_ctx->cleanup_delay_timer); - } - ACQUIRE_LOCK(prov_ctx_lock); - if (ret == ESP_OK) { - prov_ctx->prov_state = WIFI_PROV_STATE_STARTED; - /* Execute user registered callback handler */ - execute_event_cb(WIFI_PROV_START, NULL, 0); - goto exit; - } - -err: - prov_ctx->prov_state = WIFI_PROV_STATE_IDLE; - if (restore_wifi_flag & WIFI_PROV_SETTING_BIT) { - /* Restore current WiFi settings, since provisioning start has failed */ - esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg_old); - } -exit: - if (restore_wifi_flag & WIFI_PROV_STORAGE_BIT) { - /* Restore WiFi storage back to FLASH */ - esp_wifi_set_storage(WIFI_STORAGE_FLASH); - } - RELEASE_LOCK(prov_ctx_lock); - return ret; -} - -void wifi_prov_mgr_stop_provisioning(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return; - } - - ACQUIRE_LOCK(prov_ctx_lock); - - /* Launches task for stopping the provisioning service. This will do one of these: - * 1) start a task for stopping the provisioning service (returns true) - * 2) if service was already in the process of termination, this will - * wait till the service is stopped (returns false) - * 3) if service was not running, this will return immediately (returns false) - */ - wifi_prov_mgr_stop_service(0); - - RELEASE_LOCK(prov_ctx_lock); -} - -esp_err_t wifi_prov_mgr_reset_provisioning(void) -{ - esp_err_t ret = esp_wifi_restore(); - - if (ret != ESP_OK) { - ESP_LOGE(TAG, "esp_wifi_restore fail, ret is %d", ret); - ret = ESP_FAIL; - } - - return ret; -} - -esp_err_t wifi_prov_mgr_reset_sm_state_on_failure(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - - esp_err_t err = ESP_OK; - if (prov_ctx->prov_state != WIFI_PROV_STATE_FAIL) { - ESP_LOGE(TAG, "Trying reset when not in failure state. Current state: %d", prov_ctx->prov_state); - err = ESP_ERR_INVALID_STATE; - goto exit; - } - - wifi_config_t wifi_cfg = {0}; - - err = esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to set wifi config, 0x%x", err); - goto exit; - } - - prov_ctx->prov_state = WIFI_PROV_STATE_STARTED; - -exit: - RELEASE_LOCK(prov_ctx_lock); - return err; -} - -esp_err_t wifi_prov_mgr_reset_sm_state_for_reprovision(void) -{ - if (!prov_ctx_lock) { - ESP_LOGE(TAG, "Provisioning manager not initialized"); - return ESP_ERR_INVALID_STATE; - } - - ACQUIRE_LOCK(prov_ctx_lock); - - esp_err_t ret = ESP_OK; - wifi_config_t wifi_cfg_empty = {0}; - uint8_t restore_wifi_flag = 0; - - if (!prov_ctx->mgr_info.capabilities.no_auto_stop) { - ESP_LOGE(TAG, "Execute wifi_prov_mgr_disable_auto_stop() before calling this API"); - ret = ESP_ERR_INVALID_STATE; - goto exit; - } - - ret = esp_wifi_set_storage(WIFI_STORAGE_RAM); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi storage to RAM"); - goto exit; - } - restore_wifi_flag |= WIFI_PROV_STORAGE_BIT; - - ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg_empty); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to set empty Wi-Fi credentials, 0x%x", ret); - goto exit; - } - - ret = esp_wifi_disconnect(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to disconnect wifi, 0x%x", ret); - goto exit; - } - - prov_ctx->prov_state = WIFI_PROV_STATE_STARTED; - execute_event_cb(WIFI_PROV_START, NULL, 0); - -exit: - if (restore_wifi_flag & WIFI_PROV_STORAGE_BIT) { - esp_wifi_set_storage(WIFI_STORAGE_FLASH); - } - RELEASE_LOCK(prov_ctx_lock); - return ret; -} diff --git a/components/wifi_provisioning/src/scheme_ble.c b/components/wifi_provisioning/src/scheme_ble.c deleted file mode 100644 index 6b594f22c46a..000000000000 --- a/components/wifi_provisioning/src/scheme_ble.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#ifdef CONFIG_BT_CONTROLLER_ENABLED -#include "esp_bt.h" -#endif - -#include -#include - -#include "wifi_provisioning/scheme_ble.h" -#include "wifi_provisioning_priv.h" - -static const char *TAG = "wifi_prov_scheme_ble"; - -extern const wifi_prov_scheme_t wifi_prov_scheme_ble; - -static uint8_t *custom_service_uuid; - -static uint8_t *custom_manufacturer_data; -static size_t custom_manufacturer_data_len; - -static esp_err_t prov_start(protocomm_t *pc, void *config) -{ - if (!pc) { - ESP_LOGE(TAG, "Protocomm handle cannot be null"); - return ESP_ERR_INVALID_ARG; - } - - if (!config) { - ESP_LOGE(TAG, "Cannot start with null configuration"); - return ESP_ERR_INVALID_ARG; - } - - protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config; - -#if defined(CONFIG_WIFI_PROV_BLE_BONDING) - ble_config->ble_bonding = 1; -#endif - -#if defined(CONFIG_WIFI_PROV_BLE_SEC_CONN) || defined(CONFIG_BT_BLUEDROID_ENABLED) - ble_config->ble_sm_sc = 1; -#endif - -#if defined(CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION) - ble_config->ble_link_encryption = 1; -#endif - /* Start protocomm as BLE service */ - if (protocomm_ble_start(pc, ble_config) != ESP_OK) { - ESP_LOGE(TAG, "Failed to start protocomm BLE service"); - return ESP_FAIL; - } - return ESP_OK; -} - -esp_err_t wifi_prov_scheme_ble_set_service_uuid(uint8_t *uuid128) -{ - if (!uuid128) { - return ESP_ERR_INVALID_ARG; - } - custom_service_uuid = uuid128; - return ESP_OK; -} - -esp_err_t wifi_prov_scheme_ble_set_mfg_data(uint8_t *mfg_data, ssize_t mfg_data_len) -{ - if (!mfg_data || !mfg_data_len) { - return ESP_ERR_INVALID_ARG; - } - - custom_manufacturer_data = (uint8_t *) malloc(mfg_data_len); - if (custom_manufacturer_data == NULL) { - ESP_LOGE(TAG, "Error allocating memory for mfg_data"); - return ESP_ERR_NO_MEM; - } - - custom_manufacturer_data_len = mfg_data_len; - memcpy(custom_manufacturer_data, mfg_data, mfg_data_len); - return ESP_OK; -} - -static void *new_config(void) -{ - protocomm_ble_config_t *ble_config = calloc(1, sizeof(protocomm_ble_config_t)); - if (!ble_config) { - ESP_LOGE(TAG, "Error allocating memory for new configuration"); - return NULL; - } - - /* The default provisioning service UUID */ - const uint8_t service_uuid[16] = { - /* LSB <--------------------------------------- - * ---------------------------------------> MSB */ - 0x07, 0xed, 0x9b, 0x2d, 0x0f, 0x06, 0x7c, 0x87, - 0x9b, 0x43, 0x43, 0x6b, 0x4d, 0x24, 0x75, 0x17, - }; - - memcpy(ble_config->service_uuid, service_uuid, sizeof(ble_config->service_uuid)); - return ble_config; -} - -static void delete_config(void *config) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot delete null configuration"); - return; - } - - protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config; - for (unsigned int i = 0; i < ble_config->nu_lookup_count; i++) { - free((void *)ble_config->nu_lookup[i].name); - } - free(ble_config->nu_lookup); - free(ble_config); -} - -static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot set null configuration"); - return ESP_ERR_INVALID_ARG; - } - - if (!service_name) { - ESP_LOGE(TAG, "Service name cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - - protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config; - strlcpy(ble_config->device_name, service_name, sizeof(ble_config->device_name)); - - /* If a custom service UUID has been provided, override the default one */ - if (custom_service_uuid) { - memcpy(ble_config->service_uuid, custom_service_uuid, sizeof(ble_config->service_uuid)); - } - /* Set manufacturer data if it is provided by app */ - if (custom_manufacturer_data) { - size_t mfg_data_len = custom_manufacturer_data_len; - /* Manufacturer Data Length + 2 Byte header + BLE Device name + 2 Byte - * header <= 31 Bytes */ - if (mfg_data_len > (MAX_BLE_MANUFACTURER_DATA_LEN - sizeof(ble_config->device_name) - 2)) { - ESP_LOGE(TAG, "Manufacturer data length is more than the max allowed size; expect truncated mfg_data "); - /* XXX Does it even make any sense to set truncated mfg_data ? The - * only reason to not return failure from here is provisioning - * should continue as it is with error prints for mfg_data length */ - mfg_data_len = MAX_BLE_MANUFACTURER_DATA_LEN - sizeof(ble_config->device_name) - 2; - } - - ble_config->manufacturer_data = custom_manufacturer_data; - ble_config->manufacturer_data_len = mfg_data_len; - } else { - ble_config->manufacturer_data = NULL; - ble_config->manufacturer_data_len = 0; - } - - return ESP_OK; -} - -static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot set null configuration"); - return ESP_ERR_INVALID_ARG; - } - - if (!endpoint_name) { - ESP_LOGE(TAG, "EP name cannot be null"); - return ESP_ERR_INVALID_ARG; - } - - protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config; - - char *copy_ep_name = strdup(endpoint_name); - if (!copy_ep_name) { - ESP_LOGE(TAG, "Error allocating memory for EP name"); - return ESP_ERR_NO_MEM; - } - - protocomm_ble_name_uuid_t *lookup_table = ( - realloc(ble_config->nu_lookup, (ble_config->nu_lookup_count + 1) * sizeof(protocomm_ble_name_uuid_t))); - if (!lookup_table) { - ESP_LOGE(TAG, "Error allocating memory for EP-UUID lookup table"); - return ESP_ERR_NO_MEM; - } - - lookup_table[ble_config->nu_lookup_count].name = copy_ep_name; - lookup_table[ble_config->nu_lookup_count].uuid = uuid; - ble_config->nu_lookup = lookup_table; - ble_config->nu_lookup_count += 1; - return ESP_OK; -} - -/* Used when both BT and BLE are not needed by application */ -void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event_t event, void *event_data) -{ - switch (event) { - case WIFI_PROV_INIT: -#ifdef CONFIG_BT_CONTROLLER_ENABLED - esp_err_t err; - /* Release BT memory, as we need only BLE */ - err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT); - if (err != ESP_OK) { - ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err); - } else { - ESP_LOGI(TAG, "BT memory released"); - } -#endif - break; - - case WIFI_PROV_DEINIT: -#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV -#ifdef CONFIG_BT_CONTROLLER_ENABLED - /* Release memory used by BLE and Bluedroid host stack */ - err = esp_bt_mem_release(ESP_BT_MODE_BTDM); - if (err != ESP_OK) { - ESP_LOGE(TAG, "bt_mem_release of BTDM failed %d", err); - } else { - ESP_LOGI(TAG, "BTDM memory released"); - } -#endif -#endif - break; - - default: - break; - } -} - -/* Used when BT is not needed by application */ -void wifi_prov_scheme_ble_event_cb_free_bt(void *user_data, wifi_prov_cb_event_t event, void *event_data) -{ - switch (event) { - case WIFI_PROV_INIT: -#ifdef CONFIG_BT_CONTROLLER_ENABLED - esp_err_t err; - /* Release BT memory, as we need only BLE */ - err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT); - if (err != ESP_OK) { - ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err); - } else { - ESP_LOGI(TAG, "BT memory released"); - } -#endif - break; - - default: - break; - } -} - -/* Used when BLE is not needed by application */ -void wifi_prov_scheme_ble_event_cb_free_ble(void *user_data, wifi_prov_cb_event_t event, void *event_data) -{ - switch (event) { - case WIFI_PROV_DEINIT: -#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV -#ifdef CONFIG_BT_CONTROLLER_ENABLED - esp_err_t err; - /* Release memory used by BLE stack */ - err = esp_bt_mem_release(ESP_BT_MODE_BLE); - if (err != ESP_OK) { - ESP_LOGE(TAG, "bt_mem_release of BLE failed %d", err); - } else { - ESP_LOGI(TAG, "BLE memory released"); - } -#endif -#endif - break; - - default: - break; - } -} - -const wifi_prov_scheme_t wifi_prov_scheme_ble = { - .prov_start = prov_start, - .prov_stop = protocomm_ble_stop, - .new_config = new_config, - .delete_config = delete_config, - .set_config_service = set_config_service, - .set_config_endpoint = set_config_endpoint, - .wifi_mode = WIFI_MODE_STA -}; diff --git a/components/wifi_provisioning/src/scheme_console.c b/components/wifi_provisioning/src/scheme_console.c deleted file mode 100644 index 28732847acdd..000000000000 --- a/components/wifi_provisioning/src/scheme_console.c +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include - -#include -#include - -#include "wifi_provisioning/scheme_console.h" -#include "wifi_provisioning_priv.h" - -static const char *TAG = "wifi_prov_scheme_console"; - -extern const wifi_prov_scheme_t wifi_prov_scheme_console; - -static esp_err_t prov_start(protocomm_t *pc, void *config) -{ - if (!pc) { - ESP_LOGE(TAG, "Protocomm handle cannot be null"); - return ESP_ERR_INVALID_ARG; - } - - if (!config) { - ESP_LOGE(TAG, "Cannot start with null configuration"); - return ESP_ERR_INVALID_ARG; - } - - protocomm_console_config_t *console_config = (protocomm_console_config_t *) config; - - /* Start protocomm console */ - esp_err_t err = protocomm_console_start(pc, console_config); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to start protocomm HTTP server"); - return ESP_FAIL; - } - return ESP_OK; -} - -static void *new_config(void) -{ - protocomm_console_config_t *console_config = malloc(sizeof(protocomm_console_config_t)); - if (!console_config) { - ESP_LOGE(TAG, "Error allocating memory for new configuration"); - return NULL; - } - protocomm_console_config_t default_config = PROTOCOMM_CONSOLE_DEFAULT_CONFIG(); - memcpy(console_config, &default_config, sizeof(default_config)); - return console_config; -} - -static void delete_config(void *config) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot delete null configuration"); - return; - } - free(config); -} - -static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key) -{ - return ESP_OK; -} - -static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid) -{ - return ESP_OK; -} - -const wifi_prov_scheme_t wifi_prov_scheme_console = { - .prov_start = prov_start, - .prov_stop = protocomm_console_stop, - .new_config = new_config, - .delete_config = delete_config, - .set_config_service = set_config_service, - .set_config_endpoint = set_config_endpoint, - .wifi_mode = WIFI_MODE_STA -}; diff --git a/components/wifi_provisioning/src/scheme_softap.c b/components/wifi_provisioning/src/scheme_softap.c deleted file mode 100644 index 5c460c3280d0..000000000000 --- a/components/wifi_provisioning/src/scheme_softap.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include "sdkconfig.h" - -#include -#include -#include -#include - -#include -#include - -#include "wifi_provisioning/scheme_softap.h" -#include "wifi_provisioning_priv.h" - -typedef struct softap_config { - protocomm_httpd_config_t httpd_config; - char ssid[33]; - char password[65]; -} wifi_prov_softap_config_t; - -static const char *TAG = "wifi_prov_scheme_softap"; - -extern const wifi_prov_scheme_t wifi_prov_scheme_softap; -static void *scheme_softap_prov_httpd_handle; -static esp_err_t start_wifi_ap(const char *ssid, const char *pass) -{ - /* Build Wi-Fi configuration for AP mode */ - wifi_config_t wifi_config = { - .ap = { - .max_connection = 5, - }, - }; - - /* SSID can be a non NULL terminated string if `ap.ssid_len` is specified - * Hence, memcpy is used to support 32 bytes long SSID per 802.11 standard */ - const size_t ssid_len = strnlen(ssid, sizeof(wifi_config.ap.ssid)); - memcpy(wifi_config.ap.ssid, ssid, ssid_len); - wifi_config.ap.ssid_len = ssid_len; - - if (strlen(pass) == 0) { - memset(wifi_config.ap.password, 0, sizeof(wifi_config.ap.password)); - wifi_config.ap.authmode = WIFI_AUTH_OPEN; - } else { - strlcpy((char *) wifi_config.ap.password, pass, sizeof(wifi_config.ap.password)); - wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK; - } - - /* Run Wi-Fi in AP + STA mode with configuration built above */ - esp_err_t err = esp_wifi_set_mode(WIFI_MODE_APSTA); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi mode : %d", err); - return err; - } - err = esp_wifi_set_config(WIFI_IF_AP, &wifi_config); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to set Wi-Fi config : %d", err); - return err; - } - - return ESP_OK; -} - -static esp_err_t prov_start(protocomm_t *pc, void *config) -{ - if (!pc) { - ESP_LOGE(TAG, "Protocomm handle cannot be null"); - return ESP_ERR_INVALID_ARG; - } - - if (!config) { - ESP_LOGE(TAG, "Cannot start with null configuration"); - return ESP_ERR_INVALID_ARG; - } - - wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config; - - protocomm_httpd_config_t *httpd_config = &softap_config->httpd_config; - - if (scheme_softap_prov_httpd_handle) { - httpd_config->ext_handle_provided = true; - httpd_config->data.handle = scheme_softap_prov_httpd_handle; - } - - /* Start protocomm server on top of HTTP */ - esp_err_t err = protocomm_httpd_start(pc, httpd_config); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to start protocomm HTTP server"); - return err; - } - - /* Start Wi-Fi softAP with specified ssid and password */ - err = start_wifi_ap(softap_config->ssid, softap_config->password); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to start Wi-Fi AP"); - protocomm_httpd_stop(pc); - return err; - } - - return ESP_OK; -} - -static esp_err_t prov_stop(protocomm_t *pc) -{ - esp_err_t err = protocomm_httpd_stop(pc); - if (err != ESP_OK) { - ESP_LOGW(TAG, "Error occurred while stopping protocomm_httpd"); - } - - return err; -} - -static void *new_config(void) -{ - wifi_prov_softap_config_t *softap_config = calloc(1, sizeof(wifi_prov_softap_config_t)); - if (!softap_config) { - ESP_LOGE(TAG, "Error allocating memory for new configuration"); - return NULL; - } - protocomm_httpd_config_t default_config = { - .data = { - .config = PROTOCOMM_HTTPD_DEFAULT_CONFIG() - } - }; - softap_config->httpd_config = default_config; - return softap_config; -} - -static void delete_config(void *config) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot delete null configuration"); - return; - } - - wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config; - free(softap_config); -} - -static esp_err_t set_config_service(void *config, const char *service_name, const char *service_key) -{ - if (!config) { - ESP_LOGE(TAG, "Cannot set null configuration"); - return ESP_ERR_INVALID_ARG; - } - - if (!service_name) { - ESP_LOGE(TAG, "Service name cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - - wifi_prov_softap_config_t *softap_config = (wifi_prov_softap_config_t *) config; - if (service_key) { - const int service_key_len = strlen(service_key); - if (service_key_len < 8 || service_key_len >= sizeof(softap_config->password)) { - ESP_LOGE(TAG, "Incorrect passphrase length for softAP: %d (Expected: Min - 8, Max - 64)", service_key_len); - return ESP_ERR_INVALID_ARG; - } - strlcpy(softap_config->password, service_key, sizeof(softap_config->password)); - } - strlcpy(softap_config->ssid, service_name, sizeof(softap_config->ssid)); - return ESP_OK; -} - -static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, uint16_t uuid) -{ - return ESP_OK; -} - -void wifi_prov_scheme_softap_set_httpd_handle(void *handle) -{ - scheme_softap_prov_httpd_handle = handle; -} - -const wifi_prov_scheme_t wifi_prov_scheme_softap = { - .prov_start = prov_start, - .prov_stop = prov_stop, - .new_config = new_config, - .delete_config = delete_config, - .set_config_service = set_config_service, - .set_config_endpoint = set_config_endpoint, - .wifi_mode = WIFI_MODE_APSTA -}; diff --git a/components/wifi_provisioning/src/wifi_config.c b/components/wifi_provisioning/src/wifi_config.c deleted file mode 100644 index 1075a3180899..000000000000 --- a/components/wifi_provisioning/src/wifi_config.c +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright 2018 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include - -#include "wifi_constants.pb-c.h" -#include "wifi_config.pb-c.h" - -#include - -static const char* TAG = "WiFiProvConfig"; - -typedef struct wifi_prov_config_cmd { - int cmd_num; - esp_err_t (*command_handler)(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data); -} wifi_prov_config_cmd_t; - -static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data); - -static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data); - -static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data); - -static wifi_prov_config_cmd_t cmd_table[] = { - { - .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus, - .command_handler = cmd_get_status_handler - }, - { - .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig, - .command_handler = cmd_set_config_handler - }, - { - .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig, - .command_handler = cmd_apply_config_handler - } -}; - -static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data) -{ - ESP_LOGD(TAG, "Enter cmd_get_status_handler"); - wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespGetStatus *resp_payload = (RespGetStatus *) malloc(sizeof(RespGetStatus)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - resp_get_status__init(resp_payload); - - wifi_prov_config_get_data_t resp_data; - if (h->get_status_handler(&resp_data, &h->ctx) == ESP_OK) { - if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTING) { - resp_payload->sta_state = WIFI_STATION_STATE__Connecting; - resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED; - } else if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTED) { - resp_payload->sta_state = WIFI_STATION_STATE__Connected; - resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED; - WifiConnectedState *connected = (WifiConnectedState *)( - malloc(sizeof(WifiConnectedState))); - if (!connected) { - free(resp_payload); - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - resp_payload->connected = connected; - wifi_connected_state__init(connected); - - connected->ip4_addr = strdup(resp_data.conn_info.ip_addr); - if (connected->ip4_addr == NULL) { - free(resp_payload); - return ESP_ERR_NO_MEM; - } - - connected->bssid.len = sizeof(resp_data.conn_info.bssid); - connected->bssid.data = (uint8_t *) strndup(resp_data.conn_info.bssid, - sizeof(resp_data.conn_info.bssid)); - if (connected->bssid.data == NULL) { - free(connected->ip4_addr); - free(resp_payload); - return ESP_ERR_NO_MEM; - } - - connected->ssid.len = strlen(resp_data.conn_info.ssid); - connected->ssid.data = (uint8_t *) strdup(resp_data.conn_info.ssid); - if (connected->ssid.data == NULL) { - free(connected->bssid.data); - free(connected->ip4_addr); - free(resp_payload); - return ESP_ERR_NO_MEM; - } - - connected->channel = resp_data.conn_info.channel; - connected->auth_mode = resp_data.conn_info.auth_mode; - } else if (resp_data.wifi_state == WIFI_PROV_STA_DISCONNECTED) { - resp_payload->sta_state = WIFI_STATION_STATE__ConnectionFailed; - resp_payload->state_case = RESP_GET_STATUS__STATE_FAIL_REASON; - - if (resp_data.fail_reason == WIFI_PROV_STA_AUTH_ERROR) { - resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__AuthError; - } else if (resp_data.fail_reason == WIFI_PROV_STA_AP_NOT_FOUND) { - resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__NetworkNotFound; - } - } - resp_payload->status = STATUS__Success; - } - - resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS; - resp->resp_get_status = resp_payload; - return ESP_OK; -} - -static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data) -{ - ESP_LOGD(TAG, "Enter cmd_set_config_handler"); - wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespSetConfig *resp_payload = (RespSetConfig *) malloc(sizeof(RespSetConfig)); - if (resp_payload == NULL) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - resp_set_config__init(resp_payload); - - wifi_prov_config_set_data_t req_data; - memset(&req_data, 0, sizeof(req_data)); - - /* Check arguments provided in protobuf packet: - * - SSID / Passphrase string length must be within the standard limits - * - BSSID must either be NULL or have length equal to that imposed by the standard - * If any of these conditions are not satisfied, don't invoke the handler and - * send error status without closing connection */ - resp_payload->status = STATUS__InvalidArgument; - if (req->cmd_set_config->bssid.len != 0 && - req->cmd_set_config->bssid.len != sizeof(req_data.bssid)) { - ESP_LOGD(TAG, "Received invalid BSSID"); - } else if (req->cmd_set_config->ssid.len >= sizeof(req_data.ssid)) { - ESP_LOGD(TAG, "Received invalid SSID"); - } else if (req->cmd_set_config->passphrase.len >= sizeof(req_data.password)) { - ESP_LOGD(TAG, "Received invalid Passphrase"); - } else { - /* The received SSID and Passphrase are not NULL terminated so - * we memcpy over zeroed out arrays. Above length checks ensure - * that there is atleast 1 extra byte for null termination */ - memcpy(req_data.ssid, req->cmd_set_config->ssid.data, - req->cmd_set_config->ssid.len); - memcpy(req_data.password, req->cmd_set_config->passphrase.data, - req->cmd_set_config->passphrase.len); - memcpy(req_data.bssid, req->cmd_set_config->bssid.data, - req->cmd_set_config->bssid.len); - req_data.channel = req->cmd_set_config->channel; - if (h->set_config_handler(&req_data, &h->ctx) == ESP_OK) { - resp_payload->status = STATUS__Success; - } else { - resp_payload->status = STATUS__InternalError; - } - } - - resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG; - resp->resp_set_config = resp_payload; - return ESP_OK; -} - -static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data) -{ - ESP_LOGD(TAG, "Enter cmd_apply_config_handler"); - wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespApplyConfig *resp_payload = (RespApplyConfig *) malloc(sizeof(RespApplyConfig)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - - resp_apply_config__init(resp_payload); - - if (h->apply_config_handler(&h->ctx) == ESP_OK) { - resp_payload->status = STATUS__Success; - } else { - resp_payload->status = STATUS__InternalError; - } - - resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG; - resp->resp_apply_config = resp_payload; - return ESP_OK; -} - -static int lookup_cmd_handler(int cmd_id) -{ - for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_prov_config_cmd_t); i++) { - if (cmd_table[i].cmd_num == cmd_id) { - return i; - } - } - - return -1; -} -static void wifi_prov_config_command_cleanup(WiFiConfigPayload *resp, void *priv_data) -{ - if (!resp) { - return; - } - - switch (resp->msg) { - case WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus: - { - switch (resp->resp_get_status->sta_state) { - case WIFI_STATION_STATE__Connecting: - break; - case WIFI_STATION_STATE__Connected: - if (resp->resp_get_status->connected) { - if (resp->resp_get_status->connected->ip4_addr) { - free(resp->resp_get_status->connected->ip4_addr); - } - if (resp->resp_get_status->connected->bssid.data) { - free(resp->resp_get_status->connected->bssid.data); - } - if (resp->resp_get_status->connected->ssid.data) { - free(resp->resp_get_status->connected->ssid.data); - } - free(resp->resp_get_status->connected); - } - break; - case WIFI_STATION_STATE__ConnectionFailed: - break; - default: - break; - } - free(resp->resp_get_status); - } - break; - case WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig: - { - free(resp->resp_set_config); - } - break; - case WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig: - { - free(resp->resp_apply_config); - } - break; - default: - ESP_LOGE(TAG, "Unsupported response type in cleanup_handler"); - break; - } - return; -} - -static esp_err_t wifi_prov_config_command_dispatcher(WiFiConfigPayload *req, - WiFiConfigPayload *resp, void *priv_data) -{ - esp_err_t ret; - - ESP_LOGD(TAG, "In wifi_prov_config_command_dispatcher Cmd=%d", req->msg); - - int cmd_index = lookup_cmd_handler(req->msg); - if (cmd_index < 0) { - ESP_LOGE(TAG, "Invalid command handler lookup"); - return ESP_FAIL; - } - - ret = cmd_table[cmd_index].command_handler(req, resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Error executing command handler"); - return ESP_FAIL; - } - - return ESP_OK; -} - -esp_err_t wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data) -{ - WiFiConfigPayload *req; - WiFiConfigPayload resp; - esp_err_t ret; - - req = wi_fi_config_payload__unpack(NULL, inlen, inbuf); - if (!req) { - ESP_LOGE(TAG, "Unable to unpack config data"); - return ESP_ERR_INVALID_ARG; - } - - wi_fi_config_payload__init(&resp); - ret = wifi_prov_config_command_dispatcher(req, &resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Proto command dispatcher error %d", ret); - return ESP_FAIL; - } - - resp.msg = req->msg + 1; /* Response is request + 1 */ - wi_fi_config_payload__free_unpacked(req, NULL); - - *outlen = wi_fi_config_payload__get_packed_size(&resp); - if (*outlen <= 0) { - ESP_LOGE(TAG, "Invalid encoding for response"); - return ESP_FAIL; - } - - *outbuf = (uint8_t *) malloc(*outlen); - if (!*outbuf) { - ESP_LOGE(TAG, "System out of memory"); - return ESP_ERR_NO_MEM; - } - wi_fi_config_payload__pack(&resp, *outbuf); - wifi_prov_config_command_cleanup(&resp, priv_data); - - return ESP_OK; -} diff --git a/components/wifi_provisioning/src/wifi_ctrl.c b/components/wifi_provisioning/src/wifi_ctrl.c deleted file mode 100644 index 2cf496b27bda..000000000000 --- a/components/wifi_provisioning/src/wifi_ctrl.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -#include "wifi_ctrl.pb-c.h" - -#include "wifi_ctrl.h" - -static const char *TAG = "proto_wifi_ctrl"; - -typedef struct wifi_ctrl_cmd { - int cmd_id; - esp_err_t (*command_handler)(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, void *priv_data); -} wifi_ctrl_cmd_t; - -static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, - void *priv_data); - -static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, - void *priv_data); - -static wifi_ctrl_cmd_t cmd_table[] = { - { - .cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset, - .command_handler = cmd_ctrl_reset_handler - }, - { - .cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov, - .command_handler = cmd_ctrl_reprov_handler - }, -}; - -static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, void *priv_data) -{ - wifi_ctrl_handlers_t *h = (wifi_ctrl_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespCtrlReset *resp_payload = (RespCtrlReset *) malloc(sizeof(RespCtrlReset)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - - resp_ctrl_reset__init(resp_payload); - resp->status = (h->ctrl_reset() == ESP_OK ? - STATUS__Success : STATUS__InternalError); - resp->payload_case = WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET; - resp->resp_ctrl_reset = resp_payload; - return ESP_OK; -} - -static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, void *priv_data) -{ - wifi_ctrl_handlers_t *h = (wifi_ctrl_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespCtrlReprov *resp_payload = (RespCtrlReprov *) malloc(sizeof(RespCtrlReprov)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - - resp_ctrl_reprov__init(resp_payload); - resp->status = (h->ctrl_reprov() == ESP_OK ? - STATUS__Success : STATUS__InternalError); - resp->payload_case = WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV; - resp->resp_ctrl_reprov = resp_payload; - return ESP_OK; -} - -static int lookup_cmd_handler(int cmd_id) -{ - for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_ctrl_cmd_t); i++) { - if (cmd_table[i].cmd_id == cmd_id) { - return i; - } - } - - return -1; -} - -static void wifi_ctrl_cmd_cleanup(WiFiCtrlPayload *resp, void *priv_data) -{ - switch (resp->msg) { - case WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset: - { - free(resp->resp_ctrl_reset); - } - break; - case WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov: - { - free(resp->resp_ctrl_reprov); - } - break; - default: - ESP_LOGE(TAG, "Unsupported response type in cleanup_handler"); - break; - } - return; -} - -static esp_err_t wifi_ctrl_cmd_dispatcher(WiFiCtrlPayload *req, - WiFiCtrlPayload *resp, void *priv_data) -{ - esp_err_t ret; - - ESP_LOGD(TAG, "In wifi_ctrl_cmd_dispatcher Cmd=%d", req->msg); - - int cmd_index = lookup_cmd_handler(req->msg); - if (cmd_index < 0) { - ESP_LOGE(TAG, "Failed to find cmd with ID = %d in the command table", req->msg); - return ESP_FAIL; - } - - ret = cmd_table[cmd_index].command_handler(req, resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Error executing command handler"); - } - - return ret; -} - -esp_err_t wifi_ctrl_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data) -{ - WiFiCtrlPayload *req; - WiFiCtrlPayload resp; - esp_err_t ret = ESP_OK; - - req = wi_fi_ctrl_payload__unpack(NULL, inlen, inbuf); - if (!req) { - ESP_LOGE(TAG, "Unable to unpack ctrl message"); - return ESP_ERR_INVALID_ARG; - } - - wi_fi_ctrl_payload__init(&resp); - ret = wifi_ctrl_cmd_dispatcher(req, &resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Command dispatcher error %02X", ret); - ret = ESP_FAIL; - goto exit; - } - - resp.msg = req->msg + 1; /* Response is request + 1 */ - *outlen = wi_fi_ctrl_payload__get_packed_size(&resp); - if (*outlen <= 0) { - ESP_LOGE(TAG, "Invalid encoding for response"); - ret = ESP_FAIL; - goto exit; - } - - *outbuf = (uint8_t *) malloc(*outlen); - if (!*outbuf) { - ESP_LOGE(TAG, "Failed to allocate memory for the output buffer"); - ret = ESP_ERR_NO_MEM; - goto exit; - } - wi_fi_ctrl_payload__pack(&resp, *outbuf); - ESP_LOGD(TAG, "Response packet size : %d", *outlen); - exit: - - wi_fi_ctrl_payload__free_unpacked(req, NULL); - wifi_ctrl_cmd_cleanup(&resp, priv_data); - return ret; -} diff --git a/components/wifi_provisioning/src/wifi_ctrl.h b/components/wifi_provisioning/src/wifi_ctrl.h deleted file mode 100644 index dd6fc5062423..000000000000 --- a/components/wifi_provisioning/src/wifi_ctrl.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef _PROV_WIFI_CTRL_H_ -#define _PROV_WIFI_CTRL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Internal handlers for receiving and responding to protocomm - * requests from client - * - * This is to be passed as priv_data for protocomm request handler - * (refer to `wifi_ctrl_handler()`) when calling `protocomm_add_endpoint()`. - */ -typedef struct wifi_ctrl_handlers { - /** - * Handler function called when ctrl reset command is received - */ - esp_err_t (*ctrl_reset)(void); - - /** - * Handler function called when ctrl reprov command is received - */ - esp_err_t (*ctrl_reprov)(void); - -} wifi_ctrl_handlers_t; - -/** - * @brief Handler for sending on demand Wi-Fi ctrl results - * - * This is to be registered as the `prov-ctrl` endpoint handler - * (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()` - */ -esp_err_t wifi_ctrl_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/wifi_provisioning/src/wifi_provisioning_priv.h b/components/wifi_provisioning/src/wifi_provisioning_priv.h deleted file mode 100644 index a58d2589d922..000000000000 --- a/components/wifi_provisioning/src/wifi_provisioning_priv.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include - -#include "wifi_provisioning/manager.h" -#include "wifi_provisioning/wifi_config.h" -#include "wifi_provisioning/wifi_scan.h" -#include "wifi_ctrl.h" - -/** - * @brief Notify manager that provisioning is done - * - * Stops the provisioning. This is called by the get_status_handler() - * when the status is connected. This has no effect if main application - * has disabled auto stop on completion by calling - * wifi_prov_mgr_disable_auto_stop() - * - * @return - * - ESP_OK : Provisioning will be stopped - * - ESP_FAIL : Failed to stop provisioning - */ -esp_err_t wifi_prov_mgr_done(void); - -/** - * @brief Start Wi-Fi AP Scan - * - * @param[in] blocking Set true to return only after scanning is complete - * @param[in] passive Set true to perform passive scan instead of default active scan - * @param[in] group_channels Number of channels to scan in one go - * (set to 0 for scanning all channels in one go) - * @param[in] period_ms Scan time (in milli-seconds) on each channel - * - * @return - * - ESP_OK : Successfully started Wi-Fi scanning - * - ESP_FAIL : Provisioning app not running - */ -esp_err_t wifi_prov_mgr_wifi_scan_start(bool blocking, bool passive, - uint8_t group_channels, - uint32_t period_ms); - -/** - * @brief Use to query the state of Wi-Fi scan - * - * @return - * - true : Scan finished - * - false : Scan running - */ -bool wifi_prov_mgr_wifi_scan_finished(void); - -/** - * @brief Get the count of results in the scan list - * - * @return - * - count : Number of Wi-Fi Access Points detected while scanning - */ -uint16_t wifi_prov_mgr_wifi_scan_result_count(void); - -/** - * @brief Get AP record for a particular index in the scan list result - * - * @param[out] index Index of the result to fetch - * - * @return - * - result : Pointer to Access Point record - */ -const wifi_ap_record_t *wifi_prov_mgr_wifi_scan_result(uint16_t index); - -/** - * @brief Get protocomm handlers for wifi_config provisioning endpoint - * - * @param[out] ptr pointer to structure to be set - * - * @return - * - ESP_OK : success - * - ESP_ERR_INVALID_ARG : null argument - */ -esp_err_t get_wifi_prov_handlers(wifi_prov_config_handlers_t *ptr); - -/** - * @brief Get protocomm handlers for wifi_scan provisioning endpoint - * - * @param[out] ptr pointer to structure to be set - * - * @return - * - ESP_OK : success - * - ESP_ERR_INVALID_ARG : null argument - */ -esp_err_t get_wifi_scan_handlers(wifi_prov_scan_handlers_t *ptr); - -/** - * @brief Get protocomm handlers for wifi_ctrl provisioning endpoint - * - * @param[in] ptr pointer to structure to be set - * - * @return - * - ESP_OK : success - * - ESP_ERR_INVALID_ARG : null argument - */ -esp_err_t get_wifi_ctrl_handlers(wifi_ctrl_handlers_t *ptr); diff --git a/components/wifi_provisioning/src/wifi_scan.c b/components/wifi_provisioning/src/wifi_scan.c deleted file mode 100644 index bfc0596f5215..000000000000 --- a/components/wifi_provisioning/src/wifi_scan.c +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include - -#include "wifi_scan.pb-c.h" - -#include - -static const char *TAG = "proto_wifi_scan"; - -typedef struct wifi_prov_scan_cmd { - int cmd_num; - esp_err_t (*command_handler)(WiFiScanPayload *req, - WiFiScanPayload *resp, void *priv_data); -} wifi_prov_scan_cmd_t; - -static esp_err_t cmd_scan_start_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, - void *priv_data); - -static esp_err_t cmd_scan_status_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, - void *priv_data); - -static esp_err_t cmd_scan_result_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, - void *priv_data); - -static wifi_prov_scan_cmd_t cmd_table[] = { - { - .cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanStart, - .command_handler = cmd_scan_start_handler - }, - { - .cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanStatus, - .command_handler = cmd_scan_status_handler - }, - { - .cmd_num = WI_FI_SCAN_MSG_TYPE__TypeCmdScanResult, - .command_handler = cmd_scan_result_handler - } -}; - -static esp_err_t cmd_scan_start_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, void *priv_data) -{ - wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespScanStart *resp_payload = (RespScanStart *) malloc(sizeof(RespScanStart)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - - resp_scan_start__init(resp_payload); - resp->status = (h->scan_start(req->cmd_scan_start->blocking, - req->cmd_scan_start->passive, - req->cmd_scan_start->group_channels, - req->cmd_scan_start->period_ms, - &h->ctx) == ESP_OK ? - STATUS__Success : STATUS__InternalError); - resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_START; - resp->resp_scan_start = resp_payload; - return ESP_OK; -} - -static esp_err_t cmd_scan_status_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, void *priv_data) -{ - bool scan_finished = false; - uint16_t result_count = 0; - - wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespScanStatus *resp_payload = (RespScanStatus *) malloc(sizeof(RespScanStatus)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - - resp_scan_status__init(resp_payload); - resp->status = (h->scan_status(&scan_finished, &result_count, &h->ctx) == ESP_OK ? - STATUS__Success : STATUS__InternalError); - resp_payload->scan_finished = scan_finished; - resp_payload->result_count = result_count; - resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_STATUS; - resp->resp_scan_status = resp_payload; - return ESP_OK; -} - -static esp_err_t cmd_scan_result_handler(WiFiScanPayload *req, - WiFiScanPayload *resp, void *priv_data) -{ - esp_err_t err; - wifi_prov_scan_result_t scan_result = {{0}, {0}, 0, 0, 0}; - WiFiScanResult **results = NULL; - wifi_prov_scan_handlers_t *h = (wifi_prov_scan_handlers_t *) priv_data; - if (!h) { - ESP_LOGE(TAG, "Command invoked without handlers"); - return ESP_ERR_INVALID_STATE; - } - - RespScanResult *resp_payload = (RespScanResult *) malloc(sizeof(RespScanResult)); - if (!resp_payload) { - ESP_LOGE(TAG, "Error allocating memory"); - return ESP_ERR_NO_MEM; - } - resp_scan_result__init(resp_payload); - - resp->status = STATUS__Success; - resp->payload_case = WI_FI_SCAN_PAYLOAD__PAYLOAD_RESP_SCAN_RESULT; - resp->resp_scan_result = resp_payload; - /* Allocate memory only if there are non-zero scan results */ - if (req->cmd_scan_result->count) { - results = (WiFiScanResult **) calloc(req->cmd_scan_result->count, - sizeof(WiFiScanResult *)); - if (!results) { - ESP_LOGE(TAG, "Failed to allocate memory for results array"); - return ESP_ERR_NO_MEM; - } - } - resp_payload->entries = results; - resp_payload->n_entries = req->cmd_scan_result->count; - - /* If req->cmd_scan_result->count is 0, the below loop will - * be skipped. - */ - for (uint16_t i = 0; i < req->cmd_scan_result->count; i++) { - err = h->scan_result(i + req->cmd_scan_result->start_index, - &scan_result, &h->ctx); - if (err != ESP_OK) { - resp->status = STATUS__InternalError; - break; - } - - results[i] = (WiFiScanResult *) malloc(sizeof(WiFiScanResult)); - if (!results[i]) { - ESP_LOGE(TAG, "Failed to allocate memory for result entry"); - return ESP_ERR_NO_MEM; - } - wi_fi_scan_result__init(results[i]); - - results[i]->ssid.len = strnlen(scan_result.ssid, 32); - results[i]->ssid.data = (uint8_t *) strndup(scan_result.ssid, 32); - if (!results[i]->ssid.data) { - ESP_LOGE(TAG, "Failed to allocate memory for scan result entry SSID"); - return ESP_ERR_NO_MEM; - } - - results[i]->channel = scan_result.channel; - results[i]->rssi = scan_result.rssi; - results[i]->auth = scan_result.auth; - - results[i]->bssid.len = sizeof(scan_result.bssid); - results[i]->bssid.data = malloc(results[i]->bssid.len); - if (!results[i]->bssid.data) { - ESP_LOGE(TAG, "Failed to allocate memory for scan result entry BSSID"); - return ESP_ERR_NO_MEM; - } - memcpy(results[i]->bssid.data, scan_result.bssid, results[i]->bssid.len); - } - return ESP_OK; -} - - -static int lookup_cmd_handler(int cmd_id) -{ - for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_prov_scan_cmd_t); i++) { - if (cmd_table[i].cmd_num == cmd_id) { - return i; - } - } - - return -1; -} - -static void wifi_prov_scan_cmd_cleanup(WiFiScanPayload *resp, void *priv_data) -{ - switch (resp->msg) { - case WI_FI_SCAN_MSG_TYPE__TypeRespScanStart: - { - free(resp->resp_scan_start); - } - break; - case WI_FI_SCAN_MSG_TYPE__TypeRespScanStatus: - { - free(resp->resp_scan_status); - } - break; - case WI_FI_SCAN_MSG_TYPE__TypeRespScanResult: - { - if (!resp->resp_scan_result) return; - if (resp->resp_scan_result->entries) { - for (uint16_t i = 0; i < resp->resp_scan_result->n_entries; i++) { - if (!resp->resp_scan_result->entries[i]) continue; - free(resp->resp_scan_result->entries[i]->ssid.data); - free(resp->resp_scan_result->entries[i]->bssid.data); - free(resp->resp_scan_result->entries[i]); - } - free(resp->resp_scan_result->entries); - } - free(resp->resp_scan_result); - } - break; - default: - ESP_LOGE(TAG, "Unsupported response type in cleanup_handler"); - break; - } - return; -} - -static esp_err_t wifi_prov_scan_cmd_dispatcher(WiFiScanPayload *req, - WiFiScanPayload *resp, void *priv_data) -{ - esp_err_t ret; - - ESP_LOGD(TAG, "In wifi_prov_scan_cmd_dispatcher Cmd=%d", req->msg); - - int cmd_index = lookup_cmd_handler(req->msg); - if (cmd_index < 0) { - ESP_LOGE(TAG, "Invalid command handler lookup"); - return ESP_FAIL; - } - - ret = cmd_table[cmd_index].command_handler(req, resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Error executing command handler"); - return ESP_FAIL; - } - - return ESP_OK; -} - -esp_err_t wifi_prov_scan_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen, - uint8_t **outbuf, ssize_t *outlen, void *priv_data) -{ - WiFiScanPayload *req; - WiFiScanPayload resp; - esp_err_t ret = ESP_OK; - - req = wi_fi_scan_payload__unpack(NULL, inlen, inbuf); - if (!req) { - ESP_LOGE(TAG, "Unable to unpack scan message"); - return ESP_ERR_INVALID_ARG; - } - - wi_fi_scan_payload__init(&resp); - ret = wifi_prov_scan_cmd_dispatcher(req, &resp, priv_data); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Command dispatcher error %d", ret); - ret = ESP_FAIL; - goto exit; - } - - resp.msg = req->msg + 1; /* Response is request + 1 */ - *outlen = wi_fi_scan_payload__get_packed_size(&resp); - if (*outlen <= 0) { - ESP_LOGE(TAG, "Invalid encoding for response"); - ret = ESP_FAIL; - goto exit; - } - - *outbuf = (uint8_t *) malloc(*outlen); - if (!*outbuf) { - ESP_LOGE(TAG, "System out of memory"); - ret = ESP_ERR_NO_MEM; - goto exit; - } - wi_fi_scan_payload__pack(&resp, *outbuf); - ESP_LOGD(TAG, "Response packet size : %d", *outlen); - exit: - - wi_fi_scan_payload__free_unpacked(req, NULL); - wifi_prov_scan_cmd_cleanup(&resp, priv_data); - return ret; -} diff --git a/install.sh b/install.sh index 868665c527d5..46badce82a64 100755 --- a/install.sh +++ b/install.sh @@ -26,12 +26,12 @@ done TARGETS=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "$@") echo "Installing ESP-IDF tools" -"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install --targets="${TARGETS}" +"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" --non-interactive install --targets="${TARGETS}" FEATURES=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract features "$@") echo "Installing Python environment and packages" -"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install-python-env --features="${FEATURES}" +"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" --non-interactive install-python-env --features="${FEATURES}" echo "All done! You can now run:" echo "" diff --git a/package.json b/package.json new file mode 100644 index 000000000000..946395f991f7 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "framework-espidf", + "version": "3.50202", + "description": "Espressif IoT Development Framework. Tasmota development framework for ESP32 chip", + "keywords": [ + "framework", + "esp32", + "esp32s2", + "esp32s3", + "esp32c2", + "esp32c3", + "esp32c6", + "esp32h2", + "esp32p4", + "espressif" + ], + "homepage": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/tasmota/esp-idf" + } +} diff --git a/tools/ldgen/ldgen/entity.py b/tools/ldgen/ldgen/entity.py index aecdcab91b97..659898f37008 100644 --- a/tools/ldgen/ldgen/entity.py +++ b/tools/ldgen/ldgen/entity.py @@ -181,7 +181,8 @@ def get_objects(self, archive): def _match_obj(self, archive, obj): objs = self.get_objects(archive) - match_objs = (fnmatch.filter(objs, obj + '.o') + match_objs = (fnmatch.filter(objs, obj + '.*.o') + + fnmatch.filter(objs, obj + '.o') + fnmatch.filter(objs, obj + '.*.obj') + fnmatch.filter(objs, obj + '.obj')) diff --git a/version.txt b/version.txt new file mode 100644 index 000000000000..f1316a91e88a --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +5.2.2.240629