diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be34442220..2ba3e5f845 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,3 +31,23 @@ deploy_master_github: - git remote remove github &>/dev/null || true - git remote add github git@github.com:espressif/esp-hosted.git - git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" + +.deploy_force_master_github: + stage: deploy + image: $CI_DOCKER_REGISTRY/esp32-ci-env + tags: + - deploy + when: manual + only: + - master + script: + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo -n $GH_KEY > ~/.ssh/id_rsa_base64 + - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + - git remote remove github &>/dev/null || true + - git remote add github git@github.com:espressif/esp-hosted.git + - git push -f github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" + diff --git a/README.md b/README.md index bb741f0c50..525e732834 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ ESP-Hosted solution provides following WLAN and BT/BLE features to host: - WLAN Station - WLAN Soft AP - BT/BLE Features: - - v4.2 BR/EDR and BLE + - ESP32 supports v4.2 BR/EDR and BLE + - ESP32-C3 supports v5.0 BLE ### 1.2 Supported ESP boards @@ -68,32 +69,60 @@ ESP-Hosted uses SDIO or SPI bus for interfacing ESP boards and host platform. No ##### 1.5.1 Linux Host Below table explains which feature is supported on which transport interface for Linux based host. -| ESP device | Transport Interface | WLAN support | Virtual serial interface | BT/BLE support | +| ESP device | Transport Interface | WLAN support | Virtual serial interface | Bluetooth support | |:---------:|:-------:|:---------:|:--------:|:--------:| -| ESP32 | SDIO | Yes | Yes | Yes | -| ESP32 | SPI | Yes | Yes | Yes | -| ESP32 | UART | No | No | Yes | +| ESP32 | SDIO | Yes | Yes | BT/BLE 4.2 | +| ESP32 | SPI | Yes | Yes | BT/BLE 4.2 | +| ESP32 | UART | No | No | BT/BLE 4.2 | | ESP32-S2 | SDIO | NA | NA | NA | | ESP32-S2 | SPI | Yes | Yes | NA | | ESP32-S2 | UART | No | No | NA | | ESP32-C3 | SDIO | NA | NA | NA | -| ESP32-C3 | SPI | Yes | Yes | No | -| ESP32-C3 | UART | No | No | No | +| ESP32-C3 | SPI | Yes | Yes | BLE 5.0 | +| ESP32-C3 | UART | No | No | BLE 5.0 | + +Note: +* BT stands for Bluetooth BR/EDR and BLE stands for Bluetooth Low Energy specifications. +* ESP-Hosted related BR/EDR 4.2 and BLE 4.2 functionalities are tested with bluez 5.43+. Whereas BLE 5.0 functionalities are tested with bluez 5.45+. +* We suggest latest stable bluez version to be used. Any other bluetooth stack instead of bluez also could be used. +* bluez 5.45 on-wards BLE 5.0 HCI commands are supported. +* BLE 5.0 has backward compability of BLE 4.2. ##### 1.5.2 MCU Host Below table explains which feature is supported on which transport interface for MCU based host. -| ESP device | Transport Interface | WLAN support | Virtual serial interface | BT/BLE support | +| ESP device | Transport Interface | WLAN support | Virtual serial interface | Bluetooth support | |:------------:|:-------:|:---------:|:--------:|:--------:| | ESP32 | SDIO | No | No | No | -| ESP32 | SPI | Yes | Yes | HCI interface can be implemented over virtual serial interface | -| ESP32 | UART | No | No | No | +| ESP32 | SPI | Yes | Yes | BT/BLE 4.2\* | +| ESP32 | UART | No | No | BT/BLE 4.2\*\* | | ESP32-S2 | SDIO | NA | NA | NA | | ESP32-S2 | SPI | Yes | Yes | NA | | ESP32-S2 | UART | No | No | NA | | ESP32-C3 | SDIO | NA | NA | NA | -| ESP32-C3 | SPI | Yes | Yes | No | -| ESP32-C3 | UART | No | No | No | +| ESP32-C3 | SPI | Yes | Yes | BLE 5.0\* | +| ESP32-C3 | UART | No | No | BLE 5.0\*\* | + +Note: BT stands for Bluetooth BR/EDR and BLE stands for Bluetooth Low Energy specifications. + +\* BT/BLE over SPI +> BT/BLE support over SPI is not readily available. In order to implement it, one needs to: +> +> Port BT/BLE stack to MCU, \ +> Add a new virtual serial interface using the serial interface API's provided in host driver of ESP-Hosted solution. +> HCI implementation in Linux Driver `host/linux/host_driver/esp32` could be used as reference. Search keyword: `ESP_HCI_IF` +> Register this serial interface with BT/BLE stack as a HCI interface. + +\*\* BT/BLE over UART +> BT/BLE support over UART is not readily available. In order to implement this, one needs to: +> +> Port BT/BLE stack to MCU, \ +> Register the UART serial interface as a HCI interface with BT/BLE stack +> With the help of this UART interface, BT/BLE stack can directly interact with BT controller present on ESP32 bypassing host driver and firmware +> ESP Hosted host driver and a firmware plays no role in this communication + +* Linux hosts support OTA update (Over The Air ESP32 firmware update) in C and python. MCU hosts can refer the same for their development. For detailed documentation please read +[ota_update.md](docs/Linux_based_host/ota_update.md). --- @@ -172,18 +201,20 @@ This section describes the data communication protocol used at the transport lay ##### 3.2.1 Payload Format This section explains the payload format used for data transfer on SDIO and SPI interfaces. -* Host and peripheral makes use of 8 byte payload header which preceeds every data packet. +* Host and peripheral makes use of 12 byte payload header which preceeds every data packet. * This payload header provides additional information about the data packet. Based on this header, host/peripheral consumes transmitted data packet. * Payload format is as below | Field | Length | Description | |:-------:|:---------:|:--------| | Interface type | 4 bits | Possible values: STA(0), SoftAP(1), Serial interface(2), HCI (3), Priv interface(4). Rest all values are reserved | -| Reserved | 4 bits | Not in use | -| Reserved | 1 byte | Not in use | +| Interface number | 4 bits | Unused | +| Flags | 1 byte | Additional flags like `MORE_FRAGMENT` in fragmentation | | Packet length | 2 bytes | Actual length of data packet | | Offset to packet | 2 bytes | Offset of actual data packet | -| Reserved | 1 byte | Not in use | +| Checksum | 2 bytes | checksum for complete packet (Includes header and payload) | +| Reserved2 | 1 byte | Not in use | +| seq_num | 2 bytes | Sequence number for serial inerface | | Packet type | 1 byte | reserved when interface type is 0,1 and 2. Applicable only for interface type 3 and 4 | ### 3.3 Integration Guide diff --git a/common/esp_hosted_config.pb-c.c b/common/esp_hosted_config.pb-c.c index e51f328fed..d6ccff1c84 100644 --- a/common/esp_hosted_config.pb-c.c +++ b/common/esp_hosted_config.pb-c.c @@ -1039,6 +1039,522 @@ void esp_hosted_resp_connected_sta__free_unpacked assert(message->base.descriptor == &esp_hosted_resp_connected_sta__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } +void esp_hosted_cmd_otabegin__init + (EspHostedCmdOTABegin *message) +{ + static EspHostedCmdOTABegin init_value = ESP_HOSTED_CMD_OTABEGIN__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_otabegin__get_packed_size + (const EspHostedCmdOTABegin *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otabegin__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_otabegin__pack + (const EspHostedCmdOTABegin *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otabegin__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_otabegin__pack_to_buffer + (const EspHostedCmdOTABegin *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otabegin__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdOTABegin * + esp_hosted_cmd_otabegin__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdOTABegin *) + protobuf_c_message_unpack (&esp_hosted_cmd_otabegin__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_otabegin__free_unpacked + (EspHostedCmdOTABegin *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otabegin__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_otabegin__init + (EspHostedRespOTABegin *message) +{ + static EspHostedRespOTABegin init_value = ESP_HOSTED_RESP_OTABEGIN__INIT; + *message = init_value; +} +size_t esp_hosted_resp_otabegin__get_packed_size + (const EspHostedRespOTABegin *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_otabegin__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_otabegin__pack + (const EspHostedRespOTABegin *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_otabegin__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_otabegin__pack_to_buffer + (const EspHostedRespOTABegin *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_otabegin__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespOTABegin * + esp_hosted_resp_otabegin__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespOTABegin *) + protobuf_c_message_unpack (&esp_hosted_resp_otabegin__descriptor, + allocator, len, data); +} +void esp_hosted_resp_otabegin__free_unpacked + (EspHostedRespOTABegin *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_otabegin__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_cmd_otawrite__init + (EspHostedCmdOTAWrite *message) +{ + static EspHostedCmdOTAWrite init_value = ESP_HOSTED_CMD_OTAWRITE__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_otawrite__get_packed_size + (const EspHostedCmdOTAWrite *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otawrite__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_otawrite__pack + (const EspHostedCmdOTAWrite *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otawrite__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_otawrite__pack_to_buffer + (const EspHostedCmdOTAWrite *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otawrite__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdOTAWrite * + esp_hosted_cmd_otawrite__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdOTAWrite *) + protobuf_c_message_unpack (&esp_hosted_cmd_otawrite__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_otawrite__free_unpacked + (EspHostedCmdOTAWrite *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otawrite__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_otawrite__init + (EspHostedRespOTAWrite *message) +{ + static EspHostedRespOTAWrite init_value = ESP_HOSTED_RESP_OTAWRITE__INIT; + *message = init_value; +} +size_t esp_hosted_resp_otawrite__get_packed_size + (const EspHostedRespOTAWrite *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_otawrite__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_otawrite__pack + (const EspHostedRespOTAWrite *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_otawrite__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_otawrite__pack_to_buffer + (const EspHostedRespOTAWrite *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_otawrite__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespOTAWrite * + esp_hosted_resp_otawrite__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespOTAWrite *) + protobuf_c_message_unpack (&esp_hosted_resp_otawrite__descriptor, + allocator, len, data); +} +void esp_hosted_resp_otawrite__free_unpacked + (EspHostedRespOTAWrite *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_otawrite__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_cmd_otaend__init + (EspHostedCmdOTAEnd *message) +{ + static EspHostedCmdOTAEnd init_value = ESP_HOSTED_CMD_OTAEND__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_otaend__get_packed_size + (const EspHostedCmdOTAEnd *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otaend__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_otaend__pack + (const EspHostedCmdOTAEnd *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otaend__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_otaend__pack_to_buffer + (const EspHostedCmdOTAEnd *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otaend__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdOTAEnd * + esp_hosted_cmd_otaend__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdOTAEnd *) + protobuf_c_message_unpack (&esp_hosted_cmd_otaend__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_otaend__free_unpacked + (EspHostedCmdOTAEnd *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_otaend__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_otaend__init + (EspHostedRespOTAEnd *message) +{ + static EspHostedRespOTAEnd init_value = ESP_HOSTED_RESP_OTAEND__INIT; + *message = init_value; +} +size_t esp_hosted_resp_otaend__get_packed_size + (const EspHostedRespOTAEnd *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_otaend__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_otaend__pack + (const EspHostedRespOTAEnd *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_otaend__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_otaend__pack_to_buffer + (const EspHostedRespOTAEnd *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_otaend__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespOTAEnd * + esp_hosted_resp_otaend__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespOTAEnd *) + protobuf_c_message_unpack (&esp_hosted_resp_otaend__descriptor, + allocator, len, data); +} +void esp_hosted_resp_otaend__free_unpacked + (EspHostedRespOTAEnd *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_otaend__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_cmd_set_vendor_specific_ie__init + (EspHostedCmdSetVendorSpecificIE *message) +{ + static EspHostedCmdSetVendorSpecificIE init_value = ESP_HOSTED_CMD_SET_VENDOR_SPECIFIC_IE__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_set_vendor_specific_ie__get_packed_size + (const EspHostedCmdSetVendorSpecificIE *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_vendor_specific_ie__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_set_vendor_specific_ie__pack + (const EspHostedCmdSetVendorSpecificIE *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_vendor_specific_ie__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_set_vendor_specific_ie__pack_to_buffer + (const EspHostedCmdSetVendorSpecificIE *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_vendor_specific_ie__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdSetVendorSpecificIE * + esp_hosted_cmd_set_vendor_specific_ie__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdSetVendorSpecificIE *) + protobuf_c_message_unpack (&esp_hosted_cmd_set_vendor_specific_ie__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_set_vendor_specific_ie__free_unpacked + (EspHostedCmdSetVendorSpecificIE *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_vendor_specific_ie__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_set_vendor_specific_ie__init + (EspHostedRespSetVendorSpecificIE *message) +{ + static EspHostedRespSetVendorSpecificIE init_value = ESP_HOSTED_RESP_SET_VENDOR_SPECIFIC_IE__INIT; + *message = init_value; +} +size_t esp_hosted_resp_set_vendor_specific_ie__get_packed_size + (const EspHostedRespSetVendorSpecificIE *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_vendor_specific_ie__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_set_vendor_specific_ie__pack + (const EspHostedRespSetVendorSpecificIE *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_vendor_specific_ie__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_set_vendor_specific_ie__pack_to_buffer + (const EspHostedRespSetVendorSpecificIE *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_vendor_specific_ie__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespSetVendorSpecificIE * + esp_hosted_resp_set_vendor_specific_ie__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespSetVendorSpecificIE *) + protobuf_c_message_unpack (&esp_hosted_resp_set_vendor_specific_ie__descriptor, + allocator, len, data); +} +void esp_hosted_resp_set_vendor_specific_ie__free_unpacked + (EspHostedRespSetVendorSpecificIE *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_vendor_specific_ie__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_cmd_set_wi_fi_maxtxpower__init + (EspHostedCmdSetWiFiMAXTXPower *message) +{ + static EspHostedCmdSetWiFiMAXTXPower init_value = ESP_HOSTED_CMD_SET_WI_FI_MAXTXPOWER__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__get_packed_size + (const EspHostedCmdSetWiFiMAXTXPower *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__pack + (const EspHostedCmdSetWiFiMAXTXPower *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__pack_to_buffer + (const EspHostedCmdSetWiFiMAXTXPower *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdSetWiFiMAXTXPower * + esp_hosted_cmd_set_wi_fi_maxtxpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdSetWiFiMAXTXPower *) + protobuf_c_message_unpack (&esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_set_wi_fi_maxtxpower__free_unpacked + (EspHostedCmdSetWiFiMAXTXPower *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_set_wi_fi_maxtxpower__init + (EspHostedRespSetWiFiMAXTXPower *message) +{ + static EspHostedRespSetWiFiMAXTXPower init_value = ESP_HOSTED_RESP_SET_WI_FI_MAXTXPOWER__INIT; + *message = init_value; +} +size_t esp_hosted_resp_set_wi_fi_maxtxpower__get_packed_size + (const EspHostedRespSetWiFiMAXTXPower *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_set_wi_fi_maxtxpower__pack + (const EspHostedRespSetWiFiMAXTXPower *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_set_wi_fi_maxtxpower__pack_to_buffer + (const EspHostedRespSetWiFiMAXTXPower *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_wi_fi_maxtxpower__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespSetWiFiMAXTXPower * + esp_hosted_resp_set_wi_fi_maxtxpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespSetWiFiMAXTXPower *) + protobuf_c_message_unpack (&esp_hosted_resp_set_wi_fi_maxtxpower__descriptor, + allocator, len, data); +} +void esp_hosted_resp_set_wi_fi_maxtxpower__free_unpacked + (EspHostedRespSetWiFiMAXTXPower *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_set_wi_fi_maxtxpower__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_cmd_get_wi_fi_curr_txpower__init + (EspHostedCmdGetWiFiCurrTXPower *message) +{ + static EspHostedCmdGetWiFiCurrTXPower init_value = ESP_HOSTED_CMD_GET_WI_FI_CURR_TXPOWER__INIT; + *message = init_value; +} +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__get_packed_size + (const EspHostedCmdGetWiFiCurrTXPower *message) +{ + assert(message->base.descriptor == &esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__pack + (const EspHostedCmdGetWiFiCurrTXPower *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__pack_to_buffer + (const EspHostedCmdGetWiFiCurrTXPower *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedCmdGetWiFiCurrTXPower * + esp_hosted_cmd_get_wi_fi_curr_txpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedCmdGetWiFiCurrTXPower *) + protobuf_c_message_unpack (&esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor, + allocator, len, data); +} +void esp_hosted_cmd_get_wi_fi_curr_txpower__free_unpacked + (EspHostedCmdGetWiFiCurrTXPower *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void esp_hosted_resp_get_wi_fi_curr_txpower__init + (EspHostedRespGetWiFiCurrTXPower *message) +{ + static EspHostedRespGetWiFiCurrTXPower init_value = ESP_HOSTED_RESP_GET_WI_FI_CURR_TXPOWER__INIT; + *message = init_value; +} +size_t esp_hosted_resp_get_wi_fi_curr_txpower__get_packed_size + (const EspHostedRespGetWiFiCurrTXPower *message) +{ + assert(message->base.descriptor == &esp_hosted_resp_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t esp_hosted_resp_get_wi_fi_curr_txpower__pack + (const EspHostedRespGetWiFiCurrTXPower *message, + uint8_t *out) +{ + assert(message->base.descriptor == &esp_hosted_resp_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t esp_hosted_resp_get_wi_fi_curr_txpower__pack_to_buffer + (const EspHostedRespGetWiFiCurrTXPower *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &esp_hosted_resp_get_wi_fi_curr_txpower__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +EspHostedRespGetWiFiCurrTXPower * + esp_hosted_resp_get_wi_fi_curr_txpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (EspHostedRespGetWiFiCurrTXPower *) + protobuf_c_message_unpack (&esp_hosted_resp_get_wi_fi_curr_txpower__descriptor, + allocator, len, data); +} +void esp_hosted_resp_get_wi_fi_curr_txpower__free_unpacked + (EspHostedRespGetWiFiCurrTXPower *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &esp_hosted_resp_get_wi_fi_curr_txpower__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} void esp_hosted_config_payload__init (EspHostedConfigPayload *message) { @@ -1453,136 +1969,411 @@ const ProtobufCMessageDescriptor esp_hosted_resp_set_mac_address__descriptor = "EspHostedRespSetMacAddress", "EspHostedRespSetMacAddress", "", - sizeof(EspHostedRespSetMacAddress), + sizeof(EspHostedRespSetMacAddress), + 1, + esp_hosted_resp_set_mac_address__field_descriptors, + esp_hosted_resp_set_mac_address__field_indices_by_name, + 1, esp_hosted_resp_set_mac_address__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_set_mac_address__init, + NULL,NULL,NULL /* reserved[123] */ +}; +#define esp_hosted_cmd_get_apconfig__field_descriptors NULL +#define esp_hosted_cmd_get_apconfig__field_indices_by_name NULL +#define esp_hosted_cmd_get_apconfig__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_get_apconfig__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdGetAPConfig", + "EspHostedCmdGetAPConfig", + "EspHostedCmdGetAPConfig", + "", + sizeof(EspHostedCmdGetAPConfig), + 0, + esp_hosted_cmd_get_apconfig__field_descriptors, + esp_hosted_cmd_get_apconfig__field_indices_by_name, + 0, esp_hosted_cmd_get_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_get_apconfig__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_get_apconfig__field_descriptors[6] = +{ + { + "ssid", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BYTES, + offsetof(EspHostedRespGetAPConfig, has_ssid), + offsetof(EspHostedRespGetAPConfig, ssid), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "bssid", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BYTES, + offsetof(EspHostedRespGetAPConfig, has_bssid), + offsetof(EspHostedRespGetAPConfig, bssid), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "rssi", + 3, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespGetAPConfig, has_rssi), + offsetof(EspHostedRespGetAPConfig, rssi), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "chnl", + 4, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespGetAPConfig, has_chnl), + offsetof(EspHostedRespGetAPConfig, chnl), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "ecn", + 5, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_ENUM, + offsetof(EspHostedRespGetAPConfig, has_ecn), + offsetof(EspHostedRespGetAPConfig, ecn), + &esp_hosted_encryption_mode__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp", + 6, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespGetAPConfig, has_resp), + offsetof(EspHostedRespGetAPConfig, resp), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned esp_hosted_resp_get_apconfig__field_indices_by_name[] = { + 1, /* field[1] = bssid */ + 3, /* field[3] = chnl */ + 4, /* field[4] = ecn */ + 5, /* field[5] = resp */ + 2, /* field[2] = rssi */ + 0, /* field[0] = ssid */ +}; +static const ProtobufCIntRange esp_hosted_resp_get_apconfig__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 6 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_get_apconfig__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedRespGetAPConfig", + "EspHostedRespGetAPConfig", + "EspHostedRespGetAPConfig", + "", + sizeof(EspHostedRespGetAPConfig), + 6, + esp_hosted_resp_get_apconfig__field_descriptors, + esp_hosted_resp_get_apconfig__field_indices_by_name, + 1, esp_hosted_resp_get_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_get_apconfig__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_cmd_set_apconfig__field_descriptors[5] = +{ + { + "ssid", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(EspHostedCmdSetAPConfig, ssid), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "pwd", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(EspHostedCmdSetAPConfig, pwd), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "bssid", + 3, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(EspHostedCmdSetAPConfig, bssid), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "is_wpa3_supported", + 4, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BOOL, + offsetof(EspHostedCmdSetAPConfig, has_is_wpa3_supported), + offsetof(EspHostedCmdSetAPConfig, is_wpa3_supported), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "listen_interval", + 5, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedCmdSetAPConfig, has_listen_interval), + offsetof(EspHostedCmdSetAPConfig, listen_interval), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned esp_hosted_cmd_set_apconfig__field_indices_by_name[] = { + 2, /* field[2] = bssid */ + 3, /* field[3] = is_wpa3_supported */ + 4, /* field[4] = listen_interval */ + 1, /* field[1] = pwd */ + 0, /* field[0] = ssid */ +}; +static const ProtobufCIntRange esp_hosted_cmd_set_apconfig__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 5 } +}; +const ProtobufCMessageDescriptor esp_hosted_cmd_set_apconfig__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdSetAPConfig", + "EspHostedCmdSetAPConfig", + "EspHostedCmdSetAPConfig", + "", + sizeof(EspHostedCmdSetAPConfig), + 5, + esp_hosted_cmd_set_apconfig__field_descriptors, + esp_hosted_cmd_set_apconfig__field_indices_by_name, + 1, esp_hosted_cmd_set_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_set_apconfig__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_set_apconfig__field_descriptors[1] = +{ + { + "resp", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespSetAPConfig, has_resp), + offsetof(EspHostedRespSetAPConfig, resp), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned esp_hosted_resp_set_apconfig__field_indices_by_name[] = { + 0, /* field[0] = resp */ +}; +static const ProtobufCIntRange esp_hosted_resp_set_apconfig__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_set_apconfig__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedRespSetAPConfig", + "EspHostedRespSetAPConfig", + "EspHostedRespSetAPConfig", + "", + sizeof(EspHostedRespSetAPConfig), 1, - esp_hosted_resp_set_mac_address__field_descriptors, - esp_hosted_resp_set_mac_address__field_indices_by_name, - 1, esp_hosted_resp_set_mac_address__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_set_mac_address__init, + esp_hosted_resp_set_apconfig__field_descriptors, + esp_hosted_resp_set_apconfig__field_indices_by_name, + 1, esp_hosted_resp_set_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_set_apconfig__init, NULL,NULL,NULL /* reserved[123] */ }; -#define esp_hosted_cmd_get_apconfig__field_descriptors NULL -#define esp_hosted_cmd_get_apconfig__field_indices_by_name NULL -#define esp_hosted_cmd_get_apconfig__number_ranges NULL -const ProtobufCMessageDescriptor esp_hosted_cmd_get_apconfig__descriptor = +#define esp_hosted_cmd_get_soft_apconfig__field_descriptors NULL +#define esp_hosted_cmd_get_soft_apconfig__field_indices_by_name NULL +#define esp_hosted_cmd_get_soft_apconfig__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_get_soft_apconfig__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdGetAPConfig", - "EspHostedCmdGetAPConfig", - "EspHostedCmdGetAPConfig", + "EspHostedCmdGetSoftAPConfig", + "EspHostedCmdGetSoftAPConfig", + "EspHostedCmdGetSoftAPConfig", "", - sizeof(EspHostedCmdGetAPConfig), + sizeof(EspHostedCmdGetSoftAPConfig), 0, - esp_hosted_cmd_get_apconfig__field_descriptors, - esp_hosted_cmd_get_apconfig__field_indices_by_name, - 0, esp_hosted_cmd_get_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_get_apconfig__init, + esp_hosted_cmd_get_soft_apconfig__field_descriptors, + esp_hosted_cmd_get_soft_apconfig__field_indices_by_name, + 0, esp_hosted_cmd_get_soft_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_get_soft_apconfig__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_resp_get_apconfig__field_descriptors[6] = +static const ProtobufCFieldDescriptor esp_hosted_resp_get_soft_apconfig__field_descriptors[8] = { { "ssid", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedRespGetAPConfig, has_ssid), - offsetof(EspHostedRespGetAPConfig, ssid), + offsetof(EspHostedRespGetSoftAPConfig, has_ssid), + offsetof(EspHostedRespGetSoftAPConfig, ssid), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "bssid", + "pwd", 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedRespGetAPConfig, has_bssid), - offsetof(EspHostedRespGetAPConfig, bssid), + offsetof(EspHostedRespGetSoftAPConfig, has_pwd), + offsetof(EspHostedRespGetSoftAPConfig, pwd), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "rssi", + "chnl", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetAPConfig, has_rssi), - offsetof(EspHostedRespGetAPConfig, rssi), + offsetof(EspHostedRespGetSoftAPConfig, has_chnl), + offsetof(EspHostedRespGetSoftAPConfig, chnl), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "chnl", + "ecn", 4, PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_ENUM, + offsetof(EspHostedRespGetSoftAPConfig, has_ecn), + offsetof(EspHostedRespGetSoftAPConfig, ecn), + &esp_hosted_encryption_mode__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "max_conn", + 5, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetAPConfig, has_chnl), - offsetof(EspHostedRespGetAPConfig, chnl), + offsetof(EspHostedRespGetSoftAPConfig, has_max_conn), + offsetof(EspHostedRespGetSoftAPConfig, max_conn), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "ecn", - 5, + "ssid_hidden", + 6, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_ENUM, - offsetof(EspHostedRespGetAPConfig, has_ecn), - offsetof(EspHostedRespGetAPConfig, ecn), - &esp_hosted_encryption_mode__descriptor, + PROTOBUF_C_TYPE_BOOL, + offsetof(EspHostedRespGetSoftAPConfig, has_ssid_hidden), + offsetof(EspHostedRespGetSoftAPConfig, ssid_hidden), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "bw", + 7, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespGetSoftAPConfig, has_bw), + offsetof(EspHostedRespGetSoftAPConfig, bw), + NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "resp", - 6, + 8, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetAPConfig, has_resp), - offsetof(EspHostedRespGetAPConfig, resp), + offsetof(EspHostedRespGetSoftAPConfig, has_resp), + offsetof(EspHostedRespGetSoftAPConfig, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_get_apconfig__field_indices_by_name[] = { - 1, /* field[1] = bssid */ - 3, /* field[3] = chnl */ - 4, /* field[4] = ecn */ - 5, /* field[5] = resp */ - 2, /* field[2] = rssi */ +static const unsigned esp_hosted_resp_get_soft_apconfig__field_indices_by_name[] = { + 6, /* field[6] = bw */ + 2, /* field[2] = chnl */ + 3, /* field[3] = ecn */ + 4, /* field[4] = max_conn */ + 1, /* field[1] = pwd */ + 7, /* field[7] = resp */ 0, /* field[0] = ssid */ + 5, /* field[5] = ssid_hidden */ }; -static const ProtobufCIntRange esp_hosted_resp_get_apconfig__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_get_soft_apconfig__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 6 } + { 0, 8 } }; -const ProtobufCMessageDescriptor esp_hosted_resp_get_apconfig__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_get_soft_apconfig__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespGetAPConfig", - "EspHostedRespGetAPConfig", - "EspHostedRespGetAPConfig", + "EspHostedRespGetSoftAPConfig", + "EspHostedRespGetSoftAPConfig", + "EspHostedRespGetSoftAPConfig", "", - sizeof(EspHostedRespGetAPConfig), - 6, - esp_hosted_resp_get_apconfig__field_descriptors, - esp_hosted_resp_get_apconfig__field_indices_by_name, - 1, esp_hosted_resp_get_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_get_apconfig__init, + sizeof(EspHostedRespGetSoftAPConfig), + 8, + esp_hosted_resp_get_soft_apconfig__field_descriptors, + esp_hosted_resp_get_soft_apconfig__field_indices_by_name, + 1, esp_hosted_resp_get_soft_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_get_soft_apconfig__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_cmd_set_apconfig__field_descriptors[5] = +static const ProtobufCFieldDescriptor esp_hosted_cmd_set_soft_apconfig__field_descriptors[7] = { { "ssid", @@ -1590,7 +2381,7 @@ static const ProtobufCFieldDescriptor esp_hosted_cmd_set_apconfig__field_descrip PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - offsetof(EspHostedCmdSetAPConfig, ssid), + offsetof(EspHostedCmdSetSoftAPConfig, ssid), NULL, NULL, 0, /* flags */ @@ -1602,721 +2393,894 @@ static const ProtobufCFieldDescriptor esp_hosted_cmd_set_apconfig__field_descrip PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - offsetof(EspHostedCmdSetAPConfig, pwd), + offsetof(EspHostedCmdSetSoftAPConfig, pwd), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "bssid", + "chnl", 3, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(EspHostedCmdSetAPConfig, bssid), + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedCmdSetSoftAPConfig, has_chnl), + offsetof(EspHostedCmdSetSoftAPConfig, chnl), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "is_wpa3_supported", + "ecn", 4, PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_ENUM, + offsetof(EspHostedCmdSetSoftAPConfig, has_ecn), + offsetof(EspHostedCmdSetSoftAPConfig, ecn), + &esp_hosted_encryption_mode__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "max_conn", + 5, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedCmdSetSoftAPConfig, has_max_conn), + offsetof(EspHostedCmdSetSoftAPConfig, max_conn), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "ssid_hidden", + 6, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL, - offsetof(EspHostedCmdSetAPConfig, has_is_wpa3_supported), - offsetof(EspHostedCmdSetAPConfig, is_wpa3_supported), + offsetof(EspHostedCmdSetSoftAPConfig, has_ssid_hidden), + offsetof(EspHostedCmdSetSoftAPConfig, ssid_hidden), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "listen_interval", - 5, + "bw", + 7, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedCmdSetAPConfig, has_listen_interval), - offsetof(EspHostedCmdSetAPConfig, listen_interval), + offsetof(EspHostedCmdSetSoftAPConfig, has_bw), + offsetof(EspHostedCmdSetSoftAPConfig, bw), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_cmd_set_apconfig__field_indices_by_name[] = { - 2, /* field[2] = bssid */ - 3, /* field[3] = is_wpa3_supported */ - 4, /* field[4] = listen_interval */ +static const unsigned esp_hosted_cmd_set_soft_apconfig__field_indices_by_name[] = { + 6, /* field[6] = bw */ + 2, /* field[2] = chnl */ + 3, /* field[3] = ecn */ + 4, /* field[4] = max_conn */ 1, /* field[1] = pwd */ 0, /* field[0] = ssid */ + 5, /* field[5] = ssid_hidden */ }; -static const ProtobufCIntRange esp_hosted_cmd_set_apconfig__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_cmd_set_soft_apconfig__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 5 } + { 0, 7 } }; -const ProtobufCMessageDescriptor esp_hosted_cmd_set_apconfig__descriptor = +const ProtobufCMessageDescriptor esp_hosted_cmd_set_soft_apconfig__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdSetAPConfig", - "EspHostedCmdSetAPConfig", - "EspHostedCmdSetAPConfig", + "EspHostedCmdSetSoftAPConfig", + "EspHostedCmdSetSoftAPConfig", + "EspHostedCmdSetSoftAPConfig", "", - sizeof(EspHostedCmdSetAPConfig), - 5, - esp_hosted_cmd_set_apconfig__field_descriptors, - esp_hosted_cmd_set_apconfig__field_indices_by_name, - 1, esp_hosted_cmd_set_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_set_apconfig__init, + sizeof(EspHostedCmdSetSoftAPConfig), + 7, + esp_hosted_cmd_set_soft_apconfig__field_descriptors, + esp_hosted_cmd_set_soft_apconfig__field_indices_by_name, + 1, esp_hosted_cmd_set_soft_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_set_soft_apconfig__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_resp_set_apconfig__field_descriptors[1] = +static const ProtobufCFieldDescriptor esp_hosted_resp_set_soft_apconfig__field_descriptors[1] = { { "resp", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespSetAPConfig, has_resp), - offsetof(EspHostedRespSetAPConfig, resp), + offsetof(EspHostedRespSetSoftAPConfig, has_resp), + offsetof(EspHostedRespSetSoftAPConfig, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_set_apconfig__field_indices_by_name[] = { +static const unsigned esp_hosted_resp_set_soft_apconfig__field_indices_by_name[] = { 0, /* field[0] = resp */ }; -static const ProtobufCIntRange esp_hosted_resp_set_apconfig__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 1 } -}; -const ProtobufCMessageDescriptor esp_hosted_resp_set_apconfig__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespSetAPConfig", - "EspHostedRespSetAPConfig", - "EspHostedRespSetAPConfig", - "", - sizeof(EspHostedRespSetAPConfig), - 1, - esp_hosted_resp_set_apconfig__field_descriptors, - esp_hosted_resp_set_apconfig__field_indices_by_name, - 1, esp_hosted_resp_set_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_set_apconfig__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define esp_hosted_cmd_get_soft_apconfig__field_descriptors NULL -#define esp_hosted_cmd_get_soft_apconfig__field_indices_by_name NULL -#define esp_hosted_cmd_get_soft_apconfig__number_ranges NULL -const ProtobufCMessageDescriptor esp_hosted_cmd_get_soft_apconfig__descriptor = +static const ProtobufCIntRange esp_hosted_resp_set_soft_apconfig__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_set_soft_apconfig__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdGetSoftAPConfig", - "EspHostedCmdGetSoftAPConfig", - "EspHostedCmdGetSoftAPConfig", + "EspHostedRespSetSoftAPConfig", + "EspHostedRespSetSoftAPConfig", + "EspHostedRespSetSoftAPConfig", "", - sizeof(EspHostedCmdGetSoftAPConfig), - 0, - esp_hosted_cmd_get_soft_apconfig__field_descriptors, - esp_hosted_cmd_get_soft_apconfig__field_indices_by_name, - 0, esp_hosted_cmd_get_soft_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_get_soft_apconfig__init, + sizeof(EspHostedRespSetSoftAPConfig), + 1, + esp_hosted_resp_set_soft_apconfig__field_descriptors, + esp_hosted_resp_set_soft_apconfig__field_indices_by_name, + 1, esp_hosted_resp_set_soft_apconfig__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_set_soft_apconfig__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_resp_get_soft_apconfig__field_descriptors[8] = +static const ProtobufCFieldDescriptor esp_hosted_scan_result__field_descriptors[5] = { { "ssid", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedRespGetSoftAPConfig, has_ssid), - offsetof(EspHostedRespGetSoftAPConfig, ssid), + offsetof(EspHostedScanResult, has_ssid), + offsetof(EspHostedScanResult, ssid), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "pwd", + "chnl", 2, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedRespGetSoftAPConfig, has_pwd), - offsetof(EspHostedRespGetSoftAPConfig, pwd), + PROTOBUF_C_TYPE_UINT32, + offsetof(EspHostedScanResult, has_chnl), + offsetof(EspHostedScanResult, chnl), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "chnl", + "rssi", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetSoftAPConfig, has_chnl), - offsetof(EspHostedRespGetSoftAPConfig, chnl), + offsetof(EspHostedScanResult, has_rssi), + offsetof(EspHostedScanResult, rssi), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "ecn", + "bssid", 4, PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BYTES, + offsetof(EspHostedScanResult, has_bssid), + offsetof(EspHostedScanResult, bssid), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "ecn", + 5, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_ENUM, - offsetof(EspHostedRespGetSoftAPConfig, has_ecn), - offsetof(EspHostedRespGetSoftAPConfig, ecn), + offsetof(EspHostedScanResult, has_ecn), + offsetof(EspHostedScanResult, ecn), &esp_hosted_encryption_mode__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_scan_result__field_indices_by_name[] = { + 3, /* field[3] = bssid */ + 1, /* field[1] = chnl */ + 4, /* field[4] = ecn */ + 2, /* field[2] = rssi */ + 0, /* field[0] = ssid */ +}; +static const ProtobufCIntRange esp_hosted_scan_result__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 5 } +}; +const ProtobufCMessageDescriptor esp_hosted_scan_result__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedScanResult", + "EspHostedScanResult", + "EspHostedScanResult", + "", + sizeof(EspHostedScanResult), + 5, + esp_hosted_scan_result__field_descriptors, + esp_hosted_scan_result__field_indices_by_name, + 1, esp_hosted_scan_result__number_ranges, + (ProtobufCMessageInit) esp_hosted_scan_result__init, + NULL,NULL,NULL /* reserved[123] */ +}; +#define esp_hosted_cmd_scan_result__field_descriptors NULL +#define esp_hosted_cmd_scan_result__field_indices_by_name NULL +#define esp_hosted_cmd_scan_result__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_scan_result__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdScanResult", + "EspHostedCmdScanResult", + "EspHostedCmdScanResult", + "", + sizeof(EspHostedCmdScanResult), + 0, + esp_hosted_cmd_scan_result__field_descriptors, + esp_hosted_cmd_scan_result__field_indices_by_name, + 0, esp_hosted_cmd_scan_result__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_scan_result__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_scan_result__field_descriptors[3] = +{ { - "max_conn", - 5, + "count", + 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetSoftAPConfig, has_max_conn), - offsetof(EspHostedRespGetSoftAPConfig, max_conn), + PROTOBUF_C_TYPE_UINT32, + offsetof(EspHostedRespScanResult, has_count), + offsetof(EspHostedRespScanResult, count), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "ssid_hidden", - 6, + "entries", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedRespScanResult, n_entries), + offsetof(EspHostedRespScanResult, entries), + &esp_hosted_scan_result__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp", + 3, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BOOL, - offsetof(EspHostedRespGetSoftAPConfig, has_ssid_hidden), - offsetof(EspHostedRespGetSoftAPConfig, ssid_hidden), + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespScanResult, has_resp), + offsetof(EspHostedRespScanResult, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_resp_scan_result__field_indices_by_name[] = { + 0, /* field[0] = count */ + 1, /* field[1] = entries */ + 2, /* field[2] = resp */ +}; +static const ProtobufCIntRange esp_hosted_resp_scan_result__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_scan_result__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedRespScanResult", + "EspHostedRespScanResult", + "EspHostedRespScanResult", + "", + sizeof(EspHostedRespScanResult), + 3, + esp_hosted_resp_scan_result__field_descriptors, + esp_hosted_resp_scan_result__field_indices_by_name, + 1, esp_hosted_resp_scan_result__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_scan_result__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_connected_stalist__field_descriptors[2] = +{ { - "bw", - 7, + "mac", + 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetSoftAPConfig, has_bw), - offsetof(EspHostedRespGetSoftAPConfig, bw), + PROTOBUF_C_TYPE_BYTES, + offsetof(EspHostedConnectedSTAList, has_mac), + offsetof(EspHostedConnectedSTAList, mac), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "resp", - 8, + "rssi", + 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespGetSoftAPConfig, has_resp), - offsetof(EspHostedRespGetSoftAPConfig, resp), + offsetof(EspHostedConnectedSTAList, has_rssi), + offsetof(EspHostedConnectedSTAList, rssi), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_get_soft_apconfig__field_indices_by_name[] = { - 6, /* field[6] = bw */ - 2, /* field[2] = chnl */ - 3, /* field[3] = ecn */ - 4, /* field[4] = max_conn */ - 1, /* field[1] = pwd */ - 7, /* field[7] = resp */ - 0, /* field[0] = ssid */ - 5, /* field[5] = ssid_hidden */ +static const unsigned esp_hosted_connected_stalist__field_indices_by_name[] = { + 0, /* field[0] = mac */ + 1, /* field[1] = rssi */ }; -static const ProtobufCIntRange esp_hosted_resp_get_soft_apconfig__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_connected_stalist__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 8 } + { 0, 2 } }; -const ProtobufCMessageDescriptor esp_hosted_resp_get_soft_apconfig__descriptor = +const ProtobufCMessageDescriptor esp_hosted_connected_stalist__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespGetSoftAPConfig", - "EspHostedRespGetSoftAPConfig", - "EspHostedRespGetSoftAPConfig", + "EspHostedConnectedSTAList", + "EspHostedConnectedSTAList", + "EspHostedConnectedSTAList", "", - sizeof(EspHostedRespGetSoftAPConfig), - 8, - esp_hosted_resp_get_soft_apconfig__field_descriptors, - esp_hosted_resp_get_soft_apconfig__field_indices_by_name, - 1, esp_hosted_resp_get_soft_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_get_soft_apconfig__init, + sizeof(EspHostedConnectedSTAList), + 2, + esp_hosted_connected_stalist__field_descriptors, + esp_hosted_connected_stalist__field_indices_by_name, + 1, esp_hosted_connected_stalist__number_ranges, + (ProtobufCMessageInit) esp_hosted_connected_stalist__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_cmd_set_soft_apconfig__field_descriptors[7] = +#define esp_hosted_cmd_connected_sta__field_descriptors NULL +#define esp_hosted_cmd_connected_sta__field_indices_by_name NULL +#define esp_hosted_cmd_connected_sta__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_connected_sta__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdConnectedSTA", + "EspHostedCmdConnectedSTA", + "EspHostedCmdConnectedSTA", + "", + sizeof(EspHostedCmdConnectedSTA), + 0, + esp_hosted_cmd_connected_sta__field_descriptors, + esp_hosted_cmd_connected_sta__field_indices_by_name, + 0, esp_hosted_cmd_connected_sta__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_connected_sta__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_connected_sta__field_descriptors[3] = { { - "ssid", + "num", 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(EspHostedCmdSetSoftAPConfig, ssid), + PROTOBUF_C_TYPE_UINT32, + offsetof(EspHostedRespConnectedSTA, has_num), + offsetof(EspHostedRespConnectedSTA, num), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "pwd", + "stations", 2, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(EspHostedCmdSetSoftAPConfig, pwd), - NULL, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedRespConnectedSTA, n_stations), + offsetof(EspHostedRespConnectedSTA, stations), + &esp_hosted_connected_stalist__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "chnl", + "resp", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedCmdSetSoftAPConfig, has_chnl), - offsetof(EspHostedCmdSetSoftAPConfig, chnl), - NULL, + offsetof(EspHostedRespConnectedSTA, has_resp), + offsetof(EspHostedRespConnectedSTA, resp), NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "ecn", - 4, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_ENUM, - offsetof(EspHostedCmdSetSoftAPConfig, has_ecn), - offsetof(EspHostedCmdSetSoftAPConfig, ecn), - &esp_hosted_encryption_mode__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_resp_connected_sta__field_indices_by_name[] = { + 0, /* field[0] = num */ + 2, /* field[2] = resp */ + 1, /* field[1] = stations */ +}; +static const ProtobufCIntRange esp_hosted_resp_connected_sta__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_connected_sta__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedRespConnectedSTA", + "EspHostedRespConnectedSTA", + "EspHostedRespConnectedSTA", + "", + sizeof(EspHostedRespConnectedSTA), + 3, + esp_hosted_resp_connected_sta__field_descriptors, + esp_hosted_resp_connected_sta__field_indices_by_name, + 1, esp_hosted_resp_connected_sta__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_connected_sta__init, + NULL,NULL,NULL /* reserved[123] */ +}; +#define esp_hosted_cmd_otabegin__field_descriptors NULL +#define esp_hosted_cmd_otabegin__field_indices_by_name NULL +#define esp_hosted_cmd_otabegin__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_otabegin__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdOTABegin", + "EspHostedCmdOTABegin", + "EspHostedCmdOTABegin", + "", + sizeof(EspHostedCmdOTABegin), + 0, + esp_hosted_cmd_otabegin__field_descriptors, + esp_hosted_cmd_otabegin__field_indices_by_name, + 0, esp_hosted_cmd_otabegin__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_otabegin__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_otabegin__field_descriptors[1] = +{ { - "max_conn", - 5, + "resp", + 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedCmdSetSoftAPConfig, has_max_conn), - offsetof(EspHostedCmdSetSoftAPConfig, max_conn), + offsetof(EspHostedRespOTABegin, has_resp), + offsetof(EspHostedRespOTABegin, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_resp_otabegin__field_indices_by_name[] = { + 0, /* field[0] = resp */ +}; +static const ProtobufCIntRange esp_hosted_resp_otabegin__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor esp_hosted_resp_otabegin__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedRespOTABegin", + "EspHostedRespOTABegin", + "EspHostedRespOTABegin", + "", + sizeof(EspHostedRespOTABegin), + 1, + esp_hosted_resp_otabegin__field_descriptors, + esp_hosted_resp_otabegin__field_indices_by_name, + 1, esp_hosted_resp_otabegin__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_otabegin__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_cmd_otawrite__field_descriptors[1] = +{ { - "ssid_hidden", - 6, + "ota_data", + 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BOOL, - offsetof(EspHostedCmdSetSoftAPConfig, has_ssid_hidden), - offsetof(EspHostedCmdSetSoftAPConfig, ssid_hidden), + PROTOBUF_C_TYPE_BYTES, + offsetof(EspHostedCmdOTAWrite, has_ota_data), + offsetof(EspHostedCmdOTAWrite, ota_data), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_cmd_otawrite__field_indices_by_name[] = { + 0, /* field[0] = ota_data */ +}; +static const ProtobufCIntRange esp_hosted_cmd_otawrite__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor esp_hosted_cmd_otawrite__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdOTAWrite", + "EspHostedCmdOTAWrite", + "EspHostedCmdOTAWrite", + "", + sizeof(EspHostedCmdOTAWrite), + 1, + esp_hosted_cmd_otawrite__field_descriptors, + esp_hosted_cmd_otawrite__field_indices_by_name, + 1, esp_hosted_cmd_otawrite__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_otawrite__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_otawrite__field_descriptors[1] = +{ { - "bw", - 7, + "resp", + 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedCmdSetSoftAPConfig, has_bw), - offsetof(EspHostedCmdSetSoftAPConfig, bw), + offsetof(EspHostedRespOTAWrite, has_resp), + offsetof(EspHostedRespOTAWrite, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_cmd_set_soft_apconfig__field_indices_by_name[] = { - 6, /* field[6] = bw */ - 2, /* field[2] = chnl */ - 3, /* field[3] = ecn */ - 4, /* field[4] = max_conn */ - 1, /* field[1] = pwd */ - 0, /* field[0] = ssid */ - 5, /* field[5] = ssid_hidden */ +static const unsigned esp_hosted_resp_otawrite__field_indices_by_name[] = { + 0, /* field[0] = resp */ }; -static const ProtobufCIntRange esp_hosted_cmd_set_soft_apconfig__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_otawrite__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 7 } + { 0, 1 } }; -const ProtobufCMessageDescriptor esp_hosted_cmd_set_soft_apconfig__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_otawrite__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdSetSoftAPConfig", - "EspHostedCmdSetSoftAPConfig", - "EspHostedCmdSetSoftAPConfig", + "EspHostedRespOTAWrite", + "EspHostedRespOTAWrite", + "EspHostedRespOTAWrite", "", - sizeof(EspHostedCmdSetSoftAPConfig), - 7, - esp_hosted_cmd_set_soft_apconfig__field_descriptors, - esp_hosted_cmd_set_soft_apconfig__field_indices_by_name, - 1, esp_hosted_cmd_set_soft_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_set_soft_apconfig__init, + sizeof(EspHostedRespOTAWrite), + 1, + esp_hosted_resp_otawrite__field_descriptors, + esp_hosted_resp_otawrite__field_indices_by_name, + 1, esp_hosted_resp_otawrite__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_otawrite__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_resp_set_soft_apconfig__field_descriptors[1] = +#define esp_hosted_cmd_otaend__field_descriptors NULL +#define esp_hosted_cmd_otaend__field_indices_by_name NULL +#define esp_hosted_cmd_otaend__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_otaend__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdOTAEnd", + "EspHostedCmdOTAEnd", + "EspHostedCmdOTAEnd", + "", + sizeof(EspHostedCmdOTAEnd), + 0, + esp_hosted_cmd_otaend__field_descriptors, + esp_hosted_cmd_otaend__field_indices_by_name, + 0, esp_hosted_cmd_otaend__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_otaend__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_otaend__field_descriptors[1] = { { "resp", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespSetSoftAPConfig, has_resp), - offsetof(EspHostedRespSetSoftAPConfig, resp), + offsetof(EspHostedRespOTAEnd, has_resp), + offsetof(EspHostedRespOTAEnd, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_set_soft_apconfig__field_indices_by_name[] = { +static const unsigned esp_hosted_resp_otaend__field_indices_by_name[] = { 0, /* field[0] = resp */ }; -static const ProtobufCIntRange esp_hosted_resp_set_soft_apconfig__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_otaend__number_ranges[1 + 1] = { { 1, 0 }, { 0, 1 } }; -const ProtobufCMessageDescriptor esp_hosted_resp_set_soft_apconfig__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_otaend__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespSetSoftAPConfig", - "EspHostedRespSetSoftAPConfig", - "EspHostedRespSetSoftAPConfig", + "EspHostedRespOTAEnd", + "EspHostedRespOTAEnd", + "EspHostedRespOTAEnd", "", - sizeof(EspHostedRespSetSoftAPConfig), + sizeof(EspHostedRespOTAEnd), 1, - esp_hosted_resp_set_soft_apconfig__field_descriptors, - esp_hosted_resp_set_soft_apconfig__field_indices_by_name, - 1, esp_hosted_resp_set_soft_apconfig__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_set_soft_apconfig__init, + esp_hosted_resp_otaend__field_descriptors, + esp_hosted_resp_otaend__field_indices_by_name, + 1, esp_hosted_resp_otaend__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_otaend__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_scan_result__field_descriptors[5] = +static const ProtobufCFieldDescriptor esp_hosted_cmd_set_vendor_specific_ie__field_descriptors[4] = { { - "ssid", + "enable", 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedScanResult, has_ssid), - offsetof(EspHostedScanResult, ssid), + PROTOBUF_C_TYPE_BOOL, + offsetof(EspHostedCmdSetVendorSpecificIE, has_enable), + offsetof(EspHostedCmdSetVendorSpecificIE, enable), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "chnl", + "type", 2, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT32, - offsetof(EspHostedScanResult, has_chnl), - offsetof(EspHostedScanResult, chnl), - NULL, + PROTOBUF_C_TYPE_ENUM, + offsetof(EspHostedCmdSetVendorSpecificIE, has_type), + offsetof(EspHostedCmdSetVendorSpecificIE, type), + &esp_hosted_vendor_ietype__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "rssi", + "idx", 3, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedScanResult, has_rssi), - offsetof(EspHostedScanResult, rssi), - NULL, + PROTOBUF_C_TYPE_ENUM, + offsetof(EspHostedCmdSetVendorSpecificIE, has_idx), + offsetof(EspHostedCmdSetVendorSpecificIE, idx), + &esp_hosted_ieid__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "bssid", + "vendor_ie_data", 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedScanResult, has_bssid), - offsetof(EspHostedScanResult, bssid), - NULL, + offsetof(EspHostedCmdSetVendorSpecificIE, has_vendor_ie_data), + offsetof(EspHostedCmdSetVendorSpecificIE, vendor_ie_data), NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "ecn", - 5, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_ENUM, - offsetof(EspHostedScanResult, has_ecn), - offsetof(EspHostedScanResult, ecn), - &esp_hosted_encryption_mode__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_scan_result__field_indices_by_name[] = { - 3, /* field[3] = bssid */ - 1, /* field[1] = chnl */ - 4, /* field[4] = ecn */ - 2, /* field[2] = rssi */ - 0, /* field[0] = ssid */ -}; -static const ProtobufCIntRange esp_hosted_scan_result__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 5 } -}; -const ProtobufCMessageDescriptor esp_hosted_scan_result__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedScanResult", - "EspHostedScanResult", - "EspHostedScanResult", - "", - sizeof(EspHostedScanResult), - 5, - esp_hosted_scan_result__field_descriptors, - esp_hosted_scan_result__field_indices_by_name, - 1, esp_hosted_scan_result__number_ranges, - (ProtobufCMessageInit) esp_hosted_scan_result__init, - NULL,NULL,NULL /* reserved[123] */ -}; -#define esp_hosted_cmd_scan_result__field_descriptors NULL -#define esp_hosted_cmd_scan_result__field_indices_by_name NULL -#define esp_hosted_cmd_scan_result__number_ranges NULL -const ProtobufCMessageDescriptor esp_hosted_cmd_scan_result__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdScanResult", - "EspHostedCmdScanResult", - "EspHostedCmdScanResult", - "", - sizeof(EspHostedCmdScanResult), - 0, - esp_hosted_cmd_scan_result__field_descriptors, - esp_hosted_cmd_scan_result__field_indices_by_name, - 0, esp_hosted_cmd_scan_result__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_scan_result__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor esp_hosted_resp_scan_result__field_descriptors[3] = -{ - { - "count", - 1, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT32, - offsetof(EspHostedRespScanResult, has_count), - offsetof(EspHostedRespScanResult, count), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "entries", - 2, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(EspHostedRespScanResult, n_entries), - offsetof(EspHostedRespScanResult, entries), - &esp_hosted_scan_result__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, +static const unsigned esp_hosted_cmd_set_vendor_specific_ie__field_indices_by_name[] = { + 0, /* field[0] = enable */ + 2, /* field[2] = idx */ + 1, /* field[1] = type */ + 3, /* field[3] = vendor_ie_data */ +}; +static const ProtobufCIntRange esp_hosted_cmd_set_vendor_specific_ie__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor esp_hosted_cmd_set_vendor_specific_ie__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdSetVendorSpecificIE", + "EspHostedCmdSetVendorSpecificIE", + "EspHostedCmdSetVendorSpecificIE", + "", + sizeof(EspHostedCmdSetVendorSpecificIE), + 4, + esp_hosted_cmd_set_vendor_specific_ie__field_descriptors, + esp_hosted_cmd_set_vendor_specific_ie__field_indices_by_name, + 1, esp_hosted_cmd_set_vendor_specific_ie__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_set_vendor_specific_ie__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_set_vendor_specific_ie__field_descriptors[1] = +{ { "resp", - 3, + 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespScanResult, has_resp), - offsetof(EspHostedRespScanResult, resp), + offsetof(EspHostedRespSetVendorSpecificIE, has_resp), + offsetof(EspHostedRespSetVendorSpecificIE, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_scan_result__field_indices_by_name[] = { - 0, /* field[0] = count */ - 1, /* field[1] = entries */ - 2, /* field[2] = resp */ +static const unsigned esp_hosted_resp_set_vendor_specific_ie__field_indices_by_name[] = { + 0, /* field[0] = resp */ }; -static const ProtobufCIntRange esp_hosted_resp_scan_result__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_set_vendor_specific_ie__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 3 } + { 0, 1 } }; -const ProtobufCMessageDescriptor esp_hosted_resp_scan_result__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_set_vendor_specific_ie__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespScanResult", - "EspHostedRespScanResult", - "EspHostedRespScanResult", + "EspHostedRespSetVendorSpecificIE", + "EspHostedRespSetVendorSpecificIE", + "EspHostedRespSetVendorSpecificIE", "", - sizeof(EspHostedRespScanResult), - 3, - esp_hosted_resp_scan_result__field_descriptors, - esp_hosted_resp_scan_result__field_indices_by_name, - 1, esp_hosted_resp_scan_result__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_scan_result__init, + sizeof(EspHostedRespSetVendorSpecificIE), + 1, + esp_hosted_resp_set_vendor_specific_ie__field_descriptors, + esp_hosted_resp_set_vendor_specific_ie__field_indices_by_name, + 1, esp_hosted_resp_set_vendor_specific_ie__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_set_vendor_specific_ie__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_connected_stalist__field_descriptors[2] = +static const ProtobufCFieldDescriptor esp_hosted_cmd_set_wi_fi_maxtxpower__field_descriptors[1] = { { - "mac", + "wifi_max_tx_power", 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(EspHostedConnectedSTAList, has_mac), - offsetof(EspHostedConnectedSTAList, mac), + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedCmdSetWiFiMAXTXPower, has_wifi_max_tx_power), + offsetof(EspHostedCmdSetWiFiMAXTXPower, wifi_max_tx_power), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, +}; +static const unsigned esp_hosted_cmd_set_wi_fi_maxtxpower__field_indices_by_name[] = { + 0, /* field[0] = wifi_max_tx_power */ +}; +static const ProtobufCIntRange esp_hosted_cmd_set_wi_fi_maxtxpower__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "EspHostedCmdSetWiFiMAXTXPower", + "EspHostedCmdSetWiFiMAXTXPower", + "EspHostedCmdSetWiFiMAXTXPower", + "", + sizeof(EspHostedCmdSetWiFiMAXTXPower), + 1, + esp_hosted_cmd_set_wi_fi_maxtxpower__field_descriptors, + esp_hosted_cmd_set_wi_fi_maxtxpower__field_indices_by_name, + 1, esp_hosted_cmd_set_wi_fi_maxtxpower__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_set_wi_fi_maxtxpower__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor esp_hosted_resp_set_wi_fi_maxtxpower__field_descriptors[1] = +{ { - "rssi", - 2, + "resp", + 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedConnectedSTAList, has_rssi), - offsetof(EspHostedConnectedSTAList, rssi), + offsetof(EspHostedRespSetWiFiMAXTXPower, has_resp), + offsetof(EspHostedRespSetWiFiMAXTXPower, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_connected_stalist__field_indices_by_name[] = { - 0, /* field[0] = mac */ - 1, /* field[1] = rssi */ +static const unsigned esp_hosted_resp_set_wi_fi_maxtxpower__field_indices_by_name[] = { + 0, /* field[0] = resp */ }; -static const ProtobufCIntRange esp_hosted_connected_stalist__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_set_wi_fi_maxtxpower__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 2 } + { 0, 1 } }; -const ProtobufCMessageDescriptor esp_hosted_connected_stalist__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_set_wi_fi_maxtxpower__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedConnectedSTAList", - "EspHostedConnectedSTAList", - "EspHostedConnectedSTAList", + "EspHostedRespSetWiFiMAXTXPower", + "EspHostedRespSetWiFiMAXTXPower", + "EspHostedRespSetWiFiMAXTXPower", "", - sizeof(EspHostedConnectedSTAList), - 2, - esp_hosted_connected_stalist__field_descriptors, - esp_hosted_connected_stalist__field_indices_by_name, - 1, esp_hosted_connected_stalist__number_ranges, - (ProtobufCMessageInit) esp_hosted_connected_stalist__init, + sizeof(EspHostedRespSetWiFiMAXTXPower), + 1, + esp_hosted_resp_set_wi_fi_maxtxpower__field_descriptors, + esp_hosted_resp_set_wi_fi_maxtxpower__field_indices_by_name, + 1, esp_hosted_resp_set_wi_fi_maxtxpower__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_set_wi_fi_maxtxpower__init, NULL,NULL,NULL /* reserved[123] */ }; -#define esp_hosted_cmd_connected_sta__field_descriptors NULL -#define esp_hosted_cmd_connected_sta__field_indices_by_name NULL -#define esp_hosted_cmd_connected_sta__number_ranges NULL -const ProtobufCMessageDescriptor esp_hosted_cmd_connected_sta__descriptor = +#define esp_hosted_cmd_get_wi_fi_curr_txpower__field_descriptors NULL +#define esp_hosted_cmd_get_wi_fi_curr_txpower__field_indices_by_name NULL +#define esp_hosted_cmd_get_wi_fi_curr_txpower__number_ranges NULL +const ProtobufCMessageDescriptor esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedCmdConnectedSTA", - "EspHostedCmdConnectedSTA", - "EspHostedCmdConnectedSTA", + "EspHostedCmdGetWiFiCurrTXPower", + "EspHostedCmdGetWiFiCurrTXPower", + "EspHostedCmdGetWiFiCurrTXPower", "", - sizeof(EspHostedCmdConnectedSTA), + sizeof(EspHostedCmdGetWiFiCurrTXPower), 0, - esp_hosted_cmd_connected_sta__field_descriptors, - esp_hosted_cmd_connected_sta__field_indices_by_name, - 0, esp_hosted_cmd_connected_sta__number_ranges, - (ProtobufCMessageInit) esp_hosted_cmd_connected_sta__init, + esp_hosted_cmd_get_wi_fi_curr_txpower__field_descriptors, + esp_hosted_cmd_get_wi_fi_curr_txpower__field_indices_by_name, + 0, esp_hosted_cmd_get_wi_fi_curr_txpower__number_ranges, + (ProtobufCMessageInit) esp_hosted_cmd_get_wi_fi_curr_txpower__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_resp_connected_sta__field_descriptors[3] = +static const ProtobufCFieldDescriptor esp_hosted_resp_get_wi_fi_curr_txpower__field_descriptors[2] = { { - "num", + "wifi_curr_tx_power", 1, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT32, - offsetof(EspHostedRespConnectedSTA, has_num), - offsetof(EspHostedRespConnectedSTA, num), - NULL, + PROTOBUF_C_TYPE_INT32, + offsetof(EspHostedRespGetWiFiCurrTXPower, has_wifi_curr_tx_power), + offsetof(EspHostedRespGetWiFiCurrTXPower, wifi_curr_tx_power), NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "stations", - 2, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(EspHostedRespConnectedSTA, n_stations), - offsetof(EspHostedRespConnectedSTA, stations), - &esp_hosted_connected_stalist__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "resp", - 3, + 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - offsetof(EspHostedRespConnectedSTA, has_resp), - offsetof(EspHostedRespConnectedSTA, resp), + offsetof(EspHostedRespGetWiFiCurrTXPower, has_resp), + offsetof(EspHostedRespGetWiFiCurrTXPower, resp), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned esp_hosted_resp_connected_sta__field_indices_by_name[] = { - 0, /* field[0] = num */ - 2, /* field[2] = resp */ - 1, /* field[1] = stations */ +static const unsigned esp_hosted_resp_get_wi_fi_curr_txpower__field_indices_by_name[] = { + 1, /* field[1] = resp */ + 0, /* field[0] = wifi_curr_tx_power */ }; -static const ProtobufCIntRange esp_hosted_resp_connected_sta__number_ranges[1 + 1] = +static const ProtobufCIntRange esp_hosted_resp_get_wi_fi_curr_txpower__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 3 } + { 0, 2 } }; -const ProtobufCMessageDescriptor esp_hosted_resp_connected_sta__descriptor = +const ProtobufCMessageDescriptor esp_hosted_resp_get_wi_fi_curr_txpower__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "EspHostedRespConnectedSTA", - "EspHostedRespConnectedSTA", - "EspHostedRespConnectedSTA", + "EspHostedRespGetWiFiCurrTXPower", + "EspHostedRespGetWiFiCurrTXPower", + "EspHostedRespGetWiFiCurrTXPower", "", - sizeof(EspHostedRespConnectedSTA), - 3, - esp_hosted_resp_connected_sta__field_descriptors, - esp_hosted_resp_connected_sta__field_indices_by_name, - 1, esp_hosted_resp_connected_sta__number_ranges, - (ProtobufCMessageInit) esp_hosted_resp_connected_sta__init, + sizeof(EspHostedRespGetWiFiCurrTXPower), + 2, + esp_hosted_resp_get_wi_fi_curr_txpower__field_descriptors, + esp_hosted_resp_get_wi_fi_curr_txpower__field_indices_by_name, + 1, esp_hosted_resp_get_wi_fi_curr_txpower__number_ranges, + (ProtobufCMessageInit) esp_hosted_resp_get_wi_fi_curr_txpower__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor esp_hosted_config_payload__field_descriptors[29] = +static const ProtobufCFieldDescriptor esp_hosted_config_payload__field_descriptors[41] = { { "msg", @@ -2666,6 +3630,150 @@ static const ProtobufCFieldDescriptor esp_hosted_config_payload__field_descripto 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "cmd_ota_begin", + 38, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_ota_begin), + &esp_hosted_cmd_otabegin__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_ota_begin", + 39, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_ota_begin), + &esp_hosted_resp_otabegin__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "cmd_ota_write", + 40, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_ota_write), + &esp_hosted_cmd_otawrite__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_ota_write", + 41, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_ota_write), + &esp_hosted_resp_otawrite__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "cmd_ota_end", + 42, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_ota_end), + &esp_hosted_cmd_otaend__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_ota_end", + 43, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_ota_end), + &esp_hosted_resp_otaend__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "cmd_set_vendor_specific_ie", + 44, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_set_vendor_specific_ie), + &esp_hosted_cmd_set_vendor_specific_ie__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_set_vendor_specific_ie", + 45, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_set_vendor_specific_ie), + &esp_hosted_resp_set_vendor_specific_ie__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "cmd_set_wifi_max_tx_power", + 46, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_set_wifi_max_tx_power), + &esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_set_wifi_max_tx_power", + 47, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_set_wifi_max_tx_power), + &esp_hosted_resp_set_wi_fi_maxtxpower__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "cmd_get_wifi_curr_tx_power", + 48, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, cmd_get_wifi_curr_tx_power), + &esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "resp_get_wifi_curr_tx_power", + 49, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(EspHostedConfigPayload, payload_case), + offsetof(EspHostedConfigPayload, resp_get_wifi_curr_tx_power), + &esp_hosted_resp_get_wi_fi_curr_txpower__descriptor, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned esp_hosted_config_payload__field_indices_by_name[] = { 21, /* field[21] = cmd_connected_stas_list */ @@ -2674,12 +3782,18 @@ static const unsigned esp_hosted_config_payload__field_indices_by_name[] = { 1, /* field[1] = cmd_get_mac_address */ 27, /* field[27] = cmd_get_power_save_mode */ 11, /* field[11] = cmd_get_softap_config */ + 39, /* field[39] = cmd_get_wifi_curr_tx_power */ 3, /* field[3] = cmd_get_wifi_mode */ + 29, /* field[29] = cmd_ota_begin */ + 33, /* field[33] = cmd_ota_end */ + 31, /* field[31] = cmd_ota_write */ 19, /* field[19] = cmd_scan_ap_list */ 9, /* field[9] = cmd_set_ap_config */ 23, /* field[23] = cmd_set_mac_address */ 25, /* field[25] = cmd_set_power_save_mode */ 13, /* field[13] = cmd_set_softap_config */ + 35, /* field[35] = cmd_set_vendor_specific_ie */ + 37, /* field[37] = cmd_set_wifi_max_tx_power */ 5, /* field[5] = cmd_set_wifi_mode */ 17, /* field[17] = cmd_stop_softap */ 0, /* field[0] = msg */ @@ -2689,12 +3803,18 @@ static const unsigned esp_hosted_config_payload__field_indices_by_name[] = { 2, /* field[2] = resp_get_mac_address */ 28, /* field[28] = resp_get_power_save_mode */ 12, /* field[12] = resp_get_softap_config */ + 40, /* field[40] = resp_get_wifi_curr_tx_power */ 4, /* field[4] = resp_get_wifi_mode */ + 30, /* field[30] = resp_ota_begin */ + 34, /* field[34] = resp_ota_end */ + 32, /* field[32] = resp_ota_write */ 20, /* field[20] = resp_scan_ap_list */ 10, /* field[10] = resp_set_ap_config */ 24, /* field[24] = resp_set_mac_address */ 26, /* field[26] = resp_set_power_save_mode */ 14, /* field[14] = resp_set_softap_config */ + 36, /* field[36] = resp_set_vendor_specific_ie */ + 38, /* field[38] = resp_set_wifi_max_tx_power */ 6, /* field[6] = resp_set_wifi_mode */ 18, /* field[18] = resp_stop_softap */ }; @@ -2702,7 +3822,7 @@ static const ProtobufCIntRange esp_hosted_config_payload__number_ranges[2 + 1] = { { 1, 0 }, { 10, 1 }, - { 0, 29 } + { 0, 41 } }; const ProtobufCMessageDescriptor esp_hosted_config_payload__descriptor = { @@ -2712,7 +3832,7 @@ const ProtobufCMessageDescriptor esp_hosted_config_payload__descriptor = "EspHostedConfigPayload", "", sizeof(EspHostedConfigPayload), - 29, + 41, esp_hosted_config_payload__field_descriptors, esp_hosted_config_payload__field_indices_by_name, 2, esp_hosted_config_payload__number_ranges, @@ -2759,22 +3879,26 @@ const ProtobufCEnumDescriptor esp_hosted_encryption_mode__descriptor = esp_hosted_encryption_mode__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -static const ProtobufCEnumValue esp_hosted_status__enum_values_by_number[4] = +static const ProtobufCEnumValue esp_hosted_status__enum_values_by_number[6] = { { "TYPE_CONNECTED", "ESP_HOSTED_STATUS__TYPE_CONNECTED", 0 }, { "TYPE_NOT_CONNECTED", "ESP_HOSTED_STATUS__TYPE_NOT_CONNECTED", 1 }, { "TYPE_NO_AP_FOUND", "ESP_HOSTED_STATUS__TYPE_NO_AP_FOUND", 2 }, { "TYPE_CONNECTION_FAIL", "ESP_HOSTED_STATUS__TYPE_CONNECTION_FAIL", 3 }, + { "TYPE_INVALID_ARGUMET", "ESP_HOSTED_STATUS__TYPE_INVALID_ARGUMET", 4 }, + { "TYPE_OUT_OF_RANGE", "ESP_HOSTED_STATUS__TYPE_OUT_OF_RANGE", 5 }, }; static const ProtobufCIntRange esp_hosted_status__value_ranges[] = { -{0, 0},{0, 4} +{0, 0},{0, 6} }; -static const ProtobufCEnumValueIndex esp_hosted_status__enum_values_by_name[4] = +static const ProtobufCEnumValueIndex esp_hosted_status__enum_values_by_name[6] = { { "TYPE_CONNECTED", 0 }, { "TYPE_CONNECTION_FAIL", 3 }, + { "TYPE_INVALID_ARGUMET", 4 }, { "TYPE_NOT_CONNECTED", 1 }, { "TYPE_NO_AP_FOUND", 2 }, + { "TYPE_OUT_OF_RANGE", 5 }, }; const ProtobufCEnumDescriptor esp_hosted_status__descriptor = { @@ -2783,15 +3907,77 @@ const ProtobufCEnumDescriptor esp_hosted_status__descriptor = "EspHostedStatus", "EspHostedStatus", "", - 4, + 6, esp_hosted_status__enum_values_by_number, - 4, + 6, esp_hosted_status__enum_values_by_name, 1, esp_hosted_status__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -static const ProtobufCEnumValue esp_hosted_config_msg_type__enum_values_by_number[28] = +static const ProtobufCEnumValue esp_hosted_vendor_ietype__enum_values_by_number[5] = +{ + { "VND_IE_TYPE_BEACON", "ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_BEACON", 0 }, + { "VND_IE_TYPE_PROBE_REQ", "ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_PROBE_REQ", 1 }, + { "VND_IE_TYPE_PROBE_RESP", "ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_PROBE_RESP", 2 }, + { "VND_IE_TYPE_ASSOC_REQ", "ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_ASSOC_REQ", 3 }, + { "VND_IE_TYPE_ASSOC_RESP", "ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_ASSOC_RESP", 4 }, +}; +static const ProtobufCIntRange esp_hosted_vendor_ietype__value_ranges[] = { +{0, 0},{0, 5} +}; +static const ProtobufCEnumValueIndex esp_hosted_vendor_ietype__enum_values_by_name[5] = +{ + { "VND_IE_TYPE_ASSOC_REQ", 3 }, + { "VND_IE_TYPE_ASSOC_RESP", 4 }, + { "VND_IE_TYPE_BEACON", 0 }, + { "VND_IE_TYPE_PROBE_REQ", 1 }, + { "VND_IE_TYPE_PROBE_RESP", 2 }, +}; +const ProtobufCEnumDescriptor esp_hosted_vendor_ietype__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "EspHostedVendorIEType", + "EspHostedVendorIEType", + "EspHostedVendorIEType", + "", + 5, + esp_hosted_vendor_ietype__enum_values_by_number, + 5, + esp_hosted_vendor_ietype__enum_values_by_name, + 1, + esp_hosted_vendor_ietype__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; +static const ProtobufCEnumValue esp_hosted_ieid__enum_values_by_number[2] = +{ + { "VND_IE_ID_0", "ESP_HOSTED_IEID__VND_IE_ID_0", 0 }, + { "VND_IE_ID_1", "ESP_HOSTED_IEID__VND_IE_ID_1", 1 }, +}; +static const ProtobufCIntRange esp_hosted_ieid__value_ranges[] = { +{0, 0},{0, 2} +}; +static const ProtobufCEnumValueIndex esp_hosted_ieid__enum_values_by_name[2] = +{ + { "VND_IE_ID_0", 0 }, + { "VND_IE_ID_1", 1 }, +}; +const ProtobufCEnumDescriptor esp_hosted_ieid__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "EspHostedIEID", + "EspHostedIEID", + "EspHostedIEID", + "", + 2, + esp_hosted_ieid__enum_values_by_number, + 2, + esp_hosted_ieid__enum_values_by_name, + 1, + esp_hosted_ieid__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; +static const ProtobufCEnumValue esp_hosted_config_msg_type__enum_values_by_number[40] = { { "TypeCmdGetMACAddress", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetMACAddress", 0 }, { "TypeRespGetMACAddress", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetMACAddress", 1 }, @@ -2821,11 +4007,23 @@ static const ProtobufCEnumValue esp_hosted_config_msg_type__enum_values_by_numbe { "TypeRespSetPowerSaveMode", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetPowerSaveMode", 25 }, { "TypeCmdGetPowerSaveMode", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetPowerSaveMode", 26 }, { "TypeRespGetPowerSaveMode", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetPowerSaveMode", 27 }, + { "TypeCmdOTABegin", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTABegin", 28 }, + { "TypeRespOTABegin", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTABegin", 29 }, + { "TypeCmdOTAWrite", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAWrite", 30 }, + { "TypeRespOTAWrite", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAWrite", 31 }, + { "TypeCmdOTAEnd", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAEnd", 32 }, + { "TypeRespOTAEnd", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAEnd", 33 }, + { "TypeCmdSetVendorSpecificIE", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetVendorSpecificIE", 34 }, + { "TypeRespSetVendorSpecificIE", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetVendorSpecificIE", 35 }, + { "TypeCmdSetWiFiMAXTXPower", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetWiFiMAXTXPower", 36 }, + { "TypeRespSetWiFiMAXTXPower", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetWiFiMAXTXPower", 37 }, + { "TypeCmdGetWiFiCurrTXPower", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetWiFiCurrTXPower", 38 }, + { "TypeRespGetWiFiCurrTXPower", "ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetWiFiCurrTXPower", 39 }, }; static const ProtobufCIntRange esp_hosted_config_msg_type__value_ranges[] = { -{0, 0},{0, 28} +{0, 0},{0, 40} }; -static const ProtobufCEnumValueIndex esp_hosted_config_msg_type__enum_values_by_name[28] = +static const ProtobufCEnumValueIndex esp_hosted_config_msg_type__enum_values_by_name[40] = { { "TypeCmdDisconnectAP", 14 }, { "TypeCmdGetAPConfig", 6 }, @@ -2834,11 +4032,17 @@ static const ProtobufCEnumValueIndex esp_hosted_config_msg_type__enum_values_by_ { "TypeCmdGetMACAddress", 0 }, { "TypeCmdGetPowerSaveMode", 26 }, { "TypeCmdGetSoftAPConfig", 10 }, + { "TypeCmdGetWiFiCurrTXPower", 38 }, { "TypeCmdGetWiFiMode", 2 }, + { "TypeCmdOTABegin", 28 }, + { "TypeCmdOTAEnd", 32 }, + { "TypeCmdOTAWrite", 30 }, { "TypeCmdSetAPConfig", 8 }, { "TypeCmdSetMacAddress", 22 }, { "TypeCmdSetPowerSaveMode", 24 }, { "TypeCmdSetSoftAPConfig", 12 }, + { "TypeCmdSetVendorSpecificIE", 34 }, + { "TypeCmdSetWiFiMAXTXPower", 36 }, { "TypeCmdSetWiFiMode", 4 }, { "TypeCmdStopSoftAP", 16 }, { "TypeRespDisconnectAP", 15 }, @@ -2848,11 +4052,17 @@ static const ProtobufCEnumValueIndex esp_hosted_config_msg_type__enum_values_by_ { "TypeRespGetMACAddress", 1 }, { "TypeRespGetPowerSaveMode", 27 }, { "TypeRespGetSoftAPConfig", 11 }, + { "TypeRespGetWiFiCurrTXPower", 39 }, { "TypeRespGetWiFiMode", 3 }, + { "TypeRespOTABegin", 29 }, + { "TypeRespOTAEnd", 33 }, + { "TypeRespOTAWrite", 31 }, { "TypeRespSetAPConfig", 9 }, { "TypeRespSetMacAddress", 23 }, { "TypeRespSetPowerSaveMode", 25 }, { "TypeRespSetSoftAPConfig", 13 }, + { "TypeRespSetVendorSpecificIE", 35 }, + { "TypeRespSetWiFiMAXTXPower", 37 }, { "TypeRespSetWiFiMode", 5 }, { "TypeRespStopSoftAP", 17 }, }; @@ -2863,9 +4073,9 @@ const ProtobufCEnumDescriptor esp_hosted_config_msg_type__descriptor = "EspHostedConfigMsgType", "EspHostedConfigMsgType", "", - 28, + 40, esp_hosted_config_msg_type__enum_values_by_number, - 28, + 40, esp_hosted_config_msg_type__enum_values_by_name, 1, esp_hosted_config_msg_type__value_ranges, diff --git a/common/include/adapter.h b/common/include/adapter.h index 4c66df6829..3393d3cc76 100644 --- a/common/include/adapter.h +++ b/common/include/adapter.h @@ -4,18 +4,31 @@ #ifndef __ESP_NETWORK_ADAPTER__H #define __ESP_NETWORK_ADAPTER__H +#define PRIO_Q_SERIAL 0 +#define PRIO_Q_BT 1 +#define PRIO_Q_OTHERS 2 +#define MAX_PRIORITY_QUEUES 3 + +/* ESP Payload Header Flags */ +#define MORE_FRAGMENT (1 << 0) + struct esp_payload_header { - uint8_t if_type:4; - uint8_t if_num:4; - uint8_t reserved1; - uint16_t len; - uint16_t offset; - uint8_t reserved2; + uint8_t if_type:4; + uint8_t if_num:4; + uint8_t flags; + uint16_t len; + uint16_t offset; + uint16_t checksum; + uint16_t seq_num; + uint8_t reserved2; + /* Position of union field has to always be last, + * this is required for hci_pkt_type */ union { - uint8_t reserved3; - uint8_t hci_pkt_type; /* Packet type for HCI interface */ - uint8_t priv_pkt_type; /* Packet type for priv interface */ + uint8_t reserved3; + uint8_t hci_pkt_type; /* Packet type for HCI interface */ + uint8_t priv_pkt_type; /* Packet type for priv interface */ }; + /* Do no add anything here */ } __attribute__((packed)); typedef enum { @@ -63,4 +76,19 @@ struct esp_priv_event { uint8_t event_len; uint8_t event_data[0]; }__attribute__((packed)); + + +static inline uint16_t compute_checksum(uint8_t *buf, uint16_t len) +{ + uint16_t checksum = 0; + uint16_t i = 0; + + while(i < len) { + checksum += buf[i]; + i++; + } + + return checksum; +} + #endif diff --git a/common/include/esp_hosted_config.pb-c.h b/common/include/esp_hosted_config.pb-c.h index 538a6a6ce6..c7931ae17c 100644 --- a/common/include/esp_hosted_config.pb-c.h +++ b/common/include/esp_hosted_config.pb-c.h @@ -39,6 +39,18 @@ typedef struct _EspHostedRespScanResult EspHostedRespScanResult; typedef struct _EspHostedConnectedSTAList EspHostedConnectedSTAList; typedef struct _EspHostedCmdConnectedSTA EspHostedCmdConnectedSTA; typedef struct _EspHostedRespConnectedSTA EspHostedRespConnectedSTA; +typedef struct _EspHostedCmdOTABegin EspHostedCmdOTABegin; +typedef struct _EspHostedRespOTABegin EspHostedRespOTABegin; +typedef struct _EspHostedCmdOTAWrite EspHostedCmdOTAWrite; +typedef struct _EspHostedRespOTAWrite EspHostedRespOTAWrite; +typedef struct _EspHostedCmdOTAEnd EspHostedCmdOTAEnd; +typedef struct _EspHostedRespOTAEnd EspHostedRespOTAEnd; +typedef struct _EspHostedCmdSetVendorSpecificIE EspHostedCmdSetVendorSpecificIE; +typedef struct _EspHostedRespSetVendorSpecificIE EspHostedRespSetVendorSpecificIE; +typedef struct _EspHostedCmdSetWiFiMAXTXPower EspHostedCmdSetWiFiMAXTXPower; +typedef struct _EspHostedRespSetWiFiMAXTXPower EspHostedRespSetWiFiMAXTXPower; +typedef struct _EspHostedCmdGetWiFiCurrTXPower EspHostedCmdGetWiFiCurrTXPower; +typedef struct _EspHostedRespGetWiFiCurrTXPower EspHostedRespGetWiFiCurrTXPower; typedef struct _EspHostedConfigPayload EspHostedConfigPayload; @@ -59,9 +71,24 @@ typedef enum _EspHostedStatus { ESP_HOSTED_STATUS__TYPE_CONNECTED = 0, ESP_HOSTED_STATUS__TYPE_NOT_CONNECTED = 1, ESP_HOSTED_STATUS__TYPE_NO_AP_FOUND = 2, - ESP_HOSTED_STATUS__TYPE_CONNECTION_FAIL = 3 + ESP_HOSTED_STATUS__TYPE_CONNECTION_FAIL = 3, + ESP_HOSTED_STATUS__TYPE_INVALID_ARGUMET = 4, + ESP_HOSTED_STATUS__TYPE_OUT_OF_RANGE = 5 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(ESP_HOSTED_STATUS) } EspHostedStatus; +typedef enum _EspHostedVendorIEType { + ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_BEACON = 0, + ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_PROBE_REQ = 1, + ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_PROBE_RESP = 2, + ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_ASSOC_REQ = 3, + ESP_HOSTED_VENDOR_IETYPE__VND_IE_TYPE_ASSOC_RESP = 4 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(ESP_HOSTED_VENDOR_IETYPE) +} EspHostedVendorIEType; +typedef enum _EspHostedIEID { + ESP_HOSTED_IEID__VND_IE_ID_0 = 0, + ESP_HOSTED_IEID__VND_IE_ID_1 = 1 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(ESP_HOSTED_IEID) +} EspHostedIEID; typedef enum _EspHostedConfigMsgType { ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetMACAddress = 0, ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetMACAddress = 1, @@ -90,7 +117,19 @@ typedef enum _EspHostedConfigMsgType { ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetPowerSaveMode = 24, ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetPowerSaveMode = 25, ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetPowerSaveMode = 26, - ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetPowerSaveMode = 27 + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetPowerSaveMode = 27, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTABegin = 28, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTABegin = 29, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAWrite = 30, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAWrite = 31, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAEnd = 32, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAEnd = 33, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetVendorSpecificIE = 34, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetVendorSpecificIE = 35, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetWiFiMAXTXPower = 36, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetWiFiMAXTXPower = 37, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetWiFiCurrTXPower = 38, + ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetWiFiCurrTXPower = 39 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(ESP_HOSTED_CONFIG_MSG_TYPE) } EspHostedConfigMsgType; @@ -411,6 +450,140 @@ struct _EspHostedRespConnectedSTA , 0,0, 0,NULL, 0,0 } +struct _EspHostedCmdOTABegin +{ + ProtobufCMessage base; +}; +#define ESP_HOSTED_CMD_OTABEGIN__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_otabegin__descriptor) \ + } + + +struct _EspHostedRespOTABegin +{ + ProtobufCMessage base; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_OTABEGIN__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_otabegin__descriptor) \ + , 0,0 } + + +struct _EspHostedCmdOTAWrite +{ + ProtobufCMessage base; + protobuf_c_boolean has_ota_data; + ProtobufCBinaryData ota_data; +}; +#define ESP_HOSTED_CMD_OTAWRITE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_otawrite__descriptor) \ + , 0,{0,NULL} } + + +struct _EspHostedRespOTAWrite +{ + ProtobufCMessage base; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_OTAWRITE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_otawrite__descriptor) \ + , 0,0 } + + +struct _EspHostedCmdOTAEnd +{ + ProtobufCMessage base; +}; +#define ESP_HOSTED_CMD_OTAEND__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_otaend__descriptor) \ + } + + +struct _EspHostedRespOTAEnd +{ + ProtobufCMessage base; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_OTAEND__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_otaend__descriptor) \ + , 0,0 } + + +struct _EspHostedCmdSetVendorSpecificIE +{ + ProtobufCMessage base; + protobuf_c_boolean has_enable; + protobuf_c_boolean enable; + protobuf_c_boolean has_type; + EspHostedVendorIEType type; + protobuf_c_boolean has_idx; + EspHostedIEID idx; + protobuf_c_boolean has_vendor_ie_data; + ProtobufCBinaryData vendor_ie_data; +}; +#define ESP_HOSTED_CMD_SET_VENDOR_SPECIFIC_IE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_set_vendor_specific_ie__descriptor) \ + , 0,0, 0,0, 0,0, 0,{0,NULL} } + + +struct _EspHostedRespSetVendorSpecificIE +{ + ProtobufCMessage base; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_SET_VENDOR_SPECIFIC_IE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_set_vendor_specific_ie__descriptor) \ + , 0,0 } + + +struct _EspHostedCmdSetWiFiMAXTXPower +{ + ProtobufCMessage base; + protobuf_c_boolean has_wifi_max_tx_power; + int32_t wifi_max_tx_power; +}; +#define ESP_HOSTED_CMD_SET_WI_FI_MAXTXPOWER__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor) \ + , 0,0 } + + +struct _EspHostedRespSetWiFiMAXTXPower +{ + ProtobufCMessage base; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_SET_WI_FI_MAXTXPOWER__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_set_wi_fi_maxtxpower__descriptor) \ + , 0,0 } + + +struct _EspHostedCmdGetWiFiCurrTXPower +{ + ProtobufCMessage base; +}; +#define ESP_HOSTED_CMD_GET_WI_FI_CURR_TXPOWER__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor) \ + } + + +struct _EspHostedRespGetWiFiCurrTXPower +{ + ProtobufCMessage base; + protobuf_c_boolean has_wifi_curr_tx_power; + int32_t wifi_curr_tx_power; + protobuf_c_boolean has_resp; + int32_t resp; +}; +#define ESP_HOSTED_RESP_GET_WI_FI_CURR_TXPOWER__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&esp_hosted_resp_get_wi_fi_curr_txpower__descriptor) \ + , 0,0, 0,0 } + + typedef enum { ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD__NOT_SET = 0, ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_MAC_ADDRESS = 10, @@ -441,6 +614,18 @@ typedef enum { ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_POWER_SAVE_MODE = 35, ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_POWER_SAVE_MODE = 36, ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_POWER_SAVE_MODE = 37, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_BEGIN = 38, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_BEGIN = 39, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_WRITE = 40, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_WRITE = 41, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_END = 42, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_END = 43, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_VENDOR_SPECIFIC_IE = 44, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_VENDOR_SPECIFIC_IE = 45, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_WIFI_MAX_TX_POWER = 46, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_WIFI_MAX_TX_POWER = 47, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_WIFI_CURR_TX_POWER = 48, + ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_WIFI_CURR_TX_POWER = 49, } EspHostedConfigPayload__PayloadCase; struct _EspHostedConfigPayload @@ -478,6 +663,18 @@ struct _EspHostedConfigPayload EspHostedRespSetMode *resp_set_power_save_mode; EspHostedCmdGetMode *cmd_get_power_save_mode; EspHostedRespGetMode *resp_get_power_save_mode; + EspHostedCmdOTABegin *cmd_ota_begin; + EspHostedRespOTABegin *resp_ota_begin; + EspHostedCmdOTAWrite *cmd_ota_write; + EspHostedRespOTAWrite *resp_ota_write; + EspHostedCmdOTAEnd *cmd_ota_end; + EspHostedRespOTAEnd *resp_ota_end; + EspHostedCmdSetVendorSpecificIE *cmd_set_vendor_specific_ie; + EspHostedRespSetVendorSpecificIE *resp_set_vendor_specific_ie; + EspHostedCmdSetWiFiMAXTXPower *cmd_set_wifi_max_tx_power; + EspHostedRespSetWiFiMAXTXPower *resp_set_wifi_max_tx_power; + EspHostedCmdGetWiFiCurrTXPower *cmd_get_wifi_curr_tx_power; + EspHostedRespGetWiFiCurrTXPower *resp_get_wifi_curr_tx_power; }; }; #define ESP_HOSTED_CONFIG_PAYLOAD__INIT \ @@ -941,6 +1138,234 @@ EspHostedRespConnectedSTA * void esp_hosted_resp_connected_sta__free_unpacked (EspHostedRespConnectedSTA *message, ProtobufCAllocator *allocator); +/* EspHostedCmdOTABegin methods */ +void esp_hosted_cmd_otabegin__init + (EspHostedCmdOTABegin *message); +size_t esp_hosted_cmd_otabegin__get_packed_size + (const EspHostedCmdOTABegin *message); +size_t esp_hosted_cmd_otabegin__pack + (const EspHostedCmdOTABegin *message, + uint8_t *out); +size_t esp_hosted_cmd_otabegin__pack_to_buffer + (const EspHostedCmdOTABegin *message, + ProtobufCBuffer *buffer); +EspHostedCmdOTABegin * + esp_hosted_cmd_otabegin__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_otabegin__free_unpacked + (EspHostedCmdOTABegin *message, + ProtobufCAllocator *allocator); +/* EspHostedRespOTABegin methods */ +void esp_hosted_resp_otabegin__init + (EspHostedRespOTABegin *message); +size_t esp_hosted_resp_otabegin__get_packed_size + (const EspHostedRespOTABegin *message); +size_t esp_hosted_resp_otabegin__pack + (const EspHostedRespOTABegin *message, + uint8_t *out); +size_t esp_hosted_resp_otabegin__pack_to_buffer + (const EspHostedRespOTABegin *message, + ProtobufCBuffer *buffer); +EspHostedRespOTABegin * + esp_hosted_resp_otabegin__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_otabegin__free_unpacked + (EspHostedRespOTABegin *message, + ProtobufCAllocator *allocator); +/* EspHostedCmdOTAWrite methods */ +void esp_hosted_cmd_otawrite__init + (EspHostedCmdOTAWrite *message); +size_t esp_hosted_cmd_otawrite__get_packed_size + (const EspHostedCmdOTAWrite *message); +size_t esp_hosted_cmd_otawrite__pack + (const EspHostedCmdOTAWrite *message, + uint8_t *out); +size_t esp_hosted_cmd_otawrite__pack_to_buffer + (const EspHostedCmdOTAWrite *message, + ProtobufCBuffer *buffer); +EspHostedCmdOTAWrite * + esp_hosted_cmd_otawrite__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_otawrite__free_unpacked + (EspHostedCmdOTAWrite *message, + ProtobufCAllocator *allocator); +/* EspHostedRespOTAWrite methods */ +void esp_hosted_resp_otawrite__init + (EspHostedRespOTAWrite *message); +size_t esp_hosted_resp_otawrite__get_packed_size + (const EspHostedRespOTAWrite *message); +size_t esp_hosted_resp_otawrite__pack + (const EspHostedRespOTAWrite *message, + uint8_t *out); +size_t esp_hosted_resp_otawrite__pack_to_buffer + (const EspHostedRespOTAWrite *message, + ProtobufCBuffer *buffer); +EspHostedRespOTAWrite * + esp_hosted_resp_otawrite__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_otawrite__free_unpacked + (EspHostedRespOTAWrite *message, + ProtobufCAllocator *allocator); +/* EspHostedCmdOTAEnd methods */ +void esp_hosted_cmd_otaend__init + (EspHostedCmdOTAEnd *message); +size_t esp_hosted_cmd_otaend__get_packed_size + (const EspHostedCmdOTAEnd *message); +size_t esp_hosted_cmd_otaend__pack + (const EspHostedCmdOTAEnd *message, + uint8_t *out); +size_t esp_hosted_cmd_otaend__pack_to_buffer + (const EspHostedCmdOTAEnd *message, + ProtobufCBuffer *buffer); +EspHostedCmdOTAEnd * + esp_hosted_cmd_otaend__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_otaend__free_unpacked + (EspHostedCmdOTAEnd *message, + ProtobufCAllocator *allocator); +/* EspHostedRespOTAEnd methods */ +void esp_hosted_resp_otaend__init + (EspHostedRespOTAEnd *message); +size_t esp_hosted_resp_otaend__get_packed_size + (const EspHostedRespOTAEnd *message); +size_t esp_hosted_resp_otaend__pack + (const EspHostedRespOTAEnd *message, + uint8_t *out); +size_t esp_hosted_resp_otaend__pack_to_buffer + (const EspHostedRespOTAEnd *message, + ProtobufCBuffer *buffer); +EspHostedRespOTAEnd * + esp_hosted_resp_otaend__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_otaend__free_unpacked + (EspHostedRespOTAEnd *message, + ProtobufCAllocator *allocator); +/* EspHostedCmdSetVendorSpecificIE methods */ +void esp_hosted_cmd_set_vendor_specific_ie__init + (EspHostedCmdSetVendorSpecificIE *message); +size_t esp_hosted_cmd_set_vendor_specific_ie__get_packed_size + (const EspHostedCmdSetVendorSpecificIE *message); +size_t esp_hosted_cmd_set_vendor_specific_ie__pack + (const EspHostedCmdSetVendorSpecificIE *message, + uint8_t *out); +size_t esp_hosted_cmd_set_vendor_specific_ie__pack_to_buffer + (const EspHostedCmdSetVendorSpecificIE *message, + ProtobufCBuffer *buffer); +EspHostedCmdSetVendorSpecificIE * + esp_hosted_cmd_set_vendor_specific_ie__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_set_vendor_specific_ie__free_unpacked + (EspHostedCmdSetVendorSpecificIE *message, + ProtobufCAllocator *allocator); +/* EspHostedRespSetVendorSpecificIE methods */ +void esp_hosted_resp_set_vendor_specific_ie__init + (EspHostedRespSetVendorSpecificIE *message); +size_t esp_hosted_resp_set_vendor_specific_ie__get_packed_size + (const EspHostedRespSetVendorSpecificIE *message); +size_t esp_hosted_resp_set_vendor_specific_ie__pack + (const EspHostedRespSetVendorSpecificIE *message, + uint8_t *out); +size_t esp_hosted_resp_set_vendor_specific_ie__pack_to_buffer + (const EspHostedRespSetVendorSpecificIE *message, + ProtobufCBuffer *buffer); +EspHostedRespSetVendorSpecificIE * + esp_hosted_resp_set_vendor_specific_ie__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_set_vendor_specific_ie__free_unpacked + (EspHostedRespSetVendorSpecificIE *message, + ProtobufCAllocator *allocator); +/* EspHostedCmdSetWiFiMAXTXPower methods */ +void esp_hosted_cmd_set_wi_fi_maxtxpower__init + (EspHostedCmdSetWiFiMAXTXPower *message); +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__get_packed_size + (const EspHostedCmdSetWiFiMAXTXPower *message); +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__pack + (const EspHostedCmdSetWiFiMAXTXPower *message, + uint8_t *out); +size_t esp_hosted_cmd_set_wi_fi_maxtxpower__pack_to_buffer + (const EspHostedCmdSetWiFiMAXTXPower *message, + ProtobufCBuffer *buffer); +EspHostedCmdSetWiFiMAXTXPower * + esp_hosted_cmd_set_wi_fi_maxtxpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_set_wi_fi_maxtxpower__free_unpacked + (EspHostedCmdSetWiFiMAXTXPower *message, + ProtobufCAllocator *allocator); +/* EspHostedRespSetWiFiMAXTXPower methods */ +void esp_hosted_resp_set_wi_fi_maxtxpower__init + (EspHostedRespSetWiFiMAXTXPower *message); +size_t esp_hosted_resp_set_wi_fi_maxtxpower__get_packed_size + (const EspHostedRespSetWiFiMAXTXPower *message); +size_t esp_hosted_resp_set_wi_fi_maxtxpower__pack + (const EspHostedRespSetWiFiMAXTXPower *message, + uint8_t *out); +size_t esp_hosted_resp_set_wi_fi_maxtxpower__pack_to_buffer + (const EspHostedRespSetWiFiMAXTXPower *message, + ProtobufCBuffer *buffer); +EspHostedRespSetWiFiMAXTXPower * + esp_hosted_resp_set_wi_fi_maxtxpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_set_wi_fi_maxtxpower__free_unpacked + (EspHostedRespSetWiFiMAXTXPower *message, + ProtobufCAllocator *allocator); +/* EspHostedCmdGetWiFiCurrTXPower methods */ +void esp_hosted_cmd_get_wi_fi_curr_txpower__init + (EspHostedCmdGetWiFiCurrTXPower *message); +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__get_packed_size + (const EspHostedCmdGetWiFiCurrTXPower *message); +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__pack + (const EspHostedCmdGetWiFiCurrTXPower *message, + uint8_t *out); +size_t esp_hosted_cmd_get_wi_fi_curr_txpower__pack_to_buffer + (const EspHostedCmdGetWiFiCurrTXPower *message, + ProtobufCBuffer *buffer); +EspHostedCmdGetWiFiCurrTXPower * + esp_hosted_cmd_get_wi_fi_curr_txpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_cmd_get_wi_fi_curr_txpower__free_unpacked + (EspHostedCmdGetWiFiCurrTXPower *message, + ProtobufCAllocator *allocator); +/* EspHostedRespGetWiFiCurrTXPower methods */ +void esp_hosted_resp_get_wi_fi_curr_txpower__init + (EspHostedRespGetWiFiCurrTXPower *message); +size_t esp_hosted_resp_get_wi_fi_curr_txpower__get_packed_size + (const EspHostedRespGetWiFiCurrTXPower *message); +size_t esp_hosted_resp_get_wi_fi_curr_txpower__pack + (const EspHostedRespGetWiFiCurrTXPower *message, + uint8_t *out); +size_t esp_hosted_resp_get_wi_fi_curr_txpower__pack_to_buffer + (const EspHostedRespGetWiFiCurrTXPower *message, + ProtobufCBuffer *buffer); +EspHostedRespGetWiFiCurrTXPower * + esp_hosted_resp_get_wi_fi_curr_txpower__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void esp_hosted_resp_get_wi_fi_curr_txpower__free_unpacked + (EspHostedRespGetWiFiCurrTXPower *message, + ProtobufCAllocator *allocator); /* EspHostedConfigPayload methods */ void esp_hosted_config_payload__init (EspHostedConfigPayload *message); @@ -1034,6 +1459,42 @@ typedef void (*EspHostedCmdConnectedSTA_Closure) typedef void (*EspHostedRespConnectedSTA_Closure) (const EspHostedRespConnectedSTA *message, void *closure_data); +typedef void (*EspHostedCmdOTABegin_Closure) + (const EspHostedCmdOTABegin *message, + void *closure_data); +typedef void (*EspHostedRespOTABegin_Closure) + (const EspHostedRespOTABegin *message, + void *closure_data); +typedef void (*EspHostedCmdOTAWrite_Closure) + (const EspHostedCmdOTAWrite *message, + void *closure_data); +typedef void (*EspHostedRespOTAWrite_Closure) + (const EspHostedRespOTAWrite *message, + void *closure_data); +typedef void (*EspHostedCmdOTAEnd_Closure) + (const EspHostedCmdOTAEnd *message, + void *closure_data); +typedef void (*EspHostedRespOTAEnd_Closure) + (const EspHostedRespOTAEnd *message, + void *closure_data); +typedef void (*EspHostedCmdSetVendorSpecificIE_Closure) + (const EspHostedCmdSetVendorSpecificIE *message, + void *closure_data); +typedef void (*EspHostedRespSetVendorSpecificIE_Closure) + (const EspHostedRespSetVendorSpecificIE *message, + void *closure_data); +typedef void (*EspHostedCmdSetWiFiMAXTXPower_Closure) + (const EspHostedCmdSetWiFiMAXTXPower *message, + void *closure_data); +typedef void (*EspHostedRespSetWiFiMAXTXPower_Closure) + (const EspHostedRespSetWiFiMAXTXPower *message, + void *closure_data); +typedef void (*EspHostedCmdGetWiFiCurrTXPower_Closure) + (const EspHostedCmdGetWiFiCurrTXPower *message, + void *closure_data); +typedef void (*EspHostedRespGetWiFiCurrTXPower_Closure) + (const EspHostedRespGetWiFiCurrTXPower *message, + void *closure_data); typedef void (*EspHostedConfigPayload_Closure) (const EspHostedConfigPayload *message, void *closure_data); @@ -1045,6 +1506,8 @@ typedef void (*EspHostedConfigPayload_Closure) extern const ProtobufCEnumDescriptor esp_hosted_encryption_mode__descriptor; extern const ProtobufCEnumDescriptor esp_hosted_status__descriptor; +extern const ProtobufCEnumDescriptor esp_hosted_vendor_ietype__descriptor; +extern const ProtobufCEnumDescriptor esp_hosted_ieid__descriptor; extern const ProtobufCEnumDescriptor esp_hosted_config_msg_type__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_cmd_get_mac_address__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_resp_get_mac_address__descriptor; @@ -1070,6 +1533,18 @@ extern const ProtobufCMessageDescriptor esp_hosted_resp_scan_result__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_connected_stalist__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_cmd_connected_sta__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_resp_connected_sta__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_otabegin__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_otabegin__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_otawrite__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_otawrite__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_otaend__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_otaend__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_set_vendor_specific_ie__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_set_vendor_specific_ie__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_set_wi_fi_maxtxpower__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_set_wi_fi_maxtxpower__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_cmd_get_wi_fi_curr_txpower__descriptor; +extern const ProtobufCMessageDescriptor esp_hosted_resp_get_wi_fi_curr_txpower__descriptor; extern const ProtobufCMessageDescriptor esp_hosted_config_payload__descriptor; PROTOBUF_C__END_DECLS diff --git a/common/proto/README.md b/common/proto/README.md index 6acabdf859..24d35146e4 100644 --- a/common/proto/README.md +++ b/common/proto/README.md @@ -1,17 +1,18 @@ # About Proto Files -The `esp_hosted_config.proto` file is protobuf file which has messages for command and response to communicate between Host and ESP32. Using `esp_hosted_config.proto` file, protobuf generated C and python files are present in `esp/esp_driver/network_adapter/main` and `host/linux/host_control/python_support`. +The `esp_hosted_config.proto` file is protobuf file which has messages for command and response to communicate between Host and ESP32. Using `esp_hosted_config.proto` file, protobuf generated C files are [esp_hosted_config.pb-c.c](../esp_hosted_config.pb-c.c) and (esp_hosted_config.pb-c.h)[../include/esp_hosted_config.pb-c.h]. -User can add his own message field in `.proto` file and generate respective C and python files. +User can add his own message field in `.proto` file and generate respective C files. To generate C based protobuf files, run ``` -protoc-c esp_hosted_config.proto --c_out=../../esp/esp_driver/network_adapter/main/ -``` +cd /common/proto -To generate Python based protobuf files, run -``` -protoc esp_hosted_config.proto --python_out=../../host/linux/host_control/python_support/ +protoc-c esp_hosted_config.proto --c_out=. + +mv esp_hosted_config.pb-c.c ../ + +mv esp_hosted_config.pb-c.h ../include/ ``` -Existing control commands available for use. To send an new command, add python function in `host/linux/host_control/python_support/commands.py`. Similarly add respective C function in `esp/esp_driver/network_adapter/main/slave_commands.c` to handle added message field. User can test added functionality using `host/linux/host_control/python_support/test.py`. +Existing control commands available for use. To send an new command, add C function in `host/host_common/commands.c`, create python binding in `host/linux/host_control/python_support/commands_map_py_to_c.py` and its python function in `host/linux/host_control/python_support/commands_lib.py`. Similarly add respective ESP side C function in `esp/esp_driver/network_adapter/main/slave_commands.c` to handle added message field. User can test added functionality using `host/linux/host_control/python_support/test.py`. diff --git a/common/proto/esp_hosted_config.proto b/common/proto/esp_hosted_config.proto index edf0fbd322..68757c67ab 100644 --- a/common/proto/esp_hosted_config.proto +++ b/common/proto/esp_hosted_config.proto @@ -69,6 +69,8 @@ enum EspHostedStatus { TYPE_NOT_CONNECTED = 1; TYPE_NO_AP_FOUND = 2; TYPE_CONNECTION_FAIL = 3; + TYPE_INVALID_ARGUMET = 4; + TYPE_OUT_OF_RANGE = 5; } message EspHostedCmdSetAPConfig { @@ -142,6 +144,68 @@ message EspHostedRespConnectedSTA { int32 resp = 3; } +message EspHostedCmdOTABegin { +} + +message EspHostedRespOTABegin { + int32 resp = 1; +} + +message EspHostedCmdOTAWrite { + bytes ota_data = 1; +} + +message EspHostedRespOTAWrite { + int32 resp = 1; +} + +message EspHostedCmdOTAEnd { +} + +message EspHostedRespOTAEnd { + int32 resp = 1; +} + +enum EspHostedVendorIEType { + VND_IE_TYPE_BEACON = 0; + VND_IE_TYPE_PROBE_REQ = 1; + VND_IE_TYPE_PROBE_RESP = 2; + VND_IE_TYPE_ASSOC_REQ = 3; + VND_IE_TYPE_ASSOC_RESP = 4; +} + +enum EspHostedIEID { + VND_IE_ID_0 = 0; + VND_IE_ID_1 = 1; +} + +message EspHostedCmdSetVendorSpecificIE { + bool enable = 1; + EspHostedVendorIEType type = 2; + EspHostedIEID idx = 3; + bytes vendor_ie_data = 4; +} + +message EspHostedRespSetVendorSpecificIE { + int32 resp = 1; +} + +message EspHostedCmdSetWiFiMAXTXPower { + int32 wifi_max_tx_power = 1; +} + +message EspHostedRespSetWiFiMAXTXPower { + int32 resp = 1; +} + +message EspHostedCmdGetWiFiCurrTXPower { +} + +message EspHostedRespGetWiFiCurrTXPower { + int32 wifi_curr_tx_power = 1; + int32 resp = 2; +} + enum EspHostedConfigMsgType { TypeCmdGetMACAddress = 0; TypeRespGetMACAddress = 1; @@ -171,6 +235,18 @@ enum EspHostedConfigMsgType { TypeRespSetPowerSaveMode = 25; TypeCmdGetPowerSaveMode = 26; TypeRespGetPowerSaveMode = 27; + TypeCmdOTABegin = 28; + TypeRespOTABegin = 29; + TypeCmdOTAWrite = 30; + TypeRespOTAWrite = 31; + TypeCmdOTAEnd = 32; + TypeRespOTAEnd = 33; + TypeCmdSetVendorSpecificIE = 34; + TypeRespSetVendorSpecificIE = 35; + TypeCmdSetWiFiMAXTXPower = 36; + TypeRespSetWiFiMAXTXPower = 37; + TypeCmdGetWiFiCurrTXPower = 38; + TypeRespGetWiFiCurrTXPower = 39; } message EspHostedConfigPayload { @@ -204,5 +280,17 @@ message EspHostedConfigPayload { EspHostedRespSetMode resp_set_power_save_mode = 35; EspHostedCmdGetMode cmd_get_power_save_mode = 36; EspHostedRespGetMode resp_get_power_save_mode = 37; + EspHostedCmdOTABegin cmd_ota_begin = 38; + EspHostedRespOTABegin resp_ota_begin = 39; + EspHostedCmdOTAWrite cmd_ota_write = 40; + EspHostedRespOTAWrite resp_ota_write = 41; + EspHostedCmdOTAEnd cmd_ota_end = 42; + EspHostedRespOTAEnd resp_ota_end = 43; + EspHostedCmdSetVendorSpecificIE cmd_set_vendor_specific_ie = 44; + EspHostedRespSetVendorSpecificIE resp_set_vendor_specific_ie = 45; + EspHostedCmdSetWiFiMAXTXPower cmd_set_wifi_max_tx_power = 46; + EspHostedRespSetWiFiMAXTXPower resp_set_wifi_max_tx_power = 47; + EspHostedCmdGetWiFiCurrTXPower cmd_get_wifi_curr_tx_power = 48; + EspHostedRespGetWiFiCurrTXPower resp_get_wifi_curr_tx_power = 49; } } diff --git a/docs/Linux_based_host/Getting_started.md b/docs/Linux_based_host/Getting_started.md index db2a0ee045..42a81a4241 100644 --- a/docs/Linux_based_host/Getting_started.md +++ b/docs/Linux_based_host/Getting_started.md @@ -32,7 +32,6 @@ $ cd host/linux/host_control/python_support/ --- * **Connect to external access point** * `station_connect.py` script configures ESP peripheral in WiFi station mode and connects to an external AP with user-provided credentials. - * This script also runs DHCP client that obtains IP address from an external AP. * The script accepts arguments such as SSID, password, optionally BSSID of an external AP, wpa3 support and listen interval (AP beacon intervals). For example: ``` $ python station_connect.py 'xyz' 'xyz123456' --bssid='e5:6c:67:3c:cf:65' --is_wpa3_supported=True --listen_interval=3 @@ -40,8 +39,16 @@ $ cd host/linux/host_control/python_support/ :warning:`Note: WPA3 option is only applicable if target AP supports WPA3.` * As an end result of this script: * Wi-Fi station interface of ESP peripheral will be connected to an external AP - * `ethsta0` interface will be up and it will also have an IP address - * Network data path will be open for higher applications to use this interface for data communication + * `ethsta0` interface will be up and ESP32's MAC address will be assigned to it. + +Note: +* User needs to run DHCP client to obtain IP address from an external AP. After that network data path will be open for higher applications to use this interface for data communication. For an example as below. + +``` +sudo dhclient ethsta0 -r + +sudo dhclient ethsta0 -v +``` --- * **Disconnect from external access point** * `station_disconnect.py` script disconnects ESP peripheral station from an external AP. @@ -49,7 +56,7 @@ $ cd host/linux/host_control/python_support/ $ python station_disconnect.py ``` * As an end result of this script: - * `ethsta0` interface will be in down state and it won't have IP address + * `ethsta0` interface will be in down state * Network data path will be in closed state, hence there won't be any data communication on this interface #### 1.1.2 Wi-Fi softAP Mode Operations @@ -71,7 +78,13 @@ $ cd host/linux/host_control/python_support/ * As an end result of this script: * SoftAP interface will be up and running on ESP peripheral * `ethap0` interface will be in `up` state - * To start data connection, set up a DHCP server on the Raspberry Pi, or configure a static IP address for AP interface (`ethap0`). + * To start data connection, set up a DHCP server on the Raspberry Pi, or configure a static IP address for AP interface (`ethap0`). For an example as below: + +``` +sudo dnsmasq --no-daemon --no-resolv --no-poll --dhcp-script=/system/bin/dhcp_announce --dhcp-range=192.168.4.1,192.168.4.20,1h + +sudo ifconfig ethap0 192.168.4.5 +``` --- * **Stop softAP** * `softap_stop.py` script disables wifi softAP mode on ESP peripheral. @@ -103,6 +116,12 @@ hci0: Type: Primary Bus: SDIO * This interface supports all standard HCI commands. Use standard hci tools to control and configure this interface. ### 2.1 BT/BLE Test procedure + +* ESP-Hosted related BR/EDR 4.2 and BLE 4.2 functionalities are tested with `bluez` 5.43+. +Whereas BLE 5.0 functionalities are tested with `bluez` 5.45+. +* We suggest latest stable `bluez` version to be used. Any other bluetooth stack instead of `bluez` also could be used. +* To upgrade `bluez` for particular version, follow this [link](https://scribles.net/updating-bluez-on-raspberry-pi-from-5-43-to-5-50/). Replace bluez `older version` to `expected version` while following mentioned link. + #### 2.1.1 GATT server 1. Go to `bluez-5.xx` folder. Run `./test/example-gatt-server`. This will start GATT server on Raspberry-Pi. @@ -129,8 +148,138 @@ Run `hcitool scan` for BT device scanning. Run `hcitool lescan` for BLE device scanning. +### 2.2 BLE 5.0 testing + +Only ESP32C3 HCI controller supports BLE 5.0. Several new features are introduced in BLE 5.0. The major areas of improvement are: +1. Slot Availability Mask (SAM) +2. 2 Msym/s PHY for LE +3. LE Long Range +4. High Duty Cycle Non-Connectable Advertising +5. LE Advertising Extensions +6. LE Channel Selection Algorithm #2 + +To test BLE 5.0 on RPi minimum `bluez` version `5.45` and above required. If `bluez` version is less than 5.45 ,then upgrade `bluez` version. + +Check current `bluez` version by running following command on RPi: + +``` +bluetoothctl -v +``` +:warning: `hcitool lescan` is deprecated. Please dont use it. + +### 2.2.1 Basic scan, pair, connect + +Execute following steps on linux host. +Steps: +1. Run `sudo bluetoothctl`. +2. To Turn on power, run `power on`. +3. Make device discoverable, run `discoverable on`. +4. Make device pairable on, run `pairable on`. +5. Set current agent to default, run `default-agent`. +6. Turn on bluetooth support, run `agent on`. +7. Start btmon to collect log in separate terminal window, run `sudo btmon &`. +8. Turn on mobile phone's bluetooth so that linux host can detect it. +9. Start scanning, run `scan on` in bluetoothctl window. +10. Once mobile phone's MAC address is listed in scan list, stop scanning, run `scan off`. +11. To trust, run `trust `. +12. To pair, run `pair `. +13. To connect, run `connect `. +14. Once connected, please run `discoverable off`. + +#### 2.2.2 GATT Server + +BLE 5.0 has backword compability. It can connect with BLE4.2 devices. +Below example demonstrate linux host as GATT server and mobile phone as GATT client. We are using `nRF connect` application for GATT client operartion. + +Execute following steps on linux host. +Steps: +1. Run `sudo bluetoothctl`. +2. Run `list` to get MAC address of ESP32. +3. To set device name, run `menu advertise`. Then `name `. +4. To come back to main menu, run `back`. +5. To start advertising, run `advertise on`. +Perform below steps on Mobile Phone: +6. Turn on mobile phone's bluetooth. Open nRF connect application, ESP32's MAC address will be displayed under `SCANNER` tab as a result of scan. +7. Click on connect. Client tab will be open. Click on `Generic Attribute` option. +8. Perform read/write on listed characteristics fields in `Generic Attribute` service. +To disconnet: +9. Run `disconnect ` on linux host's `bluetoothctrl` OR click on `DISCONNECT` in nRF connect application's `GATT client` screen. + +#### 2.2.3 GATT client + +BLE 5.0 has backword compability. It can connect with BLE4.2 devices. +Below example demonstrate linux host as GATT client and mobile phone as GATT server. We are using `nRF connect` application for GATT server operartion. + +Execute following steps on linux host. +Steps: +1. Run `sudo bluetoothctl`. +2. To Turn on power, run `power on`. +3. Make device discoverable, run `discoverable on`. +4. Make device pairable, run `pairable on`. +5. Set current agent to default, run `default-agent`. +6. Turn on bluetooth support, run `agent on`. +7. Turn on mobile phone's bluetooth so that linux host can detect it. +8. Start scanning, run `scan on`. +9. Once mobile phone's MAC address is listed in scan list, stop scanning, run `scan off`. +10. Start btmon to collect log in separate terminal window, run `sudo btmon &`. +11. To trust, run `trust `. +12. To pair, run `pair `. +13. To connect, run `connect `. +14. Once connected, please run `discoverable off`. +15. Go to gatt menu, run `menu gatt`. +16. list available attributes, run `list-attributes`. +17. select characteristic of service, run `select-attribute `. +18. perform read/write operation on selected characteristic. +19. To disconnect, run `disconnect `. + +#### 2.2.4 1M, 2M, CODED phy for LE + +BLE5.0 supports 1M, 2M and CODED phy. To use 2M and CODED phy for gatt read/write procedure as follow: + +Note: +* Default selected phy is 1M. To perform gatt read/write with BLE5.0 peripheral, both host and peripheral must have same phy configuration. + +* 'PHY' feature in BLE 5.0 is verified with btmgmt tool from bluez version 5.56+. + +* If `bluez` version is less than 5.56 ,then upgrade `bluez` version. + +##### Using 1M phy: +1M phy is default phy for BLE5.0. Follow above mentioned steps in section 2.2.1 +for connection. After connection follow gatt read/write from gatt menu in bluetoothctl. + +##### Using 2M phy: +2M phy can not use for connection in BLE5.0 . So configure phy as 1M and 2M both, make connection with other BLE5.0 device and then set phy as 2M. On peripheral side make primary phy as 1M and secondary phy as 2M. + +Steps: +1. To configure phy as 1M and 2M both, run `sudo hcitool cmd 08 31 03 03 03`. +2. To check selected phy, Go to `bluez-5.56` directory. Run `sudo ./tools/btmgmt --index hci0` and run `phy`. +3. Connect to BLE5.0 device using above mentioned steps in section 2.2.1. +4. while executing connect command, there is `LE Enhanced Connection Complete` event in `btmon` log. Note down `handle` value. +5. After connection, exit form bluetoothctl. Run `exit` in bluetoothctl. +6. Now configure phy into 2M. Run `sudo hcitool cmd 08 32 03 02 02 00`. +7. Follow gatt read/write from `gatt menu` in bluetoothctl. + +##### Using CODED phy: +Configure CODED phy on host and peripheral side. + +Steps: +1. To configure phy as CODED phy, run `sudo hcitool cmd 08 31 03 04 04`. +2. To check selected phy, Go to `bluez-5.56` directory. Run `sudo ./tools/btmgmt --index hci0` and run `phy`. +3. Connect to BLE5.0 device using above mentioned steps in section 2.2.1. +4. Follow gatt read/write from gatt menu in bluetoothctl. + +## 3. OTA operation + +OTA (Over The Air) update performs following operations. +* Erase ota flash partition of ESP32 +* Download chunk from URL and write that chunk into flash, one by one, till whole binary is written +* Validate the complete written binary in flash +* Sets newly written OTA partition as boot partition +* Reboot the ESP32 after 5 second + +Please follow [OTA update documentation](ota_update.md) for further details. -## 3. Troubleshoot Instructions +## 4. Troubleshoot Instructions Please refer following for troubleshoot instructions if something goes wrong. diff --git a/docs/Linux_based_host/Linux_based_architecture.md b/docs/Linux_based_host/Linux_based_architecture.md index c8fcb8bc66..670223a9ce 100644 --- a/docs/Linux_based_host/Linux_based_architecture.md +++ b/docs/Linux_based_host/Linux_based_architecture.md @@ -41,8 +41,8 @@ This registers HCI interface with Linux kernel. This interface is implemented ov * These commands are used to control and configure Wi-Fi on ESP peripheral. * Control interface makes use of virtual serial interface provided by ESP Host driver. * There are 2 flavors of control interface implementation: - * Python based implementation * C based implementation + * Python based implementation - It uses C based implementation using `ctypes` package. * API's are described in subsequent section --- @@ -127,3 +127,12 @@ Following are few ready to use convenience script provided in the repository. Th python connected_stations_list.py ``` +* **OTA update** + `ota_update.py` script updates ESP32 firmware with provided URL of binary file. This script will perform following operation. + - Erase ota flash partition of ESP32 + - Download chunk from URL and write that chunk into flash, one by one, till whole binary is written + - Validate the complete written binary in flash + - Sets newly written OTA partition as boot partition + - Reboot the ESP32 after 5 second + + Please refer [ota](ota_update.md) for detailed documentation. diff --git a/docs/Linux_based_host/Linux_based_readme.md b/docs/Linux_based_host/Linux_based_readme.md index da15e44ee3..82d7c46a03 100644 --- a/docs/Linux_based_host/Linux_based_readme.md +++ b/docs/Linux_based_host/Linux_based_readme.md @@ -44,20 +44,10 @@ Make sure that Raspberry-Pi is equipped with following: * Python 2.x or 3.x ```sh $ sudo apt install python - $ sudo apt install python-pip ``` or ```sh $ sudo apt install python3 - $ sudo apt install python3-pip - ``` - * Protobuf - ```sh - $ pip install protobuf - ``` - or - ```sh - $ pip3 install protobuf ``` * Clone ESP-Hosted code repository ``` @@ -107,6 +97,22 @@ Prepare connections based on interface requirements and setup host as below. * After loading ESP firmware, execute below command to create `hci0` interface ```sh $ sudo hciattach -s 921600 /dev/serial0 any 921600 flow + +* **Wifi over SPI and Bluetooth over UART** + * Connection Setup + * Prepare connections as per section [1.1 Hardware Setup](SPI_setup.md#11-hardware-setup) of [SPI Setup document](SPI_setup.md) + * Prepare UART connections as per section [1.1 Hardware Setup](UART_setup.md#11-hardware-setup) of [UART setup document](UART_setup.md) + * Host Software + * Prepare Raspberry-Pi as per [1.2 Raspberry-Pi Software Setup](SPI_setup.md#12-raspberry-pi-software-setup) of [SPI Setup document](SPI_setup.md) + * Prepare Raspberry-Pi for UART operations as per section [1.2 Raspberry-Pi Software Setup](UART_setup.md#12-raspberry-pi-software-setup) of [UART setup document](UART_setup.md) + * Compile and load host driver as below: + ```sh + $ cd host/linux/host_control/ + $ ./rpi_init.sh spi btuart + ``` + * After loading ESP firmware, execute below command to create `hci0` interface + ```sh + $ sudo hciattach -s 921600 /dev/serial0 any 921600 flow ``` #### 1.3.1 ESP Firmware Setup @@ -183,20 +189,14 @@ This section identifies Raspberry-Pi specific setup requirements. * Install following tools on Linux Host machine. * Git * Python 2.x or 3.x: We have tested ESP-Hosted solution with python 2.7.13 and 3.5.3 - * Protobuf: - :warning:`Note: We have tested ESP-Hosted solution with Protobuf version >= 3.13.0` - ``` - $ pip install protobuf - or - $ pip3 install protobuf - ``` - * Bluetooth Stack and utilities: - :warning:`Note: We have tested ESP-Hosted solution with bluez 5.43+` + * Bluetooth Stack and utilities: + :warning:`Note: ESP-Hosted related BR/EDR 4.2 and BLE 4.2 functionalities are tested with bluez 5.43+. Whereas BLE 5.0 functionalities are tested with bluez 5.45+.` * bluetooth * bluez * bluez-tools * rfkill * bluez-firmware + * We suggest latest stable bluez version to be used. Any other bluetooth stack instead of bluez also could be used. ### 2.2 ESP-IDF Setup :warning:`Note: ESP-IDF is needed to compile ESP-Hosted firmware source. Skip this step if you are planning to use pre-built release binaries.` @@ -208,6 +208,7 @@ ESP-IDF release version to be used for ESP peripherals are | ESP32 | release v4.0 | | ESP32-S2 | release v4.2 | | ESP32-C3 | release v4.3 | +| ESP32-C3 (HCI over UART)| release v4.4 (beta)| Clone appropriate ESP-IDF version as per your ESP peripheral. The control path between Linux host and ESP peripheral is based on `protobuf`. For that, corresponding stack layer, `protocomm` from ESP-IDF is used. Run following command in ESP-IDF directory to make `protocomm_priv.h` available for control path. ``` diff --git a/docs/Linux_based_host/SPI_setup.md b/docs/Linux_based_host/SPI_setup.md index b115018814..af78fbe167 100644 --- a/docs/Linux_based_host/SPI_setup.md +++ b/docs/Linux_based_host/SPI_setup.md @@ -8,12 +8,12 @@ Raspberry-Pi pinout can be found [here!](https://pinout.xyz/pinout/spi) #### 1.1.1 ESP32 setup | Raspberry-Pi Pin | ESP32 Pin | Function | |:-------:|:---------:|:--------:| -| 24 | IO5 | CS0 | -| 23 | IO18 | SCLK | -| 21 | IO19 | MISO | -| 19 | IO23 | MOSI | +| 24 | IO15 | CS0 | +| 23 | IO14 | SCLK | +| 21 | IO12 | MISO | +| 19 | IO13 | MOSI | | 25 | GND | Ground | -| 11 | IO2 | Handshake | +| 15 | IO2 | Handshake | | 13 | IO4 | Data Ready | | 31 | EN | ESP32 Reset | @@ -29,7 +29,7 @@ Setup image is here. | 21 | IO13 | MISO | | 19 | IO11 | MOSI | | 25 | GND | Ground | -| 11 | IO2 | Handshake | +| 15 | IO2 | Handshake | | 13 | IO4 | Data ready | | 31 | RST | ESP32 Reset | @@ -45,7 +45,7 @@ Setup image is here. | 21 | IO02 | MISO | | 19 | IO07 | MOSI | | 25 | GND | Ground | -| 11 | IO03 | Handshake | +| 15 | IO03 | Handshake | | 13 | IO04 | Data ready | | 31 | RST | ESP32 Reset | @@ -59,9 +59,13 @@ The SPI master driver is disabled by default on Raspberry-Pi OS. To enable it ad dtparam=spi=on dtoverlay=disable-bt ``` +In addition, below options are set as the SPI clock frequency in analyzer is observed to be smaller than expected clock. This is RaspberryPi specific [issue](https://github.com/raspberrypi/linux/issues/2286). +``` +core_freq=250 +core_freq_min=250 +``` Please reboot Raspberry-Pi after changing this file. - ## 2. Load ESP-Hosted Solution ### 2.1 Host Software * Execute following commands in root directory of cloned ESP-Hosted repository on Raspberry-Pi @@ -105,6 +109,20 @@ Where, ``` * This command will flash `SPI` interface binaries on `esp32s2` chip. +##### ESP32-C3 +```sh +$ python esptool.py --port --baud 960000 --before default_reset --after hard_reset \ +--chip esp32c3 write_flash --flash_mode dio --flash_size detect --flash_freq 80m \ +0x0 esp_hosted_bootloader_esp32c3_spi_v.bin \ +0x8000 esp_hosted_partition-table_esp32c3_spi_v.bin \ +0x10000 esp_hosted_firmware_esp32c3_spi_v.bin + +Where, + : serial port of ESP peripheral + : 0.1,0.2 etc. Latest from [release page](https://github.com/espressif/esp-hosted/releases) +``` +* This command will flash `SPI` interface binaries on `esp32c3` chip. + * Windows user can use ESP Flash Programming Tool to flash the pre-built binary. #### 2.2.2 Source Compilation @@ -115,23 +133,33 @@ Where, ```sh $ cd esp/esp_driver/network_adapter ``` + ##### Using cmake -* Set target if the ESP32S2 is being used. Skip if ESP32 is being used. + +* :warning: `Set target if the ESP32S2 or ESP32C3 is being used. Skip if ESP32 is being used.` ``` $ idf.py set-target esp32s2 ``` +or +``` +$ idf.py set-target esp32c3 +``` + * Execute following command to configure project ```sh $ idf.py menuconfig ``` * This will open project configuration window. To select SPI transport interface, navigate to `Example Configuration -> Transport layer -> SPI interface -> select` and exit from menuconfig. + +* For ESP32C3, select chip revision in addition. Navigate to `Component config → ESP32C3-Specific → Minimum Supported ESP32-C3 Revision` and select chip version of ESP32C3. + * Use below command to compile and flash the project. Replace with ESP peripheral's serial port. ```sh $ idf.py -p build flash ``` ##### Using make -:warning: *make* build system is only supported till ESP32. Please refer cmake section above for ESP32-S2. +:warning: *make* build system is only supported till ESP32. Please refer cmake section above for ESP32-S2 and ESP32-C3. * Execute following command to configure project ```sh $ make menuconfig diff --git a/docs/Linux_based_host/UART_setup.md b/docs/Linux_based_host/UART_setup.md index c5eb80a79b..e904a0d94b 100644 --- a/docs/Linux_based_host/UART_setup.md +++ b/docs/Linux_based_host/UART_setup.md @@ -1,10 +1,13 @@ # Bluetooth/BLE connectivity Setup over UART -This section is only applicable to ESP32 boards. ESP32-S2 does not support Bluetooth/BLE. +This section is only applicable to ESP32 and ESP32C3 boards. ESP32-S2 does not support Bluetooth/BLE. ## 1. Setup ### 1.1 Hardware Setup In this setup, ESP32 board provides Bluetooth/BLE capabilities to host over UART interface. Please connect ESP peripheral to Raspberry-Pi with jumper cables as mentioned below. It may be good to use small length cables to ensure signal integrity. Power ESP32 and Raspberry Pi separately with a power supply that provide sufficient power. ESP32 can be powered through PC using micro-USB cable. +Raspberry-Pi pinout can be found [here!](https://pinout.xyz/pinout/uart) + +#### 1.1.1 ESP32 setup | Raspberry-Pi Pin Function | Raspberry-Pi Pin | ESP32 Pin | ESP32 Pin Function | |:-------:|:--------:|:---------:|:--------:| | RX | 10 | IO5 | TX | @@ -13,7 +16,22 @@ In this setup, ESP32 board provides Bluetooth/BLE capabilities to host over UART | RTS | 11 | IO23 | CTS | | Ground | 39 | GND | Ground | -Raspberry-Pi pinout can be found [here!](https://pinout.xyz/pinout/uart) +Setup image is here. + +![alt text](rpi_esp32_uart_setup.jpg "setup of Raspberry-Pi as host and ESP32 as slave with UART transport") + +#### 1.1.2 ESP32-C3 setup +| Raspberry-Pi Pin Function | Raspberry-Pi Pin | ESP32C3 Pin | ESP32C3 Pin Function | +|:-------:|:--------:|:---------:|:--------:| +| RX | 10 | IO5 | TX | +| TX | 8 | IO18 | RX | +| CTS | 36 | IO19 | RTS | +| RTS | 11 | IO8 | CTS | +| Ground | 39 | GND | Ground | + +Setup image is here. + +![alt text](rpi_esp32c3_uart_setup.jpg "setup of Raspberry-Pi as host and ESP32C3 as slave with UART transport") ### 1.2 Raspberry-Pi Software Setup By default, the UART pins on Raspberry-Pi are in disabled state. In order to enable UART and setup it for bluetooth connection, follow below steps. @@ -55,20 +73,41 @@ One can load pre-built release binaries on ESP peripheral or compile those from #### 2.2.1 Load Pre-built Release Binaries * Download pre-built firmware binaries from [releases](https://github.com/espressif/esp-hosted/releases) -* Please note that this binary is made for UART baudrate of 921600. * Linux users can run below command to flash these binaries. Edit with ESP peripheral's serial port. + +##### ESP32 +* Please note that this binary is made for UART baudrate of 921600. ```sh -$ python esptool.py --chip esp32 --port --baud 960000 --before default_reset \ +$ python esptool.py --chip esp32 --port --baud --before default_reset \ --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \ -0x1000 esp_hosted_bootloader_esp32_sdio_uart_v.bin \ -0x10000 esp_hosted_firmware_esp32_sdio_uart_v.bin \ -0x8000 esp_hosted_partition-table_esp32_sdio_uart_v.bin +0x1000 esp_hosted_bootloader_esp32__uart_v.bin \ +0xd000 esp_hosted_ota_data_initial_esp32__v.bin \ +0x10000 esp_hosted_firmware_esp32__uart_v.bin \ +0x8000 esp_hosted_partition-table_esp32__uart_v.bin + +Where, + : serial port of ESP peripheral + : 0.1,0.2 etc. Latest from [release page](https://github.com/espressif/esp-hosted/releases) + : sdio or spi +``` +* This command will flash `SDIO+UART` or `SPI+UART` interface binaries on `esp32` chip. + +##### ESP32-C3 +* Please note that this binary is made for UART baudrate of 921600. + +```sh +$ python esptool.py --port --baud --before default_reset --after hard_reset \ +--chip esp32c3 write_flash --flash_mode dio --flash_size detect --flash_freq 80m \ +0x0 esp_hosted_bootloader_esp32c3_spi_v.bin \ +0xd000 esp_hosted_ota_data_initial_esp32c3_spi_v.bin \ +0x8000 esp_hosted_partition-table_esp32c3_spi_v.bin \ +0x10000 esp_hosted_firmware_esp32c3_spi_v.bin \ Where, : serial port of ESP peripheral : 0.1,0.2 etc. Latest from [release page](https://github.com/espressif/esp-hosted/releases) ``` -* This command will flash `SDIO+UART` interface binaries on `esp32` chip. +* This command will flash `SPI+UART` interface binaries on `esp32c3` chip. * Windows user can use ESP Flash Programming Tool to flash the pre-built binary. @@ -81,25 +120,29 @@ $ cd esp/esp_driver/network_adapter ``` ##### Using cmake -* Set target if the ESP32S2 is being used. Skip if ESP32 is being used. + +* :warning: `Set target if the ESP32C3 is being used. Skip if ESP32 is being used.` ``` -$ idf.py set-target esp32s2 +$ idf.py set-target esp32c3 ``` -* Execute following command to configure the project + +* Execute following command to configure project ```sh $ idf.py menuconfig ``` -* This will open project configuration window. - * Navigate to `Component config -> Bluetooth -> Bluetooth controller -> HCI mode -> UART(H4) -> select` - * Also to set baud rate by navigating to, `Component config -> Bluetooth -> Bluetooth controller -> HCI UART(H4) Options -> UART Baudrate for HCI -> -> Ok` - * exit from menuconfig. +* This will open project configuration window. To select SPI transport interface, navigate to `Example Configuration -> Transport layer -> SPI interface -> select` and exit from menuconfig. + +* Change UART Baudrate for HCI as `Component config -> Example Configuration -> UART Baudrate for HCI`. Default is 921600. + +* For ESP32C3, select chip revision in addition. Navigate to `Component config → ESP32C3-Specific → Minimum Supported ESP32-C3 Revision` and select chip version of ESP32C3. + * Use below command to compile and flash the project. Replace with ESP peripheral's serial port. ```sh $ idf.py -p build flash ``` ##### Using make -:warning: *make* build system is only supported till ESP32. Please refer cmake section above for ESP32-S2. +:warning: *make* build system is only supported till ESP32. Please refer cmake section above for ESP32-C3. * Execute following command to configure the project ```sh $ make menuconfig @@ -116,8 +159,14 @@ $ make flash ## 3. Post Setup * After setting up host and loading ESP firmware, execute below command to create `hci0` interface ```sh - $ sudo hciattach -s /dev/serial0 any flow + $ sudo hciattach -s /dev/serial0 any flow ``` * should match UART baud rate of ESP peripheral + +### For ESP32 * Check `CONFIG_BT_HCI_UART_BAUDRATE` parameter in *esp/esp_driver/network_adapter/sdkconfig* -* Alternatively baud rate could be located in menuconfig at, `Component config -> Bluetooth -> Bluetooth controller -> HCI UART(H4) Options -> UART Baudrate for HCI` +* Alternatively baud rate could be located in menuconfig at, * Alternatively baud rate could be located in menuconfig at, `Component config -> Bluetooth -> Bluetooth controller -> HCI UART(H4) Options -> UART Baudrate for HCI` + +### For ESP32-C3 +* Check `CONFIG_EXAMPLE_ESP32C3_HCI_UART_BAUDRATE` parameter in *esp/esp_driver/network_adapter/sdkconfig* +* Alternatively baud rate could be located in menuconfig at, `Component config -> Example Configuration -> UART Baudrate for HCI` \ No newline at end of file diff --git a/docs/Linux_based_host/directory_structure.md b/docs/Linux_based_host/directory_structure.md index 3a3ba91952..59688eefaf 100644 --- a/docs/Linux_based_host/directory_structure.md +++ b/docs/Linux_based_host/directory_structure.md @@ -3,13 +3,11 @@ ``` ├── linux │   ├── host_control (Contain necessary files for installation of control path) -│   │   ├── c_support (Contain files to test basic control path commands) +│   │   ├── c_support (Contain files to test basic control path commands and stress.c for stress testing) │   │   ├── python_support (Contain python scripts for Wi-Fi functionality, -│   │   │ │ `test.py` to test basic control path commands, also -│   │   │ │ `commands.py` control path commands implementation using -│   │   │ │ python protobuf generated files) -│   │   │   └── transport (Handles read/write operation of control path commands on -│   │   │ ESP-Hosted character driver) +│   │   │ `test.py` to test basic control path commands, stress.py for stress testing, also +│   │   │ `commands_lib.py` control path commands implementation using +│   │   │ `ctypes` module converts command requests from python to c and maps command responses from c to python) │   │   ├── rpi_init.sh (Installation sequence for ESP-Hosted driver) │   │   └── spidev_disabler.dts (dts file for SPI transport) │   └── host_driver (Contain ESP-Hosted kernel module files) diff --git a/docs/Linux_based_host/ota_update.md b/docs/Linux_based_host/ota_update.md new file mode 100644 index 0000000000..f00905c2e8 --- /dev/null +++ b/docs/Linux_based_host/ota_update.md @@ -0,0 +1,38 @@ +## **ESP-Hosted OTA update ESP32 image** + +Please note, Maximum size of New OTA image binary depends upon - +1. Total flash size available +2. OTA partition size in partition table +As per current limits, upto 1MB binary size is supported which is configurable using custom partition table CSV. Please refer [partition tables](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html) for more info. + +There are basic three control path commands for OTA are provided in C and python, as follows: +* esp_ota_begin() -- Sets available OTA partition in flash for OTA write operation and erase it. +* esp_ota_write() -- Write chunk of OTA image data on OTA partition in flash. +* esp_ota_end() -- Validate written OTA image, set OTA partition for next boot and reboot ESP32 after 5 sec. + +Definition of these commands are present in [commands.c](host/host_common/commands.c) and [commands_lib.py](host/linux/host_control/python_support/commands_lib.py) files. + +## **How to use** + +### On ESP32 side +Build and flash ESP-Hosted application using `idf.py build flash monitor`. + +### On Host side + +#### Note +1. Please stop ongoing BT/BLE operations before starting OTA process. +2. OTA operation should not get interrupted by any other control path command. +3. OTA update using HTTP URL is only supported in python. In case HTTP based OTA update is desired, user can do the same using third party HTTP client library. +4. The OTA update using C currently assumes the complete binary is downloaded locally. + +### Python Implementation +User can skip step 1, if station is connected to AP and IP is assigned to `ethsta0` interface. + +1. Perform station connect using [wifi station mode operations](Getting_started.md#111-wi-fi-station-mode-operations) +-> Connect to external access point. + +2. For further details follow this [Link](../python_demo.md#ota-update). + +### C Implementation + +For Further details follow this [Link](../c_demo.md#c-demo-application). diff --git a/docs/Linux_based_host/rpi_esp32_uart_setup.jpg b/docs/Linux_based_host/rpi_esp32_uart_setup.jpg new file mode 100644 index 0000000000..3b80fc95d4 Binary files /dev/null and b/docs/Linux_based_host/rpi_esp32_uart_setup.jpg differ diff --git a/docs/Linux_based_host/rpi_esp32c3_uart_setup.jpg b/docs/Linux_based_host/rpi_esp32c3_uart_setup.jpg new file mode 100644 index 0000000000..f8e48e07d1 Binary files /dev/null and b/docs/Linux_based_host/rpi_esp32c3_uart_setup.jpg differ diff --git a/docs/MCU_based_host/MCU_based_readme.md b/docs/MCU_based_host/MCU_based_readme.md index 48a4ffad28..6b358f43ae 100644 --- a/docs/MCU_based_host/MCU_based_readme.md +++ b/docs/MCU_based_host/MCU_based_readme.md @@ -139,6 +139,10 @@ Run following command and navigate to `Example Configuration -> Transport layer ``` $ make menuconfig ``` +:warning: Skip below step for ESP32-S2 or ESP32-C3. Run for ESP32 only. + +Change SPI controller to VSPI. Please navigate to `Example Configuration → SPI Configuration` and change value of `SPI controller to use` to `3` + To build and flash the app on ESP peripheral, run @@ -165,6 +169,10 @@ Run following command and navigate to `Example Configuration -> Transport layer $ idf.py menuconfig ``` +:warning: Skip below step for ESP32-S2 or ESP32-C3. Run for ESP32 only. + +Change SPI controller to VSPI. Please navigate to `Example Configuration → SPI Configuration` and change value of `SPI controller to use` to `3` + To build and flash the app on ESP peripheral, run ```sh diff --git a/docs/c_api.md b/docs/c_api.md index 0e71c8a7f4..ecf8fe92c7 100644 --- a/docs/c_api.md +++ b/docs/c_api.md @@ -1,6 +1,8 @@ # Control Interface: C API's -This document describes C API's provided for control interface. Please refer [test.c](../host/linux/host_control/c_support/test.c) to get an idea how to use these API's. +This document describes C API's provided for control path interface. Please refer [commands.c](../host/host_common/commands.c) for API's definition. [c_demo.md](c_demo.md) gives overview of how to test control path interface in application also how to perform stress testing of control path interface. + +A [stress.c](../host/linux/host_control/c_support/stress.c) can use for stress testing of control path commands. In which, `STRESS_TEST_COUNT` variable represents number of iterations and `STRESS_TEST` variable defines which test should get executed. ## 1. Data Structures @@ -110,6 +112,24 @@ BSSID or MAC address of station of length 17. ex. "XX:XX:XX:XX:XX:XX". - `int rssi` : RSSI signal strength of station. +--- + +_struct_ `vendor_ie_data_t`: + +This contains vendor information element to ESP32 softAP. + +*Public Members* +- `uint8_t element_id` : +Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD). +- `uint8_t length` : +Length of all bytes in the element data (payload) following this field. Minimum 4(offset for `vendor_oui` and `vendor_oui_type` field). +- `uint8_t vendor_oui[3]` : +Vendor identifier (OUI). +- `uint8_t vendor_oui_type` : +Vendor-specific OUI type. +- `uint8_t payload[0]` : +Payload. Length is equal to value in 'length' field, minus 4. + --- ## 2. Functions @@ -122,7 +142,7 @@ This is used to get the MAC address of station or softAP interface of ESP32 - `mode` : - `WIFI_MODE_STA` : station - `WIFI_MODE_AP` : softAP -- `mac` : +- `mac` : String in form of "XX:XX:XX:XX:XX:XX" in success case. It should be large enough to store string in form "XX:XX:XX:XX:XX:XX" @@ -418,6 +438,142 @@ User should free `esp_hosted_wifi_connected_stations_list` handler after use. --- +### 2.15 `int wifi_set_vendor_specific_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, void* vnd_ie, uint16_t vnd_ie_size)` +Function set 802.11 Vendor-Specific Information Element. This function needs to get called before starting of ESP32 softAP. + +#### Parameters +- `enable` : +If true, specified IE is enabled. If false, specified IE is removed. +- `type` : +Information Element type. Determines the frame type to associate with the IE. Uses `wifi_vendor_ie_type_t` enum. +- `idx` : +Index to set or clear. Each IE type can be associated with up to two elements (indices 0 & 1). Uses `wifi_vendor_ie_id_t` enum. +- `vnd_ie` : +Pointer to vendor specific element data. First 6 bytes should be a header with fields matching vendor_ie_data_t. If enable is false, this argument is ignored and can be NULL. +- `vnd_ie_size` : +size of vnd_ie data + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.16 `int create_socket(int domain, int type, int protocol, int *sock)` + +This is used to create an endpoint for communication + +#### Parameters + +- `domain` : +The domain argument specifies a communication domain (like AF_INET, AF_INET6), this selects the protocol family which will be used for communication. These families are defined in . +- `type` : +This specifies the communication semantics (like SOCK_DGRAM, SOCK_STREAM). +- `protocol` : +This specifies a particular protocol to be used with the socket. Generally protocol value should be 0, please refer man socket for more details. +- `sock` : +This will return file descriptor (integer number) that refers to that endpoint for the new socket on success or -1 on failure. + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.17 `int close_socket(int sock)` + +This is used to close an endpoint of the communication + +#### Parameters + +- `sock` : +This specifies the file descriptor of the endpoint/socket to be closed + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.18 `int wifi_set_max_tx_power(int8_t wifi_max_tx_power)` + +Function sets maximum WiFi transmitting power at ESP32. + +#### **Note** +- The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable in wifi driver. +- Mapping Table {wifi_max_tx_power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. +- Input parameter `wifi_max_tx_power` unit is 0.25dBm, range is [8, 84] corresponding to `2dBm to 20dBm`. +- Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. + +#### Parameters +- `wifi_max_tx_power` : +Maximum WiFi transmitting power. + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE +- 5 : OUT_OF_RANGE. `wifi_max_tx_power` is not in range of [8, 84] corresponding to `2dBm to 20dBm` tx power. + +--- + +### 2.19 `int wifi_get_curr_tx_power(int8_t *wifi_curr_tx_power)` + +Function gets current WiFi transmiting power at ESP32. + +#### Parameters +- `wifi_curr_tx_power` : +Current WiFi transmitting power, unit is 0.25dBm. + +#### **Note** +It is possible that the current wifi transmit power is lesser than that of the requested max transmit power as part of `wifi_set_max_tx_power` API. + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.20 `int esp_ota_begin()` + +esp ota begin function performs an OTA begin operation for ESP32 which erases and prepares existing flash partition for new flash writing. + +#### Return +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.21 `int esp_ota_write(uint8_t* ota_data, uint32_t ota_data_len)` + +esp ota write function performs an OTA write operation for ESP32, It writes bytes from `ota_data` buffer with `ota_data_len` number of bytes to OTA partition in flash. Number of bytes can be small than size of complete binary to be flashed. In that case, this caller is expected to repeatedly call this function till total size written equals size of complete binary. + +#### Parameters + +- `ota_data` : OTA data buffer +- `ota_data_len` : length of OTA data buffer + +#### Return + +- 0 : SUCCESS +- -1 : FAILURE + +--- + +### 2.22 `int esp_ota_end()` + +esp ota end function performs an OTA end operation for ESP32, It validates written OTA image, sets newly written OTA partition as boot partition for next boot, Creates timer which reset ESP32 after 5 sec. + +#### Return +- 0 : SUCCESS +- -1 : FAILURE + +--- + ## 3. Enumerations ### 3.1 _enum_ `wifi_mode_t` @@ -471,6 +627,27 @@ Invalid power save mode --- +### 3.5 _enum_ `wifi_vendor_ie_type_t` : + +Vendor information element type. Determines the frame type that the IE will be associated with. +_Values_ : +- `WIFI_VND_IE_TYPE_BEACON` = 0 : Type beacon +- `WIFI_VND_IE_TYPE_PROBE_REQ` : Type probe request +- `WIFI_VND_IE_TYPE_PROBE_RESP` : Type probe response +- `WIFI_VND_IE_TYPE_ASSOC_REQ` : Type association request +- `WIFI_VND_IE_TYPE_ASSOC_RESP` : Type association response + +--- + +### 3.6 _enum_ `wifi_vendor_ie_id_t` : + +Vendor Information Element index. Each IE type can have up to two associated vendor ID elements. +_Values_ : +- `WIFI_VND_IE_ID_0` = 0 : ID 0 +- `WIFI_VND_IE_ID_1` : ID 1 + +--- + ## 4. Unions ### 4.1 _union_ `esp_hosted_control_config_t` : diff --git a/docs/c_demo.md b/docs/c_demo.md new file mode 100644 index 0000000000..c2b87af301 --- /dev/null +++ b/docs/c_demo.md @@ -0,0 +1,81 @@ +# C Demo Application + +[test.c](../host/linux/host_control/c_support/test.c) is a demo application to provide basic command line arguments as follows: + +| Command line argument | Operation | +|:----|:----| +| sta_connect | Connect ESP32 station to external AP, assign MAC address of ESP32 station to `ethsta0` and up `ethsta0` interface | +| sta_disconnect | Disconnect ESP32 station from external AP and down `ethsta0` interface | +| ap_start | Start ESP32 softAP, assign MAC address of ESP32 softAP to `ethap0` and up `ethap0` interface | +| ap_stop | Stop ESP32 softAP stop and down `ethap0` interface | +| scan | Scan external access points | +| sta_list | List external stations connected to softAP | +| ap_vendor_ie | Set vendor information element for ESP32 softAP | +| wifi_tx_power | sets WiFi maximum transmitting power and get WiFi current transmitting power | +| ota | performs OTA operation using local OTA binary file | + +It uses APIs present in [test_api.c](../host/linux/host_control/c_support/test_api.c). User should first modify configuration parameters in [test_config.h](../host/linux/host_control/c_support/test_config.h). Then run `make` in [c_support](../host/linux/host_control/c_support) to compile `test.c`. + +Note:- +Please execute `test.out` as below. + +``` +ex. +sudo ./test.out sta_connect sta_disconnect ap_vendor_ie ap_start ap_stop scan sta_list +``` +Note: +* After `sta_connect`, User needs to run DHCP client to obtain IP address from an external AP. Then network data path will be open for higher applications to use `ethsta0` interface for data communication. For an example as below. + +``` +sudo dhclient ethsta0 -r + +sudo dhclient ethsta0 -v +``` + +* `ap_vendor_ie` needs to get called before starting of ESP32 softAP, please edit function `test_set_vendor_specific_ie` in `test_api.c`. +`ap_vendor_ie` should get configured only once till ESP32 reboot. To remove +previous configuration set `enable` flag to `false` in `wifi_set_vendor_specific_ie` API. +After that re-configuration possible of Vendor IE. + +* After `ap_start` to start data connection, set up a DHCP server on the Raspberry Pi, or configure a static IP address for AP interface (`ethap0`). For an example as below: + +``` +sudo dnsmasq --no-daemon --no-resolv --no-poll --dhcp-script=/system/bin/dhcp_announce --dhcp-range=192.168.4.1,192.168.4.20,1h + +sudo ifconfig ethap0 192.168.4.5 +``` + +* OTA - +The OTA update using C currently assumes the complete binary is downloaded locally. +OTA update using HTTP URL is only supported in [python](python_demo.md#ota-update). In case HTTP based OTA update is desired, user can do the same using third party HTTP client library. + +``` +ex. +./test.out ota +``` + +# C stress Application + +[stress.c](../host/linux/host_control/c_support/stress.c) use for stress testing of control path APIs. It provides basic command line arguments as follows: + +| Command line argument | Operation | +|:----|:----| +| Any positive interger number | Number of iterations for stress test | +| sta_connect | Connect ESP32 station to external AP, assign MAC address of ESP32 station to `ethsta0` and up `ethsta0` interface | +| sta_disconnect | Disconnect ESP32 station from external AP and down `ethsta0` interface | +| ap_start | Start ESP32 softAP, assign MAC address of ESP32 softAP to `ethap0` and up `ethap0` interface | +| ap_stop | Stop ESP32 softAP stop and down `ethap0` interface | +| scan | Scan external access points | +| sta_list | List external stations connected to softAP | +| ap_vendor_ie | Set vendor information element for ESP32 softAP | +| wifi_tx_power | sets WiFi maximum transmitting power and get WiFi current transmitting power | + + Run `make stress` in [c_support](../host/linux/host_control/c_support) directory to compile `stress.c`. + +Note:- +Please execute `stress.out` as below. + +``` +ex. +sudo ./stress.out 1 sta_connect sta_disconnect ap_vendor_ie ap_start ap_stop scan sta_list +``` diff --git a/docs/python_api.md b/docs/python_api.md index 86928f9959..ef98f9a9dc 100644 --- a/docs/python_api.md +++ b/docs/python_api.md @@ -1,8 +1,12 @@ # Control Interface API's: Python Implementation -This document describes python API's provided for control interface. Please refer [test.py](../host/linux/host_control/python_support/test.py) to get an idea how to use these API's. +This document describes python API's provided for control interface. +[python_demo.md](python_demo.md) gives overview of how to test control path interface in application also how to perform stress testing of control path interface. -## 1. `wifi_get_mac` + +A [stress.py](../host/linux/host_control/python_support/stress.py) can use for stress testing of control path commands. In which, `STRESS_TEST_COUNT` variable represents number of iterations and `STRESS_TEST` variable defines which test should get executed. + +## 1. `wifi_get_mac(mode)` This is used to retrieve the MAC address of ESP's station or softAP interface ### Parameters @@ -16,7 +20,7 @@ String in form of "XX:XX:XX:XX:XX:XX" with MAC address of ESP interface mapping --- -## 2. `wifi_get_mode` +## 2. `wifi_get_mode()` This is used to retrieve the ESP32's Wi-Fi mode ### Return @@ -28,7 +32,7 @@ This is used to retrieve the ESP32's Wi-Fi mode --- -## 3. `wifi_set_mode` +## 3. `wifi_set_mode(mode)` This is used to set the ESP32's Wi-Fi mode ### Parameters @@ -43,7 +47,7 @@ This is used to set the ESP32's Wi-Fi mode --- -## 4. `wifi_set_mac` +## 4. `wifi_set_mac(mode, mac)` This is used to set MAC address for ESP's station or softAP interface ### Parameters @@ -65,7 +69,7 @@ For example, the MAC address can set to be "1a:XX:XX:XX:XX:XX", but can not be " --- -## 5. `wifi_set_power_save_mode` +## 5. `wifi_set_power_save_mode(power_save_mode)` Set ESP32's power save mode ### Parameters @@ -83,7 +87,7 @@ Maximum modem power saving. In this mode, interval to receive beacons is determi --- -## 6. `wifi_get_power_save_mode` +## 6. `wifi_get_power_save_mode()` Get the power save mode of ESP32 ### Return @@ -97,7 +101,7 @@ ESP32 on boot is configured in WIFI_PS_MIN_MODEM --- -## 7. `wifi_set_ap_config` +## 7. `wifi_set_ap_config(ssid, pwd, bssid, is_wpa3_supported, listen_interval)` Set the AP config to which ESP32 station should connect ### Parameters @@ -119,7 +123,7 @@ Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is se --- -## 8. `wifi_get_ap_config` +## 8. `wifi_get_ap_config()` Get the AP config to which ESP32 station is connected ### Return @@ -150,7 +154,7 @@ In case of transport failure --- -## 9. `wifi_disconnect_ap` +## 9. `wifi_disconnect_ap()` Disconnect the AP to which ESP32 station is connected ### Return @@ -158,7 +162,7 @@ Disconnect the AP to which ESP32 station is connected --- -## 10. `wifi_ap_scan_list` +## 10. `wifi_ap_scan_list()` Set the AP config to which ESP32 station should connect ### Return @@ -187,7 +191,7 @@ RSSI signal strength --- -## 11. `wifi_set_softap_config` +## 11. `wifi_set_softap_config(ssid, pwd, chnl, ecn, max_conn, ssid_hidden, bw)` Set the ESP32's softAP config ### Parameters @@ -218,7 +222,7 @@ softAP should broadcast its SSID or not --- -## 12. `wifi_get_softap_config` +## 12. `wifi_get_softap_config()` Get the ESP32's softAP config ### Return @@ -246,7 +250,7 @@ Maximum number of stations can connect to ESP32 softAP (will be in range of 1 to --- -## 13. `wifi_stop_softap` +## 13. `wifi_stop_softap()` Stop the ESP32's softAP ### Return @@ -254,14 +258,14 @@ Stop the ESP32's softAP --- -## 14. `wifi_connected_stations_list` +## 14. `wifi_connected_stations_list()` Get the list of connected station to the ESP32 softAP. ### Return -*success case* : list of Stationlist tuple(mac,rssi) +*success case* : list of Stationlist tuple(bssid,rssi) Stations credentials:: -- `mac` : +- `bssid` : MAC address of station - `rssi` : RSSI signal strength @@ -270,3 +274,102 @@ RSSI signal strength - "failure" string --- + +## 15. `create_socket(domain, types, protocol)` +This function creates an endpoint for communication + +### Parameters +- `domain` : +This specifies a communication domain (like AF_INET, AF_INET6). +- `types` : +This specifies the communication semantics (like SOCK_DGRAM, SOCK_STREAM). +- `protocol` : +This specifies a particular protocol to be used with the socket. Generally protocol value should be 0, please refer socket documentation for more details. + +### Return +- File descriptor (integer number) that refers to that endpoint/socket +- "failure" string: if failed. + +--- + +## 16. `close_socket(sock)` +This function closes endpoint of the communication + +### Parameters +- `sock` : +This specifies the file descriptor of the endpoint/socket to be closed + +### Return +- "success" or "failure" string + +--- + +## 17. `wifi_set_max_tx_power(wifi_max_tx_power)` + +Function sets maximum WiFi transmitting power at ESP32. + +#### **Note** +- The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable in wifi driver. +- Mapping Table {wifi_max_tx_power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. +- Input parameter `wifi_max_tx_power` unit is 0.25dBm, range is [8, 84] corresponding to `2dBm to 20dBm`. +- Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. + +### Parameters +- `wifi_max_tx_power` : +Maximum WiFi transmitting power. + +### Return +*Success case* : +"success" string + +*Failure case* : +"failure" string + +*Out of range case*: +"out_of_range" string. `wifi_max_tx_power` is not in range of [8, 84] corresponding to `2dBm to 20dBm` tx power. + +--- + +### 18. `wifi_get_curr_tx_power()` + +Function gets current WiFi transmiting power at ESP32. + +### Return +*Success case* : +returns Current WiFi transmitting power, unit is 0.25dBm. It is possible that the current wifi transmit power is lesser than that of the requested max transmit power as part of `wifi_set_max_tx_power` API. + +*Failure case* : +- "failure" string + +--- + +## 19. `esp_ota_begin()` +esp ota begin function performs an OTA begin operation for ESP32 which erases and prepares existing flash partition for new flash writing. + +### Return + +"success" or "failure" string + +--- + +## 20. `esp_ota_write(ota_data, ota_data_len)` +esp ota write function performs an OTA write operation for ESP32, It writes bytes from `ota_data` buffer with `ota_data_len` number of bytes to OTA partition in flash. Number of bytes can be small than size of complete binary to be flashed. In that case, this caller is expected to repeatedly call this function till total size written equals size of complete binary. +### Parameters + +- `ota_data` : OTA data buffer +- `ota_data_len` : length of OTA data buffer + +### Return + +"success" or "failure" string + +--- + +## 21. `esp_ota_end()` +esp ota end function performs an OTA end operation for ESP32, It validates written OTA image, sets newly written OTA partition as boot partition for next boot, Creates timer which reset ESP32 after 5 sec. + +### Return + +"success" or "failure" string + +--- diff --git a/docs/python_demo.md b/docs/python_demo.md new file mode 100644 index 0000000000..5fe28b1e1f --- /dev/null +++ b/docs/python_demo.md @@ -0,0 +1,81 @@ +# Demo Application + +[test.py](../host/linux/host_control/python_support/test.py) is a demo application to test control path interface: + +It uses APIs present in [test_api.py](../host/linux/host_control/python_support/test_api.py). User should first modify configuration parameters in [test_config.py](../host/linux/host_control/python_support/test_config.py). + +Note:- +Please execute `test.py` as below. + +``` +sudo python test.py +``` +Note: +* After `test_station_mode_connect` API call, User needs to run DHCP client to obtain IP address from an external AP. Then network data path will be open for higher applications to use `ethsta0` interface for data communication. For an example as below. + +``` +sudo dhclient ethsta0 -r + +sudo dhclient ethsta0 -v +``` + +* After `test_softap_mode_start` API ,to start data connection, set up a DHCP server on the Raspberry Pi, or configure a static IP address for AP interface (`ethap0`). For an example as below: + +``` +sudo dnsmasq --no-daemon --no-resolv --no-poll --dhcp-script=/system/bin/dhcp_announce --dhcp-range=192.168.4.1,192.168.4.20,1h + +sudo ifconfig ethap0 192.168.4.5 +``` + +# Stress Application + +[stress.py](../host/linux/host_control/python_support/stress.py) use for stress testing of control path APIs. User should first modify configuration parameters in [test_config.py](../host/linux/host_control/python_support/test_config.py). `STRESS_TEST_COUNT` variable is defined in `stress.py` for number of iterations for stress testing. + +Note:- +Please execute `stress.py` as below. +``` +ex. +sudo python stress.py +``` + +# OTA update + +* `ota_update.py` is script which placed in `host/linux/host_control/python_support/` directory. Use below command to navigate to this directory. +```sh +$ cd host/linux/host_control/python_support/ +``` + +* This script assumes station is connected to AP, IP is assigned to `ethsta0` and HTTP URL is accessible. + +* [ota_update.py](host/linux/host_control/python_support/ota_update.py) python script is used to do OTA update on ESP32. It downloads **chunk** of OTA image data using HTTP client over `ethsta0` interface and writes on ESP32. After successful completion it restarts ESP32 after 5 sec. + +Usage: +1. Start HTTP server on a remote machine which contains OTA image. +Following python command can be used to start HTTP server if it's not running already. + +Syntax: +``` +python3 -m http.server +``` +Example: +``` +python3 -m http.server 9999 +``` + +2. Pass OTA image URL as command line argument to ota_update.py. + +Syntax: +``` +python3 ota_update.py "http://:/ota_image.bin" +``` +Example: +``` +python3 ota_update.py "http://192.168.0.106:9999/network_adapter.bin" +``` + +3. It will performs following operations. +* Erase ota flash partition of ESP32 +* Download chunk from URL and write that chunk into flash, one by one, till whole binary is written +* Validate the complete written binary in flash +* Sets newly written OTA partition as boot partition +* Reboot the ESP32 after 5 second diff --git a/esp/esp_driver/network_adapter/main/CMakeLists.txt b/esp/esp_driver/network_adapter/main/CMakeLists.txt index e914caa5b7..4c7a6ae0d4 100644 --- a/esp/esp_driver/network_adapter/main/CMakeLists.txt +++ b/esp/esp_driver/network_adapter/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(COMPONENT_SRCS "slave_commands.c" "../../../../common/esp_hosted_config.pb-c.c" "protocomm_pserial.c" "app_main.c") +set(COMPONENT_SRCS "slave_commands.c" "../../../../common/esp_hosted_config.pb-c.c" "protocomm_pserial.c" "app_main.c" "slave_bt.c") set(COMPONENT_ADD_INCLUDEDIRS "." "../../../../common/include") if(CONFIG_ESP_SDIO_HOST_INTERFACE) diff --git a/esp/esp_driver/network_adapter/main/Kconfig.projbuild b/esp/esp_driver/network_adapter/main/Kconfig.projbuild index 467c50f489..2a84a87078 100644 --- a/esp/esp_driver/network_adapter/main/Kconfig.projbuild +++ b/esp/esp_driver/network_adapter/main/Kconfig.projbuild @@ -25,7 +25,7 @@ menu "Example Configuration" config ESP_SPI_CONTROLLER int "SPI controller to use" depends on IDF_TARGET_ESP32 && ESP_SPI_HOST_INTERFACE - default 3 + default 2 range 2 3 help SPI controller to be used. HSPI->2, VSPI->3 @@ -44,6 +44,12 @@ menu "Example Configuration" GPIO pin for indicating host that SPI slave has data to be read by host endmenu + config ESP_OTA_WORKAROUND + bool "OTA workaround - Add sleeps while OTA write" + default y + help + Enable/disable sleeps while OTA operations + config ESP_SERIAL_DEBUG bool "Debug Serial driver data path" default 0 @@ -56,4 +62,18 @@ menu "Example Configuration" help Enable/disable debug prints in wlan driver data path + config ESP_BT_DEBUG + bool "Debug Bluetooth driver data path" + default 0 + help + Enable/disable debug prints in Bluetooth driver data path + + config EXAMPLE_ESP32C3_HCI_UART_BAUDRATE + int "UART Baudrate for HCI" + range 115200 921600 + depends on IDF_TARGET_ESP32C3 + default 921600 + help + UART Baudrate for HCI over ESP32C3. Please use standard baudrate. + endmenu diff --git a/esp/esp_driver/network_adapter/main/app_main.c b/esp/esp_driver/network_adapter/main/app_main.c index 26f46c9c60..0361b6af8a 100644 --- a/esp/esp_driver/network_adapter/main/app_main.c +++ b/esp/esp_driver/network_adapter/main/app_main.c @@ -44,6 +44,8 @@ #include #include "protocomm_pserial.h" #include "slave_commands.h" +#include "driver/periph_ctrl.h" +#include "slave_bt.c" #define EV_STR(s) "================ "s" ================" static const char TAG[] = "NETWORK_ADAPTER"; @@ -58,24 +60,16 @@ static const char TAG_RX_S[] = "CONTROL H -> S"; static const char TAG_TX_S[] = "CONTROL S -> H"; #endif -#ifdef CONFIG_BT_HCI_UART_NO -#define BT_TX_PIN 5 -#define BT_RX_PIN 18 -#define BT_RTS_PIN 19 -#define BT_CTS_PIN 23 -#endif - -#ifdef CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI -#define VHCI_MAX_TIMEOUT_MS 2000 -static SemaphoreHandle_t vhci_send_sem; -static void deinitialize_bluetooth(void); -static esp_err_t initialise_bluetooth(void); +#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS +#define STATS_TICKS pdMS_TO_TICKS(1000*2) +#define ARRAY_SIZE_OFFSET 5 #endif volatile uint8_t action = 0; volatile uint8_t datapath = 0; volatile uint8_t station_connected = 0; volatile uint8_t softap_started = 0; +volatile uint8_t ota_ongoing = 0; #ifdef ESP_DEBUG_STATS uint32_t from_wlan_count = 0; @@ -86,30 +80,31 @@ uint32_t to_host_sent_count = 0; interface_context_t *if_context = NULL; interface_handle_t *if_handle = NULL; -QueueHandle_t to_host_queue = NULL; -QueueHandle_t from_host_queue = NULL; +QueueHandle_t to_host_queue[MAX_PRIORITY_QUEUES] = {NULL}; #if CONFIG_ESP_SPI_HOST_INTERFACE #ifdef CONFIG_IDF_TARGET_ESP32S2 #define TO_HOST_QUEUE_SIZE 5 -#define FROM_HOST_QUEUE_SIZE 5 #else -#define TO_HOST_QUEUE_SIZE 10 -#define FROM_HOST_QUEUE_SIZE 10 +#define TO_HOST_QUEUE_SIZE 20 #endif #else #define TO_HOST_QUEUE_SIZE 100 -#define FROM_HOST_QUEUE_SIZE 100 #endif +#define ETH_DATA_LEN 1500 + static protocomm_t *pc_pserial; static struct rx_data { uint8_t valid; + uint16_t cur_seq_no; int len; - uint8_t data[1024]; + uint8_t data[4096]; } r; +uint8_t ap_mac[MAC_LEN] = {0}; + static void print_firmware_version() { ESP_LOGI(TAG, "*********************************************************************"); @@ -135,31 +130,7 @@ static uint8_t get_capabilities() cap |= ESP_WLAN_SDIO_SUPPORT; #endif #ifdef CONFIG_BT_ENABLED - ESP_LOGI(TAG, "- BT/BLE"); -#if CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI -#if CONFIG_ESP_SPI_HOST_INTERFACE - ESP_LOGI(TAG, " - HCI Over SPI"); - cap |= ESP_BT_SPI_SUPPORT; -#else - ESP_LOGI(TAG, " - HCI Over SDIO"); - cap |= ESP_BT_SDIO_SUPPORT; -#endif -#else -#ifdef CONFIG_BT_HCI_UART_NO - ESP_LOGI(TAG, " - HCI Over UART"); - cap |= ESP_BT_UART_SUPPORT; -#endif -#endif -#if CONFIG_BTDM_CTRL_MODE_BLE_ONLY - ESP_LOGI(TAG, " - BLE only"); - cap |= ESP_BLE_ONLY_SUPPORT; -#elif CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY - ESP_LOGI(TAG, " - BR_EDR only"); - cap |= ESP_BR_EDR_ONLY_SUPPORT; -#elif CONFIG_BTDM_CTRL_MODE_BTDM - ESP_LOGI(TAG, " - BT/BLE dual mode"); - cap |= ESP_BLE_ONLY_SUPPORT | ESP_BR_EDR_ONLY_SUPPORT; -#endif + cap |= get_bluetooth_capabilities(); #endif return cap; @@ -212,20 +183,40 @@ static void esp_wifi_set_debug_log() } +void esp_update_ap_mac(void) +{ + esp_err_t ret = ESP_OK; + char mac_str[BSSID_LENGTH] = ""; + + ret = esp_wifi_get_mac(ESP_IF_WIFI_AP, ap_mac); + ESP_LOGI(TAG,"Get softap mac address"); + if (ret) { + ESP_LOGE(TAG,"Error in getting MAC of ESP softap %d", ret); + } else { + snprintf(mac_str,BSSID_LENGTH,MACSTR,MAC2STR(ap_mac)); + ESP_LOGI(TAG,"AP mac [%s] ", mac_str); + } +} + esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb) { esp_err_t ret = ESP_OK; - interface_buffer_handle_t buf_handle; + interface_buffer_handle_t buf_handle = {0}; + uint8_t * ap_buf = buffer; - if (!buffer || !eb || !datapath) { + if (!buffer || !eb || !datapath || ota_ongoing) { if (eb) { esp_wifi_internal_free_rx_buffer(eb); } return ESP_OK; } - /* Prepare buffer descriptor */ - memset(&buf_handle, 0, sizeof(buf_handle)); + /* Check destination address against self address */ + if (memcmp(ap_buf, ap_mac, MAC_LEN)) { + /* Check for multicast or broadcast address */ + if (!(ap_buf[0] & 1)) + goto DONE; + } buf_handle.if_type = ESP_AP_IF; buf_handle.if_num = 0; @@ -234,7 +225,7 @@ esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb) buf_handle.wlan_buf_handle = eb; buf_handle.free_buf_handle = esp_wifi_internal_free_rx_buffer; - ret = xQueueSend(to_host_queue, &buf_handle, portMAX_DELAY); + ret = xQueueSend(to_host_queue[PRIO_Q_OTHERS], &buf_handle, portMAX_DELAY); if (ret != pdTRUE) { ESP_LOGE(TAG, "Slave -> Host: Failed to send buffer\n"); @@ -251,9 +242,9 @@ esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb) esp_err_t wlan_sta_rx_callback(void *buffer, uint16_t len, void *eb) { esp_err_t ret = ESP_OK; - interface_buffer_handle_t buf_handle; + interface_buffer_handle_t buf_handle = {0}; - if (!buffer || !eb || !datapath) { + if (!buffer || !eb || !datapath || ota_ongoing) { if (eb) { esp_wifi_internal_free_rx_buffer(eb); } @@ -264,9 +255,6 @@ esp_err_t wlan_sta_rx_callback(void *buffer, uint16_t len, void *eb) from_wlan_count++; #endif - /* Prepare buffer descriptor */ - memset(&buf_handle, 0, sizeof(buf_handle)); - buf_handle.if_type = ESP_STA_IF; buf_handle.if_num = 0; buf_handle.payload_len = len; @@ -274,7 +262,7 @@ esp_err_t wlan_sta_rx_callback(void *buffer, uint16_t len, void *eb) buf_handle.wlan_buf_handle = eb; buf_handle.free_buf_handle = esp_wifi_internal_free_rx_buffer; - ret = xQueueSend(to_host_queue, &buf_handle, portMAX_DELAY); + ret = xQueueSend(to_host_queue[PRIO_Q_OTHERS], &buf_handle, portMAX_DELAY); if (ret != pdTRUE) { ESP_LOGE(TAG, "Slave -> Host: Failed to send buffer\n"); @@ -288,140 +276,146 @@ esp_err_t wlan_sta_rx_callback(void *buffer, uint16_t len, void *eb) return ESP_OK; } +void process_tx_pkt(interface_buffer_handle_t *buf_handle) +{ + /* Check if data path is not yet open */ + if (!datapath) { +#if CONFIG_ESP_WLAN_DEBUG + ESP_LOGD (TAG_TX, "Data path stopped"); +#endif + /* Post processing */ + if (buf_handle->free_buf_handle && buf_handle->priv_buffer_handle) { + buf_handle->free_buf_handle(buf_handle->priv_buffer_handle); + buf_handle->priv_buffer_handle = NULL; + } + usleep(100*1000); + return; + } + if (if_context && if_context->if_ops && if_context->if_ops->write) { + if_context->if_ops->write(if_handle, buf_handle); + } + /* Post processing */ + if (buf_handle->free_buf_handle && buf_handle->priv_buffer_handle) { + buf_handle->free_buf_handle(buf_handle->priv_buffer_handle); + buf_handle->priv_buffer_handle = NULL; + } +} + /* Send data to host */ void send_task(void* pvParameters) { - esp_err_t ret = ESP_OK; #ifdef ESP_DEBUG_STATS int t1, t2, t_total = 0; int d_total = 0; #endif interface_buffer_handle_t buf_handle = {0}; - + uint16_t serial_pkts_waiting = 0; + uint16_t bt_pkts_waiting = 0; + uint16_t other_pkts_waiting = 0; while (1) { + serial_pkts_waiting = uxQueueMessagesWaiting(to_host_queue[PRIO_Q_SERIAL]); + bt_pkts_waiting = uxQueueMessagesWaiting(to_host_queue[PRIO_Q_BT]); + other_pkts_waiting = uxQueueMessagesWaiting(to_host_queue[PRIO_Q_OTHERS]); + + if (serial_pkts_waiting) { + while (serial_pkts_waiting) { + if (xQueueReceive(to_host_queue[PRIO_Q_SERIAL], &buf_handle, portMAX_DELAY)) + process_tx_pkt(&buf_handle); + serial_pkts_waiting--; + } + } else if (bt_pkts_waiting) { + if (xQueueReceive(to_host_queue[PRIO_Q_BT], &buf_handle, portMAX_DELAY)) + process_tx_pkt(&buf_handle); + } else if (other_pkts_waiting) { + if (xQueueReceive(to_host_queue[PRIO_Q_OTHERS], &buf_handle, portMAX_DELAY)) + process_tx_pkt(&buf_handle); + } else { + vTaskDelay(1); + } + } +} - ret = xQueueReceive(to_host_queue, &buf_handle, portMAX_DELAY); - - if (datapath) { - if (ret == pdTRUE) { -#ifdef ESP_DEBUG_STATS - to_host_count++; - - /* Send data */ - t1 = XTHAL_GET_CCOUNT(); -#endif +void process_serial_rx_pkt(uint8_t *buf) +{ + struct esp_payload_header *header = NULL; + uint16_t payload_len = 0; + uint8_t *payload = NULL; + int rem_buff_size; - if (if_context && if_context->if_ops && if_context->if_ops->write) { - if_context->if_ops->write(if_handle, &buf_handle); - } + header = (struct esp_payload_header *) buf; + payload_len = le16toh(header->len); + payload = buf + le16toh(header->offset); + rem_buff_size = sizeof(r.data) - r.len; -#ifdef ESP_DEBUG_STATS - t2 = XTHAL_GET_CCOUNT(); - t_total += t2 - t1; - d_total += buf_handle.payload_len; +#if CONFIG_ESP_SERIAL_DEBUG + ESP_LOG_BUFFER_HEXDUMP(TAG_RX_S, payload, payload_len, ESP_LOG_INFO); #endif -#if CONFIG_ESP_WLAN_DEBUG - ESP_LOG_BUFFER_HEXDUMP(TAG_TX, buf_handle.payload, buf_handle.payload_len, ESP_LOG_INFO); -#endif - /* Post processing */ - if (buf_handle.free_buf_handle && buf_handle.priv_buffer_handle) { - buf_handle.free_buf_handle(buf_handle.priv_buffer_handle); - buf_handle.priv_buffer_handle = NULL; - } + while (r.valid) + { + ESP_LOGI(TAG,"curr seq: %u header seq: %u\n", + r.cur_seq_no, header->seq_num); + vTaskDelay(10); + } -#ifdef ESP_DEBUG_STATS - to_host_sent_count++; - } - if (t_total) { - ESP_LOGI("TX complete. Total time spent in tx = %d for %d bytes\n", t_total, d_total); - t_total = 0; -#endif - } + if (!r.len) { + /* New Buffer */ + r.cur_seq_no = le16toh(header->seq_num); + } - } else { - if (ret == pdTRUE) { -#if CONFIG_ESP_WLAN_DEBUG - ESP_LOGD (TAG_TX, "Data path stopped"); -#endif + if (header->seq_num != r.cur_seq_no) { + /* Sequence number mismatch */ + r.valid = 1; + protocomm_pserial_data_ready(pc_pserial, r.len); + return; + } - /* Post processing */ - if (buf_handle.free_buf_handle && buf_handle.priv_buffer_handle) { - buf_handle.free_buf_handle(buf_handle.priv_buffer_handle); - buf_handle.priv_buffer_handle = NULL; - } - } + memcpy((r.data + r.len), payload, min(payload_len, rem_buff_size)); + r.len += payload_len; - sleep(1); - } + if (!(header->flags & MORE_FRAGMENT)) { + /* Received complete buffer */ + r.valid = 1; + protocomm_pserial_data_ready(pc_pserial, r.len); } } -void process_rx_task(void* pvParameters) +void process_rx_pkt(interface_buffer_handle_t **buf_handle_p) { - esp_err_t ret = ESP_OK; - interface_buffer_handle_t buf_handle = {0}; - struct esp_payload_header *header; - uint8_t *payload; - uint16_t payload_len; - - while (1) { - ret = xQueueReceive(from_host_queue, &buf_handle, portMAX_DELAY); + struct esp_payload_header *header = NULL; + uint8_t *payload = NULL; + uint16_t payload_len = 0; + interface_buffer_handle_t *buf_handle = *buf_handle_p; - if (ret != pdTRUE) { - continue; - } - - header = (struct esp_payload_header *) buf_handle.payload; - payload = buf_handle.payload + le16toh(header->offset); - payload_len = le16toh(header->len); + header = (struct esp_payload_header *) buf_handle->payload; + payload = buf_handle->payload + le16toh(header->offset); + payload_len = le16toh(header->len); #if CONFIG_ESP_WLAN_DEBUG - ESP_LOG_BUFFER_HEXDUMP(TAG_RX, payload, 8, ESP_LOG_INFO); -#endif - - if ((buf_handle.if_type == ESP_STA_IF) && station_connected) { - /* Forward data to wlan driver */ - esp_wifi_internal_tx(ESP_IF_WIFI_STA, payload, payload_len); - } else if (buf_handle.if_type == ESP_AP_IF && softap_started) { - /* Forward data to wlan driver */ - esp_wifi_internal_tx(ESP_IF_WIFI_AP, payload, payload_len); - } else if (buf_handle.if_type == ESP_SERIAL_IF) { - /* Process AT command*/ - memcpy(r.data, payload, min(payload_len, sizeof(r.data))); - r.valid = 1; - r.len = min(payload_len, sizeof(r.data)); -#if CONFIG_ESP_SERIAL_DEBUG - ESP_LOG_BUFFER_HEXDUMP(TAG_RX_S, r.data, r.len, ESP_LOG_INFO); -#endif - protocomm_pserial_data_ready(pc_pserial, r.len); -#ifdef CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI - } else if (buf_handle.if_type == ESP_HCI_IF) { - /* VHCI needs one extra byte at the start of payload */ - /* that is accomodated in esp_payload_header */ - payload--; - payload_len++; - - if (!esp_vhci_host_check_send_available()) { - ESP_LOGD(TAG, "VHCI not available"); - } - - if (vhci_send_sem) { - if (xSemaphoreTake(vhci_send_sem, VHCI_MAX_TIMEOUT_MS) == pdTRUE) { - esp_vhci_host_send_packet(payload, payload_len); - } else { - ESP_LOGI(TAG, "VHCI sem timeout"); - } - } -#endif - } - - /* Free buffer handle */ - if (buf_handle.free_buf_handle && buf_handle.priv_buffer_handle) { - buf_handle.free_buf_handle(buf_handle.priv_buffer_handle); - buf_handle.priv_buffer_handle = NULL; - } + ESP_LOG_BUFFER_HEXDUMP(TAG_RX, payload, 8, ESP_LOG_INFO); +#endif + + if ((buf_handle->if_type == ESP_STA_IF) && station_connected) { + /* Forward data to wlan driver */ + esp_wifi_internal_tx(ESP_IF_WIFI_STA, payload, payload_len); + //ESP_LOG_BUFFER_HEXDUMP("spi_sta_rx", payload, payload_len, ESP_LOG_INFO); + } else if (buf_handle->if_type == ESP_AP_IF && softap_started) { + /* Forward data to wlan driver */ + esp_wifi_internal_tx(ESP_IF_WIFI_AP, payload, payload_len); + } else if (buf_handle->if_type == ESP_SERIAL_IF) { + process_serial_rx_pkt(buf_handle->payload); + } +#if defined(CONFIG_BT_ENABLED) && BLUETOOTH_HCI + else if (buf_handle->if_type == ESP_HCI_IF) { + process_hci_rx_pkt(payload, payload_len); + } +#endif + + /* Free buffer handle */ + if (buf_handle->free_buf_handle && buf_handle->priv_buffer_handle) { + buf_handle->free_buf_handle(buf_handle->priv_buffer_handle); + buf_handle->priv_buffer_handle = NULL; } } @@ -429,13 +423,12 @@ void process_rx_task(void* pvParameters) void recv_task(void* pvParameters) { interface_buffer_handle_t *buf_handle = NULL; - esp_err_t ret; for (;;) { if (!datapath) { /* Datapath is not enabled by host yet*/ - sleep(1); + usleep(100*1000); continue; } @@ -448,161 +441,79 @@ void recv_task(void* pvParameters) } } - ret = xQueueSend(from_host_queue, buf_handle, portMAX_DELAY); + process_rx_pkt(&buf_handle); - if (ret != pdTRUE) { - ESP_LOGE(TAG, "Host -> Slave: Failed to send buffer\n"); - if (buf_handle->free_buf_handle && buf_handle->priv_buffer_handle) { - buf_handle->free_buf_handle(buf_handle->priv_buffer_handle); - } - } free(buf_handle); buf_handle = NULL; } } -static int32_t serial_read_data(uint8_t *data, int32_t len) +static ssize_t serial_read_data(uint8_t *data, ssize_t len) { len = min(len, r.len); if (r.valid) { memcpy(data, r.data, len); r.valid = 0; r.len = 0; + r.cur_seq_no = 0; } else { printf("No data to be read, len %d \n", len); } return len; } -static int32_t serial_write_data(uint8_t* data, int32_t len) -{ - interface_buffer_handle_t buf_handle = {0}; - - buf_handle.if_type = ESP_SERIAL_IF; - buf_handle.if_num = 0; - buf_handle.payload = data; - buf_handle.payload_len = len; - - if (datapath && if_context && if_context->if_ops && if_context->if_ops->write) - if_context->if_ops->write(if_handle, &buf_handle); -#if CONFIG_ESP_SERIAL_DEBUG - ESP_LOG_BUFFER_HEXDUMP(TAG_TX_S, data, len, ESP_LOG_INFO); -#endif - return len; -} - -#ifdef CONFIG_BT_ENABLED - -#ifdef CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI -static void controller_rcv_pkt_ready(void) -{ - if (vhci_send_sem) - xSemaphoreGive(vhci_send_sem); -} - -static int host_rcv_pkt(uint8_t *data, uint16_t len) +static esp_err_t serial_write_data(uint8_t* data, ssize_t len) { esp_err_t ret = ESP_OK; - interface_buffer_handle_t buf_handle; - uint8_t *buf = NULL; - - buf = (uint8_t *) malloc(len); - - if (!buf) { - ESP_LOGE(TAG, "HCI Send packet: memory allocation failed"); - return ESP_FAIL; - } - - memcpy(buf, data, len); - - memset(&buf_handle, 0, sizeof(buf_handle)); + uint8_t *pos = data; + int32_t left_len = len; + int32_t frag_len = 0; + static uint16_t seq_num = 0; - buf_handle.if_type = ESP_HCI_IF; - buf_handle.if_num = 0; - buf_handle.payload_len = len; - buf_handle.payload = buf; - buf_handle.wlan_buf_handle = buf; - buf_handle.free_buf_handle = free; + do { + interface_buffer_handle_t buf_handle = {0}; - ret = xQueueSend(to_host_queue, &buf_handle, portMAX_DELAY); + seq_num++; - if (ret != pdTRUE) { - ESP_LOGE(TAG, "HCI send packet: Failed to send buffer\n"); - free(buf); - return ESP_FAIL; - } + buf_handle.if_type = ESP_SERIAL_IF; + buf_handle.if_num = 0; + buf_handle.seq_num = seq_num; - return 0; -} - -static esp_vhci_host_callback_t vhci_host_cb = { - controller_rcv_pkt_ready, - host_rcv_pkt -}; -#endif + if (left_len > ETH_DATA_LEN) { + frag_len = ETH_DATA_LEN; + buf_handle.flag = MORE_FRAGMENT; + } else { + frag_len = left_len; + buf_handle.flag = 0; + buf_handle.priv_buffer_handle = data; + buf_handle.free_buf_handle = free; + } -static esp_err_t initialise_bluetooth(void) -{ - esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); + buf_handle.payload = pos; + buf_handle.payload_len = frag_len; -#ifdef CONFIG_BT_HCI_UART_NO -#if CONFIG_BT_HCI_UART_NO == 1 - periph_module_enable(PERIPH_UART1_MODULE); -#elif CONFIG_BT_HCI_UART_NO == 2 - periph_module_enable(PERIPH_UART2_MODULE); -#endif + ret = xQueueSend(to_host_queue[PRIO_Q_SERIAL], &buf_handle, portMAX_DELAY); - periph_module_enable(PERIPH_UHCI0_MODULE); - ESP_ERROR_CHECK( uart_set_pin(CONFIG_BT_HCI_UART_NO, BT_TX_PIN, - BT_RX_PIN, BT_RTS_PIN, BT_CTS_PIN) ); -#endif - ESP_ERROR_CHECK( esp_bt_controller_init(&bt_cfg) ); -#ifdef CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY - ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_BLE) ); -#elif CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY - ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) ); -#elif CONFIG_BTDM_CONTROLLER_MODE_BTDM - ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_BTDM) ); + if (ret != pdTRUE) { + ESP_LOGE(TAG, "Control packet: Failed to send buffer\n"); + if (data) { + free(data); + data = NULL; + } + return ESP_FAIL; + } +#if CONFIG_ESP_SERIAL_DEBUG + ESP_LOG_BUFFER_HEXDUMP(TAG_TX_S, data, frag_len, ESP_LOG_INFO); #endif -#ifdef CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI - esp_err_t ret = ESP_OK; - ret = esp_vhci_host_register_callback(&vhci_host_cb); - - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to register VHCI callback"); - return ret; - } - - vhci_send_sem = xSemaphoreCreateBinary(); - if (vhci_send_sem == NULL) { - ESP_LOGE(TAG, "Failed to create VHCI send sem"); - return ESP_ERR_NO_MEM; - } - - xSemaphoreGive(vhci_send_sem); -#endif + left_len -= frag_len; + pos += frag_len; + } while(left_len); return ESP_OK; } -static void deinitialize_bluetooth(void) -{ -#ifdef CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI - if (vhci_send_sem) { - /* Dummy take and give sema before deleting it */ - xSemaphoreTake(vhci_send_sem, portMAX_DELAY); - xSemaphoreGive(vhci_send_sem); - vSemaphoreDelete(vhci_send_sem); - vhci_send_sem = NULL; - } - esp_bt_controller_disable(); - esp_bt_controller_deinit(); -#endif -} -#endif - static esp_err_t initialise_wifi(void) { wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); @@ -640,24 +551,138 @@ int event_handler(uint8_t val) { switch(val) { case ESP_OPEN_DATA_PATH: - ESP_EARLY_LOGI(TAG, "Start Data Path"); datapath = 1; - if_handle->state = ACTIVE; + if (if_handle) { + if_handle->state = ACTIVE; + ESP_EARLY_LOGI(TAG, "Start Data Path"); + } else { + ESP_EARLY_LOGI(TAG, "Failed to Start Data Path"); + } break; case ESP_CLOSE_DATA_PATH: - ESP_EARLY_LOGI(TAG, "Stop Data Path"); datapath = 0; - if_handle->state = DEACTIVE; + if (if_handle) { + ESP_EARLY_LOGI(TAG, "Stop Data Path"); + if_handle->state = DEACTIVE; + } else { + ESP_EARLY_LOGI(TAG, "Failed to Stop Data Path"); + } break; } return 0; } +#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS +/* These functions are only for debugging purpose + * Please do not enable in production environments + */ +static esp_err_t print_real_time_stats(TickType_t xTicksToWait) +{ + TaskStatus_t *start_array = NULL, *end_array = NULL; + UBaseType_t start_array_size, end_array_size; + uint32_t start_run_time, end_run_time; + esp_err_t ret; + + //Allocate array to store current task states + start_array_size = uxTaskGetNumberOfTasks() + ARRAY_SIZE_OFFSET; + start_array = malloc(sizeof(TaskStatus_t) * start_array_size); + if (start_array == NULL) { + ret = ESP_ERR_NO_MEM; + goto exit; + } + //Get current task states + start_array_size = uxTaskGetSystemState(start_array, start_array_size, &start_run_time); + if (start_array_size == 0) { + ret = ESP_ERR_INVALID_SIZE; + goto exit; + } + + vTaskDelay(xTicksToWait); + + //Allocate array to store tasks states post delay + end_array_size = uxTaskGetNumberOfTasks() + ARRAY_SIZE_OFFSET; + end_array = malloc(sizeof(TaskStatus_t) * end_array_size); + if (end_array == NULL) { + ret = ESP_ERR_NO_MEM; + goto exit; + } + //Get post delay task states + end_array_size = uxTaskGetSystemState(end_array, end_array_size, &end_run_time); + if (end_array_size == 0) { + ret = ESP_ERR_INVALID_SIZE; + goto exit; + } + + //Calculate total_elapsed_time in units of run time stats clock period. + uint32_t total_elapsed_time = (end_run_time - start_run_time); + if (total_elapsed_time == 0) { + ret = ESP_ERR_INVALID_STATE; + goto exit; + } + + printf("| Task | Run Time | Percentage\n"); + //Match each task in start_array to those in the end_array + for (int i = 0; i < start_array_size; i++) { + int k = -1; + for (int j = 0; j < end_array_size; j++) { + if (start_array[i].xHandle == end_array[j].xHandle) { + k = j; + //Mark that task have been matched by overwriting their handles + start_array[i].xHandle = NULL; + end_array[j].xHandle = NULL; + break; + } + } + //Check if matching task found + if (k >= 0) { + uint32_t task_elapsed_time = end_array[k].ulRunTimeCounter - start_array[i].ulRunTimeCounter; + uint32_t percentage_time = (task_elapsed_time * 100UL) / (total_elapsed_time * portNUM_PROCESSORS); + printf("| %s | %d | %d%%\n", start_array[i].pcTaskName, task_elapsed_time, percentage_time); + } + } + + //Print unmatched tasks + for (int i = 0; i < start_array_size; i++) { + if (start_array[i].xHandle != NULL) { + printf("| %s | Deleted\n", start_array[i].pcTaskName); + } + } + for (int i = 0; i < end_array_size; i++) { + if (end_array[i].xHandle != NULL) { + printf("| %s | Created\n", end_array[i].pcTaskName); + } + } + ret = ESP_OK; + +exit: //Common return path + if (start_array) + free(start_array); + if (end_array) + free(end_array); + return ret; +} + +void task_runtime_stats_task(void* pvParameters) +{ + while (1) { + printf("\n\nGetting real time stats over %d ticks\n", STATS_TICKS); + if (print_real_time_stats(STATS_TICKS) == ESP_OK) { + printf("Real time stats obtained\n"); + } else { + printf("Error getting real time stats\n"); + } + vTaskDelay(pdMS_TO_TICKS(1000*2)); + } +} +#endif + void app_main() { esp_err_t ret; uint8_t capa = 0; + uint8_t prio_q_idx = 0; + uint8_t mac[MAC_LEN] = {0}; print_firmware_version(); capa = get_capabilities(); @@ -673,6 +698,14 @@ void app_main() #ifdef CONFIG_BT_ENABLED initialise_bluetooth(); + + ret = esp_read_mac(mac, ESP_MAC_BT); + if (ret) { + ESP_LOGE(TAG,"Failed to read BT Mac addr\n"); + } else { + ESP_LOGI(TAG, "ESP Bluetooth MAC addr: %2x-%2x-%2x-%2x-%2x-%2x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + } #endif pc_pserial = protocomm_new(); @@ -696,24 +729,30 @@ void app_main() return; } - if_handle = if_context->if_ops->init(capa); + if_handle = if_context->if_ops->init(); if (!if_handle) { ESP_LOGE(TAG, "Failed to initialize driver\n"); return; } - to_host_queue = xQueueCreate(TO_HOST_QUEUE_SIZE, sizeof(interface_buffer_handle_t)); - assert(to_host_queue != NULL); + sleep(1); + + /* send capabilities to host */ + generate_startup_event(capa); - from_host_queue = xQueueCreate(FROM_HOST_QUEUE_SIZE, sizeof(interface_buffer_handle_t)); - assert(from_host_queue != NULL); + for (prio_q_idx=0; prio_q_idxpriv; ret = compose_tlv(&out, &outlen); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to compose tlv"); + return ESP_FAIL; + } + + //ESP_LOG_BUFFER_HEXDUMP("serial_tx", out, /*outlen*/ outlen<16?outlen:16, ESP_LOG_INFO); ret = (pserial_cfg->xmit)(out, (ssize_t) outlen); - free(out); - return ret; + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to transmit data"); + return ESP_FAIL; + } + return ESP_OK; } esp_err_t protocomm_pserial_data_ready(protocomm_t *pc, int len) { - printf("data ready \n"); struct pserial_config *pserial_cfg = NULL; pserial_cfg = (struct pserial_config *) pc->priv; if (!pserial_cfg) { @@ -196,7 +204,7 @@ static void pserial_task(void *params) { protocomm_t *pc = (protocomm_t *) params; struct pserial_config *pserial_cfg = NULL; - int len = 0; + int len = 0, ret = 0; uint8_t *buf = NULL; pserial_cfg = (struct pserial_config *) pc->priv; @@ -208,14 +216,22 @@ static void pserial_task(void *params) while (xQueueReceive(pserial_cfg->req_queue, &len, portMAX_DELAY) == pdTRUE) { buf = (uint8_t *) malloc(len); if (buf == NULL) { - ESP_LOGE(TAG,"Failed to allocate memory"); + ESP_LOGE(TAG,"%s Failed to allocate memory", __func__); return; } len = pserial_cfg->recv(buf, len); if (len) { - protocomm_pserial_common_handler(pc, buf, len); - free(buf); - buf = NULL; + //ESP_LOG_BUFFER_HEXDUMP("serial_rx", buf, /*len*/len<16?len:16, ESP_LOG_INFO); + ret = protocomm_pserial_common_handler(pc, buf, len); + if (ret) + ESP_LOGI(TAG, "protocomm_pserial_common_handler failed %d\n", ret); + if (buf) { + free(buf); + buf = NULL; + } + if (ret != ESP_OK) { + return; + } } } @@ -235,7 +251,7 @@ esp_err_t protocomm_pserial_start(protocomm_t *pc, pserial_xmit xmit, pserial_re pserial_cfg = (struct pserial_config *) malloc(sizeof(struct pserial_config)); if (pserial_cfg == NULL) { - ESP_LOGE(TAG,"Failed to allocate memory"); + ESP_LOGE(TAG,"%s Failed to allocate memory", __func__); return ESP_ERR_NO_MEM; } pserial_cfg->xmit = xmit; @@ -243,8 +259,8 @@ esp_err_t protocomm_pserial_start(protocomm_t *pc, pserial_xmit xmit, pserial_re pserial_cfg->req_queue = xQueueCreate(REQ_Q_MAX, sizeof(ssize_t)); pc->priv = pserial_cfg; - - xTaskCreate(pserial_task, "pserial_task", 4096, (void *) pc, TASK_PRIORITY, NULL); + + xTaskCreate(pserial_task, "pserial_task", 4096, (void *) pc, CONTROL_PATH_TASK_PRIORITY, NULL); return ESP_OK; } diff --git a/esp/esp_driver/network_adapter/main/sdio_slave_api.c b/esp/esp_driver/network_adapter/main/sdio_slave_api.c index 7e7ae0d461..9a21ceb1c8 100644 --- a/esp/esp_driver/network_adapter/main/sdio_slave_api.c +++ b/esp/esp_driver/network_adapter/main/sdio_slave_api.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "esp_log.h" #include "interface.h" #include "adapter.h" @@ -32,7 +33,7 @@ interface_context_t context; interface_handle_t if_handle_g; static const char TAG[] = "SDIO_SLAVE"; -static interface_handle_t * sdio_init(uint8_t capabilities); +static interface_handle_t * sdio_init(void); static int32_t sdio_write(interface_handle_t *handle, interface_buffer_handle_t *buf_handle); interface_buffer_handle_t * sdio_read(interface_handle_t *if_handle); static esp_err_t sdio_reset(interface_handle_t *handle); @@ -64,7 +65,7 @@ int interface_remove_driver() return 0; } -static void event_cb(uint8_t val) +IRAM_ATTR static void event_cb(uint8_t val) { if (val == ESP_RESET) { sdio_reset(&if_handle_g); @@ -74,7 +75,64 @@ static void event_cb(uint8_t val) if (context.event_handler) { context.event_handler(val); } +} + +void generate_startup_event(uint8_t cap) +{ + struct esp_payload_header *header = NULL; + interface_buffer_handle_t buf_handle = {0}; + struct esp_priv_event *event = NULL; + uint8_t *pos = NULL; + uint16_t len = 0; + esp_err_t ret = ESP_OK; + + memset(&buf_handle, 0, sizeof(buf_handle)); + + buf_handle.payload = heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_DMA); + assert(buf_handle.payload); + memset(buf_handle.payload, 0, BUFFER_SIZE); + + header = (struct esp_payload_header *) buf_handle.payload; + + header->if_type = ESP_PRIV_IF; + header->if_num = 0; + header->offset = htole16(sizeof(struct esp_payload_header)); + header->priv_pkt_type = ESP_PACKET_TYPE_EVENT; + + /* Populate event data */ + event = (struct esp_priv_event *) (buf_handle.payload + sizeof(struct esp_payload_header)); + + event->event_type = ESP_PRIV_EVENT_INIT; + + /* Populate TLVs for event */ + pos = event->event_data; + + /* TLVs start */ + + /* TLV - Capability */ + *pos = ESP_PRIV_CAPABILITY; pos++;len++; + *pos = LENGTH_1_BYTE; pos++;len++; + *pos = cap; pos++;len++; + + /* TLVs end */ + + event->event_len = len; + + /* payload len = Event len + sizeof(event type) + sizeof(event len) */ + len += 2; + header->len = htole16(len); + + buf_handle.payload_len = len + sizeof(struct esp_payload_header); + header->checksum = htole16(compute_checksum(buf_handle.payload, buf_handle.payload_len)); + ret = sdio_slave_transmit(buf_handle.payload, buf_handle.payload_len); + if (ret != ESP_OK) { + ESP_LOGE(TAG , "sdio slave tx error, ret : 0x%x\r\n", ret); + free(buf_handle.payload); + return; + } + + free(buf_handle.payload); } static void sdio_read_done(void *handle) @@ -82,10 +140,9 @@ static void sdio_read_done(void *handle) sdio_slave_recv_load_buf((sdio_slave_buf_handle_t) handle); } - -static interface_handle_t * sdio_init(uint8_t capabilities) +static interface_handle_t * sdio_init(void) { - esp_err_t ret = 0; + esp_err_t ret = ESP_OK; sdio_slave_config_t config = { .sending_mode = SDIO_SLAVE_SEND_STREAM, .send_queue_size = SDIO_SLAVE_QUEUE_SIZE, @@ -133,9 +190,6 @@ static interface_handle_t * sdio_init(uint8_t capabilities) return NULL; } - /* Advertise slave capabilities at 0th offset of reg HOST_SLCHOST_CONF_W0_REG */ - sdio_slave_write_reg(0, capabilities); - memset(&if_handle_g, 0, sizeof(if_handle_g)); if_handle_g.state = INIT; @@ -145,10 +199,10 @@ static interface_handle_t * sdio_init(uint8_t capabilities) static int32_t sdio_write(interface_handle_t *handle, interface_buffer_handle_t *buf_handle) { esp_err_t ret = ESP_OK; - int32_t total_len; + int32_t total_len = 0; uint8_t* sendbuf = NULL; uint16_t offset = 0; - struct esp_payload_header *header; + struct esp_payload_header *header = NULL; if (!handle || !buf_handle) { ESP_LOGE(TAG , "Invalid arguments"); @@ -159,7 +213,6 @@ static int32_t sdio_write(interface_handle_t *handle, interface_buffer_handle_t return ESP_FAIL; } - if (!buf_handle->payload_len || !buf_handle->payload) { ESP_LOGE(TAG , "Invalid arguments, len:%d", buf_handle->payload_len); return ESP_FAIL; @@ -185,6 +238,10 @@ static int32_t sdio_write(interface_handle_t *handle, interface_buffer_handle_t header->offset = htole16(offset); memcpy(sendbuf + offset, buf_handle->payload, buf_handle->payload_len); + + header->checksum = htole16(compute_checksum(sendbuf, + offset+buf_handle->payload_len)); + ret = sdio_slave_transmit(sendbuf, total_len); if (ret != ESP_OK) { ESP_LOGE(TAG , "sdio slave transmit error, ret : 0x%x\r\n", ret); @@ -200,7 +257,8 @@ static int32_t sdio_write(interface_handle_t *handle, interface_buffer_handle_t interface_buffer_handle_t * sdio_read(interface_handle_t *if_handle) { interface_buffer_handle_t *buf_handle = NULL; - struct esp_payload_header *header; + struct esp_payload_header *header = NULL; + uint16_t rx_checksum = 0, checksum = 0, len; if (!if_handle) { ESP_LOGE(TAG, "Invalid arguments to sdio_read"); @@ -222,6 +280,18 @@ interface_buffer_handle_t * sdio_read(interface_handle_t *if_handle) header = (struct esp_payload_header *) buf_handle->payload; + rx_checksum = le16toh(header->checksum); + + header->checksum = 0; + len = le16toh(header->len) + le16toh(header->offset); + + checksum = compute_checksum(buf_handle->payload, len); + + if (checksum != rx_checksum) { + sdio_read_done(buf_handle->sdio_buf_handle); + return NULL; + } + buf_handle->if_type = header->if_type; buf_handle->if_num = header->if_num; buf_handle->free_buf_handle = sdio_read_done; @@ -231,7 +301,7 @@ interface_buffer_handle_t * sdio_read(interface_handle_t *if_handle) static esp_err_t sdio_reset(interface_handle_t *handle) { - esp_err_t ret; + esp_err_t ret = ESP_OK; sdio_slave_stop(); diff --git a/esp/esp_driver/network_adapter/main/slave_bt.c b/esp/esp_driver/network_adapter/main/slave_bt.c new file mode 100644 index 0000000000..e1a48f649b --- /dev/null +++ b/esp/esp_driver/network_adapter/main/slave_bt.c @@ -0,0 +1,441 @@ +// Copyright 2015-2021 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. +// + +#ifdef CONFIG_BT_ENABLED +#include +#include "driver/periph_ctrl.h" +#include "driver/gpio.h" +#include "driver/uart.h" +#include "soc/lldesc.h" +#include "esp_bt.h" +#include "esp_log.h" +#include "slave_bt.h" + +#ifdef CONFIG_IDF_TARGET_ESP32C3 +#include "esp_private/gdma.h" +#if BLUETOOTH_UART +#include "hal/uhci_ll.h" +#endif +#endif + +static const char BT_TAG[] = "ESP_BT"; +extern QueueHandle_t to_host_queue[MAX_PRIORITY_QUEUES]; + +#if BLUETOOTH_HCI +/* ***** HCI specific part ***** */ + +#define VHCI_MAX_TIMEOUT_MS 2000 +static SemaphoreHandle_t vhci_send_sem; + +static void controller_rcv_pkt_ready(void) +{ + if (vhci_send_sem) + xSemaphoreGive(vhci_send_sem); +} + +static int host_rcv_pkt(uint8_t *data, uint16_t len) +{ + esp_err_t ret = ESP_OK; + interface_buffer_handle_t buf_handle; + uint8_t *buf = NULL; + + buf = (uint8_t *) malloc(len); + + if (!buf) { + ESP_LOGE(BT_TAG, "HCI Send packet: memory allocation failed"); + return ESP_FAIL; + } + + memcpy(buf, data, len); + + memset(&buf_handle, 0, sizeof(buf_handle)); + + buf_handle.if_type = ESP_HCI_IF; + buf_handle.if_num = 0; + buf_handle.payload_len = len; + buf_handle.payload = buf; + buf_handle.wlan_buf_handle = buf; + buf_handle.free_buf_handle = free; + +#if CONFIG_ESP_BT_DEBUG + ESP_LOG_BUFFER_HEXDUMP("bt_tx", data, len, ESP_LOG_INFO); +#endif + ret = xQueueSend(to_host_queue[PRIO_Q_BT], &buf_handle, portMAX_DELAY); + + if (ret != pdTRUE) { + ESP_LOGE(BT_TAG, "HCI send packet: Failed to send buffer\n"); + free(buf); + return ESP_FAIL; + } + + return 0; +} + +static esp_vhci_host_callback_t vhci_host_cb = { + controller_rcv_pkt_ready, + host_rcv_pkt +}; + +void process_hci_rx_pkt(uint8_t *payload, uint16_t payload_len) { + /* VHCI needs one extra byte at the start of payload */ + /* that is accomodated in esp_payload_header */ +#if CONFIG_ESP_BT_DEBUG + ESP_LOG_BUFFER_HEXDUMP("bt_rx", payload, payload_len, ESP_LOG_INFO); +#endif + payload--; + payload_len++; + + if (!esp_vhci_host_check_send_available()) { + ESP_LOGD(BT_TAG, "VHCI not available"); + } + + if (vhci_send_sem) { + if (xSemaphoreTake(vhci_send_sem, VHCI_MAX_TIMEOUT_MS) == pdTRUE) { + esp_vhci_host_send_packet(payload, payload_len); + } else { + ESP_LOGI(BT_TAG, "VHCI sem timeout"); + } + } +} + +#elif BLUETOOTH_UART +/* ***** UART specific part ***** */ + +#ifdef CONFIG_IDF_TARGET_ESP32C3 +// Operation functions for HCI UART Transport Layer +static bool hci_uart_tl_init(void); +static void hci_uart_tl_deinit(void); +static void hci_uart_tl_recv_async(uint8_t *buf, uint32_t size, esp_bt_hci_tl_callback_t callback, void *arg); +static void hci_uart_tl_send_async(uint8_t *buf, uint32_t size, esp_bt_hci_tl_callback_t callback, void *arg); +static void hci_uart_tl_flow_on(void); +static bool hci_uart_tl_flow_off(void); +static void hci_uart_tl_finish_transfers(void); + +struct uart_txrxchannel { + esp_bt_hci_tl_callback_t callback; + void *arg; + lldesc_t link; +}; + +struct uart_env_tag { + struct uart_txrxchannel tx; + struct uart_txrxchannel rx; +}; + +struct uart_env_tag uart_env; + +static volatile uhci_dev_t *s_uhci_hw = &UHCI0; +static gdma_channel_handle_t s_rx_channel; +static gdma_channel_handle_t s_tx_channel; + +static esp_bt_hci_tl_t s_hci_uart_tl_funcs = { + ._magic = ESP_BT_HCI_TL_MAGIC_VALUE, + ._version = ESP_BT_HCI_TL_VERSION, + ._reserved = 0, + ._open = (void *)hci_uart_tl_init, + ._close = (void *)hci_uart_tl_deinit, + ._finish_transfers = (void *)hci_uart_tl_finish_transfers, + ._recv = (void *)hci_uart_tl_recv_async, + ._send = (void *)hci_uart_tl_send_async, + ._flow_on = (void *)hci_uart_tl_flow_on, + ._flow_off = (void *)hci_uart_tl_flow_off, +}; + +static bool hci_uart_tl_init(void) +{ + return true; +} + +static void hci_uart_tl_deinit(void) +{ +} + +static IRAM_ATTR void hci_uart_tl_recv_async(uint8_t *buf, uint32_t size, + esp_bt_hci_tl_callback_t callback, void *arg) +{ + assert(buf != NULL); + assert(size != 0); + assert(callback != NULL); + uart_env.rx.callback = callback; + uart_env.rx.arg = arg; + + memset(&uart_env.rx.link, 0, sizeof(lldesc_t)); + uart_env.rx.link.buf = buf; + uart_env.rx.link.size = size; + + s_uhci_hw->pkt_thres.thrs = size; + + gdma_start(s_rx_channel, (intptr_t)(&uart_env.rx.link)); +} + +static IRAM_ATTR void hci_uart_tl_send_async(uint8_t *buf, uint32_t size, + esp_bt_hci_tl_callback_t callback, void *arg) +{ + assert(buf != NULL); + assert(size != 0); + assert(callback != NULL); + + uart_env.tx.callback = callback; + uart_env.tx.arg = arg; + + memset(&uart_env.tx.link, 0, sizeof(lldesc_t)); + uart_env.tx.link.length = size; + uart_env.tx.link.buf = buf; + uart_env.tx.link.eof = 1; + + gdma_start(s_tx_channel, (intptr_t)(&uart_env.tx.link)); +} + +static void hci_uart_tl_flow_on(void) +{ +} + +static bool hci_uart_tl_flow_off(void) +{ + return true; +} + +static void hci_uart_tl_finish_transfers(void) +{ +} + +static IRAM_ATTR bool hci_uart_tl_rx_eof_callback(gdma_channel_handle_t dma_chan, + gdma_event_data_t *event_data, void *user_data) +{ + assert(dma_chan == s_rx_channel); + assert(uart_env.rx.callback != NULL); + esp_bt_hci_tl_callback_t callback = uart_env.rx.callback; + void *arg = uart_env.rx.arg; + + // clear callback pointer + uart_env.rx.callback = NULL; + uart_env.rx.arg = NULL; + + // call handler + callback(arg, ESP_BT_HCI_TL_STATUS_OK); + + // send notification to Bluetooth Controller task + esp_bt_h4tl_eif_io_event_notify(1); + + return true; +} + +static IRAM_ATTR bool hci_uart_tl_tx_eof_callback(gdma_channel_handle_t dma_chan, + gdma_event_data_t *event_data, void *user_data) +{ + assert(dma_chan == s_tx_channel); + assert(uart_env.tx.callback != NULL); + esp_bt_hci_tl_callback_t callback = uart_env.tx.callback; + void *arg = uart_env.tx.arg; + + // clear callback pointer + uart_env.tx.callback = NULL; + uart_env.tx.arg = NULL; + + // call handler + callback(arg, ESP_BT_HCI_TL_STATUS_OK); + + // send notification to Bluetooth Controller task + esp_bt_h4tl_eif_io_event_notify(1); + + return true; +} +#endif + +static void init_uart(void) +{ +#if BLUETOOTH_UART == 1 + periph_module_enable(PERIPH_UART1_MODULE); + periph_module_reset(PERIPH_UART1_MODULE); +#elif BLUETOOTH_UART == 2 + periph_module_enable(PERIPH_UART2_MODULE); + periph_module_reset(PERIPH_UART2_MODULE); +#endif + + periph_module_enable(PERIPH_UHCI0_MODULE); + periph_module_reset(PERIPH_UHCI0_MODULE); + +#ifdef CONFIG_IDF_TARGET_ESP32C3 + gpio_config_t io_output_conf = { + .intr_type = GPIO_PIN_INTR_DISABLE, //disable interrupt + .mode = GPIO_MODE_OUTPUT, // output mode + .pin_bit_mask = GPIO_OUTPUT_PIN_SEL, // bit mask of the output pins + .pull_down_en = 0, // disable pull-down mode + .pull_up_en = 0, // disable pull-up mode + }; + gpio_config(&io_output_conf); + + gpio_config_t io_input_conf = { + .intr_type = GPIO_PIN_INTR_DISABLE, //disable interrupt + .mode = GPIO_MODE_INPUT, // input mode + .pin_bit_mask = GPIO_INPUT_PIN_SEL, // bit mask of the input pins + .pull_down_en = 0, // disable pull-down mode + .pull_up_en = 0, // disable pull-down mode + }; + gpio_config(&io_input_conf); +#endif + + ESP_ERROR_CHECK( uart_set_pin(BLUETOOTH_UART, BT_TX_PIN, + BT_RX_PIN, BT_RTS_PIN, BT_CTS_PIN) ); + +#ifdef CONFIG_IDF_TARGET_ESP32C3 + // configure UART1 + ESP_LOGI(BT_TAG, "baud rate for HCI uart :: %d \n", + CONFIG_EXAMPLE_ESP32C3_HCI_UART_BAUDRATE); + + uart_config_t uart_config = { + .baud_rate = CONFIG_EXAMPLE_ESP32C3_HCI_UART_BAUDRATE, + + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS, + .rx_flow_ctrl_thresh = UART_RX_THRS, + .source_clk = UART_SCLK_APB, + }; + ESP_ERROR_CHECK(uart_param_config(BLUETOOTH_UART, &uart_config)); + + // install DMA driver + gdma_channel_alloc_config_t tx_channel_config = { + .flags.reserve_sibling = 1, + .direction = GDMA_CHANNEL_DIRECTION_TX, + }; + ESP_ERROR_CHECK(gdma_new_channel(&tx_channel_config, &s_tx_channel)); + gdma_channel_alloc_config_t rx_channel_config = { + .direction = GDMA_CHANNEL_DIRECTION_RX, + .sibling_chan = s_tx_channel, + }; + ESP_ERROR_CHECK(gdma_new_channel(&rx_channel_config, &s_rx_channel)); + + gdma_connect(s_tx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UART, 0)); + gdma_connect(s_rx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UART, 0)); + + gdma_strategy_config_t strategy_config = { + .auto_update_desc = false, + .owner_check = false + }; + gdma_apply_strategy(s_tx_channel, &strategy_config); + gdma_apply_strategy(s_rx_channel, &strategy_config); + + gdma_rx_event_callbacks_t rx_cbs = { + .on_recv_eof = hci_uart_tl_rx_eof_callback + }; + gdma_register_rx_event_callbacks(s_rx_channel, &rx_cbs, NULL); + + gdma_tx_event_callbacks_t tx_cbs = { + .on_trans_eof = hci_uart_tl_tx_eof_callback + }; + gdma_register_tx_event_callbacks(s_tx_channel, &tx_cbs, NULL); + + // configure UHCI + uhci_ll_init(s_uhci_hw); + uhci_ll_set_eof_mode(s_uhci_hw, UHCI_RX_LEN_EOF); + // disable software flow control + s_uhci_hw->escape_conf.val = 0; + uhci_ll_attach_uart_port(s_uhci_hw, 1); +#endif +} + +#endif + +esp_err_t initialise_bluetooth(void) +{ + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); + + +#ifdef BLUETOOTH_UART + #ifdef CONFIG_IDF_TARGET_ESP32C3 + bt_cfg.hci_tl_funcs = &s_hci_uart_tl_funcs; + #endif + + init_uart(); +#endif + ESP_ERROR_CHECK( esp_bt_controller_init(&bt_cfg) ); +#if BLUETOOTH_BLE + ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_BLE) ); +#elif BLUETOOTH_BT + ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) ); +#elif BLUETOOTH_BT_BLE + ESP_ERROR_CHECK( esp_bt_controller_enable(ESP_BT_MODE_BTDM) ); +#endif + +#if BLUETOOTH_HCI + esp_err_t ret = ESP_OK; + ret = esp_vhci_host_register_callback(&vhci_host_cb); + + if (ret != ESP_OK) { + ESP_LOGE(BT_TAG, "Failed to register VHCI callback"); + return ret; + } + + vhci_send_sem = xSemaphoreCreateBinary(); + if (vhci_send_sem == NULL) { + ESP_LOGE(BT_TAG, "Failed to create VHCI send sem"); + return ESP_ERR_NO_MEM; + } + + xSemaphoreGive(vhci_send_sem); +#endif + + return ESP_OK; +} + +void deinitialize_bluetooth(void) +{ +#if BLUETOOTH_HCI + if (vhci_send_sem) { + /* Dummy take and give sema before deleting it */ + xSemaphoreTake(vhci_send_sem, portMAX_DELAY); + xSemaphoreGive(vhci_send_sem); + vSemaphoreDelete(vhci_send_sem); + vhci_send_sem = NULL; + } + esp_bt_controller_disable(); + esp_bt_controller_deinit(); +#endif +} + +uint8_t get_bluetooth_capabilities(void) +{ + uint8_t cap = 0; + ESP_LOGI(BT_TAG, "- BT/BLE"); +#if BLUETOOTH_HCI +#if CONFIG_ESP_SPI_HOST_INTERFACE + ESP_LOGI(BT_TAG, " - HCI Over SPI"); + cap |= ESP_BT_SPI_SUPPORT; +#else + ESP_LOGI(BT_TAG, " - HCI Over SDIO"); + cap |= ESP_BT_SDIO_SUPPORT; +#endif +#elif BLUETOOTH_UART + ESP_LOGI(BT_TAG, " - HCI Over UART"); + cap |= ESP_BT_UART_SUPPORT; +#endif + +#if BLUETOOTH_BLE + ESP_LOGI(BT_TAG, " - BLE only"); + cap |= ESP_BLE_ONLY_SUPPORT; +#elif BLUETOOTH_BT + ESP_LOGI(BT_TAG, " - BR_EDR only"); + cap |= ESP_BR_EDR_ONLY_SUPPORT; +#elif BLUETOOTH_BT_BLE + ESP_LOGI(BT_TAG, " - BT/BLE dual mode"); + cap |= ESP_BLE_ONLY_SUPPORT | ESP_BR_EDR_ONLY_SUPPORT; +#endif + return cap; +} + + +#endif diff --git a/esp/esp_driver/network_adapter/main/slave_bt.h b/esp/esp_driver/network_adapter/main/slave_bt.h new file mode 100644 index 0000000000..41a5996558 --- /dev/null +++ b/esp/esp_driver/network_adapter/main/slave_bt.h @@ -0,0 +1,78 @@ +// Copyright 2015-2021 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 __SLAVE_BT_H__ +#define __SLAVE_BT_H__ + +#ifdef CONFIG_BT_ENABLED + +#ifdef CONFIG_IDF_TARGET_ESP32C3 + #if (CONFIG_BT_CTRL_MODE_EFF == 1) + #define BLUETOOTH_BLE 1 + #elif (CONFIG_BT_CTRL_MODE_EFF == 2) + #define BLUETOOTH_BT 2 + #elif (CONFIG_BT_CTRL_MODE_EFF == 3) + #define BLUETOOTH_BT_BLE 3 + #endif + + #if defined(CONFIG_BT_CTRL_HCI_MODE_VHCI) + #define BLUETOOTH_HCI 4 + #elif CONFIG_BT_CTRL_HCI_MODE_UART_H4 + #define BLUETOOTH_UART 1 + #endif + +#else + #if defined(CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY) + #define BLUETOOTH_BLE 1 + #elif defined(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) + #define BLUETOOTH_BT 2 + #elif defined(CONFIG_BTDM_CONTROLLER_MODE_BTDM) + #define BLUETOOTH_BT_BLE 3 + #endif + + #if defined(CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI) + #define BLUETOOTH_HCI 4 + #elif CONFIG_BT_HCI_UART_NO + #define BLUETOOTH_UART CONFIG_BT_HCI_UART_NO + #elif CONFIG_BTDM_CTRL_HCI_UART_NO + #define BLUETOOTH_UART CONFIG_BTDM_CTRL_HCI_UART_NO + #endif + +#endif + +#ifdef BLUETOOTH_UART + #include "driver/uart.h" + #define BT_TX_PIN 5 + #define BT_RX_PIN 18 + #define BT_RTS_PIN 19 + #ifdef CONFIG_IDF_TARGET_ESP32C3 + #define BT_CTS_PIN 8 + #define GPIO_OUTPUT_PIN_SEL ((1ULL<reason == WIFI_REASON_NO_AP_FOUND) { xEventGroupSetBits(wifi_event_group, WIFI_NO_AP_FOUND_BIT); @@ -121,6 +140,7 @@ static void softap_event_handler(void *arg, esp_event_base_t event_base, MAC2STR(event->mac), event->aid); } else if (event_id == WIFI_EVENT_AP_START) { esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, (wifi_rxcb_t) wlan_ap_rx_callback); + esp_update_ap_mac(); } else if (event_id == WIFI_EVENT_AP_STOP) { ESP_LOGI(TAG,"softap stop handler stop"); esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP,NULL); @@ -232,9 +252,9 @@ typedef struct esp_hosted_config_cmd { static esp_err_t cmd_get_mac_address_handler(EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - uint8_t mac[MAC_LEN]; - char mac_str[BSSID_LENGTH]; + esp_err_t ret = ESP_OK; + uint8_t mac[MAC_LEN] = {0}; + char mac_str[BSSID_LENGTH] = ""; EspHostedRespGetMacAddress *resp_payload = NULL; if (!req || !resp || !req->cmd_get_mac_address) { @@ -298,8 +318,8 @@ static esp_err_t cmd_get_mac_address_handler(EspHostedConfigPayload *req, static esp_err_t cmd_get_wifi_mode_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_mode_t mode; + esp_err_t ret = ESP_OK; + wifi_mode_t mode = 0; EspHostedRespGetMode *resp_payload = NULL; if (!req || !resp) { @@ -336,8 +356,8 @@ static esp_err_t cmd_get_wifi_mode_handler (EspHostedConfigPayload *req, static esp_err_t cmd_set_wifi_mode_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_mode_t num; + esp_err_t ret = ESP_OK; + wifi_mode_t num = 0; EspHostedRespSetMode *resp_payload = NULL; if (!req || !resp || !req->cmd_set_wifi_mode) { @@ -379,7 +399,7 @@ static esp_err_t cmd_set_wifi_mode_handler (EspHostedConfigPayload *req, static esp_err_t cmd_set_ap_config_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; + esp_err_t ret = ESP_OK; bool event_registered = false; wifi_config_t *wifi_cfg = NULL; EspHostedRespSetAPConfig *resp_payload = NULL; @@ -476,7 +496,7 @@ static esp_err_t cmd_set_ap_config_handler (EspHostedConfigPayload *req, } EventBits_t bits = xEventGroupWaitBits(wifi_event_group, - (WIFI_CONNECTED_BIT | WIFI_FAIL_BIT | + (WIFI_CONNECTED_BIT | WIFI_FAIL_BIT | WIFI_NO_AP_FOUND_BIT | WIFI_WRONG_PASSWORD_BIT), pdFALSE, pdFALSE, @@ -526,7 +546,7 @@ static esp_err_t cmd_set_ap_config_handler (EspHostedConfigPayload *req, static esp_err_t cmd_get_ap_config_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; + esp_err_t ret = ESP_OK; credentials_t credentials = {0}; wifi_ap_record_t *ap_info = NULL; EspHostedRespGetAPConfig *resp_payload = NULL; @@ -621,7 +641,7 @@ static esp_err_t cmd_get_ap_config_handler (EspHostedConfigPayload *req, static esp_err_t cmd_disconnect_ap_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; + esp_err_t ret = ESP_OK; EspHostedRespGetStatus *resp_payload = NULL; if (!req || !resp) { ESP_LOGE(TAG, "Invalid parameters"); @@ -664,8 +684,8 @@ static esp_err_t cmd_disconnect_ap_handler (EspHostedConfigPayload *req, static esp_err_t cmd_get_softap_config_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_bandwidth_t get_bw; + esp_err_t ret = ESP_OK; + wifi_bandwidth_t get_bw = 0; credentials_t credentials = {0}; wifi_config_t get_conf = {0}; EspHostedRespGetSoftAPConfig *resp_payload = NULL; @@ -765,8 +785,8 @@ static esp_err_t cmd_get_softap_config_handler (EspHostedConfigPayload *req, static esp_err_t cmd_set_softap_config_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - uint8_t mac[MAC_LEN]; + esp_err_t ret = ESP_OK; + uint8_t mac[MAC_LEN] = {0}; wifi_config_t *wifi_config = NULL; EspHostedRespSetSoftAPConfig *resp_payload = NULL; @@ -887,8 +907,8 @@ static esp_err_t cmd_set_softap_config_handler (EspHostedConfigPayload *req, static esp_err_t cmd_get_ap_scan_list_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_mode_t mode; + esp_err_t ret = ESP_OK; + wifi_mode_t mode = 0; uint16_t ap_count = 0; credentials_t credentials = {0}; wifi_ap_record_t *ap_info = NULL; @@ -1048,8 +1068,8 @@ static esp_err_t cmd_get_ap_scan_list_handler (EspHostedConfigPayload *req, static esp_err_t cmd_stop_softap_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_mode_t mode; + esp_err_t ret = ESP_OK; + wifi_mode_t mode = 0; EspHostedRespGetStatus *resp_payload = NULL; if (!req || !resp) { @@ -1104,8 +1124,8 @@ static esp_err_t cmd_stop_softap_handler (EspHostedConfigPayload *req, static esp_err_t get_connected_sta_list_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; - wifi_mode_t mode; + esp_err_t ret = ESP_OK; + wifi_mode_t mode = 0; credentials_t credentials = {0}; EspHostedRespConnectedSTA *resp_payload = NULL; EspHostedConnectedSTAList **results = NULL; @@ -1163,7 +1183,7 @@ static esp_err_t get_connected_sta_list_handler (EspHostedConfigPayload *req, resp_payload->num = stas_info->num; if (stas_info->num) { resp_payload->n_stations = stas_info->num; - results = (EspHostedConnectedSTAList **)calloc(stas_info->num, \ + results = (EspHostedConnectedSTAList **)calloc(stas_info->num, sizeof(EspHostedConnectedSTAList)); if (!results) { ESP_LOGE(TAG,"Failed to allocate memory for connected stations"); @@ -1173,7 +1193,7 @@ static esp_err_t get_connected_sta_list_handler (EspHostedConfigPayload *req, for (int i = 0; i < stas_info->num ; i++) { snprintf((char *)credentials.bssid,BSSID_LENGTH, MACSTR,MAC2STR(stas_info->sta[i].mac)); - results[i] = (EspHostedConnectedSTAList *)calloc(1,\ + results[i] = (EspHostedConnectedSTAList *)calloc(1, sizeof(EspHostedConnectedSTAList)); if (!results[i]) { ESP_LOGE(TAG,"Failed to allocated memory"); @@ -1329,7 +1349,7 @@ static esp_err_t cmd_get_power_save_mode_handler (EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { esp_err_t ret = ESP_OK; - wifi_ps_type_t ps_type; + wifi_ps_type_t ps_type = 0; EspHostedRespGetMode *resp_payload = NULL; if (!req || !resp) { @@ -1351,6 +1371,7 @@ static esp_err_t cmd_get_power_save_mode_handler (EspHostedConfigPayload *req, if (ret) { ESP_LOGE(TAG, "Failed to set power save mode"); resp_payload->resp = FAILURE; + return ESP_OK; } else { resp->resp_get_power_save_mode->has_mode = true; resp->resp_get_power_save_mode->mode = ps_type; @@ -1360,6 +1381,290 @@ static esp_err_t cmd_get_power_save_mode_handler (EspHostedConfigPayload *req, return ESP_OK; } +// Function OTA begin +static esp_err_t cmd_ota_begin_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + EspHostedRespOTABegin *resp_payload = NULL; + + if (!req || !resp) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + ESP_LOGI(TAG, "OTA update started"); + + resp_payload = (EspHostedRespOTABegin *) + calloc(1,sizeof(EspHostedRespOTABegin)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + esp_hosted_resp_otabegin__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_BEGIN; + resp->resp_ota_begin = resp_payload; + resp_payload->has_resp = true; + + // Identify next OTA partition + update_partition = esp_ota_get_next_update_partition(NULL); + if (update_partition == NULL) { + ESP_LOGE(TAG, "Failed to get next update partition"); + goto err; + } + + ESP_LOGI(TAG, "Prepare partition for OTA\n"); + ota_ongoing=1; +#if CONFIG_ESP_OTA_WORKAROUND + vTaskDelay(OTA_SLEEP_TIME_MS/portTICK_PERIOD_MS); +#endif + ret = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &handle); + ota_ongoing=0; + if (ret) { + ESP_LOGE(TAG, "OTA update failed in OTA begin"); + goto err; + } + + ota_msg = 1; + + resp_payload->resp = SUCCESS; + return ESP_OK; +err: + resp_payload->resp = FAILURE; + return ESP_OK; + +} + +// Function OTA write +static esp_err_t cmd_ota_write_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + EspHostedRespOTAWrite *resp_payload = NULL; + + if (!req || !resp) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + resp_payload = (EspHostedRespOTAWrite *)calloc(1,sizeof(EspHostedRespOTAWrite)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + + if (ota_msg) { + ESP_LOGI(TAG, "Flashing image\n"); + ota_msg = 0; + } + esp_hosted_resp_otawrite__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_WRITE; + resp->resp_ota_write = resp_payload; + resp_payload->has_resp = true; + + ota_ongoing=1; +#if CONFIG_ESP_OTA_WORKAROUND + /* Delay added is to give chance to transfer pending data at transport + * Care to be taken, when OTA ongoing, no other processing should happen + * So big sleep is added before any flash operations start + * */ + vTaskDelay(OTA_SLEEP_TIME_MS/portTICK_PERIOD_MS); +#endif + printf("."); + fflush(stdout); + ret = esp_ota_write( handle, (const void *)req->cmd_ota_write->ota_data.data, req->cmd_ota_write->ota_data.len); + ota_ongoing=0; + if (ret != ESP_OK) { + ESP_LOGE(TAG, "OTA write failed with return code 0x%x",ret); + resp_payload->resp = FAILURE; + return ESP_OK; + } + resp_payload->resp = SUCCESS; + return ESP_OK; +} + +// Function OTA end +static esp_err_t cmd_ota_end_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + EspHostedRespOTAEnd *resp_payload = NULL; + TimerHandle_t xTimer = NULL; + + if (!req || !resp) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + resp_payload = (EspHostedRespOTAEnd *)calloc(1,sizeof(EspHostedRespOTAEnd)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + esp_hosted_resp_otaend__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_OTA_END; + resp->resp_ota_end = resp_payload; + resp_payload->has_resp = true; + + ota_ongoing=1; +#if CONFIG_ESP_OTA_WORKAROUND + vTaskDelay(OTA_SLEEP_TIME_MS/portTICK_PERIOD_MS); +#endif + ret = esp_ota_end(handle); + ota_ongoing=0; + if (ret != ESP_OK) { + if (ret == ESP_ERR_OTA_VALIDATE_FAILED) { + ESP_LOGE(TAG, "Image validation failed, image is corrupted"); + } else { + ESP_LOGE(TAG, "OTA update failed in end (%s)!", esp_err_to_name(ret)); + } + goto err; + } + + // set OTA partition for next boot + ret = esp_ota_set_boot_partition(update_partition); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(ret)); + goto err; + } + xTimer = xTimerCreate("Timer", RESTART_TIMEOUT , pdFALSE, 0, vTimerCallback); + if (xTimer == NULL) { + ESP_LOGE(TAG, "Failed to create timer to restart system"); + goto err; + } + ret = xTimerStart(xTimer, 0); + if (ret != pdPASS) { + ESP_LOGE(TAG, "Failed to start timer to restart system"); + goto err; + } + ESP_LOGE(TAG, "**** OTA updated successfully, ESP32 will be rebooted in 5 sec ****"); + resp_payload->resp = SUCCESS; + return ESP_OK; +err: + resp_payload->resp = FAILURE; + return ESP_OK; +} + +// Function vendor specific ie +static esp_err_t cmd_set_vender_specific_ie_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + EspHostedRespSetVendorSpecificIE *resp_payload = NULL; + + if (!req || !resp || !req->cmd_set_vendor_specific_ie || + !req->cmd_set_vendor_specific_ie->vendor_ie_data.len || + !req->cmd_set_vendor_specific_ie->vendor_ie_data.data) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + resp_payload = (EspHostedRespSetVendorSpecificIE *) + calloc(1,sizeof(EspHostedRespSetVendorSpecificIE)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + esp_hosted_resp_set_vendor_specific_ie__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_VENDOR_SPECIFIC_IE; + resp->resp_set_vendor_specific_ie = resp_payload; + resp_payload->has_resp = true; + + ret = esp_wifi_set_vendor_ie(req->cmd_set_vendor_specific_ie->enable, + req->cmd_set_vendor_specific_ie->type, req->cmd_set_vendor_specific_ie->idx, + req->cmd_set_vendor_specific_ie->vendor_ie_data.data); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to set vendor information element %d \n", ret); + resp_payload->resp = FAILURE; + return ESP_OK; + } + resp_payload->resp = SUCCESS; + return ESP_OK; +} + +// Function set wifi maximum TX power +static esp_err_t cmd_set_wifi_max_tx_power_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + EspHostedRespSetWiFiMAXTXPower *resp_payload = NULL; + + if (!req || !resp ) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + resp_payload = (EspHostedRespSetWiFiMAXTXPower *) + calloc(1,sizeof(EspHostedRespSetWiFiMAXTXPower)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + esp_hosted_resp_set_wi_fi_maxtxpower__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_WIFI_MAX_TX_POWER; + resp->resp_set_wifi_max_tx_power = resp_payload; + resp_payload->has_resp = true; + + if ((req->cmd_set_wifi_max_tx_power->wifi_max_tx_power > MAX_TX_POWER) + || (req->cmd_set_wifi_max_tx_power->wifi_max_tx_power < MIN_TX_POWER)) { + ESP_LOGE(TAG, "Invalid maximum transmitting power value"); + ESP_LOGE(TAG, "Value lies between [8,84]"); + ESP_LOGE(TAG, "Please refer `wifi_set_max_tx_power` API documentation \n"); + resp_payload->resp = ESP_HOSTED_STATUS__TYPE_OUT_OF_RANGE; + return ESP_OK; + } + + ret = esp_wifi_set_max_tx_power(req->cmd_set_wifi_max_tx_power->wifi_max_tx_power); + if (ret != SUCCESS) { + ESP_LOGE(TAG, "Failed to set TX power"); + goto err; + } + resp_payload->resp = SUCCESS; + return ESP_OK; +err: + resp_payload->resp = FAILURE; + return ESP_OK; +} + +// Function get wifi TX current power +static esp_err_t cmd_get_wifi_curr_tx_power_handler (EspHostedConfigPayload *req, + EspHostedConfigPayload *resp, void *priv_data) +{ + esp_err_t ret = ESP_OK; + int8_t power = 0; + EspHostedRespGetWiFiCurrTXPower *resp_payload = NULL; + + if (!req || !resp) { + ESP_LOGE(TAG, "Invalid parameters"); + return ESP_FAIL; + } + + resp_payload = (EspHostedRespGetWiFiCurrTXPower *) + calloc(1,sizeof(EspHostedRespGetWiFiCurrTXPower)); + if (!resp_payload) { + ESP_LOGE(TAG,"Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } + + esp_hosted_resp_get_wi_fi_curr_txpower__init(resp_payload); + resp->payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_WIFI_CURR_TX_POWER; + resp->resp_get_wifi_curr_tx_power = resp_payload; + resp_payload->has_resp = true; + + ret = esp_wifi_get_max_tx_power(&power); + if (ret != SUCCESS) { + ESP_LOGE(TAG, "Failed to get TX power"); + goto err; + } + resp_payload->has_wifi_curr_tx_power = true; + resp_payload->wifi_curr_tx_power = power; + resp_payload->resp = SUCCESS; + return ESP_OK; +err: + resp_payload->resp = FAILURE; + return ESP_OK; +} + static esp_hosted_config_cmd_t cmd_table[] = { { .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetMACAddress , @@ -1417,6 +1722,30 @@ static esp_hosted_config_cmd_t cmd_table[] = { .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetPowerSaveMode, .command_handler = cmd_get_power_save_mode_handler }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTABegin, + .command_handler = cmd_ota_begin_handler + }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAWrite, + .command_handler = cmd_ota_write_handler + }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAEnd, + .command_handler = cmd_ota_end_handler + }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetVendorSpecificIE, + .command_handler = cmd_set_vender_specific_ie_handler + }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetWiFiMAXTXPower, + .command_handler = cmd_set_wifi_max_tx_power_handler + }, + { + .cmd_num = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetWiFiCurrTXPower, + .command_handler = cmd_get_wifi_curr_tx_power_handler + }, }; @@ -1434,7 +1763,7 @@ static esp_err_t esp_hosted_config_command_dispatcher( EspHostedConfigPayload *req, EspHostedConfigPayload *resp, void *priv_data) { - esp_err_t ret; + esp_err_t ret = ESP_OK; int cmd_index = 0; if (!req || !resp) { @@ -1554,6 +1883,30 @@ static void esp_hosted_config_cleanup(EspHostedConfigPayload *resp) mem_free(resp->resp_get_power_save_mode); break; } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTABegin) : { + mem_free(resp->resp_ota_begin); + break; + } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAWrite) : { + mem_free(resp->resp_ota_write); + break; + } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespOTAEnd) : { + mem_free(resp->resp_ota_end); + break; + } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetVendorSpecificIE) : { + mem_free(resp->resp_set_vendor_specific_ie); + break; + } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespSetWiFiMAXTXPower) : { + mem_free(resp->resp_set_wifi_max_tx_power); + break; + } + case (ESP_HOSTED_CONFIG_MSG_TYPE__TypeRespGetWiFiCurrTXPower) : { + mem_free(resp->resp_get_wifi_curr_tx_power); + break; + } default: ESP_LOGE(TAG, "Unsupported response type"); break; @@ -1563,7 +1916,7 @@ static void esp_hosted_config_cleanup(EspHostedConfigPayload *resp) esp_err_t data_transfer_handler(uint32_t session_id,const uint8_t *inbuf, ssize_t inlen, uint8_t **outbuf, ssize_t *outlen, void *priv_data) { - EspHostedConfigPayload *req, resp; + EspHostedConfigPayload *req = NULL, resp = {0}; esp_err_t ret = ESP_OK; if (!inbuf || !outbuf || !outlen) { diff --git a/esp/esp_driver/network_adapter/main/slave_commands.h b/esp/esp_driver/network_adapter/main/slave_commands.h index b3f3f59e35..322c11d35a 100644 --- a/esp/esp_driver/network_adapter/main/slave_commands.h +++ b/esp/esp_driver/network_adapter/main/slave_commands.h @@ -19,6 +19,7 @@ #define PASSWORD_LENGTH 64 #define BSSID_LENGTH 19 #define TIMEOUT_IN_SEC (1000 / portTICK_RATE_MS) +#define MAC_LEN 6 typedef struct { uint8_t ssid[SSID_LENGTH]; diff --git a/esp/esp_driver/network_adapter/main/spi_slave_api.c b/esp/esp_driver/network_adapter/main/spi_slave_api.c index cdc91ab7e2..329d65ef6c 100644 --- a/esp/esp_driver/network_adapter/main/spi_slave_api.c +++ b/esp/esp_driver/network_adapter/main/spi_slave_api.c @@ -68,7 +68,7 @@ static const char TAG[] = "SPI_DRIVER"; #else #error "Please choose correct SPI controller" #endif - + #define DMA_CHAN ESP_SPI_CONTROLLER #elif defined CONFIG_IDF_TARGET_ESP32S2 @@ -102,26 +102,23 @@ static const char TAG[] = "SPI_DRIVER"; #define SPI_TX_QUEUE_SIZE 5 #endif -#define LENGTH_1_BYTE 1 - static interface_context_t context; static interface_handle_t if_handle_g; static uint8_t gpio_handshake = CONFIG_ESP_SPI_GPIO_HANDSHAKE; static uint8_t gpio_data_ready = CONFIG_ESP_SPI_GPIO_DATA_READY; -static QueueHandle_t spi_rx_queue = NULL; -static QueueHandle_t spi_tx_queue = NULL; -static uint8_t dummy_queued = pdFALSE; +static QueueHandle_t spi_rx_queue[MAX_PRIORITY_QUEUES] = {NULL}; +static QueueHandle_t spi_tx_queue[MAX_PRIORITY_QUEUES] = {NULL}; -static interface_handle_t * esp_spi_init(uint8_t capabilities); +static interface_handle_t * esp_spi_init(void); static int32_t esp_spi_write(interface_handle_t *handle, interface_buffer_handle_t *buf_handle); static interface_buffer_handle_t * esp_spi_read(interface_handle_t *if_handle); static esp_err_t esp_spi_reset(interface_handle_t *handle); static void esp_spi_deinit(interface_handle_t *handle); static void esp_spi_read_done(void *handle); +static void queue_next_transaction(void); -static xSemaphoreHandle spi_sema; if_ops_t if_ops = { .init = esp_spi_init, @@ -149,31 +146,78 @@ int interface_remove_driver() return 0; } -static int is_valid_trans_buffer(uint8_t *trans_buf) +void generate_startup_event(uint8_t cap) { - struct esp_payload_header *header; - uint16_t len, offset; + struct esp_payload_header *header = NULL; + interface_buffer_handle_t buf_handle = {0}; + struct esp_priv_event *event = NULL; + uint8_t *pos = NULL; + uint16_t len = 0; - if (!trans_buf) { - return pdFALSE; - } + memset(&buf_handle, 0, sizeof(buf_handle)); - header = (struct esp_payload_header *) trans_buf; + buf_handle.payload = heap_caps_malloc(SPI_BUFFER_SIZE, MALLOC_CAP_DMA); + assert(buf_handle.payload); + memset(buf_handle.payload, 0, SPI_BUFFER_SIZE); - len = le16toh(header->len); - offset = le16toh(header->offset); + header = (struct esp_payload_header *) buf_handle.payload; - if (!len || (len > SPI_BUFFER_SIZE)) { - return pdFALSE; - } + header->if_type = ESP_PRIV_IF; + header->if_num = 0; + header->offset = htole16(sizeof(struct esp_payload_header)); + header->priv_pkt_type = ESP_PACKET_TYPE_EVENT; - if ((header->if_type >= ESP_MAX_IF) || (header->if_num)) { - return pdFALSE; - } + /* Populate event data */ + event = (struct esp_priv_event *) (buf_handle.payload + sizeof(struct esp_payload_header)); + + event->event_type = ESP_PRIV_EVENT_INIT; - return pdTRUE; + /* Populate TLVs for event */ + pos = event->event_data; + + /* TLVs start */ + + /* TLV - Board type */ + *pos = ESP_PRIV_FIRMWARE_CHIP_ID; pos++;len++; + *pos = LENGTH_1_BYTE; pos++;len++; + *pos = CONFIG_IDF_FIRMWARE_CHIP_ID; pos++;len++; + + /* TLV - Peripheral clock in MHz */ + *pos = ESP_PRIV_SPI_CLK_MHZ; pos++;len++; + *pos = LENGTH_1_BYTE; pos++;len++; +#ifdef CONFIG_IDF_TARGET_ESP32 + *pos = SPI_CLK_MHZ_ESP32; pos++;len++; +#elif defined CONFIG_IDF_TARGET_ESP32S2 + *pos = SPI_CLK_MHZ_ESP32_S2; pos++;len++; +#elif defined CONFIG_IDF_TARGET_ESP32C3 + *pos = SPI_CLK_MHZ_ESP32_C3; pos++;len++; +#endif + + /* TLV - Capability */ + *pos = ESP_PRIV_CAPABILITY; pos++;len++; + *pos = LENGTH_1_BYTE; pos++;len++; + *pos = cap; pos++;len++; + + /* TLVs end */ + + event->event_len = len; + + /* payload len = Event len + sizeof(event type) + sizeof(event len) */ + len += 2; + header->len = htole16(len); + + buf_handle.payload_len = len + sizeof(struct esp_payload_header); + header->checksum = htole16(compute_checksum(buf_handle.payload, buf_handle.payload_len)); + + xQueueSend(spi_tx_queue[PRIO_Q_OTHERS], &buf_handle, portMAX_DELAY); + + /* indicate waiting data on ready pin */ + WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (1 << gpio_data_ready)); + /* process first data packet here to start transactions */ + queue_next_transaction(); } + /* Invoked after transaction is queued and ready for pickup by master */ static void IRAM_ATTR spi_post_setup_cb(spi_slave_transaction_t *trans) { @@ -187,15 +231,6 @@ static void IRAM_ATTR spi_post_trans_cb(spi_slave_transaction_t *trans) { /* Clear handshake line */ WRITE_PERI_REG(GPIO_OUT_W1TC_REG, (1 << gpio_handshake)); - - if (trans && is_valid_trans_buffer((uint8_t *)trans->tx_buffer)) { - /* Host has consumed a valid TX buffer - * Clear Data ready line */ - WRITE_PERI_REG(GPIO_OUT_W1TC_REG, (1 << gpio_data_ready)); - } - - if (spi_sema) - xSemaphoreGiveFromISR(spi_sema, NULL); } static uint8_t * get_next_tx_buffer(uint32_t *len) @@ -203,30 +238,33 @@ static uint8_t * get_next_tx_buffer(uint32_t *len) interface_buffer_handle_t buf_handle = {0}; esp_err_t ret = ESP_OK; uint8_t *sendbuf = NULL; - struct esp_payload_header *header; + struct esp_payload_header *header = NULL; /* Get or create new tx_buffer * 1. Check if SPI TX queue has pending buffers. Return if valid buffer is obtained. - * 2. Prepare dummy tx buffer as below: - * a. Return if dummy tx buffer is already configured - * b. Create a new empty tx buffer and return */ + * 2. Create a new empty tx buffer and return */ /* Get buffer from SPI Tx queue */ - ret = xQueueReceive(spi_tx_queue, &buf_handle, 0); + if(uxQueueMessagesWaiting(spi_tx_queue[PRIO_Q_SERIAL])) + ret = xQueueReceive(spi_tx_queue[PRIO_Q_SERIAL], &buf_handle, portMAX_DELAY); + else if(uxQueueMessagesWaiting(spi_tx_queue[PRIO_Q_BT])) + ret = xQueueReceive(spi_tx_queue[PRIO_Q_BT], &buf_handle, portMAX_DELAY); + else if(uxQueueMessagesWaiting(spi_tx_queue[PRIO_Q_OTHERS])) + ret = xQueueReceive(spi_tx_queue[PRIO_Q_OTHERS], &buf_handle, portMAX_DELAY); + else + ret = pdFALSE; + if (ret == pdTRUE && buf_handle.payload) { if (len) *len = buf_handle.payload_len; + /* Return real data buffer from queue */ return buf_handle.payload; } - /* Dummy transaction is already queued. Return. */ - if (dummy_queued) { - if (len) - *len = 0; - return NULL; - } + /* No real data pending, clear ready line and indicate host an idle state */ + WRITE_PERI_REG(GPIO_OUT_W1TC_REG, (1 << gpio_data_ready)); - /* Create empty tx buffer */ + /* Create empty dummy buffer */ sendbuf = heap_caps_malloc(SPI_BUFFER_SIZE, MALLOC_CAP_DMA); if (!sendbuf) { ESP_LOGE(TAG, "Failed to allocate memory for dummy transaction"); @@ -254,8 +292,9 @@ static uint8_t * get_next_tx_buffer(uint32_t *len) static int process_spi_rx(interface_buffer_handle_t *buf_handle) { int ret = 0; - struct esp_payload_header *header; - uint16_t len, offset; + struct esp_payload_header *header = NULL; + uint16_t len = 0, offset = 0; + uint16_t rx_checksum = 0, checksum = 0; /* Validate received buffer. Drop invalid buffer. */ @@ -272,6 +311,15 @@ static int process_spi_rx(interface_buffer_handle_t *buf_handle) return -1; } + rx_checksum = le16toh(header->checksum); + header->checksum = 0; + + checksum = compute_checksum(buf_handle->payload, len+offset); + + if (checksum != rx_checksum) { + return -1; + } + /* Buffer is valid */ buf_handle->if_type = header->if_type; buf_handle->if_num = header->if_num; @@ -279,7 +327,13 @@ static int process_spi_rx(interface_buffer_handle_t *buf_handle) buf_handle->payload_len = le16toh(header->len) + offset; buf_handle->priv_buffer_handle = buf_handle->payload; - ret = xQueueSend(spi_rx_queue, buf_handle, portMAX_DELAY); + if (header->if_type == ESP_SERIAL_IF) { + ret = xQueueSend(spi_rx_queue[PRIO_Q_SERIAL], buf_handle, portMAX_DELAY); + } else if (header->if_type == ESP_HCI_IF) { + ret = xQueueSend(spi_rx_queue[PRIO_Q_BT], buf_handle, portMAX_DELAY); + } else { + ret = xQueueSend(spi_rx_queue[PRIO_Q_OTHERS], buf_handle, portMAX_DELAY); + } if (ret != pdTRUE) return -1; @@ -287,77 +341,7 @@ static int process_spi_rx(interface_buffer_handle_t *buf_handle) return 0; } -static void spi_transaction_tx_task(void* pvParameters) -{ - spi_slave_transaction_t *spi_trans; - esp_err_t ret = 0; - interface_buffer_handle_t buf_handle; - - for(;;) { - ret = xQueueReceive(spi_tx_queue, &buf_handle, portMAX_DELAY); - - if (ret == pdTRUE && buf_handle.payload) { - spi_trans = malloc(sizeof(spi_slave_transaction_t)); - assert(spi_trans); - - memset(spi_trans, 0, sizeof(spi_slave_transaction_t)); - - /* Attach Rx Buffer */ - spi_trans->rx_buffer = heap_caps_malloc(SPI_BUFFER_SIZE, MALLOC_CAP_DMA); - assert(spi_trans->rx_buffer); - - memset(spi_trans->rx_buffer, 0, SPI_BUFFER_SIZE); - - /* Attach Tx Buffer */ - spi_trans->tx_buffer = buf_handle.payload; - - /* Transaction len */ - spi_trans->length = SPI_BUFFER_SIZE * SPI_BITS_PER_WORD; - - /* Set Data ready high */ - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (1 << gpio_data_ready)); - - /* Execute transaction */ - ret = xSemaphoreTake(spi_sema, portMAX_DELAY); - - if (ret != pdTRUE) { - ESP_LOGE(TAG, "Failed to obtain semaphore\n"); - - free(spi_trans->rx_buffer); - spi_trans->rx_buffer = NULL; - free((void *)spi_trans->tx_buffer); - spi_trans->tx_buffer = NULL; - free(spi_trans); - spi_trans = NULL; - - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (0 << gpio_data_ready)); - continue; - } - - ret = spi_slave_queue_trans(ESP_SPI_CONTROLLER, spi_trans, - portMAX_DELAY); - if (ret != ESP_OK) { - ESP_LOGE(TAG , "spi transmit error, ret : 0x%x\r\n", ret); - - free(spi_trans->rx_buffer); - spi_trans->rx_buffer = NULL; - free((void *)spi_trans->tx_buffer); - spi_trans->tx_buffer = NULL; - free(spi_trans); - spi_trans = NULL; - - if (spi_sema) - xSemaphoreGive(spi_sema); - - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (0 << gpio_data_ready)); - - continue; - } - } - } -} - -static void queue_dummy_transaction() +static void queue_next_transaction(void) { spi_slave_transaction_t *spi_trans = NULL; esp_err_t ret = ESP_OK; @@ -366,7 +350,8 @@ static void queue_dummy_transaction() tx_buffer = get_next_tx_buffer(&len); if (!tx_buffer) { - /* No need to queue dummy transaction */ + /* Queue next transaction failed */ + ESP_LOGE(TAG , "Failed to queue new transaction\r\n"); return; } @@ -386,41 +371,38 @@ static void queue_dummy_transaction() /* Transaction len */ spi_trans->length = SPI_BUFFER_SIZE * SPI_BITS_PER_WORD; - ret = spi_slave_queue_trans(ESP_SPI_CONTROLLER, spi_trans, 0); + ret = spi_slave_queue_trans(ESP_SPI_CONTROLLER, spi_trans, portMAX_DELAY); if (ret != ESP_OK) { + ESP_LOGI(TAG, "Failed to queue next SPI transfer\n"); free(spi_trans->rx_buffer); spi_trans->rx_buffer = NULL; free((void *)spi_trans->tx_buffer); spi_trans->tx_buffer = NULL; free(spi_trans); spi_trans = NULL; - xSemaphoreGive(spi_sema); return; } - - if (!len) { - /* queued dummy transaction, release semaphore */ - dummy_queued = pdTRUE; - } else { - /* Queued transaction with valid TX Buffer. Set Data ready high. */ - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (1 << gpio_data_ready)); - } } static void spi_transaction_post_process_task(void* pvParameters) { spi_slave_transaction_t *spi_trans = NULL; - esp_err_t ret = 0; - interface_buffer_handle_t rx_buf_handle; - struct esp_payload_header *header; + esp_err_t ret = ESP_OK; + interface_buffer_handle_t rx_buf_handle = {0}; for (;;) { memset(&rx_buf_handle, 0, sizeof(rx_buf_handle)); + /* Await transmission result, after any kind of transmission a new packet + * (dummy or real) must be placed in SPI slave + */ ret = spi_slave_get_trans_result(ESP_SPI_CONTROLLER, &spi_trans, portMAX_DELAY); + /* Queue new transaction to get ready as soon as possible */ + queue_next_transaction(); + if (ret != ESP_OK) { ESP_LOGE(TAG , "spi transmit error, ret : 0x%x\r\n", ret); continue; @@ -431,32 +413,13 @@ static void spi_transaction_post_process_task(void* pvParameters) continue; } + /* Free any tx buffer, data is not relevant anymore */ if (spi_trans->tx_buffer) { - header = (struct esp_payload_header *) spi_trans->tx_buffer; - - if (header->if_type == 0xF && header->if_num == 0xF && header->offset == 0) { - /* Dummy Tx buffer consumed by host */ - dummy_queued = pdFALSE; - } - free((void *)spi_trans->tx_buffer); spi_trans->tx_buffer = NULL; } - /* Check if dummy transaction is needed - * - * If failed to obtain spi_sema: - * - Transaction is already queued. - * - No need to queue dummy transaction - * - * If spi_sema is obtained: queue dummy transaction - **/ - - ret = xSemaphoreTake(spi_sema, 0); - - if (ret == pdTRUE) - queue_dummy_transaction(); - + /* Process received data */ if (spi_trans->rx_buffer) { rx_buf_handle.payload = spi_trans->rx_buffer; @@ -470,78 +433,16 @@ static void spi_transaction_post_process_task(void* pvParameters) } } + /* Free Transfer structure */ free(spi_trans); spi_trans = NULL; } } -static void generate_startup_event(uint8_t cap) -{ - struct esp_payload_header *header; - interface_buffer_handle_t buf_handle; - struct esp_priv_event *event; - uint8_t *pos; - uint16_t len = 0; - - memset(&buf_handle, 0, sizeof(buf_handle)); - - buf_handle.payload = heap_caps_malloc(SPI_BUFFER_SIZE, MALLOC_CAP_DMA); - assert(buf_handle.payload); - - header = (struct esp_payload_header *) buf_handle.payload; - - header->if_type = ESP_PRIV_IF; - header->if_num = 0; - header->offset = htole16(sizeof(struct esp_payload_header)); - header->priv_pkt_type = ESP_PACKET_TYPE_EVENT; - - /* Populate event data */ - event = (struct esp_priv_event *) (buf_handle.payload + sizeof(struct esp_payload_header)); - - event->event_type = ESP_PRIV_EVENT_INIT; - - /* Populate TLVs for event */ - pos = event->event_data; - - /* TLVs start */ - - /* TLV - Board type */ - *pos = ESP_PRIV_FIRMWARE_CHIP_ID; pos++;len++; - *pos = LENGTH_1_BYTE; pos++;len++; - *pos = CONFIG_IDF_FIRMWARE_CHIP_ID; pos++;len++; - - /* TLV - Peripheral clock in MHz */ - *pos = ESP_PRIV_SPI_CLK_MHZ; pos++;len++; - *pos = LENGTH_1_BYTE; pos++;len++; -#ifdef CONFIG_IDF_TARGET_ESP32 - *pos = SPI_CLK_MHZ_ESP32; pos++;len++; -#elif defined CONFIG_IDF_TARGET_ESP32S2 - *pos = SPI_CLK_MHZ_ESP32_S2; pos++;len++; -#elif defined CONFIG_IDF_TARGET_ESP32C3 - *pos = SPI_CLK_MHZ_ESP32_C3; pos++;len++; -#endif - - /* TLV - Capability */ - *pos = ESP_PRIV_CAPABILITY; pos++;len++; - *pos = LENGTH_1_BYTE; pos++;len++; - *pos = cap; pos++;len++; - - /* TLVs end */ - - event->event_len = len; - - /* payload len = Event len + sizeof(event type) + sizeof(event len) */ - len += 2; - header->len = htole16(len); - - buf_handle.payload_len = len + sizeof(struct esp_payload_header); - - xQueueSend(spi_tx_queue, &buf_handle, portMAX_DELAY); -} - -static interface_handle_t * esp_spi_init(uint8_t capabilities) +static interface_handle_t * esp_spi_init(void) { esp_err_t ret = ESP_OK; + uint8_t prio_q_idx = 0; /* Configuration for the SPI bus */ spi_bus_config_t buscfg={ @@ -551,7 +452,13 @@ static interface_handle_t * esp_spi_init(uint8_t capabilities) .quadwp_io_num = -1, .quadhd_io_num = -1, .max_transfer_sz = SPI_BUFFER_SIZE, +#if 0 + /* + * Moving ESP32 SPI slave interrupts in flash, Keeping it in IRAM gives crash, + * While performing flash erase operation. + */ .intr_flags=ESP_INTR_FLAG_IRAM +#endif }; /* Configuration for the SPI slave interface */ @@ -598,36 +505,29 @@ static interface_handle_t * esp_spi_init(uint8_t capabilities) memset(&if_handle_g, 0, sizeof(if_handle_g)); if_handle_g.state = INIT; - spi_rx_queue = xQueueCreate(SPI_RX_QUEUE_SIZE, sizeof(interface_buffer_handle_t)); - assert(spi_rx_queue != NULL); - - spi_tx_queue = xQueueCreate(SPI_TX_QUEUE_SIZE, sizeof(interface_buffer_handle_t)); - assert(spi_tx_queue != NULL); + for (prio_q_idx=0; prio_q_idxlen = htole16(buf_handle->payload_len); offset = sizeof(struct esp_payload_header); header->offset = htole16(offset); + header->seq_num = htole16(buf_handle->seq_num); + header->flags = buf_handle->flag; /* copy the data from caller */ memcpy(tx_buf_handle.payload + offset, buf_handle->payload, buf_handle->payload_len); - ret = xQueueSend(spi_tx_queue, &tx_buf_handle, portMAX_DELAY); + + header->checksum = htole16(compute_checksum(tx_buf_handle.payload, + offset+buf_handle->payload_len)); + + if (header->if_type == ESP_SERIAL_IF) + ret = xQueueSend(spi_tx_queue[PRIO_Q_SERIAL], &tx_buf_handle, portMAX_DELAY); + else if (header->if_type == ESP_HCI_IF) + ret = xQueueSend(spi_tx_queue[PRIO_Q_BT], &tx_buf_handle, portMAX_DELAY); + else + ret = xQueueSend(spi_tx_queue[PRIO_Q_OTHERS], &tx_buf_handle, portMAX_DELAY); if (ret != pdTRUE) return ESP_FAIL; + /* indicate waiting data on ready pin */ + WRITE_PERI_REG(GPIO_OUT_W1TS_REG, (1 << gpio_data_ready)); + return buf_handle->payload_len; } @@ -702,7 +616,20 @@ static interface_buffer_handle_t * esp_spi_read(interface_handle_t *if_handle) buf_handle = malloc(sizeof(interface_buffer_handle_t)); assert(buf_handle); - ret = xQueueReceive(spi_rx_queue, buf_handle, portMAX_DELAY); + while (1) { + if(uxQueueMessagesWaiting(spi_rx_queue[PRIO_Q_SERIAL])) { + ret = xQueueReceive(spi_rx_queue[PRIO_Q_SERIAL], buf_handle, portMAX_DELAY); + break; + } else if(uxQueueMessagesWaiting(spi_rx_queue[PRIO_Q_BT])) { + ret = xQueueReceive(spi_rx_queue[PRIO_Q_BT], buf_handle, portMAX_DELAY); + break; + } else if(uxQueueMessagesWaiting(spi_rx_queue[PRIO_Q_OTHERS])) { + ret = xQueueReceive(spi_rx_queue[PRIO_Q_OTHERS], buf_handle, portMAX_DELAY); + break; + } else { + vTaskDelay(1); + } + } if (ret != pdTRUE) { free(buf_handle); @@ -714,7 +641,7 @@ static interface_buffer_handle_t * esp_spi_read(interface_handle_t *if_handle) static esp_err_t esp_spi_reset(interface_handle_t *handle) { - esp_err_t ret; + esp_err_t ret = ESP_OK; ret = spi_slave_free(ESP_SPI_CONTROLLER); if (ESP_OK != ret) { ESP_LOGE(TAG, "spi slave bus free failed\n"); @@ -724,10 +651,7 @@ static esp_err_t esp_spi_reset(interface_handle_t *handle) static void esp_spi_deinit(interface_handle_t *handle) { - esp_err_t ret; - - if (spi_sema) - vSemaphoreDelete(spi_sema); + esp_err_t ret = ESP_OK; ret = spi_slave_free(ESP_SPI_CONTROLLER); if (ESP_OK != ret) { diff --git a/esp/esp_driver/network_adapter/sdkconfig.defaults b/esp/esp_driver/network_adapter/sdkconfig.defaults index 6934dabd97..bc3ec5651c 100644 --- a/esp/esp_driver/network_adapter/sdkconfig.defaults +++ b/esp/esp_driver/network_adapter/sdkconfig.defaults @@ -7,7 +7,11 @@ CONFIG_SDIO_DAT2_DISABLED= CONFIG_BT_ENABLED=y CONFIG_BT_CONTROLLER_ONLY=y CONFIG_BT_BLUEDROID_ENABLED= -CONFIG_BTDM_CONTROLLER_MODE_BTDM=y -CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y +CONFIG_BTDM_CTRL_MODE_BTDM=y +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y CONFIG_ESP32_WIFI_NVS_ENABLED= + +# OTA +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_PARTITION_TABLE_TWO_OTA=y diff --git a/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32 b/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32 new file mode 100644 index 0000000000..aed5aab135 --- /dev/null +++ b/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32 @@ -0,0 +1,36 @@ +CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 +CONFIG_SDIO_DAT2_DISABLED= + +# BT Configuration +CONFIG_BT_ENABLED=y +CONFIG_BT_CONTROLLER_ONLY=y +CONFIG_BT_BLUEDROID_ENABLED= +CONFIG_BTDM_CONTROLLER_MODE_BTDM=y +CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y +CONFIG_BTDM_CTRL_AUTO_LATENCY=y + +CONFIG_ESP32_WIFI_NVS_ENABLED= + +# BT over UART +#CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4=y +#CONFIG_BTDM_CTRL_HCI_MODE_UART_H4=y +#CONFIG_BT_HCI_UART_NO=1 +#CONFIG_BT_HCI_UART_BAUDRATE=921600 + +#CO-EX config +CONFIG_FREERTOS_UNICORE=n +CONFIG_FREERTOS_HZ=400 +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y +CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=64 + +# OTA +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_PARTITION_TABLE_TWO_OTA=y diff --git a/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3 b/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3 new file mode 100644 index 0000000000..351dc63dee --- /dev/null +++ b/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3 @@ -0,0 +1,15 @@ +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +CONFIG_FREERTOS_UNICORE=y +CONFIG_SDIO_DAT2_DISABLED= + +# BT Configuration +CONFIG_BT_ENABLED=y +CONFIG_BT_CONTROLLER_ONLY=y +CONFIG_BT_BLUEDROID_ENABLED= +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CTRL_MODE_BTDM=n +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y + +CONFIG_ESP32_WIFI_NVS_ENABLED= diff --git a/host/host_common/commands.c b/host/host_common/commands.c index 968897892b..bc16d4bc9f 100644 --- a/host/host_common/commands.c +++ b/host/host_common/commands.c @@ -8,6 +8,16 @@ #include "platform_wrapper.h" #include "esp_hosted_config.pb-c.h" +#ifndef STM32F469xx +#include +#include +#include +#include +#include +#include +#include +#endif + #ifdef STM32F469xx #include "common.h" #define command_log(...) printf(__VA_ARGS__); printf("\r"); @@ -16,6 +26,12 @@ #define min(X, Y) (((X) < (Y)) ? (X) : (Y)) #endif +#ifndef STM32F469xx +#define MAX_INTERFACE_LEN IFNAMSIZ +#define MAC_LEN 7 +#define MAC_STR_LEN 17 +#endif + #define SUCCESS 0 #define FAILURE -1 #define MAC_LENGTH 19 @@ -46,6 +62,40 @@ } \ } +#ifndef STM32F469xx +// Function converts mac string to byte stream +static int convert_mac_to_bytes(uint8_t *out, size_t out_len, char *s) +{ + int mac[MAC_LEN] = {0}; + int num_bytes = 0; + if (!s || (strlen(s) < MAC_STR_LEN) || (out_len < MAC_LEN)) { + return FAILURE; + } + + num_bytes = sscanf(s, "%2x:%2x:%2x:%2x:%2x:%2x", + &mac[0],&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); + + if ((num_bytes < (MAC_LEN - 1)) || + (mac[0] > 0xFF) || + (mac[1] > 0xFF) || + (mac[2] > 0xFF) || + (mac[3] > 0xFF) || + (mac[4] > 0xFF) || + (mac[5] > 0xFF)) { + return FAILURE; + } + + out[0] = mac[0]&0xff; + out[1] = mac[1]&0xff; + out[2] = mac[2]&0xff; + out[3] = mac[3]&0xff; + out[4] = mac[4]&0xff; + out[5] = mac[5]&0xff; + return SUCCESS; +} +#endif + + // Function returns MAC address of ESP32 station/softap int wifi_get_mac (int mode, char *mac) { @@ -63,7 +113,7 @@ int wifi_get_mac (int mode, char *mac) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetMACAddress; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_MAC_ADDRESS ; - EspHostedCmdGetMacAddress *req_payload = (EspHostedCmdGetMacAddress *) \ + EspHostedCmdGetMacAddress *req_payload = (EspHostedCmdGetMacAddress *) esp_hosted_calloc(1, sizeof(EspHostedCmdGetMacAddress)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -112,10 +162,12 @@ int wifi_get_mac (int mode, char *mac) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -145,7 +197,7 @@ int wifi_set_mac (int mode, char *mac) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetMacAddress; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_MAC_ADDRESS; - EspHostedCmdSetMacAddress *req_payload = (EspHostedCmdSetMacAddress *) \ + EspHostedCmdSetMacAddress *req_payload = (EspHostedCmdSetMacAddress *) esp_hosted_calloc(1, sizeof(EspHostedCmdSetMacAddress)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -194,10 +246,12 @@ int wifi_set_mac (int mode, char *mac) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -255,10 +309,12 @@ int wifi_get_mode (int *mode) *mode = resp->resp_get_wifi_mode->mode; mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return FAILURE; @@ -281,7 +337,7 @@ int wifi_set_mode (int mode) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetWiFiMode; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_WIFI_MODE; - EspHostedCmdSetMode *req_payload = (EspHostedCmdSetMode *) \ + EspHostedCmdSetMode *req_payload = (EspHostedCmdSetMode *) esp_hosted_calloc( 1, sizeof(EspHostedCmdSetMode)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -328,10 +384,12 @@ int wifi_set_mode (int mode) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -368,7 +426,7 @@ int wifi_set_ap_config (esp_hosted_control_config_t ap_config) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetAPConfig ; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_AP_CONFIG; - EspHostedCmdSetAPConfig *req_payload = (EspHostedCmdSetAPConfig *) \ + EspHostedCmdSetAPConfig *req_payload = (EspHostedCmdSetAPConfig *) esp_hosted_calloc(1, sizeof(EspHostedCmdSetAPConfig)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -413,17 +471,19 @@ int wifi_set_ap_config (esp_hosted_control_config_t ap_config) } if (resp->resp_set_ap_config->resp == INVALID_PASSWORD) { - command_log("Invalid password %s for SSID %s\n",\ + command_log("Invalid password %s for SSID %s\n", (char *)&ap_config.station.pwd, (char *)&ap_config.station.ssid); mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return INVALID_PASSWORD; } else if (resp->resp_set_ap_config->resp == NO_AP_FOUND) { command_log("SSID: %s not found\n", (char *)&ap_config.station.ssid); mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return NO_AP_FOUND; } else if (resp->resp_set_ap_config->resp) { command_log("Failed to connect with AP\n"); @@ -433,10 +493,12 @@ int wifi_set_ap_config (esp_hosted_control_config_t ap_config) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -523,10 +585,12 @@ int wifi_get_ap_config (esp_hosted_control_config_t *ap_config) mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return FAILURE; @@ -577,10 +641,12 @@ int wifi_disconnect_ap () mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return FAILURE; @@ -638,7 +704,7 @@ int wifi_set_softap_config (esp_hosted_control_config_t softap_config) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetSoftAPConfig; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_SOFTAP_CONFIG; - EspHostedCmdSetSoftAPConfig *req_payload = (EspHostedCmdSetSoftAPConfig *) \ + EspHostedCmdSetSoftAPConfig *req_payload = (EspHostedCmdSetSoftAPConfig *) esp_hosted_calloc(1, sizeof(EspHostedCmdSetSoftAPConfig)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -695,10 +761,12 @@ int wifi_set_softap_config (esp_hosted_control_config_t softap_config) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -771,10 +839,12 @@ int wifi_get_softap_config (esp_hosted_control_config_t *softap_config) mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return FAILURE; @@ -825,10 +895,12 @@ int wifi_stop_softap () mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return FAILURE; @@ -913,10 +985,12 @@ esp_hosted_wifi_scanlist_t* wifi_ap_scan_list (int *count) mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return list; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return NULL; @@ -974,7 +1048,7 @@ esp_hosted_wifi_connected_stations_list* wifi_connected_stations_list(int *num) *num = resp->resp_connected_stas_list->num; if (resp->resp_connected_stas_list->num) { - list = (esp_hosted_wifi_connected_stations_list *) \ + list = (esp_hosted_wifi_connected_stations_list *) esp_hosted_calloc(resp->resp_connected_stas_list->num, sizeof(esp_hosted_wifi_connected_stations_list)); if (!list) { @@ -991,10 +1065,12 @@ esp_hosted_wifi_connected_stations_list* wifi_connected_stations_list(int *num) mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return list; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); return NULL; @@ -1018,7 +1094,7 @@ int wifi_set_power_save_mode (int power_save_mode) req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetPowerSaveMode; req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_POWER_SAVE_MODE; - EspHostedCmdSetMode *req_payload = (EspHostedCmdSetMode *) \ + EspHostedCmdSetMode *req_payload = (EspHostedCmdSetMode *) esp_hosted_calloc(1, sizeof(EspHostedCmdSetMode)); if (!req_payload) { command_log("Failed to allocate memory for req_payload\n"); @@ -1064,10 +1140,12 @@ int wifi_set_power_save_mode (int power_save_mode) mem_free(tx_data); mem_free(rx_data); mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); err2: mem_free(tx_data); err3: @@ -1127,11 +1205,562 @@ int wifi_get_power_save_mode (int *power_save_mode) *power_save_mode = resp->resp_get_power_save_mode->mode; mem_free(tx_data); mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; + +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); + return FAILURE; +} + +// Function set 802.11 Vendor-Specific Information Element +int wifi_set_vendor_specific_ie(bool enable, wifi_vendor_ie_type_t type, + wifi_vendor_ie_id_t idx, void* vnd_ie, uint16_t vnd_ie_size) +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + if ((type > WIFI_VND_IE_TYPE_ASSOC_RESP) || (type < WIFI_VND_IE_TYPE_BEACON)) { + command_log("Invalid vendor ie type \n"); + return FAILURE; + } + + if ((idx > WIFI_VND_IE_ID_1) || (idx < WIFI_VND_IE_ID_0)) { + command_log("Invalid vendor ie ID index \n"); + return FAILURE; + } + if (!vnd_ie) { + command_log("Invalid vendor IE buffer \n"); + return FAILURE; + } + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetVendorSpecificIE; + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_VENDOR_SPECIFIC_IE; + + EspHostedCmdSetVendorSpecificIE *req_payload = (EspHostedCmdSetVendorSpecificIE *) + esp_hosted_calloc(1, sizeof(EspHostedCmdSetVendorSpecificIE)); + if (!req_payload) { + command_log("Failed to allocate memory for req_payload\n"); + return FAILURE; + } + esp_hosted_cmd_set_vendor_specific_ie__init(req_payload); + req_payload->has_enable = true; + req_payload->enable = enable; + req_payload->has_type = true; + req_payload->type = type; + req_payload->has_idx = true; + req_payload->idx = idx; + req_payload->has_vendor_ie_data = true; + req_payload->vendor_ie_data.len = vnd_ie_size; + req_payload->vendor_ie_data.data = vnd_ie; + req.cmd_set_vendor_specific_ie = req_payload; + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + goto err3; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + goto err3; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_set_vendor_specific_ie)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_set_vendor_specific_ie->resp) { + command_log("Failed to set vendor specific information element\n"); + goto err1; + } + + mem_free(tx_data); + mem_free(rx_data); + mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); +err3: + mem_free(req_payload); + return FAILURE; +} + +// Function sets maximum transmitting power +int wifi_set_max_tx_power(int8_t wifi_max_tx_power) +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdSetWiFiMAXTXPower; + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_WIFI_MAX_TX_POWER; + + EspHostedCmdSetWiFiMAXTXPower *req_payload = (EspHostedCmdSetWiFiMAXTXPower *) + esp_hosted_calloc( 1, sizeof(EspHostedCmdSetWiFiMAXTXPower)); + if (!req_payload) { + command_log("Failed to allocate memory for req_payload\n"); + return FAILURE; + } + + esp_hosted_cmd_set_wi_fi_maxtxpower__init(req_payload); + req_payload->has_wifi_max_tx_power = true; + req_payload->wifi_max_tx_power = wifi_max_tx_power; + req.cmd_set_wifi_max_tx_power = req_payload; + + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + goto err3; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + goto err3; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_set_wifi_max_tx_power)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_set_wifi_max_tx_power->resp == ESP_HOSTED_STATUS__TYPE_OUT_OF_RANGE) { + command_log("Out of range maximum transmitting power argument \n"); + command_log("Must lie between [8,84] \n"); + command_log("Please refer `wifi_set_max_tx_power` API documentation \n"); + mem_free(tx_data); + mem_free(rx_data); + mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return OUT_OF_RANGE; + } else if (resp->resp_set_wifi_max_tx_power->resp) { + command_log("Failed to set WiFi maximum TX power\n"); + goto err1; + } + + mem_free(tx_data); + mem_free(rx_data); + mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); +err3: + mem_free(req_payload); + return FAILURE; +} + +// Function gets wifi current transmiting power +int wifi_get_curr_tx_power(int8_t *wifi_curr_tx_power) +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + if (!wifi_curr_tx_power) { + printf("Invalid argument \n"); + return FAILURE; + } + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdGetWiFiCurrTXPower; + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_WIFI_CURR_TX_POWER; + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + return FAILURE; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + return FAILURE; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_get_wifi_curr_tx_power)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_get_wifi_curr_tx_power->resp) { + command_log("Failed to get WiFi current TX power\n"); + goto err1; + } + *wifi_curr_tx_power = resp->resp_get_wifi_curr_tx_power->wifi_curr_tx_power; + mem_free(tx_data); + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return SUCCESS; err1: mem_free(rx_data); err2: mem_free(tx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); return FAILURE; } + +// Function performs an OTA begin for ESP32 +int esp_ota_begin() +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTABegin; + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_BEGIN; + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + return FAILURE; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + return FAILURE; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_ota_begin)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_ota_begin->resp) { + command_log("Failed to start OTA begin\n"); + goto err1; + } + + mem_free(tx_data); + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; + +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); + return FAILURE; +} + +// Function performs an OTA write for ESP32 +int esp_ota_write(uint8_t* ota_data, uint32_t ota_data_len) +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + if (!ota_data || (ota_data_len == 0)) { + command_log("Invalid parameter\n"); + return FAILURE; + } + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAWrite; + + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_WRITE; + + EspHostedCmdOTAWrite *req_payload = (EspHostedCmdOTAWrite *) + esp_hosted_calloc(1, sizeof(EspHostedCmdOTAWrite)); + if (!req_payload) { + command_log("Failed to allocate memory for req_payload\n"); + return FAILURE; + } + esp_hosted_cmd_otawrite__init(req_payload); + req_payload->has_ota_data = true; + req_payload->ota_data.data = ota_data; + req_payload->ota_data.len = ota_data_len; + req.cmd_ota_write = req_payload; + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + goto err3; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + goto err3; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_ota_write)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_ota_write->resp) { + command_log("Failed to give OTA update\n"); + goto err1; + } + + mem_free(tx_data); + mem_free(rx_data); + mem_free(req_payload); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; + +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); +err3: + mem_free(req_payload); + return FAILURE; +} + +// Function performs an OTA end for ESP32 +int esp_ota_end() +{ + EspHostedConfigPayload req, *resp = NULL; + uint32_t tx_len = 0, rx_len = 0; + uint8_t *tx_data = NULL, *rx_data = NULL; + + esp_hosted_config_payload__init (&req); + req.has_msg = true; + req.msg = ESP_HOSTED_CONFIG_MSG_TYPE__TypeCmdOTAEnd; + req.payload_case = ESP_HOSTED_CONFIG_PAYLOAD__PAYLOAD_CMD_OTA_END; + tx_len = esp_hosted_config_payload__get_packed_size(&req); + if (!tx_len) { + command_log("Invalid tx length\n"); + return FAILURE; + } + + tx_data = (uint8_t *)esp_hosted_calloc(1, tx_len); + if (!tx_data) { + command_log("Failed to allocate memory for tx_data\n"); + return FAILURE; + } + + esp_hosted_config_payload__pack(&req, tx_data); + + rx_data = transport_pserial_data_handler(tx_data, tx_len, + TIMEOUT_PSERIAL_RESP, &rx_len); + if (!rx_data || !rx_len) { + command_log("Failed to process rx_data\n"); + goto err2; + } + + resp = esp_hosted_config_payload__unpack(NULL, rx_len, rx_data); + if ((!resp) || (!resp->resp_ota_end)) { + command_log("Failed to unpack rx_data\n"); + goto err1; + } + + if (resp->resp_ota_end->resp) { + command_log("Failed to OTA end\n"); + goto err1; + } + + mem_free(tx_data); + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); + return SUCCESS; + +err1: + mem_free(rx_data); + esp_hosted_config_payload__free_unpacked(resp, NULL); +err2: + mem_free(tx_data); + return FAILURE; +} + +#ifndef STM32F469xx + +// Function ups in given interface +int interface_up(int sockfd, char* iface) +{ + int ret = SUCCESS; + struct ifreq req = {0}; + size_t if_name_len = strnlen(iface, MAX_INTERFACE_LEN-1); + + if (!iface) { + command_log("Invalid parameter\n"); + return FAILURE; + } + + if (if_name_len < sizeof(req.ifr_name)) { + memcpy(req.ifr_name,iface,if_name_len); + req.ifr_name[if_name_len]='\0'; + } else { + printf("Failed: Max interface length allowed is %u \n", sizeof(req.ifr_name)-1); + return FAILURE; + } + + req.ifr_flags |= IFF_UP; + ret = ioctl(sockfd, SIOCSIFFLAGS, &req); + if (ret < 0) { + return FAILURE; + } + return SUCCESS; +} + +// Function downs in given interface +int interface_down(int sockfd, char* iface) +{ + int ret = SUCCESS; + struct ifreq req = {0}; + size_t if_name_len = strnlen(iface, MAX_INTERFACE_LEN-1); + + if (!iface) { + command_log("Invalid parameter\n"); + return FAILURE; + } + + if (if_name_len < sizeof(req.ifr_name)) { + memcpy(req.ifr_name,iface,if_name_len); + req.ifr_name[if_name_len]='\0'; + } else { + printf("Failed: Max interface length allowed is %u \n", sizeof(req.ifr_name)-1); + return FAILURE; + } + + req.ifr_flags &= ~IFF_UP; + ret = ioctl(sockfd, SIOCSIFFLAGS, &req); + if (ret < 0) { + return FAILURE; + } + return SUCCESS; +} + +// Function sets mac address to given interface +int set_hw_addr(int sockfd, char* iface, char* mac) +{ + int ret = SUCCESS; + struct ifreq req = {0}; + char mac_bytes[MAC_LEN] = ""; + size_t if_name_len = strnlen(iface, MAX_INTERFACE_LEN-1); + + if (!iface || !mac) { + command_log("Invalid parameter\n"); + return FAILURE; + } + + if (if_name_len < sizeof(req.ifr_name)) { + memcpy(req.ifr_name,iface,if_name_len); + req.ifr_name[if_name_len]='\0'; + } else { + printf("Failed: Max interface length allowed is %u \n", sizeof(req.ifr_name)-1); + return FAILURE; + } + + memset(mac_bytes, '\0', MAC_LEN); + ret = convert_mac_to_bytes((uint8_t *)&mac_bytes, sizeof(mac_bytes), mac); + + if (ret) { + printf("Failed to convert mac address \n"); + return FAILURE; + } + + req.ifr_hwaddr.sa_family = ARPHRD_ETHER; + memcpy(req.ifr_hwaddr.sa_data, mac_bytes, MAC_LEN); + ret = ioctl(sockfd, SIOCSIFHWADDR, &req); + + if (ret < 0) { + return FAILURE; + } + return SUCCESS; +} + +// Function creates an endpoint for communication and returns a file descriptor (integer number) that refers to that endpoint +int create_socket(int domain, int type, int protocol, int *sock) +{ + if (!sock) { + command_log("Invalid parameter\n"); + return FAILURE; + } + + *sock = socket(domain, type, protocol); + if (*sock < 0) + { + printf("Failure to open socket\n"); + return FAILURE; + } + return SUCCESS; +} + +// Function closes an endpoint for communication +int close_socket(int sock) +{ + int ret; + ret = close(sock); + if (ret < 0) { + printf("Failure to close socket\n"); + return FAILURE; + } + return SUCCESS; +} + +#endif diff --git a/host/host_common/include/commands.h b/host/host_common/include/commands.h index 4f553daaf1..e90bc1da87 100644 --- a/host/host_common/include/commands.h +++ b/host/host_common/include/commands.h @@ -18,6 +18,8 @@ #define NOT_CONNECTED 1 #define NO_AP_FOUND 2 #define INVALID_PASSWORD 3 +#define INVALID_ARGUMENT 4 +#define OUT_OF_RANGE 5 typedef enum { WIFI_MODE_NONE = 0, /**< null mode */ @@ -50,6 +52,19 @@ typedef enum { WIFI_PS_INVALID, } wifi_ps_type_t; +typedef enum { + WIFI_VND_IE_TYPE_BEACON = 0, + WIFI_VND_IE_TYPE_PROBE_REQ, + WIFI_VND_IE_TYPE_PROBE_RESP, + WIFI_VND_IE_TYPE_ASSOC_REQ, + WIFI_VND_IE_TYPE_ASSOC_RESP, +} wifi_vendor_ie_type_t; + +typedef enum { + WIFI_VND_IE_ID_0, + WIFI_VND_IE_ID_1, +} wifi_vendor_ie_id_t; + typedef struct { uint8_t ssid[SSID_LENGTH]; uint8_t pwd[PASSWORD_LENGTH]; @@ -90,6 +105,13 @@ typedef struct { int rssi; } esp_hosted_wifi_connected_stations_list; +typedef struct { + uint8_t element_id; /**< Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */ + uint8_t length; /**< Length of all bytes in the element data following this field. Minimum 4. */ + uint8_t vendor_oui[3]; /**< Vendor identifier (OUI). */ + uint8_t vendor_oui_type; /**< Vendor-specific OUI type. */ + uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ +} vendor_ie_data_t; /* wifi get mac function returns status SUCCESS(0) or FAILURE(-1) * Input parameter @@ -152,7 +174,7 @@ int wifi_set_mode(int mode); * - SUCCESS(0) : succeed * - FAILURE(-1) : failed * - NO_AP_FOUND(2) : Given AP not found - * - INVALID_PASSWORD(3) : Invalid password for AP + * - INVALID_PASSWORD(3) : Invalid password for AP */ int wifi_set_ap_config(esp_hosted_control_config_t ap_config); @@ -265,4 +287,102 @@ int wifi_set_power_save_mode(int power_save_mode); * 3 : WIFI_PS_INVALID, Invalid power save mode. In case of failure of command */ int wifi_get_power_save_mode(int *power_save_mode); -#endif + +/* + * wifi set vendor specific ie function set 802.11 Vendor-Specific Information Element + * returns SUCCESS(0) or FAILURE(-1) + * Input parameter: + * enable : If true, specified IE is enabled. If false, specified IE is removed. + * type : Information Element type. Determines the frame type to associate with the IE. + * idx : Index to set or clear. Each IE type can be associated with up to two elements (indices 0 & 1). + * vnd_ie : Pointer to vendor specific element data. First 6 bytes should be a header with fields matching vendor_ie_data_t. If enable is false, this argument is ignored and can be NULL. + * vnd_ie_size : size of vnd_ie data + */ +int wifi_set_vendor_specific_ie(bool enable, wifi_vendor_ie_type_t type, + wifi_vendor_ie_id_t idx, void* vnd_ie, uint16_t vnd_ie_size); + +/* + * wifi_set_max_tx_power function set maximum transmitting power. + * returns SUCCESS(0) or FAILURE(-1) + * + * @attention 1. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable in wifi driver. + * @attention 2. Mapping Table {wifi_max_tx_power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, + * {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. + * @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm to 20dBm. + * @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. + * + * Input parameter: + * wifi_max_tx_power : Maximum WiFi transmitting power. + * + * returns OUT_OF_RANGE(5), If `wifi_max_tx_power` range is not in [8, 84] corresponding to `2dBm to 20dBm` tx power. + */ +int wifi_set_max_tx_power(int8_t wifi_max_tx_power); + +/* + * wifi_get_curr_tx_power function gets WiFi current transmiting power + * returns SUCCESS(0) or FAILURE(-1) + * + * Output parameter: + * wifi_curr_tx_power : WiFi current transmitting power, unit is 0.25dBm. + */ +int wifi_get_curr_tx_power(int8_t *wifi_curr_tx_power); + +/* + * esp ota begin function performs an OTA begin operation for ESP32 + * which sets partition for OTA write and erase it. + * returns SUCCESS(0) or FAILURE(-1) + */ +int esp_ota_begin(); + +/* + * esp ota write function performs an OTA write operation for ESP32, + * It writes ota_data buffer to OTA partition in flash + * returns SUCCESS(0) or FAILURE(-1) + * Input parameter: + * ota_data : OTA data buffer + * ota_data_len : length of OTA data buffer + */ +int esp_ota_write(uint8_t* ota_data, uint32_t ota_data_len); + +/* + * esp ota end function performs an OTA end operation for ESP32, + * It validates written OTA image, set OTA partition as boot partition for next boot, + * Creates timer which reset ESP32 after 5 sec, + * returns SUCCESS(0) or FAILURE(-1) + */ +int esp_ota_end(); + +#ifndef STM32F469xx +/* + * interface_up function ups the given interface + * returns SUCCESS(0) or FAILURE(-1) + */ +int interface_up(int sockfd, char* iface); + +/* + * interface_down function downs the given interface + * returns SUCCESS(0) or FAILURE(-1) + */ +int interface_down(int sockfd, char* iface); + +/* + * Function sets mac address to the given interface + * returns SUCCESS(0) or FAILURE(-1) + */ +int set_hw_addr(int sockfd, char* iface, char* mac); + +/* + * function creates an endpoint for communication and returns a file descriptor (integer number) that refers to that endpoint + * function returns the status SUCCESS(0) or FAILURE(-1) + * int *sock : User should get file descriptor for the new socket on success + */ +int create_socket(int domain, int type, int protocol, int *sock); + +/* + * function closes an endpoint of communication. + * function returns the status SUCCESS(0) or FAILURE(-1) + * int sock : file descrepter of the socket to be closed + */ +int close_socket(int sock); +#endif /* STM32F469xx */ +#endif /* __COMMANDS_H */ diff --git a/host/host_common/transport_pserial.c b/host/host_common/transport_pserial.c index 7f66bc92a3..434c6cb66e 100644 --- a/host/host_common/transport_pserial.c +++ b/host/host_common/transport_pserial.c @@ -153,6 +153,8 @@ uint8_t * transport_pserial_data_handler(uint8_t* data, uint16_t data_length, if (! read_buf) { command_log("Failed to read RX data\n"); goto err; + } else if (!pro_len) { + command_log("Zero protobuf data length received \n"); } ret = esp_hosted_driver_close(&esp_hosted_driver_handle); diff --git a/host/linux/host_control/c_support/stress.c b/host/linux/host_control/c_support/stress.c index dcd7a0a2a4..17978233c5 100644 --- a/host/linux/host_control/c_support/stress.c +++ b/host/linux/host_control/c_support/stress.c @@ -20,135 +20,47 @@ #include #include "test_api.h" -#define STRESS_TEST_COUNT 50 - -#define TEST_MODE_NONE (1 << 0) -#define TEST_SCAN_WIFI (1 << 1) -#define TEST_STATION_MAC (1 << 2) -#define TEST_STATION_CONNECT_DISCONNECT (1 << 3) -#define TEST_SOFTAP_MAC (1 << 4) -#define TEST_SOFTAP_START_STOP (1 << 5) -#define TEST_STATION_SOFTAP_MODE (1 << 6) -#define TEST_POWER_SAVE (1 << 7) - -#define STRESS_TEST (TEST_MODE_NONE | TEST_SCAN_WIFI | TEST_STATION_MAC | \ - TEST_STATION_CONNECT_DISCONNECT | TEST_SOFTAP_MAC | \ - TEST_SOFTAP_START_STOP | TEST_STATION_SOFTAP_MODE | TEST_POWER_SAVE) - /***** Please Read *****/ /* Before use stress.c : User must enter user configuration parameter in "test_config.h" file */ -int main() +int main(int argc, char *argv[]) { - /* Below APIs could be used by demo application */ - int ret = control_path_platform_init(); - if (ret != SUCCESS) { - printf("EXIT!!!!\n"); - exit(0); - } - -#if (STRESS_TEST & TEST_MODE_NONE) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - test_set_wifi_mode_none(); - - test_get_wifi_mode(); - } -#endif - -#if (STRESS_TEST & TEST_SCAN_WIFI) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - test_get_available_wifi(); - } -#endif - - /* station mode */ -#if (STRESS_TEST & TEST_STATION_MAC) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - test_set_wifi_mode_station(); - - test_station_mode_set_mac_addr_of_esp(); - - test_station_mode_get_mac_addr(); - } -#endif - -#if (STRESS_TEST & TEST_STATION_CONNECT_DISCONNECT) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - test_station_mode_connect(); - - test_station_mode_get_info(); - - test_station_mode_disconnect(); - } -#endif - - /* softap mode */ -#if (STRESS_TEST & TEST_SOFTAP_MAC) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - - test_set_wifi_mode_softap(); - - test_softap_mode_set_mac_addr_of_esp(); - - test_softap_mode_get_mac_addr(); - } -#endif - -#if (STRESS_TEST & TEST_SOFTAP_START_STOP) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - test_softap_mode_start(); - - test_softap_mode_get_info(); - - printf("Connect station to softAP : %s within 15 seconds\n", SOFTAP_MODE_SSID); - - sleep(15); - - test_softap_mode_connected_clients_info(); - - test_softap_mode_stop(); - - } -#endif - - /* station + softap mode*/ -#if (STRESS_TEST & TEST_STATION_SOFTAP_MODE) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - - test_set_wifi_mode_station_softap(); - - test_get_available_wifi(); - - test_station_mode_connect(); - - test_softap_mode_start(); - - test_station_mode_get_info(); - - test_softap_mode_get_info(); - - test_station_mode_disconnect(); - - test_softap_mode_stop(); - } -#endif - - /* power save mode */ -#if (STRESS_TEST & TEST_POWER_SAVE) - for (int i=0; i < STRESS_TEST_COUNT; i++) { - printf("************** %d ****************** \n", i); - - test_set_wifi_power_save_mode(); - - test_get_wifi_power_save_mode(); - } -#endif - return 0; + /* Below APIs could be used by demo application */ + char* num = argv[1]; + int ret = 0, stress_test_count = 0; + ret = control_path_platform_init(); + if (ret != SUCCESS) { + printf("EXIT!!!!\n"); + exit(0); + } + + stress_test_count = atoi(num); + for (int i=2; i +#include +#include +#include +#include #include "test_api.h" -void test_get_wifi_mode() +#define STA_INTERFACE "ethsta0" +#define AP_INTERFACE "ethap0" + +#define WIFI_VENDOR_IE_ELEMENT_ID 0xDD +#define OFFSET 4 +#define VENDOR_OUI_0 1 +#define VENDOR_OUI_1 2 +#define VENDOR_OUI_2 3 +#define VENDOR_OUI_TYPE 22 + + +int test_get_wifi_mode() { int mode = 0; int ret = wifi_get_mode(&mode); +#ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); if (ret == SUCCESS) { printf("wifi mode is %d \n",mode); } else { printf("Failed to get wifi mode \n"); + return FAILURE; } printf("====\n\n"); +#endif + return SUCCESS; } int test_set_wifi_mode(int mode) @@ -42,10 +62,11 @@ int test_set_wifi_mode(int mode) printf("wifi mode is %d \n", mode); } else { printf("error in setting mode \n"); + return FAILURE; } printf("====\n\n"); #endif - return ret; + return SUCCESS; } int test_set_wifi_mode_none() @@ -68,18 +89,22 @@ int test_set_wifi_mode_station_softap() return test_set_wifi_mode(WIFI_MODE_APSTA); } -void test_station_mode_get_mac_addr() +int test_station_mode_get_mac_addr() { char mac[MAC_LENGTH] = ""; int ret = SUCCESS; +#ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); ret = wifi_get_mac(WIFI_MODE_STA, mac); if (ret == SUCCESS) { printf("Station mode: mac address %s \n", mac); } else { printf("Failed to get station mode MAC address \n"); + return FAILURE; } printf("====\n\n"); +#endif + return SUCCESS; } int test_station_mode_set_mac_addr_of_esp() @@ -93,11 +118,12 @@ int test_station_mode_set_mac_addr_of_esp() printf("MAC address is set \n"); } else { printf("MAC address is not set \n"); + return FAILURE; } printf("====\n\n"); #endif - return ret; + return SUCCESS; } int test_softap_mode_set_mac_addr_of_esp() @@ -111,29 +137,35 @@ int test_softap_mode_set_mac_addr_of_esp() printf("MAC address is set \n"); } else { printf("MAC address is not set \n"); + return FAILURE; } printf("====\n\n"); #endif - - return ret; + return SUCCESS; } -void test_softap_mode_get_mac_addr() +int test_softap_mode_get_mac_addr() { char mac[MAC_LENGTH] = ""; int ret = wifi_get_mac(WIFI_MODE_AP, mac); +#ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); if (ret == SUCCESS) { printf("Softap mode: mac address %s \n", mac); } else { printf("Failed to get softap mode MAC address \n"); + return FAILURE; } printf("====\n\n"); +#endif + return SUCCESS; } int test_station_mode_connect() { - int ret = SUCCESS; + int ret = SUCCESS, sockfd = 0; + char mac[MAC_LENGTH] = ""; + esp_hosted_control_config_t config = {0}; strcpy((char *)&config.station.ssid , STATION_MODE_SSID); @@ -143,21 +175,73 @@ int test_station_mode_connect() config.station.listen_interval = STATION_MODE_LISTEN_INTERVAL; ret = wifi_set_ap_config(config); -#ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); if (ret == SUCCESS) { - printf("Connected to AP \n"); + printf("Connected to AP: '%s'\n",STATION_MODE_SSID); } else if (ret == NO_AP_FOUND){ printf("SSID: %s not found \n",(char *)&config.station.ssid); + return FAILURE; } else if (ret == INVALID_PASSWORD){ printf("Invalid password %s for SSID %s\n", (char *)&config.station.pwd ,\ (char *)&config.station.ssid); + return FAILURE; } else { printf("Failed to connect with AP \n"); + return FAILURE; + } + + ret = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP, &sockfd); + if (ret < 0) { + printf("Failure to open socket\n"); + return FAILURE; + } + + ret = interface_down(sockfd, STA_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface down\n", STA_INTERFACE); + } else { + printf("Unable to down %s interface\n", STA_INTERFACE); + goto close_sock; + } + + ret = wifi_get_mac(WIFI_MODE_STA, mac); + if (ret == SUCCESS) { + printf("Station mode: mac address %s \n", mac); + } else { + printf("Failed to get station mode MAC address \n"); + goto close_sock; + } + + ret = set_hw_addr(sockfd, STA_INTERFACE, mac); + if (ret == SUCCESS) { + printf("MAC address %s set to %s interface\n", mac, STA_INTERFACE); + } else { + printf("Unable to set MAC address to %s interface\n", STA_INTERFACE); + goto close_sock; + } + + ret = interface_up(sockfd, STA_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface up\n", STA_INTERFACE); + } else { + printf("Unable to up %s interface\n", STA_INTERFACE); + goto close_sock; + } + + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + return FAILURE; } printf("====\n\n"); -#endif - return ret; + return SUCCESS; + +close_sock: + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + } + return FAILURE; } int test_station_mode_get_info() @@ -175,13 +259,14 @@ int test_station_mode_get_info() printf("AP's encryption mode %d \n", config.station.encryption_mode); } else { printf("AP's status %s \n", config.station.status); + return FAILURE; } printf("====\n\n"); - return ret; + return SUCCESS; } -void test_get_available_wifi() +int test_get_available_wifi() { int count = 0; esp_hosted_wifi_scanlist_t *list = NULL; @@ -191,9 +276,11 @@ void test_get_available_wifi() list = wifi_ap_scan_list(&count); if (!count) { printf("No AP found \n"); + return FAILURE; } if (!list) { printf("Failed to get scanned AP list \n"); + return FAILURE; } else { printf("Number of available APs is %d \n", count); for (i=0; i\n",__func__); if (ret == SUCCESS) { printf("Disconnected from AP \n"); } else { printf("Failed to disconnect from AP \n"); + return FAILURE; + } + + ret = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP, &sockfd); + if (ret < 0) { + printf("Failure to open socket\n"); + return FAILURE; + } + + ret = interface_down(sockfd, STA_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface down\n", STA_INTERFACE); + } else { + printf("Unable to down %s interface\n", STA_INTERFACE); + goto close_sock; + } + + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + return FAILURE; } + printf("====\n\n"); -#endif + return SUCCESS; - return ret; +close_sock: + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + } + return FAILURE; } int test_softap_mode_start() { - int ret = SUCCESS; + int ret = SUCCESS, sockfd = 0; + char mac[MAC_LENGTH] = ""; esp_hosted_control_config_t config = {0}; strcpy((char *)&config.softap.ssid, SOFTAP_MODE_SSID); @@ -239,16 +355,67 @@ int test_softap_mode_start() config.softap.bandwidth = SOFTAP_MODE_BANDWIDTH; ret = wifi_set_softap_config(config); -#ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); if (ret == SUCCESS) { printf("esp32 softAP started \n"); } else { printf("Failed to set softAP config \n"); + return FAILURE; + } + + ret = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP, &sockfd); + if (ret < 0) { + printf("Failure to open socket\n"); + return FAILURE; + } + + ret = interface_down(sockfd, AP_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface down\n", AP_INTERFACE); + } else { + printf("Unable to down %s interface\n", AP_INTERFACE); + goto close_sock; + } + + ret = wifi_get_mac(WIFI_MODE_AP, mac); + if (ret == SUCCESS) { + printf("softAP mode: mac address %s \n", mac); + } else { + printf("Failed to get softAP mode MAC address \n"); + goto close_sock; + } + + ret = set_hw_addr(sockfd, AP_INTERFACE, mac); + if (ret == SUCCESS) { + printf("MAC address %s set to %s interface\n", mac, AP_INTERFACE); + } else { + printf("Unable to set MAC address to %s interface\n", AP_INTERFACE); + goto close_sock; } + + ret = interface_up(sockfd, AP_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface up\n", AP_INTERFACE); + } else { + printf("Unable to up %s interface\n", AP_INTERFACE); + goto close_sock; + } + + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + return FAILURE; + } + printf("====\n\n"); -#endif - return ret; + return SUCCESS; + +close_sock: + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + } + return FAILURE; } int test_softap_mode_get_info() @@ -266,13 +433,14 @@ int test_softap_mode_get_info() printf("softAP bandwidth mode %d \n", config.softap.bandwidth); } else { printf("Failed to get softAP config \n"); + return FAILURE; } printf("====\n\n"); - return ret; + return SUCCESS; } -void test_softap_mode_connected_clients_info() +int test_softap_mode_connected_clients_info() { int count = 0; esp_hosted_wifi_connected_stations_list *stations_list = NULL; @@ -282,7 +450,10 @@ void test_softap_mode_connected_clients_info() stations_list = wifi_connected_stations_list(&count); if (!count) { printf("No station found \n"); - } else if (!stations_list) { + return FAILURE; + } + + if (!stations_list) { printf("Failed to get connected stations list \n"); } else if (count) { for (i=0; i\n",__func__); if (ret == SUCCESS) { printf("ESP32 softAP stopped \n"); } else { printf("Failed to stop ESP32 softAP \n"); + return FAILURE; + } + ret = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP, &sockfd); + if (ret < 0) { + printf("Failure to open socket\n"); + return FAILURE; + } + + ret = interface_down(sockfd, AP_INTERFACE); + if (ret == SUCCESS) { + printf("%s interface down\n", AP_INTERFACE); + } else { + printf("Unable to down %s interface\n", AP_INTERFACE); + goto close_sock; + } + + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + return FAILURE; } + printf("====\n\n"); -#endif + return SUCCESS; - return ret; +close_sock: + ret = close_socket(sockfd); + if (ret < 0) { + printf("Failure to close socket\n"); + } + return FAILURE; } - int test_set_wifi_power_save_mode() { int power_save_mode = WIFI_PS_MIN_MODEM; @@ -325,23 +522,195 @@ int test_set_wifi_power_save_mode() printf("Power save mode set \n"); } else { printf("Power save mode is not set \n"); + return FAILURE; } printf("====\n\n"); #endif - return ret; + return SUCCESS; } int test_get_wifi_power_save_mode() { int power_save_mode = WIFI_PS_MIN_MODEM; int ret = wifi_get_power_save_mode(&power_save_mode); + #ifdef TEST_DEBUG_PRINTS printf("==== %s =>\n",__func__); if (ret == SUCCESS) { printf("Power save mode is %d \n", power_save_mode); } else { printf("Failed to get power save mode \n"); + return FAILURE; + } + printf("====\n\n"); +#endif + + return SUCCESS; +} + +int test_ota_begin() +{ + int ret = esp_ota_begin(); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("OTA begin success \n"); + } else { + printf("Failed start OTA begin\n"); + return FAILURE; + } + printf("====\n\n"); +#endif + + return ret; +} + +int test_ota_write(uint8_t* ota_data, uint32_t ota_data_len) +{ + int ret = esp_ota_write(ota_data, ota_data_len); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("OTA write success \n"); + + } else { + printf("Failed OTA write\n"); + return FAILURE; + } + printf("====\n\n"); +#endif + + return ret; +} + +int test_ota_end() +{ + int ret = esp_ota_end(); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("OTA end success \n"); + } else { + printf("Failed OTA end\n"); + return FAILURE; + } + printf("====\n\n"); +#endif + + return ret; +} + +int test_ota(char* image_path) +{ + FILE* f = NULL; + char ota_chunk[CHUNK_SIZE] = {0}; + int ret = test_ota_begin(); +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + f = fopen(image_path,"rb"); + if (f == NULL) { + printf("Failed to open file %s \n", image_path); + return FAILURE; + } else { + printf("Success in opening %s file \n", image_path); + } + while (!feof(f)) { + fread(&ota_chunk, CHUNK_SIZE, 1, f); + ret = test_ota_write((uint8_t* )&ota_chunk, CHUNK_SIZE); + if (ret) { + break; + } + } + ret = test_ota_end(); + if (ret) { + return FAILURE; + } + } else { + return FAILURE; + } + printf("ESP32 will restart after 5 sec\n"); + printf("====\n\n"); +#endif + return SUCCESS; +} + +int test_set_vendor_specific_ie() +{ + char *data = "Example vendor IE data"; + int vnd_ie_size = sizeof(vendor_ie_data_t)+strlen(data)+1; + vendor_ie_data_t *vnd_ie = (vendor_ie_data_t *)malloc(vnd_ie_size); + if (!vnd_ie) { + printf("Failed to allocate memory for vnd_ie\n"); + return FAILURE; + } + + vnd_ie->element_id = WIFI_VENDOR_IE_ELEMENT_ID; + vnd_ie->length = strlen(data) + OFFSET; + if (vnd_ie->length < OFFSET) { + printf("Length should not be less than %d bytes \n", OFFSET); + free(vnd_ie); + return FAILURE; + } + + vnd_ie->vendor_oui[0] = VENDOR_OUI_0; + vnd_ie->vendor_oui[1] = VENDOR_OUI_1; + vnd_ie->vendor_oui[2] = VENDOR_OUI_2; + vnd_ie->vendor_oui_type = VENDOR_OUI_TYPE; + memcpy(vnd_ie->payload, data, strlen(data)); + + int ret = wifi_set_vendor_specific_ie(true, WIFI_VND_IE_TYPE_BEACON, + WIFI_VND_IE_ID_0, vnd_ie, vnd_ie_size); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("Success in set vendor specific ie\n"); + } else { + printf("Failed to set vendor specific ie\n"); + return FAILURE; + } + printf("====\n\n"); +#endif + + free(vnd_ie); + return ret; +} + +int test_wifi_set_max_tx_power() +{ + int ret = wifi_set_max_tx_power(INPUT_WIFI_TX_POWER); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("Success in setting max tx power\n"); + } else if (ret == OUT_OF_RANGE) { + printf("Out of range TX value \n"); + } else { + printf("Failure in setting max tx power\n"); + } + printf("====\n\n"); +#endif + + return ret; +} + +int test_wifi_get_curr_tx_power() +{ + int8_t curr_tx_power = 0; + int ret = wifi_get_curr_tx_power(&curr_tx_power); + +#ifdef TEST_DEBUG_PRINTS + printf("==== %s =>\n",__func__); + if (ret == SUCCESS) { + printf("current TX power is %d \n", curr_tx_power); + } else { + printf("Failure in getting current tx power\n"); } printf("====\n\n"); #endif diff --git a/host/linux/host_control/c_support/test_api.h b/host/linux/host_control/c_support/test_api.h index dc63b97bf1..733c31274e 100644 --- a/host/linux/host_control/c_support/test_api.h +++ b/host/linux/host_control/c_support/test_api.h @@ -27,7 +27,7 @@ #include "platform_wrapper.h" #include "test_config.h" -void test_get_wifi_mode(); +int test_get_wifi_mode(); int test_set_wifi_mode(int mode); @@ -43,15 +43,15 @@ int test_station_mode_set_mac_addr_of_esp(); int test_softap_mode_set_mac_addr_of_esp(); -void test_station_mode_get_mac_addr(); +int test_station_mode_get_mac_addr(); -void test_softap_mode_get_mac_addr(); +int test_softap_mode_get_mac_addr(); int test_station_mode_connect(); int test_station_mode_get_info(); -void test_get_available_wifi(); +int test_get_available_wifi(); int test_station_mode_disconnect(); @@ -59,7 +59,7 @@ int test_softap_mode_start(); int test_softap_mode_get_info(); -void test_softap_mode_connected_clients_info(); +int test_softap_mode_connected_clients_info(); int test_softap_mode_stop(); @@ -67,4 +67,17 @@ int test_set_wifi_power_save_mode(); int test_get_wifi_power_save_mode(); +int test_ota_begin(); + +int test_ota_write(); + +int test_ota_end(); + +int test_ota(char* image_path); + +int test_set_vendor_specific_ie(); + +int test_wifi_set_max_tx_power(); + +int test_wifi_get_curr_tx_power(); #endif diff --git a/host/linux/host_control/c_support/test_config.h b/host/linux/host_control/c_support/test_config.h index 84e5b97b75..bd963f9576 100644 --- a/host/linux/host_control/c_support/test_config.h +++ b/host/linux/host_control/c_support/test_config.h @@ -21,9 +21,20 @@ #ifndef __TEST_CONFIG_H #define __TEST_CONFIG_H +#define STA_CONNECT "sta_connect" +#define STA_DISCONNECT "sta_disconnect" +#define AP_START "ap_start" +#define AP_STOP "ap_stop" +#define SCAN "scan" +#define STA_LIST "sta_list" +#define OTA "ota" +#define AP_VENDOR_IE "ap_vendor_ie" +#define WIFI_TX_POWER "wifi_tx_power" + #define MAC_LENGTH 18 #define SSID_LENGTH 32 #define PWD_LENGTH 64 +#define CHUNK_SIZE 4000 /* station mode */ #define STATION_MODE_MAC_ADDRESS "1a:11:11:11:11:11" @@ -43,6 +54,8 @@ #define SOFTAP_MODE_SSID_HIDDEN false #define SOFTAP_MODE_BANDWIDTH 2 +#define INPUT_WIFI_TX_POWER 8 + #define TEST_DEBUG_PRINTS 1 #endif diff --git a/host/linux/host_control/python_support/Makefile b/host/linux/host_control/python_support/Makefile new file mode 100644 index 0000000000..31d95553dc --- /dev/null +++ b/host/linux/host_control/python_support/Makefile @@ -0,0 +1,23 @@ +CC = gcc + +CFLAGS = -C -Wall -I$(PWD)/../../../host_common/include/ \ + -I$(PWD)/../../../../common/protobuf-c/ \ + -I$(PWD)/../../../../common/include/ + +TARGET = commands.so + +PWD := $(shell pwd) + +COMMON_DIR = $(PWD)/../../../../common +HOST_COMMON_DIR = $(PWD)/../../../host_common +C_SUPPORT_DIR = $(PWD)/../c_support + +commands.so: + $(CC) $(CFLAGS) $(COMMON_DIR)/protobuf-c/protobuf-c/protobuf-c.c \ + $(C_SUPPORT_DIR)/platform_wrapper.c \ + $(COMMON_DIR)/esp_hosted_config.pb-c.c \ + $(HOST_COMMON_DIR)/transport_pserial.c \ + -o $(TARGET) -shared -fPIC $(HOST_COMMON_DIR)/commands.c + +clean: + rm -f $(TARGET) *.o diff --git a/host/linux/host_control/python_support/ap_scan_list.py b/host/linux/host_control/python_support/ap_scan_list.py index 8f03d04cae..cd47f0a6ce 100644 --- a/host/linux/host_control/python_support/ap_scan_list.py +++ b/host/linux/host_control/python_support/ap_scan_list.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse -failure = "failure" ap_list = 'No APs Available' parser = argparse.ArgumentParser(description='ap_scan_list.py is a python script which gives scanned list of available APs. list contains ssid, channel number, rssi, mac address and authentication mode of AP. ex. python ap_scan_list.py') diff --git a/host/linux/host_control/python_support/commands.py b/host/linux/host_control/python_support/commands.py deleted file mode 100644 index 038481022e..0000000000 --- a/host/linux/host_control/python_support/commands.py +++ /dev/null @@ -1,550 +0,0 @@ -# Copyright 2015-2021 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. - -from transport import * -from esp_hosted_config_pb2 import * -import sys - -class Aplist: - def __init__(self,ssid,chnl,rssi,bssid,ecn): - self.ssid = ssid - self.chnl = chnl - self.rssi = rssi - self.bssid = bssid - self.ecn = ecn - -class Stationlist: - def __init__(self,mac,rssi): - self.mac = mac - self.rssi = rssi - -#default parameters -interface = "/dev/esps0" -endpoint = "control" -failure = -1 -success = 0 -success_str = "success" -failure_str = "failure" -not_connected_str = "not_connected" -no_ap_found_str = "no_ap_found" -invalid_password_str = "invalid_password_str" - -max_ssid_len = 32 -max_password_len = 64 -min_password_len = 8 -max_bssid_len = 17 -min_channel_no = 1 -max_channel_no = 11 -min_allowed_stations = 1 -max_allowed_stations = 10 -wifi_bw_ht20 = 1 -wifi_bw_ht40 = 2 -ssid_broadcast = 0 -ssid_not_broadcast = 1 - -wifi_ps_min_modem = 1 -wifi_ps_max_modem = 2 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 - -def get_str(string): - if sys.version_info >= (3, 0): - return string.decode('utf-8') - else: - return string - -# wifi get mac -# On success, function returns mac address of ESP32's station or softAP mode else "failure" -# mode == 1 for station mac -# mode == 2 for softAP mac - -def wifi_get_mac(mode): - if ((mode <= wifi_mode_none ) or (mode >= wifi_mode_station_softap)): - print("Invalid mode") - return failure_str - get_mac = EspHostedConfigPayload() - get_mac.msg = EspHostedConfigMsgType.TypeCmdGetMACAddress - get_mac.cmd_get_mac_address.mode = mode - protodata = get_mac.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_mac.ParseFromString(response[1]) - del tp - if response[0] != success: - return failure_str - if get_mac.resp_get_mac_address.resp != success: - return failure_str - else: - return get_str(get_mac.resp_get_mac_address.mac) - -# wifi get mode -# Function returns ESP32's wifi mode as follows -# 0: null Mode, Wi-Fi mode not set -# 1: station mode -# 2: softAP mode -# 3: station+softAP mode -# or "failure" - -def wifi_get_mode(): - get_mode = EspHostedConfigPayload() - get_mode.msg = EspHostedConfigMsgType.TypeCmdGetWiFiMode - protodata = get_mode.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_mode.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if get_mode.resp_get_wifi_mode.resp != success: - return failure_str - return get_mode.resp_get_wifi_mode.mode - -# wifi set mode -# Function sets ESP32's wifi mode -# Input parameter -# mode : WiFi mode -# (0: null Mode, Wi-Fi mode not set -# 1: station mode -# 2: softAP mode -# 3: station+softAP mode) -# Returns "success" or "failure" - -def wifi_set_mode(mode): - if (mode < wifi_mode_none or mode > wifi_mode_station_softap): - print("Invalid mode") - return failure_str - set_mode = EspHostedConfigPayload() - set_mode.msg = EspHostedConfigMsgType.TypeCmdSetWiFiMode - set_mode.cmd_set_wifi_mode.mode = mode - protodata = set_mode.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - set_mode.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if set_mode.resp_set_wifi_mode.resp != success: - return failure_str - else: - return success_str - -# wifi set ap config -# Function sets AP config to which ESP32 station should connect -# Input parameter -# ssid : string parameter, ssid of AP, max 32 bytes -# pwd : string parameter, length of password should be 8~64 bytes ASCII -# bssid : MAC address of AP, To differentiate between APs, In case multiple AP has same ssid -# is_wpa3_supported : status of wpa3 supplicant present on AP -# (False : Unsupported -# True : Supported ) -# listen_interval : Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. -# Units: AP beacon intervals. Defaults to 3 if set to 0. -# Output: -# 'success' : successfully connected to AP -# 'failure' : Failed to connect to AP -# 'no_ap_found' : AP not found -# 'invalid_password' : Invalid password - -def wifi_set_ap_config(ssid, pwd, bssid, is_wpa3_supported, listen_interval): - if (len(str(ssid)) > max_ssid_len): - print("Invalid SSID length") - return failure_str - if (len(str(pwd)) > max_password_len) : - print("Invalid Password length") - return failure_str - if (len(str(bssid)) > max_bssid_len) : - print("Invalid BSSID length") - return failure_str - if (is_wpa3_supported < 0 or listen_interval < 0) : - print("Invalid Input") - return failure_str - set_ap_config = EspHostedConfigPayload() - set_ap_config.msg = EspHostedConfigMsgType.TypeCmdSetAPConfig - set_ap_config.cmd_set_ap_config.ssid = str(ssid) - set_ap_config.cmd_set_ap_config.pwd = str(pwd) - set_ap_config.cmd_set_ap_config.bssid = str(bssid) - set_ap_config.cmd_set_ap_config.is_wpa3_supported = is_wpa3_supported - set_ap_config.cmd_set_ap_config.listen_interval = listen_interval - protodata = set_ap_config.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - set_ap_config.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if set_ap_config.resp_set_ap_config.resp == EspHostedStatus.TYPE_CONNECTION_FAIL: - print("Invalid password entered") - return invalid_password_str - elif set_ap_config.resp_set_ap_config.resp == EspHostedStatus.TYPE_NO_AP_FOUND: - print("No AP found") - return no_ap_found_str - elif set_ap_config.resp_set_ap_config.resp != success: - return failure_str - else: - return success_str - -# wifi get ap config -# Function returns AP config to which ESP32 station is connected -# Output parameter -# ssid : ssid of connected AP -# bssid : MAC address of connected AP -# channel : channel ID, 1 ~ 10 -# rssi : rssi signal strength -# encryption_mode : encryption mode -# (encryption modes are -# 0 : OPEN -# 1 : WEP -# 2 : WPA_PSK -# 3 : WPA2_PSK -# 4 : WPA_WPA2_PSK -# 5 : WPA2_ENTERPRISE -# 6 : WPA3_PSK -# 7 : WPA2_WPA3_PSK ) -# In case of not connected to AP, returns "not_connected" - -def wifi_get_ap_config(): - get_ap_config = EspHostedConfigPayload() - get_ap_config.msg = EspHostedConfigMsgType.TypeCmdGetAPConfig - protodata = get_ap_config.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_ap_config.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if get_ap_config.resp_get_ap_config.resp == EspHostedStatus.TYPE_NOT_CONNECTED: - return not_connected_str - elif get_ap_config.resp_get_ap_config.resp != success: - return failure_str - ssid = get_str(get_ap_config.resp_get_ap_config.ssid) - bssid = get_str(get_ap_config.resp_get_ap_config.bssid) - channel = get_ap_config.resp_get_ap_config.chnl - rssi = get_ap_config.resp_get_ap_config.rssi - ecn = get_ap_config.resp_get_ap_config.ecn - return ssid,bssid,channel,rssi,ecn - -# wifi disconnect ap -# Function disconnects ESP32 station from connected AP -# returns "success" or "failure" - -def wifi_disconnect_ap(): - disconnect_ap = EspHostedConfigPayload() - disconnect_ap.msg = EspHostedConfigMsgType.TypeCmdDisconnectAP - protodata = disconnect_ap.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - disconnect_ap.ParseFromString(response[1]) - del tp - if response[0] != success: - return failure_str - if disconnect_ap.resp_disconnect_ap.resp != success: - return failure_str - else: - return success_str - -# wifi set softAP config -# Function sets ESP32 softAP configurations -# returns "success" or "failure" -# Input parameter -# ssid : string parameter, ssid of softAP -# pwd : string parameter, length of password should be 8~64 bytes ASCII -# chnl : channel ID, In range of 1 to 11 -# ecn : Encryption method -# ( 0 : OPEN, -# 2 : WPA_PSK, -# 3 : WPA2_PSK, -# 4 : WPA_WPA2_PSK) -# max_conn : maximum number of stations can connect to ESP32 softAP (should be in range of 1 to 10) -# ssid_hidden : softAP should broadcast its SSID or not -# ( 0 : SSID is broadcast -# 1 : SSID is not broadcast ) -# bw : set bandwidth of ESP32 softAP -# ( 1 : WIFI_BW_HT20 -# 2 : WIFI_BW_HT40 ) - -def wifi_set_softap_config(ssid, pwd, chnl, ecn, max_conn, ssid_hidden, bw): - if (len(ssid) > max_ssid_len) : - print("Invalid SSID length") - return failure_str - if ((len(pwd) > max_password_len) or (ecn == EspHostedEncryptionMode.Type_Open and (len(pwd))) - or (ecn != EspHostedEncryptionMode.Type_Open and (len(pwd) < min_password_len))): - print("Invalid softAP password length") - return failure_str - if ((chnl < min_channel_no) or (chnl > max_channel_no)): - print("Invalid channel number") - return failure_str - if ((ecn < EspHostedEncryptionMode.Type_Open) or (ecn == EspHostedEncryptionMode.Type_WEP) - or (ecn > EspHostedEncryptionMode.Type_WPA_WPA2_PSK)): - print("Asked Encryption method is not supported in softAP mode") - return failure_str - if (max_conn < min_allowed_stations or max_conn > max_allowed_stations): - print("Invalid maximum connection number") - return failure_str - if (ssid_hidden < ssid_broadcast or ssid_hidden > ssid_not_broadcast): - print("Invalid ssid hidden status") - return failure_str - if (bw < wifi_bw_ht20 or bw > wifi_bw_ht40): - print("Invalid BW") - return failure_str - set_softap_config = EspHostedConfigPayload() - set_softap_config.msg = EspHostedConfigMsgType.TypeCmdSetSoftAPConfig - set_softap_config.cmd_set_softap_config.ssid = str(ssid) - set_softap_config.cmd_set_softap_config.pwd = str(pwd) - set_softap_config.cmd_set_softap_config.chnl = chnl - set_softap_config.cmd_set_softap_config.max_conn = max_conn - set_softap_config.cmd_set_softap_config.ssid_hidden = ssid_hidden - set_softap_config.cmd_set_softap_config.bw = bw - set_softap_config.cmd_set_softap_config.ecn = ecn - protodata = set_softap_config.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - set_softap_config.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if set_softap_config.resp_set_softap_config.resp != success: - return failure_str - else: - return success_str - -# wifi get softAP config -# Funtion gets ESP32 softAP configuration -# Output parameter -# It returns ssid,pwd,chnl,ecn,max_conn,ssid_hidden,bw in case of "success" -# ssid : string parameter, ssid of softAP -# pwd : string parameter, length of password should be 8~64 bytes ASCII -# chnl : channel ID, In range of 1 to 11 -# ecn : Encryption method -# ( 0 : OPEN, -# 2 : WPA_PSK, -# 3 : WPA2_PSK, -# 4 : WPA_WPA2_PSK) -# max_conn : maximum number of stations can connect to ESP32 softAP (will be in range of 1 to 10) -# ssid_hidden : softAP should broadcast its SSID or not -# ( 0 : SSID is broadcast -# 1 : SSID is not broadcast ) -# bw : bandwidth of ESP32 softAP -# ( 1 : WIFI_BW_HT20 -# 2 : WIFI_BW_HT40 ) -# else returns "failure" - -def wifi_get_softap_config(): - get_softap_config = EspHostedConfigPayload() - get_softap_config.msg = EspHostedConfigMsgType.TypeCmdGetSoftAPConfig - protodata = get_softap_config.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_softap_config.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if get_softap_config.resp_get_softap_config.resp != success: - return failure_str - ssid = get_str(get_softap_config.resp_get_softap_config.ssid) - pwd = get_str(get_softap_config.resp_get_softap_config.pwd) - ecn = get_softap_config.resp_get_softap_config.ecn - chnl = get_softap_config.resp_get_softap_config.chnl - max_conn = get_softap_config.resp_get_softap_config.max_conn - ssid_hidden = get_softap_config.resp_get_softap_config.ssid_hidden - bw = get_softap_config.resp_get_softap_config.bw - return ssid,pwd,chnl,ecn,max_conn,ssid_hidden,bw - -# wifi stop softAP -# Function stops ESP32 softAP -# returns "success" or "failure" - -def wifi_stop_softap(): - stop_softap = EspHostedConfigPayload() - stop_softap.msg = EspHostedConfigMsgType.TypeCmdStopSoftAP - protodata = stop_softap.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - del tp - stop_softap.ParseFromString(response[1]) - if response[0] != success: - return failure_str - if stop_softap.resp_stop_softap.resp != success: - return failure_str - else: - return success_str - -# wifi ap scan list -# Function gives scanned list of available APs -# Output parameter -# output is list of Aplist class instances(ssid,chnl,rssi,bssid,ecn) in case of "success" -# AP credentials:: -# ssid : ssid of AP -# channel : channel ID, in range of 1 to 10 -# bssid : MAC address of AP -# rssi : rssi signal strength -# encryption_mode : encryption mode -# (encryption modes are -# 0 : OPEN -# 1 : WEP -# 2 : WPA_PSK -# 3 : WPA2_PSK -# 4 : WPA_WPA2_PSK -# 5 : WPA2_ENTERPRISE -# 6 : WPA3_PSK -# 7 : WPA2_WPA3_PSK ) -# else returns "failure" - -def wifi_ap_scan_list(): - get_ap_scan_list = EspHostedConfigPayload() - get_ap_scan_list.msg = EspHostedConfigMsgType.TypeCmdGetAPScanList - protodata = get_ap_scan_list.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_ap_scan_list.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if get_ap_scan_list.resp_scan_ap_list.resp != success: - return failure_str - count = get_ap_scan_list.resp_scan_ap_list.count - ap_list = [] - for i in range(count) : - ssid = get_str(get_ap_scan_list.resp_scan_ap_list.entries[i].ssid) - chnl = get_ap_scan_list.resp_scan_ap_list.entries[i].chnl - rssi = get_ap_scan_list.resp_scan_ap_list.entries[i].rssi - bssid = get_str(get_ap_scan_list.resp_scan_ap_list.entries[i].bssid) - ecn = get_ap_scan_list.resp_scan_ap_list.entries[i].ecn - ap_list.append(Aplist(ssid,chnl,rssi,bssid,ecn)) - return ap_list - -# wifi connected stations list -# Function gives list of connected stations(maximum 10) to ESP32 softAP -# In case of "success" -# Output parameter -# Stations credentials:: -# mac : MAC address of station -# rssi : rssi signal strength -# If no station is connected, failure return from slave -# output is list of Stationlist class instances -# else returns "failure" - -def wifi_connected_stations_list(): - get_connected_stations_list = EspHostedConfigPayload() - get_connected_stations_list.msg = EspHostedConfigMsgType.TypeCmdGetConnectedSTAList - protodata = get_connected_stations_list.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_connected_stations_list.ParseFromString(response[1]) - del tp - if response[0] != success : - return failure_str - if get_connected_stations_list.resp_connected_stas_list.resp != success: - return failure_str - num = get_connected_stations_list.resp_connected_stas_list.num - if (num == 0) : - print("No station is connected") - return failure_str - else : - stas_list = [] - for i in range(num) : - mac = get_str(get_connected_stations_list.resp_connected_stas_list.stations[i].mac) - rssi = get_connected_stations_list.resp_connected_stas_list.stations[i].rssi - stas_list.append(Stationlist(mac,rssi)) - return stas_list - -# wifi set mac -# Function sets MAC address for Station and softAP interface -# mode == 1 for station mac -# mode == 2 for softAP mac -# returns "success" or "failure" -# @attention 1. First set wifi mode before setting MAC address for respective station and softAP Interface -# @attention 2. ESP32 station and softAP have different MAC addresses, do not set them to be the same. -# @attention 3. The bit 0 of the first byte of ESP32 MAC address can not be 1. -# For example, the MAC address can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX". -# @attention 4. MAC address will get reset after esp restarts - -def wifi_set_mac(mode, mac): - if (mode <= wifi_mode_none or mode >= wifi_mode_station_softap): - print("Invalid mode") - return failure_str - if (not(len(mac)) or (len(mac) > max_bssid_len)) : - print("Invalid MAC address") - return failure_str - set_mac = EspHostedConfigPayload() - set_mac.msg = EspHostedConfigMsgType.TypeCmdSetMacAddress - set_mac.cmd_set_mac_address.mode = mode - if sys.version_info >= (3, 0): - mac = bytes(mac,'utf-8') - set_mac.cmd_set_mac_address.mac = mac - protodata = set_mac.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - set_mac.ParseFromString(response[1]) - del tp - if response[0] != success: - return failure_str - if set_mac.resp_set_mac_address.resp != success: - return failure_str - else: - return success_str - -# wifi set power save mode -# Function sets ESP32's power save mode, returns "success" or "failure" -# power save mode == 1 WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. -# In this mode, station wakes up to receive beacon every DTIM period */ -# power save mode == 2 WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. -# In this mode, interval to receive beacons is determined by the -# listen_interval parameter in wifi set ap config function*/ -# Default :: power save mode is WIFI_PS_MIN_MODEM - -def wifi_set_power_save_mode(power_save_mode): - if ((power_save_mode < wifi_ps_min_modem) or (power_save_mode > wifi_ps_max_modem)): - print("Invalid power save mode") - return failure_str - set_power_save_mode = EspHostedConfigPayload() - set_power_save_mode.msg = EspHostedConfigMsgType.TypeCmdSetPowerSaveMode - set_power_save_mode.cmd_set_power_save_mode.mode = power_save_mode - protodata = set_power_save_mode.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - set_power_save_mode.ParseFromString(response[1]) - del tp - if response[0] != success: - return failure_str - if set_power_save_mode.resp_set_power_save_mode.resp != success: - return failure_str - else: - return success_str - -# wifi get power save mode -# Function returns power save mode of ESP32 or "failure" -# power save mode == 1 WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. -# In this mode, station wakes up to receive beacon every DTIM period */ -# power save mode == 2 WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. -# In this mode, interval to receive beacons is determined by the -# listen_interval parameter in wifi set ap config function*/ -# Default :: power save mode is WIFI_PS_MIN_MODEM - -def wifi_get_power_save_mode(): - get_power_save_mode = EspHostedConfigPayload() - get_power_save_mode.msg = EspHostedConfigMsgType.TypeCmdGetPowerSaveMode - protodata = get_power_save_mode.SerializeToString() - tp = Transport_pserial(interface) - response = tp.send_data(endpoint,protodata) - get_power_save_mode.ParseFromString(response[1]) - del tp - if response[0] != success: - return failure_str - if get_power_save_mode.resp_get_power_save_mode.resp != success: - return failure_str - else: - return get_power_save_mode.resp_get_power_save_mode.mode diff --git a/host/linux/host_control/python_support/commands_lib.py b/host/linux/host_control/python_support/commands_lib.py new file mode 100644 index 0000000000..25557aabad --- /dev/null +++ b/host/linux/host_control/python_support/commands_lib.py @@ -0,0 +1,546 @@ +# Copyright 2015-2021 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. + +from hosted_config import * +import commands_map_py_to_c + +# Control path platform init +# On success, It clears stale data from ringbuffer +# On failure, It exits currently running python script +def control_path_platform_init(): + ret = commands_map_py_to_c.control_path_platform_init() + if ret: + print("Control path init failed") + exit() + return + +# wifi get mac +# On success, function returns mac address of ESP32's station or softap mode else "failure" +# mode == 1 for station mac +# mode == 2 for softap mac +def wifi_get_mac(mode): + if ((mode <= WIFI_MODE_NONE ) or (mode >= WIFI_MODE_SOFTAP_STATION)): + print("Invalid mode") + return failure + mac = create_string_buffer(b"",BSSID_LENGTH) + ret = commands_map_py_to_c.wifi_get_mac(mode, mac) + if not ret : + return get_str(mac.value) + else : + return failure + +# wifi set mac +# Function sets MAC address for Station and SoftAP interface +# mode == 1 for station mac +# mode == 2 for softap mac +# returns "success" or "failure" +# @attention 1. First set wifi mode before setting MAC address for respective station and softap Interface +# @attention 2. ESP32 station and softap have different MAC addresses, do not set them to be the same. +# @attention 3. The bit 0 of the first byte of ESP32 MAC address can not be 1. +# For example, the MAC address can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX". +# @attention 4. MAC address will get reset after esp restarts +def wifi_set_mac(mode, mac): + if (mode <= WIFI_MODE_NONE or mode >= WIFI_MODE_SOFTAP_STATION): + print("Invalid mode") + return failure + if (not(len(mac)) or (len(mac) > MAX_BSSID_LEN)) : + print("Invalid MAC address") + return failure + ret = commands_map_py_to_c.wifi_set_mac(mode, set_str(mac)) + if not ret: + return success + else: + return failure + +# wifi get mode +# Function returns ESP32's wifi mode as follows +# 0: null Mode, Wi-Fi mode not set +# 1: station mode +# 2: softap mode +# 3: softap+station mode +# or "failure" + +def wifi_get_mode(): + mode = c_uint() + ret = commands_map_py_to_c.wifi_get_mode(byref(mode)) + if not ret : + return int(mode.value) + else : + return failure + +# wifi set mode +# Function sets ESP32's wifi mode +# Input parameter +# mode : WiFi mode +# (0: null Mode, Wi-Fi mode not set +# 1: station mode +# 2: softAP mode +# 3: softAP+station mode) +# Returns "success" or "failure" + +def wifi_set_mode(mode): + if (mode < WIFI_MODE_NONE or mode > WIFI_MODE_SOFTAP_STATION): + print("Invalid mode") + return failure + wifi_mode = c_uint() + wifi_mode.value = mode + ret = commands_map_py_to_c.wifi_set_mode(wifi_mode) + if not ret: + return success + else: + return failure + +# wifi set ap config +# Function sets AP config to which ESP32 station should connect +# Input parameter +# ssid : string parameter, ssid of AP, max 32 bytes +# pwd : string parameter, length of password should be 8~63 bytes ASCII +# bssid : MAC address of AP, To differentiate between APs, In case multiple AP has same ssid +# is_wpa3_supported : status of wpa3 supplicant present on AP +# (False : Unsupported +# True : Supported ) +# listen_interval : Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. +# Units: AP beacon intervals. Defaults to 3 if set to 0. + +def wifi_set_ap_config(ssid, pwd, bssid, is_wpa3_supported, listen_interval): + if (len(str(ssid)) > MAX_SSID_LEN): + print("Invalid SSID length") + return failure + if (len(str(pwd)) > (MAX_PASSWORD_LEN - 1)) : + print("Invalid Password length") + return failure + if (len(str(bssid)) > MAX_BSSID_LEN) : + print("Invalid BSSID length") + return failure + if (is_wpa3_supported < 0 or listen_interval < 0) : + print("Invalid Input") + return failure + ap_config = CONTROL_CONFIG() + ap_config.station.ssid = set_str(ssid) + ap_config.station.pwd = set_str(pwd) + ap_config.station.bssid = set_str(bssid) + ap_config.station.is_wpa3_supported = is_wpa3_supported + ap_config.station.listen_interval = listen_interval + ret = commands_map_py_to_c.wifi_set_ap_config(ap_config) + if (ret == NO_AP_FOUND): + return no_ap_found_str + elif (ret == INVALID_PASSWORD): + return invalid_password_str + elif not ret: + return success + else: + return failure + +# wifi get ap config +# Function returns AP config to which ESP32 station is connected +# Output parameter +# ssid : ssid of connected AP +# bssid : MAC address of connected AP +# channel : channel ID, 1 ~ 10 +# rssi : rssi signal strength +# encryption_mode : encryption mode +# (encryption modes are +# 0 : OPEN +# 1 : WEP +# 2 : WPA_PSK +# 3 : WPA2_PSK +# 4 : WPA_WPA2_PSK +# 5 : WPA2_ENTERPRISE +# 6 : WPA3_PSK +# 7 : WPA2_WPA3_PSK ) +# In case of not connected to AP, returns "not_connected" + +def wifi_get_ap_config(): + ap_config = CONTROL_CONFIG() + ret = commands_map_py_to_c.wifi_get_ap_config(byref(ap_config.station)) + if not ret: + ssid = get_str(ap_config.station.ssid) + bssid = get_str(ap_config.station.bssid) + channel = int(ap_config.station.channel) + rssi = int(ap_config.station.rssi) + ecn = int(ap_config.station.encryption_mode) + return ssid,bssid,channel,rssi,ecn + else: + print("status "+get_str(ap_config.station.status)) + return failure + +# wifi disconnect ap +# Function disconnects ESP32 station from connected AP +# returns "success" or "failure" + +def wifi_disconnect_ap(): + ret = commands_map_py_to_c.wifi_disconnect_ap() + if not ret: + return success + else: + return failure + +# wifi set softap config +# Function sets ESP32 softap configurations +# returns "success" or "failure" +# Input parameter +# ssid : string parameter, ssid of SoftAP +# pwd : string parameter, length of password should be 8~64 bytes ASCII +# chnl : channel ID, In range of 1 to 11 +# ecn : Encryption method +# ( 0 : OPEN, +# 2 : WPA_PSK, +# 3 : WPA2_PSK, +# 4 : WPA_WPA2_PSK) +# max_conn : maximum number of stations can connect to ESP32 SoftAP (should be in range of 1 to 10) +# ssid_hidden : softap should broadcast its SSID or not +# ( 0 : SSID is broadcast +# 1 : SSID is not broadcast ) +# bw : set bandwidth of ESP32 softap +# ( 1 : WIFI_BW_HT20 +# 2 : WIFI_BW_HT40 ) + +def wifi_set_softap_config(ssid, pwd, chnl, ecn, max_conn, ssid_hidden, bw): + if (len(ssid) > MAX_SSID_LEN) : + print("Invalid SSID length softap") + return failure + if ((len(pwd) > MAX_PASSWORD_LEN) or (ecn == WIFI_AUTH_OPEN and (len(pwd))) + or (ecn != WIFI_AUTH_OPEN and (len(pwd) < MIN_PASSWORD_LEN))): + print("Invalid softap password length") + return failure + if ((chnl < MIN_CHANNEL_NO) or (chnl > MAX_CHANNEL_NO)): + print("Invalid channel number") + return failure + if ((ecn < WIFI_AUTH_OPEN) or (ecn == WIFI_AUTH_WEP) + or (ecn > WIFI_AUTH_WPA_WPA2_PSK)): + print("Asked Encryption method is not supported in SoftAP mode") + return failure + if (max_conn < MIN_ALLOWED_STATIONS or max_conn > MAX_ALLOWED_STATIONS): + print("Invalid maximum connection number") + return failure + if (ssid_hidden < SSID_BROADCAST or ssid_hidden > SSID_NOT_BROADCAST): + print("Invalid ssid hidden status") + return failure + if (bw < WIFI_BW_HT20 or bw > WIFI_BW_HT40): + print("Invalid BW") + return failure + + softap_config = CONTROL_CONFIG() + softap_config.softap.ssid = set_str(ssid) + softap_config.softap.pwd = set_str(pwd) + softap_config.softap.channel = chnl + softap_config.softap.encryption_mode = ecn + softap_config.softap.max_connections = max_conn + softap_config.softap.ssid_hidden = ssid_hidden + softap_config.softap.bandwidth = bw + + ret = commands_map_py_to_c.wifi_set_softap_config(softap_config) + if not ret: + return success + else: + return failure + +# wifi get softap config +# Funtion gets ESP32 softAP configuration +# Output parameter +# It returns ssid,pwd,chnl,ecn,max_conn,ssid_hidden,bw in case of "success" +# ssid : string parameter, ssid of SoftAP +# pwd : string parameter, length of password should be 8~64 bytes ASCII +# chnl : channel ID, In range of 1 to 11 +# ecn : Encryption method +# ( 0 : OPEN, +# 2 : WPA_PSK, +# 3 : WPA2_PSK, +# 4 : WPA_WPA2_PSK) +# max_conn : maximum number of stations can connect to ESP32 SoftAP (will be in range of 1 to 10) +# ssid_hidden : softAP should broadcast its SSID or not +# ( 0 : SSID is broadcast +# 1 : SSID is not broadcast ) +# bw : bandwidth of ESP32 softAP +# ( 1 : WIFI_BW_HT20 +# 2 : WIFI_BW_HT40 ) +# else returns "failure" + +def wifi_get_softap_config(): + softap_config = CONTROL_CONFIG() + ret = commands_map_py_to_c.wifi_get_softap_config(byref(softap_config)) + if not ret: + ssid = get_str(softap_config.softap.ssid) + pwd = get_str(softap_config.softap.pwd) + ecn = int(softap_config.softap.encryption_mode) + chnl = int(softap_config.softap.channel) + max_conn = int(softap_config.softap.max_connections) + ssid_hidden = int(softap_config.softap.ssid_hidden) + bw = int(softap_config.softap.bandwidth) + return ssid,pwd,chnl,ecn,max_conn,ssid_hidden,bw + else: + return failure + +# wifi stop softap +# Function stops ESP32 softAP +# returns "success" or "failure" + +def wifi_stop_softap(): + ret = commands_map_py_to_c.wifi_stop_softap() + if not ret: + return success + else: + return failure + +# wifi ap scan list +# Function gives scanned list of available APs +# Output parameter +# output is list of Aplist class instances(ssid,chnl,rssi,bssid,ecn) in case of "success" +# AP credentials:: +# ssid : ssid of AP +# channel : channel ID, in range of 1 to 10 +# bssid : MAC address of AP +# rssi : rssi signal strength +# encryption_mode : encryption mode +# (encryption modes are +# 0 : OPEN +# 1 : WEP +# 2 : WPA_PSK +# 3 : WPA2_PSK +# 4 : WPA_WPA2_PSK +# 5 : WPA2_ENTERPRISE +# 6 : WPA3_PSK +# 7 : WPA2_WPA3_PSK ) +# else returns "failure" + +def wifi_ap_scan_list(): + count = c_uint() + ap_scan_list_ptr = commands_map_py_to_c.wifi_ap_scan_list(byref(count)) + if ap_scan_list_ptr is None: + return failure + list_type = WIFI_SCAN_LIST * count.value + ap_scan_list = cast(ap_scan_list_ptr, POINTER(list_type)) + ap_list = [] + if count.value: + for i in range(count.value): + ssid = get_str(ap_scan_list.contents[i].ssid) + chnl = int(ap_scan_list.contents[i].channel) + rssi = int(ap_scan_list.contents[i].rssi) + bssid = get_str(ap_scan_list.contents[i].bssid) + ecn = int(ap_scan_list.contents[i].encryption_mode) + ap_list.append(Aplist(ssid,chnl,rssi,bssid,ecn)) + commands_map_py_to_c.esp_hosted_free(ap_scan_list_ptr) + ap_scan_list_ptr = None + return ap_list + +# wifi connected stations list +# Function gives list of connected stations(maximum 10) to ESP32 softAP +# In case of "success" +# Output parameter +# Stations credentials:: +# mac : MAC address of station +# rssi : rssi signal strength +# If no station is connected, failure return from slave +# output is list of Stationlist class instances +# else returns "failure" + +def wifi_connected_stations_list(): + count = c_uint() + stations_list_ptr = commands_map_py_to_c.wifi_connected_stations_list(byref(count)) + if stations_list_ptr is None: + return failure + list_type = WIFI_STATIONS_LIST * count.value + stations_list = cast(stations_list_ptr, POINTER(list_type)) + if count.value: + stas_list = [] + for i in range(count.value): + bssid = get_str(stations_list.contents[i].bssid) + rssi = int(stations_list.contents[i].rssi) + stas_list.append(Stationlist(bssid,rssi)) + commands_map_py_to_c.esp_hosted_free(stations_list_ptr) + stations_list_ptr = None + return stas_list + else: + commands_map_py_to_c.esp_hosted_free(stations_list_ptr) + stations_list_ptr = None + print("No station is connected") + return failure + +# wifi set power save mode +# Function sets ESP32's power save mode, returns "success" or "failure" +# power save mode == 1 WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. +# In this mode, station wakes up to receive beacon every DTIM period */ +# power save mode == 2 WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. +# In this mode, interval to receive beacons is determined by the +# listen_interval parameter in wifi set ap config function*/ +# Default :: power save mode is WIFI_PS_MIN_MODEM + +def wifi_set_power_save_mode(power_save_mode): + if ((power_save_mode < WIFI_PS_MIN_MODEM) or (power_save_mode > WIFI_PS_MAX_MODEM)): + print("Unsupported power save mode") + return failure + mode = c_uint() + mode.value = power_save_mode + ret = commands_map_py_to_c.wifi_set_power_save_mode(mode) + if not ret: + return success + else: + return failure + +# wifi get power save mode +# Function returns power save mode of ESP32 or "failure" +# power save mode == 1 WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. +# In this mode, station wakes up to receive beacon every DTIM period */ +# power save mode == 2 WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. +# In this mode, interval to receive beacons is determined by the +# listen_interval parameter in wifi set ap config function*/ +# Default :: power save mode is WIFI_PS_MIN_MODEM + +def wifi_get_power_save_mode(): + mode = c_uint() + ret = commands_map_py_to_c.wifi_get_power_save_mode(byref(mode)) + if not ret: + return mode.value + else: + return failure + +# wifi_set_max_tx_power function set maximum transmitting power, returns "success" or "failure" +# +# @attention 1. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable in wifi driver. +# @attention 2. Mapping Table {wifi_max_tx_power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, +# {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. +# @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm to 20dBm. +# @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. +# +# Input parameter: +# wifi_max_tx_power : Maximum WiFi transmitting power. +# +# Returns "out_of_range" string. If `wifi_max_tx_power` range is not in [8, 84] corresponding to `2dBm to 20dBm` tx power. + +def wifi_set_max_tx_power(wifi_max_tx_power): + set_power = c_int() + set_power.value = wifi_max_tx_power + ret = commands_map_py_to_c.wifi_set_max_tx_power(set_power) + if (ret == OUT_OF_RANGE): + return out_of_range_str + elif not ret: + return success + else: + return failure + +# wifi_get_curr_tx_power function gets current transmiting power, or returns "failure" +# +# Output parameter: +# wifi_curr_tx_power : Current WiFi transmitting power, unit is 0.25dBm. + +def wifi_get_curr_tx_power(): + wifi_curr_tx_power = c_int() + ret = commands_map_py_to_c.wifi_get_curr_tx_power(byref(wifi_curr_tx_power)) + if not ret: + return wifi_curr_tx_power.value + else: + return failure + +# OTA begin +# function returns "success" or "failure" +# esp ota begin function performs an OTA begin operation for ESP32 +# which sets partition for OTA write and erase it. + +def esp_ota_begin(): + ret = commands_map_py_to_c.esp_ota_begin() + if not ret: + return success + else: + return failure + +# OTA write +# esp ota write function performs an OTA write operation for ESP32, +# function returns "success" or "failure" +# It writes ota_data buffer to OTA partition in flash +# +# Input parameter: +# ota_data : OTA data buffer +# ota_data_len : length of OTA data buffer + +def esp_ota_write(ota_data, ota_data_len): + ret = commands_map_py_to_c.esp_ota_write(ota_data, ota_data_len) + if not ret: + return success + else: + return failure + +# OTA end +# esp ota end function performs an OTA end operation for ESP32, +# function returns "success" or "failure" +# It validates written OTA image, set OTA partition as boot partition for next boot, +# Creates timer which reset ESP32 after 5 sec, + +def esp_ota_end(): + ret = commands_map_py_to_c.esp_ota_end() + if not ret: + return success + else: + return failure + +# Interface down +# This function downs the given interface iface +# function returns "success" or "failure" + +def interface_down(sockfd, iface): + ret = commands_map_py_to_c.interface_down(sockfd, iface) + if not ret: + return success + else: + return failure + +# Interface up +# This function ups the given interface iface +# function returns "success" or "failure" + +def interface_up(sockfd, iface): + ret = commands_map_py_to_c.interface_up(sockfd, iface) + if not ret: + return success + else: + return failure + +# Set HW address +# This function sets mac address to the given interface iface +# function returns "success" or "failure" + +def set_hw_addr(sockfd, iface, mac): + ret = commands_map_py_to_c.set_hw_addr(sockfd, iface, mac) + if not ret: + return success + else: + return failure + +# Create socket +# This function creates an endpoint for communication +# Function returns "file descriptor (integer number) that refers to that endpoint/socket" or "failure" +# Input parameter: +# domain: specifies a communication domain +# types: specifies the communication semantics +# protocol: specifies a particular protocol to be used with the socket + +def create_socket(domain, types, protocol): + sock = c_int() + ret = commands_map_py_to_c.create_socket(domain, types, protocol, byref(sock)) + if not ret: + return int(sock.value) + else: + return failure + +# Close socket +# This function closes an endpoint for communication +# function returns "success" or "failure" +# Input parameter: +# sock: file descriptor (integer number) that refers to the endpoint/socket + +def close_socket(sock): + ret = commands_map_py_to_c.close_socket(sock) + if not ret: + return success + else: + return failure diff --git a/host/linux/host_control/python_support/commands_map_py_to_c.py b/host/linux/host_control/python_support/commands_map_py_to_c.py new file mode 100644 index 0000000000..61f1220df8 --- /dev/null +++ b/host/linux/host_control/python_support/commands_map_py_to_c.py @@ -0,0 +1,104 @@ +# Copyright 2015-2021 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. + +from ctypes import * +from hosted_config import * +import os.path +import subprocess +import sys + +lib = os.path.isfile("commands.so") +if not lib: + print("commands.so file is missing, please run ./rpi_init.sh script.") + sys.exit() + +commands_lib = cdll.LoadLibrary(os.path.abspath("commands.so")) + +wifi_get_mac = commands_lib.wifi_get_mac +wifi_get_mac.restype = c_int + +wifi_get_mode = commands_lib.wifi_get_mode +wifi_get_mode.restype = c_int + +wifi_set_mode = commands_lib.wifi_set_mode +wifi_set_mode.restype = c_int + +wifi_set_ap_config = commands_lib.wifi_set_ap_config +wifi_set_ap_config.restype = c_int + +wifi_get_ap_config = commands_lib.wifi_get_ap_config +wifi_get_ap_config.restype = c_int + +wifi_disconnect_ap = commands_lib.wifi_disconnect_ap +wifi_disconnect_ap.restype = c_int + +wifi_set_softap_config = commands_lib.wifi_set_softap_config +wifi_set_softap_config.restype = c_int + +wifi_get_softap_config = commands_lib.wifi_get_softap_config +wifi_get_softap_config.restype = c_int + +wifi_ap_scan_list = commands_lib.wifi_ap_scan_list +wifi_ap_scan_list.restype = c_void_p + +wifi_connected_stations_list = commands_lib.wifi_connected_stations_list +wifi_connected_stations_list.restype = c_void_p + +wifi_set_mac = commands_lib.wifi_set_mac +wifi_set_mac.restype = c_int + +wifi_set_power_save_mode = commands_lib.wifi_set_power_save_mode +wifi_set_power_save_mode.restype = c_int + +wifi_get_power_save_mode = commands_lib.wifi_get_power_save_mode +wifi_get_power_save_mode.restype = c_int + +wifi_stop_softap = commands_lib.wifi_stop_softap +wifi_stop_softap.restype = c_int + +wifi_set_max_tx_power = commands_lib.wifi_set_max_tx_power +wifi_set_max_tx_power.restype = c_int + +wifi_get_curr_tx_power = commands_lib.wifi_get_curr_tx_power +wifi_get_curr_tx_power.restype = c_int + +esp_hosted_free = commands_lib.esp_hosted_free +esp_hosted_free.restype = None + +control_path_platform_init = commands_lib.control_path_platform_init +control_path_platform_init.restype = c_int + +esp_ota_begin = commands_lib.esp_ota_begin +esp_ota_begin.restype = c_int + +esp_ota_write = commands_lib.esp_ota_write +esp_ota_write.restype = c_int + +esp_ota_end = commands_lib.esp_ota_end +esp_ota_end.restype = c_int + +interface_up = commands_lib.interface_up +interface_up.restype = c_int + +interface_down = commands_lib.interface_down +interface_down.restype = c_int + +set_hw_addr = commands_lib.set_hw_addr +set_hw_addr.restype = c_int + +create_socket = commands_lib.create_socket +create_socket.restype = c_int + +close_socket = commands_lib.close_socket +close_socket.restype = c_int diff --git a/host/linux/host_control/python_support/connected_stations_list.py b/host/linux/host_control/python_support/connected_stations_list.py index e793c1f110..8d3a11ab3a 100644 --- a/host/linux/host_control/python_support/connected_stations_list.py +++ b/host/linux/host_control/python_support/connected_stations_list.py @@ -12,32 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse -# WiFi Mode -# NULL 0 -# Station 1 -# softAP 2 -# Station + softAP 3 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 -failure = "failure" -stations_list = "No station is connected" +get_mode = 'not_set' +stations_list = "No_station_is_connected" parser = argparse.ArgumentParser(description='connected_stations_list.py is a python script which gives list of mac addresses of stations connected to softAP. ex. python connected_stations_list.py') get_mode = wifi_get_mode() -if ((get_mode == wifi_mode_softap) or (get_mode == wifi_mode_station_softap)): +if ((get_mode == WIFI_MODE_SOFTAP) or (get_mode == WIFI_MODE_SOFTAP_STATION)): stations_list = wifi_connected_stations_list() if (stations_list == failure): print("failure in getting connected stations list") else: for obj in stations_list: - print(obj.mac) + print(obj.bssid) elif (get_mode == failure): print("failure in getting wifi mode") else : diff --git a/host/linux/host_control/python_support/esp_hosted_config_pb2.py b/host/linux/host_control/python_support/esp_hosted_config_pb2.py deleted file mode 100644 index ebd4eec8bc..0000000000 --- a/host/linux/host_control/python_support/esp_hosted_config_pb2.py +++ /dev/null @@ -1,1838 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: esp_hosted_config.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import enum_type_wrapper -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='esp_hosted_config.proto', - package='', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x17\x65sp_hosted_config.proto\")\n\x19\x45spHostedCmdGetMacAddress\x12\x0c\n\x04mode\x18\x01 \x01(\x05\"7\n\x1a\x45spHostedRespGetMacAddress\x12\x0b\n\x03mac\x18\x01 \x01(\x0c\x12\x0c\n\x04resp\x18\x02 \x01(\x05\"\x15\n\x13\x45spHostedCmdGetMode\"2\n\x14\x45spHostedRespGetMode\x12\x0c\n\x04mode\x18\x01 \x01(\x05\x12\x0c\n\x04resp\x18\x02 \x01(\x05\"#\n\x13\x45spHostedCmdSetMode\x12\x0c\n\x04mode\x18\x01 \x01(\x05\"$\n\x14\x45spHostedRespSetMode\x12\x0c\n\x04resp\x18\x01 \x01(\x05\"\x17\n\x15\x45spHostedCmdGetStatus\"&\n\x16\x45spHostedRespGetStatus\x12\x0c\n\x04resp\x18\x01 \x01(\x05\"6\n\x19\x45spHostedCmdSetMacAddress\x12\x0b\n\x03mac\x18\x01 \x01(\x0c\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"*\n\x1a\x45spHostedRespSetMacAddress\x12\x0c\n\x04resp\x18\x01 \x01(\x05\"\x19\n\x17\x45spHostedCmdGetAPConfig\"\x88\x01\n\x18\x45spHostedRespGetAPConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x02 \x01(\x0c\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\x0c\n\x04\x63hnl\x18\x04 \x01(\x05\x12%\n\x03\x65\x63n\x18\x05 \x01(\x0e\x32\x18.EspHostedEncryptionMode\x12\x0c\n\x04resp\x18\x06 \x01(\x05\"w\n\x17\x45spHostedCmdSetAPConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\r\n\x05\x62ssid\x18\x03 \x01(\t\x12\x19\n\x11is_wpa3_supported\x18\x04 \x01(\x08\x12\x17\n\x0flisten_interval\x18\x05 \x01(\x05\"(\n\x18\x45spHostedRespSetAPConfig\x12\x0c\n\x04resp\x18\x01 \x01(\x05\"\x1d\n\x1b\x45spHostedCmdGetSoftAPConfig\"\xaf\x01\n\x1c\x45spHostedRespGetSoftAPConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0b\n\x03pwd\x18\x02 \x01(\x0c\x12\x0c\n\x04\x63hnl\x18\x03 \x01(\x05\x12%\n\x03\x65\x63n\x18\x04 \x01(\x0e\x32\x18.EspHostedEncryptionMode\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\n\n\x02\x62w\x18\x07 \x01(\x05\x12\x0c\n\x04resp\x18\x08 \x01(\x05\"\xa0\x01\n\x1b\x45spHostedCmdSetSoftAPConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\x0c\n\x04\x63hnl\x18\x03 \x01(\x05\x12%\n\x03\x65\x63n\x18\x04 \x01(\x0e\x32\x18.EspHostedEncryptionMode\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\n\n\x02\x62w\x18\x07 \x01(\x05\",\n\x1c\x45spHostedRespSetSoftAPConfig\x12\x0c\n\x04resp\x18\x01 \x01(\x05\"u\n\x13\x45spHostedScanResult\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0c\n\x04\x63hnl\x18\x02 \x01(\r\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12%\n\x03\x65\x63n\x18\x05 \x01(\x0e\x32\x18.EspHostedEncryptionMode\"\x18\n\x16\x45spHostedCmdScanResult\"]\n\x17\x45spHostedRespScanResult\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12%\n\x07\x65ntries\x18\x02 \x03(\x0b\x32\x14.EspHostedScanResult\x12\x0c\n\x04resp\x18\x03 \x01(\x05\"6\n\x19\x45spHostedConnectedSTAList\x12\x0b\n\x03mac\x18\x01 \x01(\x0c\x12\x0c\n\x04rssi\x18\x02 \x01(\x05\"\x1a\n\x18\x45spHostedCmdConnectedSTA\"d\n\x19\x45spHostedRespConnectedSTA\x12\x0b\n\x03num\x18\x01 \x01(\r\x12,\n\x08stations\x18\x02 \x03(\x0b\x32\x1a.EspHostedConnectedSTAList\x12\x0c\n\x04resp\x18\x03 \x01(\x05\"\x8f\r\n\x16\x45spHostedConfigPayload\x12$\n\x03msg\x18\x01 \x01(\x0e\x32\x17.EspHostedConfigMsgType\x12\x39\n\x13\x63md_get_mac_address\x18\n \x01(\x0b\x32\x1a.EspHostedCmdGetMacAddressH\x00\x12;\n\x14resp_get_mac_address\x18\x0b \x01(\x0b\x32\x1b.EspHostedRespGetMacAddressH\x00\x12\x31\n\x11\x63md_get_wifi_mode\x18\x0c \x01(\x0b\x32\x14.EspHostedCmdGetModeH\x00\x12\x33\n\x12resp_get_wifi_mode\x18\r \x01(\x0b\x32\x15.EspHostedRespGetModeH\x00\x12\x31\n\x11\x63md_set_wifi_mode\x18\x0e \x01(\x0b\x32\x14.EspHostedCmdSetModeH\x00\x12\x33\n\x12resp_set_wifi_mode\x18\x0f \x01(\x0b\x32\x15.EspHostedRespSetModeH\x00\x12\x35\n\x11\x63md_get_ap_config\x18\x10 \x01(\x0b\x32\x18.EspHostedCmdGetAPConfigH\x00\x12\x37\n\x12resp_get_ap_config\x18\x11 \x01(\x0b\x32\x19.EspHostedRespGetAPConfigH\x00\x12\x35\n\x11\x63md_set_ap_config\x18\x12 \x01(\x0b\x32\x18.EspHostedCmdSetAPConfigH\x00\x12\x37\n\x12resp_set_ap_config\x18\x13 \x01(\x0b\x32\x19.EspHostedRespSetAPConfigH\x00\x12=\n\x15\x63md_get_softap_config\x18\x14 \x01(\x0b\x32\x1c.EspHostedCmdGetSoftAPConfigH\x00\x12?\n\x16resp_get_softap_config\x18\x15 \x01(\x0b\x32\x1d.EspHostedRespGetSoftAPConfigH\x00\x12=\n\x15\x63md_set_softap_config\x18\x16 \x01(\x0b\x32\x1c.EspHostedCmdSetSoftAPConfigH\x00\x12?\n\x16resp_set_softap_config\x18\x17 \x01(\x0b\x32\x1d.EspHostedRespSetSoftAPConfigH\x00\x12\x33\n\x11\x63md_disconnect_ap\x18\x18 \x01(\x0b\x32\x16.EspHostedCmdGetStatusH\x00\x12\x35\n\x12resp_disconnect_ap\x18\x19 \x01(\x0b\x32\x17.EspHostedRespGetStatusH\x00\x12\x31\n\x0f\x63md_stop_softap\x18\x1a \x01(\x0b\x32\x16.EspHostedCmdGetStatusH\x00\x12\x33\n\x10resp_stop_softap\x18\x1b \x01(\x0b\x32\x17.EspHostedRespGetStatusH\x00\x12\x33\n\x10\x63md_scan_ap_list\x18\x1c \x01(\x0b\x32\x17.EspHostedCmdScanResultH\x00\x12\x35\n\x11resp_scan_ap_list\x18\x1d \x01(\x0b\x32\x18.EspHostedRespScanResultH\x00\x12<\n\x17\x63md_connected_stas_list\x18\x1e \x01(\x0b\x32\x19.EspHostedCmdConnectedSTAH\x00\x12>\n\x18resp_connected_stas_list\x18\x1f \x01(\x0b\x32\x1a.EspHostedRespConnectedSTAH\x00\x12\x39\n\x13\x63md_set_mac_address\x18 \x01(\x0b\x32\x1a.EspHostedCmdSetMacAddressH\x00\x12;\n\x14resp_set_mac_address\x18! \x01(\x0b\x32\x1b.EspHostedRespSetMacAddressH\x00\x12\x37\n\x17\x63md_set_power_save_mode\x18\" \x01(\x0b\x32\x14.EspHostedCmdSetModeH\x00\x12\x39\n\x18resp_set_power_save_mode\x18# \x01(\x0b\x32\x15.EspHostedRespSetModeH\x00\x12\x37\n\x17\x63md_get_power_save_mode\x18$ \x01(\x0b\x32\x14.EspHostedCmdGetModeH\x00\x12\x39\n\x18resp_get_power_save_mode\x18% \x01(\x0b\x32\x15.EspHostedRespGetModeH\x00\x42\t\n\x07payload*\xb7\x01\n\x17\x45spHostedEncryptionMode\x12\r\n\tType_Open\x10\x00\x12\x0c\n\x08Type_WEP\x10\x01\x12\x10\n\x0cType_WPA_PSK\x10\x02\x12\x11\n\rType_WPA2_PSK\x10\x03\x12\x15\n\x11Type_WPA_WPA2_PSK\x10\x04\x12\x18\n\x14Type_WPA2_ENTERPRISE\x10\x05\x12\x11\n\rType_WPA3_PSK\x10\x06\x12\x16\n\x12Type_WPA2_WPA3_PSK\x10\x07*m\n\x0f\x45spHostedStatus\x12\x12\n\x0eTYPE_CONNECTED\x10\x00\x12\x16\n\x12TYPE_NOT_CONNECTED\x10\x01\x12\x14\n\x10TYPE_NO_AP_FOUND\x10\x02\x12\x18\n\x14TYPE_CONNECTION_FAIL\x10\x03*\x86\x06\n\x16\x45spHostedConfigMsgType\x12\x18\n\x14TypeCmdGetMACAddress\x10\x00\x12\x19\n\x15TypeRespGetMACAddress\x10\x01\x12\x16\n\x12TypeCmdGetWiFiMode\x10\x02\x12\x17\n\x13TypeRespGetWiFiMode\x10\x03\x12\x16\n\x12TypeCmdSetWiFiMode\x10\x04\x12\x17\n\x13TypeRespSetWiFiMode\x10\x05\x12\x16\n\x12TypeCmdGetAPConfig\x10\x06\x12\x17\n\x13TypeRespGetAPConfig\x10\x07\x12\x16\n\x12TypeCmdSetAPConfig\x10\x08\x12\x17\n\x13TypeRespSetAPConfig\x10\t\x12\x1a\n\x16TypeCmdGetSoftAPConfig\x10\n\x12\x1b\n\x17TypeRespGetSoftAPConfig\x10\x0b\x12\x1a\n\x16TypeCmdSetSoftAPConfig\x10\x0c\x12\x1b\n\x17TypeRespSetSoftAPConfig\x10\r\x12\x17\n\x13TypeCmdDisconnectAP\x10\x0e\x12\x18\n\x14TypeRespDisconnectAP\x10\x0f\x12\x15\n\x11TypeCmdStopSoftAP\x10\x10\x12\x16\n\x12TypeRespStopSoftAP\x10\x11\x12\x18\n\x14TypeCmdGetAPScanList\x10\x12\x12\x19\n\x15TypeRespGetAPScanList\x10\x13\x12\x1e\n\x1aTypeCmdGetConnectedSTAList\x10\x14\x12\x1f\n\x1bTypeRespGetConnectedSTAList\x10\x15\x12\x18\n\x14TypeCmdSetMacAddress\x10\x16\x12\x19\n\x15TypeRespSetMacAddress\x10\x17\x12\x1b\n\x17TypeCmdSetPowerSaveMode\x10\x18\x12\x1c\n\x18TypeRespSetPowerSaveMode\x10\x19\x12\x1b\n\x17TypeCmdGetPowerSaveMode\x10\x1a\x12\x1c\n\x18TypeRespGetPowerSaveMode\x10\x1b\x62\x06proto3' -) - -_ESPHOSTEDENCRYPTIONMODE = _descriptor.EnumDescriptor( - name='EspHostedEncryptionMode', - full_name='EspHostedEncryptionMode', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='Type_Open', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WEP', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA_PSK', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA2_PSK', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA_WPA2_PSK', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA2_ENTERPRISE', index=5, number=5, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA3_PSK', index=6, number=6, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='Type_WPA2_WPA3_PSK', index=7, number=7, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=3298, - serialized_end=3481, -) -_sym_db.RegisterEnumDescriptor(_ESPHOSTEDENCRYPTIONMODE) - -EspHostedEncryptionMode = enum_type_wrapper.EnumTypeWrapper(_ESPHOSTEDENCRYPTIONMODE) -_ESPHOSTEDSTATUS = _descriptor.EnumDescriptor( - name='EspHostedStatus', - full_name='EspHostedStatus', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='TYPE_CONNECTED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TYPE_NOT_CONNECTED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TYPE_NO_AP_FOUND', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TYPE_CONNECTION_FAIL', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=3483, - serialized_end=3592, -) -_sym_db.RegisterEnumDescriptor(_ESPHOSTEDSTATUS) - -EspHostedStatus = enum_type_wrapper.EnumTypeWrapper(_ESPHOSTEDSTATUS) -_ESPHOSTEDCONFIGMSGTYPE = _descriptor.EnumDescriptor( - name='EspHostedConfigMsgType', - full_name='EspHostedConfigMsgType', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='TypeCmdGetMACAddress', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetMACAddress', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetWiFiMode', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetWiFiMode', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdSetWiFiMode', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespSetWiFiMode', index=5, number=5, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetAPConfig', index=6, number=6, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetAPConfig', index=7, number=7, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdSetAPConfig', index=8, number=8, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespSetAPConfig', index=9, number=9, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetSoftAPConfig', index=10, number=10, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetSoftAPConfig', index=11, number=11, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdSetSoftAPConfig', index=12, number=12, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespSetSoftAPConfig', index=13, number=13, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdDisconnectAP', index=14, number=14, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespDisconnectAP', index=15, number=15, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdStopSoftAP', index=16, number=16, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespStopSoftAP', index=17, number=17, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetAPScanList', index=18, number=18, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetAPScanList', index=19, number=19, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetConnectedSTAList', index=20, number=20, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetConnectedSTAList', index=21, number=21, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdSetMacAddress', index=22, number=22, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespSetMacAddress', index=23, number=23, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdSetPowerSaveMode', index=24, number=24, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespSetPowerSaveMode', index=25, number=25, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeCmdGetPowerSaveMode', index=26, number=26, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='TypeRespGetPowerSaveMode', index=27, number=27, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=3595, - serialized_end=4369, -) -_sym_db.RegisterEnumDescriptor(_ESPHOSTEDCONFIGMSGTYPE) - -EspHostedConfigMsgType = enum_type_wrapper.EnumTypeWrapper(_ESPHOSTEDCONFIGMSGTYPE) -Type_Open = 0 -Type_WEP = 1 -Type_WPA_PSK = 2 -Type_WPA2_PSK = 3 -Type_WPA_WPA2_PSK = 4 -Type_WPA2_ENTERPRISE = 5 -Type_WPA3_PSK = 6 -Type_WPA2_WPA3_PSK = 7 -TYPE_CONNECTED = 0 -TYPE_NOT_CONNECTED = 1 -TYPE_NO_AP_FOUND = 2 -TYPE_CONNECTION_FAIL = 3 -TypeCmdGetMACAddress = 0 -TypeRespGetMACAddress = 1 -TypeCmdGetWiFiMode = 2 -TypeRespGetWiFiMode = 3 -TypeCmdSetWiFiMode = 4 -TypeRespSetWiFiMode = 5 -TypeCmdGetAPConfig = 6 -TypeRespGetAPConfig = 7 -TypeCmdSetAPConfig = 8 -TypeRespSetAPConfig = 9 -TypeCmdGetSoftAPConfig = 10 -TypeRespGetSoftAPConfig = 11 -TypeCmdSetSoftAPConfig = 12 -TypeRespSetSoftAPConfig = 13 -TypeCmdDisconnectAP = 14 -TypeRespDisconnectAP = 15 -TypeCmdStopSoftAP = 16 -TypeRespStopSoftAP = 17 -TypeCmdGetAPScanList = 18 -TypeRespGetAPScanList = 19 -TypeCmdGetConnectedSTAList = 20 -TypeRespGetConnectedSTAList = 21 -TypeCmdSetMacAddress = 22 -TypeRespSetMacAddress = 23 -TypeCmdSetPowerSaveMode = 24 -TypeRespSetPowerSaveMode = 25 -TypeCmdGetPowerSaveMode = 26 -TypeRespGetPowerSaveMode = 27 - - - -_ESPHOSTEDCMDGETMACADDRESS = _descriptor.Descriptor( - name='EspHostedCmdGetMacAddress', - full_name='EspHostedCmdGetMacAddress', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mode', full_name='EspHostedCmdGetMacAddress.mode', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=27, - serialized_end=68, -) - - -_ESPHOSTEDRESPGETMACADDRESS = _descriptor.Descriptor( - name='EspHostedRespGetMacAddress', - full_name='EspHostedRespGetMacAddress', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mac', full_name='EspHostedRespGetMacAddress.mac', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespGetMacAddress.resp', index=1, - number=2, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=70, - serialized_end=125, -) - - -_ESPHOSTEDCMDGETMODE = _descriptor.Descriptor( - name='EspHostedCmdGetMode', - full_name='EspHostedCmdGetMode', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=127, - serialized_end=148, -) - - -_ESPHOSTEDRESPGETMODE = _descriptor.Descriptor( - name='EspHostedRespGetMode', - full_name='EspHostedRespGetMode', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mode', full_name='EspHostedRespGetMode.mode', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespGetMode.resp', index=1, - number=2, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=150, - serialized_end=200, -) - - -_ESPHOSTEDCMDSETMODE = _descriptor.Descriptor( - name='EspHostedCmdSetMode', - full_name='EspHostedCmdSetMode', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mode', full_name='EspHostedCmdSetMode.mode', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=202, - serialized_end=237, -) - - -_ESPHOSTEDRESPSETMODE = _descriptor.Descriptor( - name='EspHostedRespSetMode', - full_name='EspHostedRespSetMode', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespSetMode.resp', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=239, - serialized_end=275, -) - - -_ESPHOSTEDCMDGETSTATUS = _descriptor.Descriptor( - name='EspHostedCmdGetStatus', - full_name='EspHostedCmdGetStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=277, - serialized_end=300, -) - - -_ESPHOSTEDRESPGETSTATUS = _descriptor.Descriptor( - name='EspHostedRespGetStatus', - full_name='EspHostedRespGetStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespGetStatus.resp', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=302, - serialized_end=340, -) - - -_ESPHOSTEDCMDSETMACADDRESS = _descriptor.Descriptor( - name='EspHostedCmdSetMacAddress', - full_name='EspHostedCmdSetMacAddress', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mac', full_name='EspHostedCmdSetMacAddress.mac', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='mode', full_name='EspHostedCmdSetMacAddress.mode', index=1, - number=2, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=342, - serialized_end=396, -) - - -_ESPHOSTEDRESPSETMACADDRESS = _descriptor.Descriptor( - name='EspHostedRespSetMacAddress', - full_name='EspHostedRespSetMacAddress', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespSetMacAddress.resp', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=398, - serialized_end=440, -) - - -_ESPHOSTEDCMDGETAPCONFIG = _descriptor.Descriptor( - name='EspHostedCmdGetAPConfig', - full_name='EspHostedCmdGetAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=442, - serialized_end=467, -) - - -_ESPHOSTEDRESPGETAPCONFIG = _descriptor.Descriptor( - name='EspHostedRespGetAPConfig', - full_name='EspHostedRespGetAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ssid', full_name='EspHostedRespGetAPConfig.ssid', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='bssid', full_name='EspHostedRespGetAPConfig.bssid', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='rssi', full_name='EspHostedRespGetAPConfig.rssi', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='chnl', full_name='EspHostedRespGetAPConfig.chnl', index=3, - number=4, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ecn', full_name='EspHostedRespGetAPConfig.ecn', index=4, - number=5, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespGetAPConfig.resp', index=5, - number=6, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=470, - serialized_end=606, -) - - -_ESPHOSTEDCMDSETAPCONFIG = _descriptor.Descriptor( - name='EspHostedCmdSetAPConfig', - full_name='EspHostedCmdSetAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ssid', full_name='EspHostedCmdSetAPConfig.ssid', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pwd', full_name='EspHostedCmdSetAPConfig.pwd', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='bssid', full_name='EspHostedCmdSetAPConfig.bssid', index=2, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='is_wpa3_supported', full_name='EspHostedCmdSetAPConfig.is_wpa3_supported', index=3, - number=4, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='listen_interval', full_name='EspHostedCmdSetAPConfig.listen_interval', index=4, - number=5, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=608, - serialized_end=727, -) - - -_ESPHOSTEDRESPSETAPCONFIG = _descriptor.Descriptor( - name='EspHostedRespSetAPConfig', - full_name='EspHostedRespSetAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespSetAPConfig.resp', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=729, - serialized_end=769, -) - - -_ESPHOSTEDCMDGETSOFTAPCONFIG = _descriptor.Descriptor( - name='EspHostedCmdGetSoftAPConfig', - full_name='EspHostedCmdGetSoftAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=771, - serialized_end=800, -) - - -_ESPHOSTEDRESPGETSOFTAPCONFIG = _descriptor.Descriptor( - name='EspHostedRespGetSoftAPConfig', - full_name='EspHostedRespGetSoftAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ssid', full_name='EspHostedRespGetSoftAPConfig.ssid', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pwd', full_name='EspHostedRespGetSoftAPConfig.pwd', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='chnl', full_name='EspHostedRespGetSoftAPConfig.chnl', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ecn', full_name='EspHostedRespGetSoftAPConfig.ecn', index=3, - number=4, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='max_conn', full_name='EspHostedRespGetSoftAPConfig.max_conn', index=4, - number=5, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ssid_hidden', full_name='EspHostedRespGetSoftAPConfig.ssid_hidden', index=5, - number=6, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='bw', full_name='EspHostedRespGetSoftAPConfig.bw', index=6, - number=7, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespGetSoftAPConfig.resp', index=7, - number=8, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=803, - serialized_end=978, -) - - -_ESPHOSTEDCMDSETSOFTAPCONFIG = _descriptor.Descriptor( - name='EspHostedCmdSetSoftAPConfig', - full_name='EspHostedCmdSetSoftAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ssid', full_name='EspHostedCmdSetSoftAPConfig.ssid', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pwd', full_name='EspHostedCmdSetSoftAPConfig.pwd', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='chnl', full_name='EspHostedCmdSetSoftAPConfig.chnl', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ecn', full_name='EspHostedCmdSetSoftAPConfig.ecn', index=3, - number=4, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='max_conn', full_name='EspHostedCmdSetSoftAPConfig.max_conn', index=4, - number=5, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ssid_hidden', full_name='EspHostedCmdSetSoftAPConfig.ssid_hidden', index=5, - number=6, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='bw', full_name='EspHostedCmdSetSoftAPConfig.bw', index=6, - number=7, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=981, - serialized_end=1141, -) - - -_ESPHOSTEDRESPSETSOFTAPCONFIG = _descriptor.Descriptor( - name='EspHostedRespSetSoftAPConfig', - full_name='EspHostedRespSetSoftAPConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespSetSoftAPConfig.resp', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1143, - serialized_end=1187, -) - - -_ESPHOSTEDSCANRESULT = _descriptor.Descriptor( - name='EspHostedScanResult', - full_name='EspHostedScanResult', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ssid', full_name='EspHostedScanResult.ssid', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='chnl', full_name='EspHostedScanResult.chnl', index=1, - number=2, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='rssi', full_name='EspHostedScanResult.rssi', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='bssid', full_name='EspHostedScanResult.bssid', index=3, - number=4, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='ecn', full_name='EspHostedScanResult.ecn', index=4, - number=5, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1189, - serialized_end=1306, -) - - -_ESPHOSTEDCMDSCANRESULT = _descriptor.Descriptor( - name='EspHostedCmdScanResult', - full_name='EspHostedCmdScanResult', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1308, - serialized_end=1332, -) - - -_ESPHOSTEDRESPSCANRESULT = _descriptor.Descriptor( - name='EspHostedRespScanResult', - full_name='EspHostedRespScanResult', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='count', full_name='EspHostedRespScanResult.count', index=0, - number=1, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='entries', full_name='EspHostedRespScanResult.entries', index=1, - number=2, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespScanResult.resp', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1334, - serialized_end=1427, -) - - -_ESPHOSTEDCONNECTEDSTALIST = _descriptor.Descriptor( - name='EspHostedConnectedSTAList', - full_name='EspHostedConnectedSTAList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mac', full_name='EspHostedConnectedSTAList.mac', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=b"", - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='rssi', full_name='EspHostedConnectedSTAList.rssi', index=1, - number=2, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1429, - serialized_end=1483, -) - - -_ESPHOSTEDCMDCONNECTEDSTA = _descriptor.Descriptor( - name='EspHostedCmdConnectedSTA', - full_name='EspHostedCmdConnectedSTA', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1485, - serialized_end=1511, -) - - -_ESPHOSTEDRESPCONNECTEDSTA = _descriptor.Descriptor( - name='EspHostedRespConnectedSTA', - full_name='EspHostedRespConnectedSTA', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='num', full_name='EspHostedRespConnectedSTA.num', index=0, - number=1, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='stations', full_name='EspHostedRespConnectedSTA.stations', index=1, - number=2, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp', full_name='EspHostedRespConnectedSTA.resp', index=2, - number=3, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1513, - serialized_end=1613, -) - - -_ESPHOSTEDCONFIGPAYLOAD = _descriptor.Descriptor( - name='EspHostedConfigPayload', - full_name='EspHostedConfigPayload', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='msg', full_name='EspHostedConfigPayload.msg', index=0, - number=1, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_get_mac_address', full_name='EspHostedConfigPayload.cmd_get_mac_address', index=1, - number=10, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_get_mac_address', full_name='EspHostedConfigPayload.resp_get_mac_address', index=2, - number=11, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_get_wifi_mode', full_name='EspHostedConfigPayload.cmd_get_wifi_mode', index=3, - number=12, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_get_wifi_mode', full_name='EspHostedConfigPayload.resp_get_wifi_mode', index=4, - number=13, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_set_wifi_mode', full_name='EspHostedConfigPayload.cmd_set_wifi_mode', index=5, - number=14, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_set_wifi_mode', full_name='EspHostedConfigPayload.resp_set_wifi_mode', index=6, - number=15, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_get_ap_config', full_name='EspHostedConfigPayload.cmd_get_ap_config', index=7, - number=16, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_get_ap_config', full_name='EspHostedConfigPayload.resp_get_ap_config', index=8, - number=17, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_set_ap_config', full_name='EspHostedConfigPayload.cmd_set_ap_config', index=9, - number=18, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_set_ap_config', full_name='EspHostedConfigPayload.resp_set_ap_config', index=10, - number=19, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_get_softap_config', full_name='EspHostedConfigPayload.cmd_get_softap_config', index=11, - number=20, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_get_softap_config', full_name='EspHostedConfigPayload.resp_get_softap_config', index=12, - number=21, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_set_softap_config', full_name='EspHostedConfigPayload.cmd_set_softap_config', index=13, - number=22, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_set_softap_config', full_name='EspHostedConfigPayload.resp_set_softap_config', index=14, - number=23, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_disconnect_ap', full_name='EspHostedConfigPayload.cmd_disconnect_ap', index=15, - number=24, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_disconnect_ap', full_name='EspHostedConfigPayload.resp_disconnect_ap', index=16, - number=25, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_stop_softap', full_name='EspHostedConfigPayload.cmd_stop_softap', index=17, - number=26, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_stop_softap', full_name='EspHostedConfigPayload.resp_stop_softap', index=18, - number=27, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_scan_ap_list', full_name='EspHostedConfigPayload.cmd_scan_ap_list', index=19, - number=28, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_scan_ap_list', full_name='EspHostedConfigPayload.resp_scan_ap_list', index=20, - number=29, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_connected_stas_list', full_name='EspHostedConfigPayload.cmd_connected_stas_list', index=21, - number=30, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_connected_stas_list', full_name='EspHostedConfigPayload.resp_connected_stas_list', index=22, - number=31, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_set_mac_address', full_name='EspHostedConfigPayload.cmd_set_mac_address', index=23, - number=32, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_set_mac_address', full_name='EspHostedConfigPayload.resp_set_mac_address', index=24, - number=33, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_set_power_save_mode', full_name='EspHostedConfigPayload.cmd_set_power_save_mode', index=25, - number=34, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_set_power_save_mode', full_name='EspHostedConfigPayload.resp_set_power_save_mode', index=26, - number=35, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='cmd_get_power_save_mode', full_name='EspHostedConfigPayload.cmd_get_power_save_mode', index=27, - number=36, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='resp_get_power_save_mode', full_name='EspHostedConfigPayload.resp_get_power_save_mode', index=28, - number=37, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='payload', full_name='EspHostedConfigPayload.payload', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=1616, - serialized_end=3295, -) - -_ESPHOSTEDRESPGETAPCONFIG.fields_by_name['ecn'].enum_type = _ESPHOSTEDENCRYPTIONMODE -_ESPHOSTEDRESPGETSOFTAPCONFIG.fields_by_name['ecn'].enum_type = _ESPHOSTEDENCRYPTIONMODE -_ESPHOSTEDCMDSETSOFTAPCONFIG.fields_by_name['ecn'].enum_type = _ESPHOSTEDENCRYPTIONMODE -_ESPHOSTEDSCANRESULT.fields_by_name['ecn'].enum_type = _ESPHOSTEDENCRYPTIONMODE -_ESPHOSTEDRESPSCANRESULT.fields_by_name['entries'].message_type = _ESPHOSTEDSCANRESULT -_ESPHOSTEDRESPCONNECTEDSTA.fields_by_name['stations'].message_type = _ESPHOSTEDCONNECTEDSTALIST -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['msg'].enum_type = _ESPHOSTEDCONFIGMSGTYPE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].message_type = _ESPHOSTEDCMDGETMACADDRESS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].message_type = _ESPHOSTEDRESPGETMACADDRESS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].message_type = _ESPHOSTEDCMDGETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].message_type = _ESPHOSTEDRESPGETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].message_type = _ESPHOSTEDCMDSETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].message_type = _ESPHOSTEDRESPSETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].message_type = _ESPHOSTEDCMDGETAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].message_type = _ESPHOSTEDRESPGETAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].message_type = _ESPHOSTEDCMDSETAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].message_type = _ESPHOSTEDRESPSETAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].message_type = _ESPHOSTEDCMDGETSOFTAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].message_type = _ESPHOSTEDRESPGETSOFTAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].message_type = _ESPHOSTEDCMDSETSOFTAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].message_type = _ESPHOSTEDRESPSETSOFTAPCONFIG -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].message_type = _ESPHOSTEDCMDGETSTATUS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].message_type = _ESPHOSTEDRESPGETSTATUS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_stop_softap'].message_type = _ESPHOSTEDCMDGETSTATUS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_stop_softap'].message_type = _ESPHOSTEDRESPGETSTATUS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].message_type = _ESPHOSTEDCMDSCANRESULT -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].message_type = _ESPHOSTEDRESPSCANRESULT -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].message_type = _ESPHOSTEDCMDCONNECTEDSTA -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].message_type = _ESPHOSTEDRESPCONNECTEDSTA -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_mac_address'].message_type = _ESPHOSTEDCMDSETMACADDRESS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_mac_address'].message_type = _ESPHOSTEDRESPSETMACADDRESS -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_power_save_mode'].message_type = _ESPHOSTEDCMDSETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_power_save_mode'].message_type = _ESPHOSTEDRESPSETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_power_save_mode'].message_type = _ESPHOSTEDCMDGETMODE -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_power_save_mode'].message_type = _ESPHOSTEDRESPGETMODE -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_stop_softap']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_stop_softap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_stop_softap']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_stop_softap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_mac_address']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_mac_address']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_power_save_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_power_save_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_power_save_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_power_save_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_power_save_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_power_save_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append( - _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_power_save_mode']) -_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_power_save_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'] -DESCRIPTOR.message_types_by_name['EspHostedCmdGetMacAddress'] = _ESPHOSTEDCMDGETMACADDRESS -DESCRIPTOR.message_types_by_name['EspHostedRespGetMacAddress'] = _ESPHOSTEDRESPGETMACADDRESS -DESCRIPTOR.message_types_by_name['EspHostedCmdGetMode'] = _ESPHOSTEDCMDGETMODE -DESCRIPTOR.message_types_by_name['EspHostedRespGetMode'] = _ESPHOSTEDRESPGETMODE -DESCRIPTOR.message_types_by_name['EspHostedCmdSetMode'] = _ESPHOSTEDCMDSETMODE -DESCRIPTOR.message_types_by_name['EspHostedRespSetMode'] = _ESPHOSTEDRESPSETMODE -DESCRIPTOR.message_types_by_name['EspHostedCmdGetStatus'] = _ESPHOSTEDCMDGETSTATUS -DESCRIPTOR.message_types_by_name['EspHostedRespGetStatus'] = _ESPHOSTEDRESPGETSTATUS -DESCRIPTOR.message_types_by_name['EspHostedCmdSetMacAddress'] = _ESPHOSTEDCMDSETMACADDRESS -DESCRIPTOR.message_types_by_name['EspHostedRespSetMacAddress'] = _ESPHOSTEDRESPSETMACADDRESS -DESCRIPTOR.message_types_by_name['EspHostedCmdGetAPConfig'] = _ESPHOSTEDCMDGETAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedRespGetAPConfig'] = _ESPHOSTEDRESPGETAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedCmdSetAPConfig'] = _ESPHOSTEDCMDSETAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedRespSetAPConfig'] = _ESPHOSTEDRESPSETAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedCmdGetSoftAPConfig'] = _ESPHOSTEDCMDGETSOFTAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedRespGetSoftAPConfig'] = _ESPHOSTEDRESPGETSOFTAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedCmdSetSoftAPConfig'] = _ESPHOSTEDCMDSETSOFTAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedRespSetSoftAPConfig'] = _ESPHOSTEDRESPSETSOFTAPCONFIG -DESCRIPTOR.message_types_by_name['EspHostedScanResult'] = _ESPHOSTEDSCANRESULT -DESCRIPTOR.message_types_by_name['EspHostedCmdScanResult'] = _ESPHOSTEDCMDSCANRESULT -DESCRIPTOR.message_types_by_name['EspHostedRespScanResult'] = _ESPHOSTEDRESPSCANRESULT -DESCRIPTOR.message_types_by_name['EspHostedConnectedSTAList'] = _ESPHOSTEDCONNECTEDSTALIST -DESCRIPTOR.message_types_by_name['EspHostedCmdConnectedSTA'] = _ESPHOSTEDCMDCONNECTEDSTA -DESCRIPTOR.message_types_by_name['EspHostedRespConnectedSTA'] = _ESPHOSTEDRESPCONNECTEDSTA -DESCRIPTOR.message_types_by_name['EspHostedConfigPayload'] = _ESPHOSTEDCONFIGPAYLOAD -DESCRIPTOR.enum_types_by_name['EspHostedEncryptionMode'] = _ESPHOSTEDENCRYPTIONMODE -DESCRIPTOR.enum_types_by_name['EspHostedStatus'] = _ESPHOSTEDSTATUS -DESCRIPTOR.enum_types_by_name['EspHostedConfigMsgType'] = _ESPHOSTEDCONFIGMSGTYPE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -EspHostedCmdGetMacAddress = _reflection.GeneratedProtocolMessageType('EspHostedCmdGetMacAddress', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDGETMACADDRESS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdGetMacAddress) - }) -_sym_db.RegisterMessage(EspHostedCmdGetMacAddress) - -EspHostedRespGetMacAddress = _reflection.GeneratedProtocolMessageType('EspHostedRespGetMacAddress', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPGETMACADDRESS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespGetMacAddress) - }) -_sym_db.RegisterMessage(EspHostedRespGetMacAddress) - -EspHostedCmdGetMode = _reflection.GeneratedProtocolMessageType('EspHostedCmdGetMode', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDGETMODE, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdGetMode) - }) -_sym_db.RegisterMessage(EspHostedCmdGetMode) - -EspHostedRespGetMode = _reflection.GeneratedProtocolMessageType('EspHostedRespGetMode', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPGETMODE, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespGetMode) - }) -_sym_db.RegisterMessage(EspHostedRespGetMode) - -EspHostedCmdSetMode = _reflection.GeneratedProtocolMessageType('EspHostedCmdSetMode', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDSETMODE, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdSetMode) - }) -_sym_db.RegisterMessage(EspHostedCmdSetMode) - -EspHostedRespSetMode = _reflection.GeneratedProtocolMessageType('EspHostedRespSetMode', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPSETMODE, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespSetMode) - }) -_sym_db.RegisterMessage(EspHostedRespSetMode) - -EspHostedCmdGetStatus = _reflection.GeneratedProtocolMessageType('EspHostedCmdGetStatus', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDGETSTATUS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdGetStatus) - }) -_sym_db.RegisterMessage(EspHostedCmdGetStatus) - -EspHostedRespGetStatus = _reflection.GeneratedProtocolMessageType('EspHostedRespGetStatus', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPGETSTATUS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespGetStatus) - }) -_sym_db.RegisterMessage(EspHostedRespGetStatus) - -EspHostedCmdSetMacAddress = _reflection.GeneratedProtocolMessageType('EspHostedCmdSetMacAddress', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDSETMACADDRESS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdSetMacAddress) - }) -_sym_db.RegisterMessage(EspHostedCmdSetMacAddress) - -EspHostedRespSetMacAddress = _reflection.GeneratedProtocolMessageType('EspHostedRespSetMacAddress', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPSETMACADDRESS, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespSetMacAddress) - }) -_sym_db.RegisterMessage(EspHostedRespSetMacAddress) - -EspHostedCmdGetAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedCmdGetAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDGETAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdGetAPConfig) - }) -_sym_db.RegisterMessage(EspHostedCmdGetAPConfig) - -EspHostedRespGetAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedRespGetAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPGETAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespGetAPConfig) - }) -_sym_db.RegisterMessage(EspHostedRespGetAPConfig) - -EspHostedCmdSetAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedCmdSetAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDSETAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdSetAPConfig) - }) -_sym_db.RegisterMessage(EspHostedCmdSetAPConfig) - -EspHostedRespSetAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedRespSetAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPSETAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespSetAPConfig) - }) -_sym_db.RegisterMessage(EspHostedRespSetAPConfig) - -EspHostedCmdGetSoftAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedCmdGetSoftAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDGETSOFTAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdGetSoftAPConfig) - }) -_sym_db.RegisterMessage(EspHostedCmdGetSoftAPConfig) - -EspHostedRespGetSoftAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedRespGetSoftAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPGETSOFTAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespGetSoftAPConfig) - }) -_sym_db.RegisterMessage(EspHostedRespGetSoftAPConfig) - -EspHostedCmdSetSoftAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedCmdSetSoftAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDSETSOFTAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdSetSoftAPConfig) - }) -_sym_db.RegisterMessage(EspHostedCmdSetSoftAPConfig) - -EspHostedRespSetSoftAPConfig = _reflection.GeneratedProtocolMessageType('EspHostedRespSetSoftAPConfig', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPSETSOFTAPCONFIG, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespSetSoftAPConfig) - }) -_sym_db.RegisterMessage(EspHostedRespSetSoftAPConfig) - -EspHostedScanResult = _reflection.GeneratedProtocolMessageType('EspHostedScanResult', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDSCANRESULT, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedScanResult) - }) -_sym_db.RegisterMessage(EspHostedScanResult) - -EspHostedCmdScanResult = _reflection.GeneratedProtocolMessageType('EspHostedCmdScanResult', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDSCANRESULT, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdScanResult) - }) -_sym_db.RegisterMessage(EspHostedCmdScanResult) - -EspHostedRespScanResult = _reflection.GeneratedProtocolMessageType('EspHostedRespScanResult', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPSCANRESULT, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespScanResult) - }) -_sym_db.RegisterMessage(EspHostedRespScanResult) - -EspHostedConnectedSTAList = _reflection.GeneratedProtocolMessageType('EspHostedConnectedSTAList', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCONNECTEDSTALIST, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedConnectedSTAList) - }) -_sym_db.RegisterMessage(EspHostedConnectedSTAList) - -EspHostedCmdConnectedSTA = _reflection.GeneratedProtocolMessageType('EspHostedCmdConnectedSTA', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCMDCONNECTEDSTA, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedCmdConnectedSTA) - }) -_sym_db.RegisterMessage(EspHostedCmdConnectedSTA) - -EspHostedRespConnectedSTA = _reflection.GeneratedProtocolMessageType('EspHostedRespConnectedSTA', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDRESPCONNECTEDSTA, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedRespConnectedSTA) - }) -_sym_db.RegisterMessage(EspHostedRespConnectedSTA) - -EspHostedConfigPayload = _reflection.GeneratedProtocolMessageType('EspHostedConfigPayload', (_message.Message,), { - 'DESCRIPTOR' : _ESPHOSTEDCONFIGPAYLOAD, - '__module__' : 'esp_hosted_config_pb2' - # @@protoc_insertion_point(class_scope:EspHostedConfigPayload) - }) -_sym_db.RegisterMessage(EspHostedConfigPayload) - - -# @@protoc_insertion_point(module_scope) diff --git a/host/linux/host_control/python_support/hosted_config.py b/host/linux/host_control/python_support/hosted_config.py new file mode 100644 index 0000000000..2bd0127ea4 --- /dev/null +++ b/host/linux/host_control/python_support/hosted_config.py @@ -0,0 +1,120 @@ +# Copyright 2015-2021 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. + +from ctypes import * +import sys + +success = "success" +failure = "failure" +no_ap_found_str = "no_ap_found" +invalid_password_str = "invalid_password_str" +out_of_range_str = "out_of_range" + +SSID_LENGTH = 32 +PASSWORD_LENGTH = 64 +BSSID_LENGTH = 17 +STATUS_LENGTH = 14 + +MAX_SSID_LEN = 32 +MAX_PASSWORD_LEN = 64 +MIN_PASSWORD_LEN = 8 +MAX_BSSID_LEN = 17 +MIN_CHANNEL_NO = 1 +MAX_CHANNEL_NO = 11 +MIN_ALLOWED_STATIONS = 1 +MAX_ALLOWED_STATIONS = 10 +SSID_BROADCAST = 0 +SSID_NOT_BROADCAST = 1 + +NOT_CONNECTED = 1 +NO_AP_FOUND = 2 +INVALID_PASSWORD = 3 +INVALID_ARGUMENT = 4 +OUT_OF_RANGE = 5 + +(WIFI_MODE_NONE, WIFI_MODE_STATION, + WIFI_MODE_SOFTAP, WIFI_MODE_SOFTAP_STATION, + WIFI_MODE_MAX) = (0, 1, 2, 3, 4) + +(WIFI_AUTH_OPEN, WIFI_AUTH_WEP, + WIFI_AUTH_WPA_PSK, WIFI_AUTH_WPA2_PSK, + WIFI_AUTH_WPA_WPA2_PSK, WIFI_AUTH_WPA2_ENTERPRISE, + WIFI_AUTH_WPA3_PSK, WIFI_AUTH_WPA2_WPA3_PSK, + WIFI_AUTH_MAX) = (0, 1, 2, 3, 4, 5, 6, 7, 8) + +(WIFI_BW_HT20, WIFI_BW_HT40) = (1, 2) + +(WIFI_PS_MIN_MODEM, WIFI_PS_MAX_MODEM, + WIFI_PS_INVALID) = (1, 2, 3) + +class STA_CONFIG(Structure): + _fields_ = [("ssid", c_char * SSID_LENGTH), + ("pwd", c_char * PASSWORD_LENGTH), + ("bssid", c_char * BSSID_LENGTH), + ("is_wpa3_supported", c_bool), + ("rssi", c_int), + ("channel", c_uint), + ("encryption_mode", c_uint), + ("listen_interval", c_ushort), + ("status", c_char * STATUS_LENGTH)] + +class SOFTAP_CONFIG(Structure): + _fields_ = [("ssid", c_char * SSID_LENGTH), + ("pwd", c_char * PASSWORD_LENGTH), + ("channel", c_uint), + ("encryption_mode", c_uint), + ("max_connections", c_uint), + ("ssid_hidden", c_bool), + ("bandwidth", c_uint)] + +class CONTROL_CONFIG(Union): + _fields_ = [("station", STA_CONFIG), + ("softap", SOFTAP_CONFIG)] + + +class WIFI_SCAN_LIST(Structure): + _fields_ = [("ssid", c_char * SSID_LENGTH), + ("bssid", c_char * BSSID_LENGTH), + ("rssi", c_int), + ("channel", c_uint), + ("encryption_mode", c_uint)] + +class WIFI_STATIONS_LIST(Structure): + _fields_ = [("bssid", c_char * BSSID_LENGTH), + ("rssi", c_int)] + +class Aplist: + def __init__(self,ssid,chnl,rssi,bssid,ecn): + self.ssid = ssid + self.chnl = chnl + self.rssi = rssi + self.bssid = bssid + self.ecn = ecn + +class Stationlist: + def __init__(self,bssid,rssi): + self.bssid = bssid + self.rssi = rssi + +def get_str(string): + if sys.version_info >= (3, 0): + return string.decode('utf-8') + else: + return string + +def set_str(string): + if sys.version_info >= (3, 0): + return string.encode('utf-8') + else: + return string diff --git a/host/linux/host_control/python_support/ota_update.py b/host/linux/host_control/python_support/ota_update.py new file mode 100644 index 0000000000..de97f51dc7 --- /dev/null +++ b/host/linux/host_control/python_support/ota_update.py @@ -0,0 +1,69 @@ +# Copyright 2015-2021 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. + +from commands_lib import * +import argparse +import requests +import os + +ota_status = "not_completed" + +# Please do not use chunk size bigger than 4000. +chunk_size = 4000 + +parser = argparse.ArgumentParser(description='ota_update.py is a python script which runs OTA update on ESP') + +parser.add_argument("url", type=str, default='', help="URL to OTA image") + +args = parser.parse_args() + +def OTA_END(): + ota_end = esp_ota_end() + if (ota_end == "failure"): + print("Failure in OTA end") + exit() + else: + print("OTA end "+str(ota_end)) + +try: + response = requests.get(args.url, stream = True) +except: + print("Error while fetching URL") + exit() + +ota_status = esp_ota_begin() +if (ota_status == "failure"): + print("Failure in OTA update") + exit() +elif (ota_status == 0): + print("OTA begin: success") +else: + print("OTA begin:"+str(ota_status)) + +if (chunk_size>4000): + chunk_size = 4000 + +for chunk in response.iter_content(chunk_size): + print("|", end="", flush=True) + ota_status = esp_ota_write(chunk, chunk_size) + print(".", end="", flush=True) + if (ota_status == "failure"): + print("Failed to write OTA update") + OTA_END() + exit() + print(".", end="", flush=True) +print("OTA write success") + +OTA_END() +print("ESP32 will restart in 5 sec"); diff --git a/host/linux/host_control/python_support/softap_config.py b/host/linux/host_control/python_support/softap_config.py index 698491908c..f90cdc8ef4 100644 --- a/host/linux/host_control/python_support/softap_config.py +++ b/host/linux/host_control/python_support/softap_config.py @@ -12,26 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse import time import os from distutils.util import strtobool -# WiFi Mode -# NULL 0 -# Station 1 -# SoftAP 2 -# Station+softAP 3 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 -success = 'success' -failure = 'failure' flag = success -softap_config = 'Not set' +ap_mac = 'not_set' +softap_config = 'not_set' parser = argparse.ArgumentParser(description='softap_config.py script to configure ESP32 softAP mode. ex. python softap_config.py \'xyz\' \'xyz123456\' 1 3 --max_conn=4 --ssid_hidden=0 --bw=1') @@ -51,7 +40,7 @@ args = parser.parse_args() -ap_mac = wifi_get_mac(wifi_mode_softap) +ap_mac = wifi_get_mac(WIFI_MODE_SOFTAP) if (ap_mac == failure): print("Failed to get softAP mac address") flag = failure @@ -81,6 +70,4 @@ os.system(command) print(command) - time.sleep(1) - print("SoftAP config successfully set") diff --git a/host/linux/host_control/python_support/softap_stop.py b/host/linux/host_control/python_support/softap_stop.py index 112986ad17..9988ac0016 100644 --- a/host/linux/host_control/python_support/softap_stop.py +++ b/host/linux/host_control/python_support/softap_stop.py @@ -12,34 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse import os -# WiFi Mode -# NULL 0 -# Station 1 -# softAP 2 -# Station + softAP 3 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 -failure = "failure" -success = "success" -stop = "Not set" +wifi_mode = 'not_set' +stop_softap = 'not_set' flag = success parser = argparse.ArgumentParser(description='softap_stop.py script will stop ESP32 softap ex. python softap_close.py') wifi_mode = wifi_get_mode() -print("WiFi Mode: "+str(wifi_mode)) if (wifi_mode == failure): print("Failed to get wifi mode") flag = failure else: + print("WiFi Mode: "+str(wifi_mode)) stop_softap = wifi_stop_softap() if (stop_softap != success): print("Failed to stop softAP") diff --git a/host/linux/host_control/python_support/station_connect.py b/host/linux/host_control/python_support/station_connect.py index 77d43dcdb1..90516f7edf 100644 --- a/host/linux/host_control/python_support/station_connect.py +++ b/host/linux/host_control/python_support/station_connect.py @@ -12,27 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse import time import os import subprocess from distutils.util import strtobool -# WiFi Mode -# NULL 0 -# Station 1 -# SoftAP 2 -# Station + softAP 3 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 -failure = "failure" -success = "success" flag = success -station_status = 'Nothing set' +sta_mac = 'not_set' +station_status = 'not_set' parser = argparse.ArgumentParser(description='station_connect.py is a python script which connect ESP32 station to AP. ex. python station_connect.py \'xyz\' \'xyz123456\' --bssid=\'e5:6c:67:3c:cf:65\' --is_wpa3_supported=True --listen_interval=3') @@ -48,7 +37,7 @@ args = parser.parse_args() -sta_mac = wifi_get_mac(wifi_mode_station) +sta_mac = wifi_get_mac(WIFI_MODE_STATION) if (sta_mac == failure): flag = failure print("Failed to get station MAC address") @@ -63,8 +52,8 @@ print("SSID: "+args.ssid+" not found") elif (station_status == invalid_password_str): print("Incorrect Password: "+args.password) - print("Failed to set AP config") - elif (station_status == success): + print("Failed to connect with AP") + else: print("Connected to "+args.ssid) if (flag != success): @@ -82,30 +71,4 @@ os.system(command) print(command) - time.sleep(1) - - for x in range (5): - command = 'sudo dhclient ethsta0 -r' - os.system(command) - print(command) - - command = 'sudo dhclient ethsta0 -v' - os.system(command) - print(command) - - try: - get_ip = subprocess.check_output('ip addr show | grep "ethsta0" | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"', shell = True) - if get_ip: - flag = success - break - except subprocess.CalledProcessError: - time.sleep(0.1) - flag = failure - - if (flag == failure): - print("Failed to assign IP address to ethsta0 interface") - else: - print("Success in setting AP config") - - - + print("Interface ethsta0 is up with MAC address "+str(sta_mac)) diff --git a/host/linux/host_control/python_support/station_disconnect.py b/host/linux/host_control/python_support/station_disconnect.py index 2693457c36..cb6f0c512f 100644 --- a/host/linux/host_control/python_support/station_disconnect.py +++ b/host/linux/host_control/python_support/station_disconnect.py @@ -12,24 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * import argparse import os -# WiFi Mode -# NULL 0 -# Station 1 -# SoftAP 2 -# Station + softAP 3 - -wifi_mode_none = 0 -wifi_mode_station = 1 -wifi_mode_softap = 2 -wifi_mode_station_softap = 3 -failure = "failure" -success = "success" +wifi_mode = 'not_set' +disconnect = "not_set" flag = success -disconnect = "Not set" parser = argparse.ArgumentParser(description='station_disconnect.py script will disconnect ESPStation from AP ex. python station_disconnect.py') @@ -38,7 +27,7 @@ if (wifi_mode == failure): print("Failed to get WiFi Mode") flag = failure -elif ((wifi_mode == wifi_mode_station) or (wifi_mode == wifi_mode_station_softap)): +elif ((wifi_mode == WIFI_MODE_STATION) or (wifi_mode == WIFI_MODE_SOFTAP_STATION)): disconnect = wifi_disconnect_ap() if (disconnect != success): print("Failed to Disconnect from AP") @@ -50,11 +39,6 @@ flag = failure if (flag == success): - command = 'sudo dhclient ethsta0 -r' - print('$ '+command) - os.system(command) - command = 'sudo ifconfig ethsta0 down' print('$ '+command) os.system(command) - diff --git a/host/linux/host_control/python_support/stress.py b/host/linux/host_control/python_support/stress.py index 6fa40f2c9e..72d1e21bf7 100644 --- a/host/linux/host_control/python_support/stress.py +++ b/host/linux/host_control/python_support/stress.py @@ -25,10 +25,12 @@ TEST_SOFTAP_START_STOP=(1 << 5) TEST_STATION_SOFTAP_MODE=(1 << 6) TEST_POWER_SAVE=(1 << 7) +TEST_WIFI_TX_POWER=(1 << 8) -STRESS_TEST=(TEST_MODE_NONE | TEST_SCAN_WIFI | TEST_STATION_MAC | TEST_STATION_CONNECT_DISCONNECT | TEST_SOFTAP_MAC | TEST_SOFTAP_START_STOP | TEST_STATION_SOFTAP_MODE | TEST_POWER_SAVE) +STRESS_TEST=(TEST_MODE_NONE | TEST_SCAN_WIFI | TEST_STATION_MAC | TEST_STATION_CONNECT_DISCONNECT | TEST_SOFTAP_MAC | TEST_SOFTAP_START_STOP | TEST_STATION_SOFTAP_MODE | TEST_POWER_SAVE | TEST_WIFI_TX_POWER) -# Test APIs +#***** Please Read ***** +#* Before use stress.py : User must enter user configuration parameter in "test_config.py" file * # Below APIs could be used by demo application @@ -129,3 +131,14 @@ test_set_wifi_power_save_mode() test_get_wifi_power_save_mode() + +# maximum transmitting power + +# set and get maximum transmitting power +if (STRESS_TEST & TEST_WIFI_TX_POWER): + for i in (range(STRESS_TEST_COUNT)): + print("*************** "+str(i)+" ****************") + test_wifi_set_max_tx_power() + + test_wifi_get_curr_tx_power() + diff --git a/host/linux/host_control/python_support/test.py b/host/linux/host_control/python_support/test.py index 5ed0e571ac..8e4a7bbfc2 100644 --- a/host/linux/host_control/python_support/test.py +++ b/host/linux/host_control/python_support/test.py @@ -13,6 +13,9 @@ # limitations under the License. from test_api import * +#***** Please Read ***** +#* Before use test.py : User must enter user configuration parameter in "test_config.py" file * + # Test APIs # Below APIs could be used by demo application @@ -53,3 +56,7 @@ test_set_wifi_power_save_mode() test_get_wifi_power_save_mode() + +# maximum transmitting power +test_wifi_set_max_tx_power() +test_wifi_get_curr_tx_power() diff --git a/host/linux/host_control/python_support/test_api.py b/host/linux/host_control/python_support/test_api.py index a0a6918363..989de3d76a 100644 --- a/host/linux/host_control/python_support/test_api.py +++ b/host/linux/host_control/python_support/test_api.py @@ -12,8 +12,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -from commands import * +from commands_lib import * from test_config import * +from socket import * +from struct import * +from fcntl import * + +sta_interface = 'ethsta0' +ap_interface = 'ethap0' + +# From linux/socket.h +AF_UNIX = 1 + +# From linux/if.h +IFF_UP = 0x1 + +# From linux/sockios.h +SIOCGIFFLAGS = 0x8913 +SIOCSIFFLAGS = 0x8914 +SIOCSIFHWADDR = 0x8924 + +# Macros for packing data in 16 bytes short character bytes +PACK_FORMAT = '16sh' + +def get_bytes(string): + if sys.version_info >= (3, 0): + return bytes(string, 'utf-8') + else: + return string def test_get_wifi_mode(): mode = wifi_get_mode() @@ -79,13 +105,53 @@ def test_softap_mode_set_mac_addr_of_esp(): print("SoftAP MAC address is not set") return + def test_station_mode_connect(): ret = wifi_set_ap_config(STATION_MODE_SSID, STATION_MODE_PWD, STATION_MODE_BSSID,\ STATION_MODE_IS_WPA3_SUPPORTED, STATION_MODE_LISTEN_INTERVAL) - if (ret == failure): + if (ret == success): + print("Connected to "+STATION_MODE_SSID) + else: print("Failed to connect to AP") + return + + sockfd = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) + if (sockfd == failure): + print("Failed to open socket") + return + + ret = interface_down(sockfd, sta_interface) + if (ret != failure): + print(sta_interface+" interface down") else: - print(ret) + print("Unable to down "+sta_interface+" interface") + + if(ret != failure): + mac = wifi_get_mac(WIFI_MODE_STATION) + if (mac != failure): + print("Station mode: mac address "+str(mac)) + else: + ret = failure + print("Failed to get MAC address") + + if(ret != failure): + ret = set_hw_addr(sockfd, sta_interface, mac) + if (ret != failure): + print("MAC address "+mac+" set to "+sta_interface+" interface") + else: + print("Unable to set MAC address to "+sta_interface) + + if(ret != failure): + ret = interface_up(sockfd, sta_interface) + if (ret != failure): + print(sta_interface+" interface up") + else: + print("Unable to up "+sta_interface+" interface") + + ret = close_socket(sockfd) + if (ret == failure): + print("Unable to close the socket") + return def test_station_mode_get_info(): ret = wifi_get_ap_config() @@ -116,6 +182,22 @@ def test_station_mode_disconnect(): print("Disconnected from AP") else: print("Failed to disconnect from AP") + return + + sockfd = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) + if (sockfd == failure): + print("Failed to open socket") + return + + ret = interface_down(sockfd, sta_interface) + if (ret != failure): + print(sta_interface+" interface down") + else: + print("Unable to down "+sta_interface+" interface") + + ret = close_socket(sockfd) + if (ret == failure): + print("Unable to close the socket") return def test_softap_mode_start(): @@ -126,6 +208,44 @@ def test_softap_mode_start(): print("ESP32 softAP started") else: print("Failed to set softAP config") + return + + sockfd = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) + if (sockfd == failure): + print("Failed to open socket") + return + + ret = interface_down(sockfd, ap_interface) + if (ret != failure): + print(ap_interface+" interface down") + else: + print("Unable to down "+ap_interface+" interface") + + if(ret != failure): + mac = wifi_get_mac(WIFI_MODE_SOFTAP) + if (mac != failure): + print("SoftAP mode: mac address "+str(mac)) + else: + ret = failure + print("Failed to get MAC address of softAP interface") + + if(ret != failure): + ret = set_hw_addr(sockfd, ap_interface, mac) + if (ret != failure): + print("MAC address "+mac+" set to "+ap_interface+" interface") + else: + print("Unable to set MAC address to "+ap_interface) + + if(ret != failure): + ret = interface_up(sockfd, ap_interface) + if (ret != failure): + print(ap_interface+" interface up") + else: + print("Unable to up "+ap_interface+" interface") + + ret = close_socket(sockfd) + if (ret == failure): + print("Unable to close the socket") return def test_softap_mode_get_info(): @@ -148,7 +268,7 @@ def test_softap_mode_connected_clients_info(): stations_list = wifi_connected_stations_list() if (stations_list != failure): for obj in stations_list: - print("station's bssid: "+obj.mac+" rssi: "+str(obj.rssi)) + print("station's bssid: "+obj.bssid+" rssi: "+str(obj.rssi)) else: print("Failed to get connected stations list") return @@ -159,6 +279,22 @@ def test_softap_mode_stop(): print("ESP32 softAP stopped") else: print("Failed to stop ESP32 softAP") + return + + sockfd = create_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) + if (sockfd == failure): + print("Failed to open socket") + return + + ret = interface_down(sockfd, ap_interface) + if (ret != failure): + print(ap_interface+" interface down") + else: + print("Unable to down "+ap_interface+" interface") + + ret = close_socket(sockfd) + if (ret == failure): + print("Unable to close the socket") return def test_set_wifi_power_save_mode(): @@ -175,4 +311,22 @@ def test_get_wifi_power_save_mode(): print("Power save mode is "+str(power_save_mode)) else: print("Failed to set power save mode") + return +def test_wifi_set_max_tx_power(): + ret = wifi_set_max_tx_power(INPUT_WIFI_TX_POWER) + if (ret == out_of_range_str): + print("Out of range") + elif (ret == success): + print("Success in setting WiFi maximum TX power") + else: + print("Failure in setting WiFi maximum TX power") + return + +def test_wifi_get_curr_tx_power(): + power = wifi_get_curr_tx_power() + if (power != failure): + print("Maximum TX power is "+str(power)) + else: + print("Failure in getting WiFi current TX power") + return diff --git a/host/linux/host_control/python_support/test_config.py b/host/linux/host_control/python_support/test_config.py index 401dd7e89e..c624511abf 100644 --- a/host/linux/host_control/python_support/test_config.py +++ b/host/linux/host_control/python_support/test_config.py @@ -39,3 +39,6 @@ SOFTAP_MODE_MAX_ALLOWED_CLIENTS=4 SOFTAP_MODE_SSID_HIDDEN=False SOFTAP_MODE_BANDWIDTH=2 + +# maximum transmitting power +INPUT_WIFI_TX_POWER = 8 diff --git a/host/linux/host_control/python_support/transport/__init__.py b/host/linux/host_control/python_support/transport/__init__.py deleted file mode 100644 index 96b25b84e0..0000000000 --- a/host/linux/host_control/python_support/transport/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2015-2021 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. -# - -from .transport import Transport -from .transport_pserial import Transport_pserial # noqa: F403, F401 diff --git a/host/linux/host_control/python_support/transport/transport.py b/host/linux/host_control/python_support/transport/transport.py deleted file mode 100644 index 9eab277f49..0000000000 --- a/host/linux/host_control/python_support/transport/transport.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2015-2021 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. -# - -# Base class for protocomm transport - -import abc - -class Transport(): - - @abc.abstractmethod - def send_session_data(self, data): - pass - - @abc.abstractmethod - def send_config_data(self, data): - pass diff --git a/host/linux/host_control/python_support/transport/transport_pserial.py b/host/linux/host_control/python_support/transport/transport_pserial.py deleted file mode 100644 index 76c6c5203a..0000000000 --- a/host/linux/host_control/python_support/transport/transport_pserial.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2015-2021 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. - -from struct import * -from .transport import Transport -import sys -import os -import select - -failure = -1 -success = 0 - -PROTO_PSER_TLV_T_EPNAME = b'\x01' -PROTO_PSER_TLV_T_DATA = b'\x02' - -# Open `/dev/esps0` in read-write mode -flags = os.O_RDWR - -# All users can read and write -mode = 0o666 - -# Timeout for select -timeout = 20 - -if sys.version_info >= (3, 0): - def get_val(string): - return bytes([string]) -else: - def get_val(string): - return str(string) - -class Transport_pserial(Transport): - def __init__(self, devname): - self.f = os.open(devname, mode, flags) - - def __del__(self): - os.close(self.f) - - def get_len(self, ep_name, in_buf): - if get_val(in_buf[0]) == PROTO_PSER_TLV_T_EPNAME: - if in_buf[1:3] == bytearray(pack(' /dev/null - else - sudo rmmod esp32_spi &> /dev/null - fi - fi + build_python_commands_lib + + cd ../host_driver/esp32/ + if [ `lsmod | grep esp32 | wc -l` != "0" ]; then + sudo rm /dev/esps0 + if [ `lsmod | grep esp32_sdio | wc -l` != "0" ]; then + sudo rmmod esp32_sdio &> /dev/null + else + sudo rmmod esp32_spi &> /dev/null + fi + fi - # For Linux other than Raspberry Pi, Please point + # For Linux other than Raspberry Pi, Please point # CROSS_COMPILE -> /bin/arm-linux-gnueabihf- # KERNEL -> Place where kernel is checked out and built # ARCH -> Architecture @@ -55,93 +65,93 @@ wlan_init() bt_init() { - sudo raspi-gpio set 15 a0 pu - sudo raspi-gpio set 14 a0 pu - sudo raspi-gpio set 16 a3 pu - sudo raspi-gpio set 17 a3 pu + sudo raspi-gpio set 15 a0 pu + sudo raspi-gpio set 14 a0 pu + sudo raspi-gpio set 16 a3 pu + sudo raspi-gpio set 17 a3 pu } usage() { - echo "This script prepares RPI for wlan and bt/ble operation over esp32 device" - echo "\nUsage: ./rpi_init.sh [arguments]" - echo "\nArguments are optional and are as below" - echo " spi: sets ESP32<->RPi communication over SPI" - echo " sdio: sets ESP32<->RPi communication over SDIO" - echo " btuart: Set GPIO pins on RPi for HCI UART operations" - echo " resetpin=6: Set GPIO pins on RPi connected to EN pin of ESP32, used to reset ESP32 (default:6 for BCM6)" - echo "\nExample:" - echo " - Prepare RPi for WLAN operation on SDIO. sdio is default if no interface mentioned" - echo " # ./rpi_init.sh or ./rpi_init.sh sdio" - echo "\n - Use spi for host<->ESP32 communication. sdio is default if no interface mentioned" - echo " # ./rpi_init.sh spi" - echo "\n - Prepare RPi for bt/ble operation over UART and WLAN over SDIO/SPI" - echo " # ./rpi_init.sh sdio btuart or ./rpi_init.sh spi btuart" - echo "\n - use GPIO pin BCM5 (GPIO29) for reset" - echo " # ./rpi_init.sh resetpin=5" - echo "\n - do btuart, use GPIO pin BCM5 (GPIO29) for reset over SDIO/SPI" - echo " # ./rpi_init.sh sdio btuart resetpin=5 or ./rpi_init.sh spi btuart resetpin=5" + echo "This script prepares RPI for wlan and bt/ble operation over esp32 device" + echo "\nUsage: ./rpi_init.sh [arguments]" + echo "\nArguments are optional and are as below" + echo " spi: sets ESP32<->RPi communication over SPI" + echo " sdio: sets ESP32<->RPi communication over SDIO" + echo " btuart: Set GPIO pins on RPi for HCI UART operations" + echo " resetpin=6: Set GPIO pins on RPi connected to EN pin of ESP32, used to reset ESP32 (default:6 for BCM6)" + echo "\nExample:" + echo " - Prepare RPi for WLAN operation on SDIO. sdio is default if no interface mentioned" + echo " # ./rpi_init.sh or ./rpi_init.sh sdio" + echo "\n - Use spi for host<->ESP32 communication. sdio is default if no interface mentioned" + echo " # ./rpi_init.sh spi" + echo "\n - Prepare RPi for bt/ble operation over UART and WLAN over SDIO/SPI" + echo " # ./rpi_init.sh sdio btuart or ./rpi_init.sh spi btuart" + echo "\n - use GPIO pin BCM5 (GPIO29) for reset" + echo " # ./rpi_init.sh resetpin=5" + echo "\n - do btuart, use GPIO pin BCM5 (GPIO29) for reset over SDIO/SPI" + echo " # ./rpi_init.sh sdio btuart resetpin=5 or ./rpi_init.sh spi btuart resetpin=5" } parse_arguments() { - while [ "$1" != "" ] ; do - case $1 in - --help | -h ) - usage - exit 0 - ;; - sdio) - IF_TYPE=$1 - ;; - spi) - IF_TYPE=$1 - ;; - resetpin=*) - echo "Recvd Option: $1" - RESETPIN=$1 - ;; - btuart) - echo "Recvd Option: $1" - BT_INIT_SET="1" - ;; - *) - echo "$1 : unknown option" - usage - exit 1 - ;; - esac - shift - done + while [ "$1" != "" ] ; do + case $1 in + --help | -h ) + usage + exit 0 + ;; + sdio) + IF_TYPE=$1 + ;; + spi) + IF_TYPE=$1 + ;; + resetpin=*) + echo "Recvd Option: $1" + RESETPIN=$1 + ;; + btuart) + echo "Recvd Option: $1" + BT_INIT_SET="1" + ;; + *) + echo "$1 : unknown option" + usage + exit 1 + ;; + esac + shift + done } parse_arguments $* if [ "$IF_TYPE" = "" ] ; then - echo "Error: No protocol selected" - usage - exit 1 + echo "Error: No protocol selected" + usage + exit 1 else - echo "Building for $IF_TYPE protocol" - MODULE_NAME=esp32_${IF_TYPE}.ko + echo "Building for $IF_TYPE protocol" + MODULE_NAME=esp32_${IF_TYPE}.ko fi if [ "$IF_TYPE" = "spi" ] ; then - rm spidev_disabler.dtbo - # Disable default spidev driver - dtc spidev_disabler.dts -O dtb > spidev_disabler.dtbo - sudo dtoverlay -d . spidev_disabler + rm spidev_disabler.dtbo + # Disable default spidev driver + dtc spidev_disabler.dts -O dtb > spidev_disabler.dtbo + sudo dtoverlay -d . spidev_disabler fi if [ `lsmod | grep bluetooth | wc -l` = "0" ]; then - echo "bluetooth module inserted" - sudo modprobe bluetooth + echo "bluetooth module inserted" + sudo modprobe bluetooth fi if [ `lsmod | grep bluetooth | wc -l` != "0" ]; then - wlan_init + wlan_init fi if [ "$BT_INIT_SET" = "1" ] ; then - bt_init + bt_init fi diff --git a/host/linux/host_driver/esp32/esp_api.h b/host/linux/host_driver/esp32/esp_api.h index 590a69cc18..111f142b93 100644 --- a/host/linux/host_driver/esp32/esp_api.h +++ b/host/linux/host_driver/esp32/esp_api.h @@ -31,5 +31,7 @@ int esp_send_packet(struct esp_adapter *adapter, struct sk_buff *skb); u8 esp_is_bt_supported_over_sdio(u32 cap); void esp_tx_pause(void); void esp_tx_resume(void); +void process_init_event(u8 *evt_buf, u8 len); +void process_capabilities(u8 cap); #endif diff --git a/host/linux/host_driver/esp32/esp_bt.c b/host/linux/host_driver/esp32/esp_bt.c index b5901a558a..3cdc89f6e3 100644 --- a/host/linux/host_driver/esp32/esp_bt.c +++ b/host/linux/host_driver/esp32/esp_bt.c @@ -94,6 +94,7 @@ ESP_BT_SEND_FRAME_PROTOTYPE() printk(KERN_ERR "%s: invalid args", __func__); return -EINVAL; } + //print_hex_dump(KERN_INFO, "bt_tx: ", DUMP_PREFIX_ADDRESS, 16, 1, skb->data, len, 1 ); /* Create space for payload header */ pad_len = sizeof(struct esp_payload_header); @@ -153,6 +154,8 @@ ESP_BT_SEND_FRAME_PROTOTYPE() /* set HCI packet type */ *(pos + pad_len - 1) = pkt_type; + hdr->checksum = cpu_to_le16(compute_checksum(skb->data, (len + pad_len))); + ret = esp_send_packet(adapter, skb); if (ret) { diff --git a/host/linux/host_driver/esp32/esp_rb.c b/host/linux/host_driver/esp32/esp_rb.c index b37ec27d69..3b5ed8bee2 100644 --- a/host/linux/host_driver/esp32/esp_rb.c +++ b/host/linux/host_driver/esp32/esp_rb.c @@ -33,9 +33,9 @@ int esp_rb_init(esp_rb_t *rb, size_t sz) return 0; } -ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block) +int esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block) { - size_t read_len = 0, temp_len = 0; + int read_len = 0, temp_len = 0; if (down_interruptible(&rb->sem)) { return -ERESTARTSYS; /* Signal interruption */ @@ -62,7 +62,7 @@ ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int if (copy_to_user((void *)buf, rb->rp, read_len)) { up(&rb->sem); - printk(KERN_WARNING "%s, Incomplete/Failed read\n", __func__); + printk(KERN_WARNING "%s, %d: Incomplete/Failed read\n", __func__, __LINE__); return -EFAULT; } @@ -75,7 +75,7 @@ ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int temp_len = min(sz-read_len,(size_t)(rb->wp - rb->rp)); if (copy_to_user((void *)buf+read_len, rb->rp, temp_len)) { up(&rb->sem); - printk(KERN_WARNING "%s, Incomplete/Failed read\n", __func__); + printk(KERN_WARNING "%s, %d: Incomplete/Failed read\n", __func__, __LINE__); return -EFAULT; } } @@ -88,8 +88,11 @@ ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int return read_len; } -size_t get_free_space(esp_rb_t *rb) +int get_free_space(esp_rb_t *rb) { + if (!rb || !rb->rp || !rb->wp) { + return -EFAULT; + } if (rb->rp == rb->wp) { return rb->size - 1; } else { @@ -97,21 +100,26 @@ size_t get_free_space(esp_rb_t *rb) } } -ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz) +int esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz) { - size_t write_len = 0, temp_len = 0; + int write_len = 0, temp_len = 0; + + if (!rb || !rb->wp || !rb->rp) { + printk(KERN_INFO "%s:%u rb uninitialized\n", __func__, __LINE__); + return -EFAULT; + } if (down_interruptible(&rb->sem)) { return -ERESTARTSYS; } - if (get_free_space(rb) == 0) { + if (get_free_space(rb) <= 0) { up(&rb->sem); - printk(KERN_ERR "%s, Ringbuffer full, no space to write\n", __func__); + printk(KERN_ERR "%s, %d, Ringbuffer full or inaccessible\n", __func__, __LINE__); return 0; } - sz = min(sz, get_free_space(rb)); + sz = min(sz, (size_t)get_free_space(rb)); if (rb->wp >= rb->rp) { write_len = min(sz, (size_t)(rb->end - rb->wp)); } else { @@ -132,6 +140,10 @@ ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz) rb->wp += temp_len; write_len += temp_len; + if (rb->wp == rb->end) { + rb->wp = rb->buf; + } + up(&rb->sem); wake_up_interruptible(&rb->wq); diff --git a/host/linux/host_driver/esp32/esp_rb.h b/host/linux/host_driver/esp32/esp_rb.h index 2a048e340f..72d8c24bc8 100644 --- a/host/linux/host_driver/esp32/esp_rb.h +++ b/host/linux/host_driver/esp32/esp_rb.h @@ -18,8 +18,8 @@ typedef struct esp_rb { int esp_rb_init(esp_rb_t *rb, size_t sz); void esp_rb_cleanup(esp_rb_t *rb); -ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block); -ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz); -size_t get_free_space(esp_rb_t *rb); +int esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block); +int esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz); +int get_free_space(esp_rb_t *rb); #endif diff --git a/host/linux/host_driver/esp32/esp_serial.c b/host/linux/host_driver/esp32/esp_serial.c index 384f79c2c8..b088a1306a 100644 --- a/host/linux/host_driver/esp32/esp_serial.c +++ b/host/linux/host_driver/esp32/esp_serial.c @@ -31,13 +31,13 @@ #include "esp_rb.h" #include "esp_api.h" -#define ESP_SERIAL_MAJOR 221 -#define ESP_SERIAL_MINOR_MAX 2 -#define ESP_RX_RB_SIZE 4096 +#define ESP_SERIAL_MAJOR 221 +#define ESP_SERIAL_MINOR_MAX 2 +#define ESP_RX_RB_SIZE 4096 +#define ESP_SERIAL_MAX_TX 4096 //#define ESP_SERIAL_TEST - static struct esp_serial_devs { struct cdev cdev; int dev_index; @@ -46,10 +46,10 @@ static struct esp_serial_devs { struct mutex lock; } devs[ESP_SERIAL_MINOR_MAX]; -static ssize_t esp_serial_read(struct file *file, char __user *user_buffer, size_t size, loff_t *offset) +static int esp_serial_read(struct file *file, char __user *user_buffer, size_t size, loff_t *offset) { struct esp_serial_devs *dev = NULL; - ssize_t ret_size = 0; + int ret_size = 0; dev = (struct esp_serial_devs *) file->private_data; ret_size = esp_rb_read_by_user(&dev->rb, user_buffer, size, !(file->f_flags & O_NONBLOCK)); if (ret_size == 0) { @@ -58,7 +58,7 @@ static ssize_t esp_serial_read(struct file *file, char __user *user_buffer, size return ret_size; } -static ssize_t esp_serial_write(struct file *file, const char __user *user_buffer, size_t size, loff_t * offset) +static int esp_serial_write(struct file *file, const char __user *user_buffer, size_t size, loff_t * offset) { struct esp_payload_header *hdr = NULL; u8 *tx_buf = NULL; @@ -66,38 +66,74 @@ static ssize_t esp_serial_write(struct file *file, const char __user *user_buffe struct sk_buff * tx_skb = NULL; int ret = 0; size_t total_len = 0; + size_t frag_len = 0; + u32 left_len = size; + static u16 seq_num = 0; + u8 flag = 0; + u8 *pos; + + if (size > ESP_SERIAL_MAX_TX) { + printk(KERN_ERR "%s: Exceed max tx buffer size [%d]\n", __func__, size); + return 0; + } + seq_num++; dev = (struct esp_serial_devs *) file->private_data; - total_len = size + sizeof(struct esp_payload_header); + pos = (u8 *) user_buffer; + + do { + /* Fragmentation support + * - Fragment large packets into multiple 1500 byte packets + * - MORE_FRAGMENT bit in flag tells if there are more fragments expected + **/ + if (left_len > ETH_DATA_LEN) { + frag_len = ETH_DATA_LEN; + flag = MORE_FRAGMENT; + } else { + frag_len = left_len; + flag = 0; + } - tx_skb = esp_alloc_skb(total_len); - if (!tx_skb) { - printk (KERN_ERR "%s: SKB alloc failed\n", __func__); - return -ENOMEM; - } + total_len = frag_len + sizeof(struct esp_payload_header); - tx_buf = skb_put(tx_skb, total_len); + tx_skb = esp_alloc_skb(total_len); + if (!tx_skb) { + printk (KERN_ERR "%s: SKB alloc failed\n", __func__); + return (size - left_len); + } - hdr = (struct esp_payload_header *) tx_buf; + tx_buf = skb_put(tx_skb, total_len); - memset (hdr, 0, sizeof(struct esp_payload_header)); + hdr = (struct esp_payload_header *) tx_buf; - hdr->if_type = ESP_SERIAL_IF; - hdr->if_num = dev->dev_index; - hdr->len = cpu_to_le16(size); - hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header)); + memset (hdr, 0, sizeof(struct esp_payload_header)); - ret = copy_from_user(tx_buf + hdr->offset, user_buffer, size); - if (ret) { - dev_kfree_skb(tx_skb); - printk(KERN_ERR "%s, Error copying buffer to send serial data\n", __func__); - return -EFAULT; - } + hdr->if_type = ESP_SERIAL_IF; + hdr->if_num = dev->dev_index; + hdr->len = cpu_to_le16(frag_len); + hdr->seq_num = cpu_to_le16(seq_num); + hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header)); + hdr->flags |= flag; - ret = esp_send_packet(dev->priv, tx_skb); - if (ret) { - printk (KERN_ERR "%s: Failed to transmit data\n", __func__); - } + ret = copy_from_user(tx_buf + hdr->offset, pos, frag_len); + if (ret) { + dev_kfree_skb(tx_skb); + printk(KERN_ERR "%s, Error copying buffer to send serial data\n", __func__); + return (size - left_len); + } + hdr->checksum = cpu_to_le16(compute_checksum(tx_skb->data, (frag_len + sizeof(struct esp_payload_header)))); + + /* print_hex_dump(KERN_INFO, "esp_serial_tx: ", DUMP_PREFIX_ADDRESS, 16, 1, pos, frag_len, 1 ); */ + + ret = esp_send_packet(dev->priv, tx_skb); + if (ret) { + printk (KERN_ERR "%s: Failed to transmit data, error %d\n", __func__, ret); + return (size - left_len); + } + + left_len -= frag_len; + pos += frag_len; + } while(left_len); return size; } @@ -148,8 +184,7 @@ const struct file_operations esp_serial_fops = { int esp_serial_data_received(int dev_index, const char *data, size_t len) { - int ret = 0; - size_t ret_len = 0; + int ret = 0, ret_len = 0; if (dev_index >= ESP_SERIAL_MINOR_MAX) { return -EINVAL; } @@ -162,6 +197,9 @@ int esp_serial_data_received(int dev_index, const char *data, size_t len) } ret_len += ret; } + if (ret <= 0) { + return ret; + } if (ret_len != len) { printk(KERN_ERR "%s, RB full, no space to receive. Dropping packet",__func__); } diff --git a/host/linux/host_driver/esp32/main.c b/host/linux/host_driver/esp32/main.c index e94844856b..6ec2ab2254 100644 --- a/host/linux/host_driver/esp32/main.c +++ b/host/linux/host_driver/esp32/main.c @@ -32,6 +32,7 @@ #include "esp_serial.h" #endif #include "esp_bt_api.h" +#include "esp_api.h" MODULE_LICENSE("GPL"); MODULE_AUTHOR("Amey Inamdar "); @@ -279,7 +280,7 @@ static int process_tx_packet (struct sk_buff *skb) /* Populate new SKB */ skb_copy_from_linear_data(skb, pos, skb->len); - skb_put(new_skb, skb->len); + skb_put(new_skb, skb->len + pad_len); /* Replace old SKB */ dev_kfree_skb_any(skb); @@ -297,7 +298,8 @@ static int process_tx_packet (struct sk_buff *skb) payload_header->if_num = priv->if_num; payload_header->len = cpu_to_le16(len); payload_header->offset = cpu_to_le16(pad_len); - payload_header->reserved1 = c % 255; + + payload_header->checksum = cpu_to_le16(compute_checksum(skb->data, (len + pad_len))); if (!stop_data) { ret = esp_send_packet(priv->adapter, skb); @@ -316,11 +318,66 @@ static int process_tx_packet (struct sk_buff *skb) return 0; } +void process_capabilities(u8 cap) +{ + struct esp_adapter *adapter = esp_get_adapter(); + printk (KERN_INFO "ESP peripheral capabilities: 0x%x\n", cap); + adapter->capabilities = cap; + + /* Reset BT */ + esp_deinit_bt(esp_get_adapter()); + + if ((cap & ESP_BT_SPI_SUPPORT) || (cap & ESP_BT_SDIO_SUPPORT)) { + msleep(200); + esp_init_bt(esp_get_adapter()); + } +} + + +static void process_event(u8 *evt_buf, u16 len) +{ + struct esp_priv_event *event; + + if (!evt_buf || !len) + return; + + event = (struct esp_priv_event *) evt_buf; + + if (event->event_type == ESP_PRIV_EVENT_INIT) { + printk (KERN_INFO "\nReceived INIT event from ESP32 peripheral"); + process_init_event(event->event_data, event->event_len); + } else { + printk (KERN_WARNING "Drop unknown event"); + } +} + +static void process_priv_communication(struct sk_buff *skb) +{ + struct esp_payload_header *header; + u8 *payload; + u16 len; + + if (!skb || !skb->data) + return; + + header = (struct esp_payload_header *) skb->data; + + payload = skb->data + le16_to_cpu(header->offset); + len = le16_to_cpu(header->len); + + if (header->priv_pkt_type == ESP_PACKET_TYPE_EVENT) { + process_event(payload, len); + } + + dev_kfree_skb(skb); +} + static void process_rx_packet(struct sk_buff *skb) { struct esp_private *priv = NULL; struct esp_payload_header *payload_header = NULL; u16 len = 0, offset = 0; + u16 rx_checksum = 0, checksum = 0; struct hci_dev *hdev = adapter.hcidev; u8 *type = NULL; int ret = 0, ret_len = 0; @@ -333,6 +390,16 @@ static void process_rx_packet(struct sk_buff *skb) len = le16_to_cpu(payload_header->len); offset = le16_to_cpu(payload_header->offset); + rx_checksum = le16_to_cpu(payload_header->checksum); + + payload_header->checksum = 0; + + checksum = compute_checksum(skb->data, (len + offset)); + + if (checksum != rx_checksum) { + dev_kfree_skb_any(skb); + return; + } if (payload_header->if_type == ESP_SERIAL_IF) { #ifdef CONFIG_SUPPORT_ESP_SERIAL @@ -340,7 +407,7 @@ static void process_rx_packet(struct sk_buff *skb) do { ret = esp_serial_data_received(payload_header->if_num, (skb->data + offset + ret_len), (len - ret_len)); - if (ret == -EINVAL) { + if (ret < 0) { printk(KERN_ERR "%s, Failed to process data for iface type %d\n", __func__, payload_header->if_num); break; } @@ -369,7 +436,7 @@ static void process_rx_packet(struct sk_buff *skb) skb->ip_summed = CHECKSUM_NONE; /* Forward skb to kernel */ - netif_rx(skb); + netif_rx_ni(skb); priv->stats.rx_bytes += skb->len; priv->stats.rx_packets++; @@ -379,6 +446,7 @@ static void process_rx_packet(struct sk_buff *skb) skb_pull(skb, offset); type = skb->data; + //print_hex_dump(KERN_INFO, "bt_rx: ", DUMP_PREFIX_ADDRESS, 16, 1, skb->data, len, 1); hci_skb_pkt_type(skb) = *type; skb_pull(skb, 1); @@ -392,6 +460,8 @@ static void process_rx_packet(struct sk_buff *skb) esp_hci_update_rx_counter(hdev, *type, skb->len); } } + } else if (payload_header->if_type == ESP_PRIV_IF) { + process_priv_communication(skb); } } diff --git a/host/linux/host_driver/esp32/sdio/esp_sdio.c b/host/linux/host_driver/esp32/sdio/esp_sdio.c index 4a5c0c2f5e..15f6c108bd 100644 --- a/host/linux/host_driver/esp32/sdio/esp_sdio.c +++ b/host/linux/host_driver/esp32/sdio/esp_sdio.c @@ -31,8 +31,8 @@ #include #define MAX_WRITE_RETRIES 2 -#define TX_MAX_PENDING_COUNT 700 -#define TX_RESUME_THRESHOLD (TX_MAX_PENDING_COUNT - (TX_MAX_PENDING_COUNT/5)) +#define TX_MAX_PENDING_COUNT 200 +#define TX_RESUME_THRESHOLD (TX_MAX_PENDING_COUNT/5) #define CHECK_SDIO_RW_ERROR(ret) do { \ if (ret) \ @@ -41,7 +41,7 @@ struct esp_sdio_context sdio_context; static atomic_t tx_pending; -static atomic_t queue_items; +static atomic_t queue_items[MAX_PRIORITY_QUEUES]; #ifdef CONFIG_ENABLE_MONITOR_PROCESS struct task_struct *monitor_thread; @@ -254,6 +254,7 @@ static void flush_sdio(struct esp_sdio_context *context) static void esp_remove(struct sdio_func *func) { struct esp_sdio_context *context; + uint8_t prio_q_idx = 0; context = sdio_get_drvdata(func); printk(KERN_INFO "%s -> Remove card", __func__); @@ -280,7 +281,9 @@ static void esp_remove(struct sdio_func *func) } } - skb_queue_purge(&(sdio_context.tx_q)); + for (prio_q_idx=0; prio_q_idxadapter)) printk (KERN_ERR "%s: Failed to get adapter\n", __func__); - skb_queue_head_init(&(sdio_context.tx_q)); - atomic_set(&queue_items, 0); + for (prio_q_idx=0; prio_q_idxadapter->if_type = ESP_IF_TYPE_SDIO; @@ -442,6 +448,7 @@ static struct sk_buff * read_packet(struct esp_adapter *adapter) static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) { u32 max_pkt_size = ESP_RX_BUFFER_SIZE - sizeof(struct esp_payload_header); + struct esp_payload_header *payload_header = (struct esp_payload_header *) skb->data; if (!adapter || !adapter->if_context || !skb || !skb->data || !skb->len) { printk(KERN_ERR "%s: Invalid args\n", __func__); @@ -464,13 +471,20 @@ static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) return -EBUSY; } - /* Notify to process queue */ - atomic_inc(&queue_items); - /* Enqueue SKB in tx_q */ atomic_inc(&tx_pending); - skb_queue_tail(&(sdio_context.tx_q), skb); + /* Notify to process queue */ + if (payload_header->if_type == ESP_SERIAL_IF) { + atomic_inc(&queue_items[PRIO_Q_SERIAL]); + skb_queue_tail(&(sdio_context.tx_q[PRIO_Q_SERIAL]), skb); + } else if (payload_header->if_type == ESP_HCI_IF) { + atomic_inc(&queue_items[PRIO_Q_BT]); + skb_queue_tail(&(sdio_context.tx_q[PRIO_Q_BT]), skb); + } else { + atomic_inc(&queue_items[PRIO_Q_OTHERS]); + skb_queue_tail(&(sdio_context.tx_q[PRIO_Q_OTHERS]), skb); + } return 0; } @@ -496,18 +510,32 @@ static int tx_process(void *data) continue; } - if (atomic_read(&queue_items) <= 0) { - msleep(10); + if (atomic_read(&queue_items[PRIO_Q_SERIAL]) > 0) { + tx_skb = skb_dequeue(&(context->tx_q[PRIO_Q_SERIAL])); + if (!tx_skb) { + continue; + } + atomic_dec(&queue_items[PRIO_Q_SERIAL]); + }else if (atomic_read(&queue_items[PRIO_Q_BT]) > 0) { + tx_skb = skb_dequeue(&(context->tx_q[PRIO_Q_BT])); + if (!tx_skb) { + continue; + } + atomic_dec(&queue_items[PRIO_Q_BT]); + } else if (atomic_read(&queue_items[PRIO_Q_OTHERS]) > 0) { + tx_skb = skb_dequeue(&(context->tx_q[PRIO_Q_OTHERS])); + if (!tx_skb) { + continue; + } + atomic_dec(&queue_items[PRIO_Q_OTHERS]); + } else { + msleep(1); continue; } - tx_skb = skb_dequeue(&(context->tx_q)); - if (!tx_skb) { - continue; - } + if (atomic_read(&tx_pending)) + atomic_dec(&tx_pending); - atomic_dec(&queue_items); - atomic_dec(&tx_pending); retry = MAX_WRITE_RETRIES; /* resume network tx queue if bearable load */ @@ -677,7 +705,6 @@ static int esp_probe(struct sdio_func *func, { struct esp_sdio_context *context = NULL; int ret = 0; - uint32_t *cap; if (func->num != 1) { return -EINVAL; @@ -691,10 +718,6 @@ static int esp_probe(struct sdio_func *func, return -ENOMEM; } - generate_slave_intr(context, BIT(ESP_RESET)); - - msleep(200); - atomic_set(&tx_pending, 0); ret = init_context(context); if (ret) { @@ -715,36 +738,7 @@ static int esp_probe(struct sdio_func *func, return ret; } - cap = kmalloc(sizeof(u32), GFP_KERNEL); - - if (!cap) { - esp_remove(func); - printk (KERN_ERR "Failed to allocate memory\n"); - deinit_sdio_func(func); - return -ENOMEM; - } - /* Read slave capabilities */ - ret = esp_read_reg(context, ESP_SLAVE_SCRATCH_REG_0, - (u8 *) cap, sizeof(* cap), ACQUIRE_LOCK); - - if (ret) { - kfree(cap); - esp_remove(func); - printk (KERN_ERR "Failed to read capability\n"); - deinit_sdio_func(func); - return ret; - } - - context->adapter->capabilities = * cap; - - print_capabilities(*cap); - - if (esp_is_bt_supported_over_sdio(*cap)) { - esp_init_bt(context->adapter); - } - - kfree(cap); context->state = ESP_CONTEXT_READY; @@ -755,7 +749,6 @@ static int esp_probe(struct sdio_func *func, printk (KERN_ERR "Failed to create monitor thread\n"); #endif - msleep(200); generate_slave_intr(context, BIT(ESP_OPEN_DATA_PATH)); return ret; } @@ -780,6 +773,30 @@ int esp_init_interface_layer(struct esp_adapter *adapter) return sdio_register_driver(&esp_sdio_driver); } +void process_init_event(u8 *evt_buf, u8 len) +{ + u8 len_left = len, tag_len; + u8 *pos; + + if (!evt_buf) + return; + + pos = evt_buf; + + while (len_left) { + tag_len = *(pos + 1); + printk(KERN_INFO "EVENT: %d\n", *pos); + if (*pos == ESP_PRIV_CAPABILITY) { + process_capabilities(*(pos + 2)); + print_capabilities(*(pos + 2)); + } else { + printk (KERN_WARNING "Unsupported tag in event"); + } + pos += (tag_len+2); + len_left -= (tag_len+2); + } +} + void esp_deinit_interface_layer(void) { sdio_unregister_driver(&esp_sdio_driver); diff --git a/host/linux/host_driver/esp32/sdio/esp_sdio_decl.h b/host/linux/host_driver/esp32/sdio/esp_sdio_decl.h index 6d3a9ee1bb..1758d5b816 100644 --- a/host/linux/host_driver/esp32/sdio/esp_sdio_decl.h +++ b/host/linux/host_driver/esp32/sdio/esp_sdio_decl.h @@ -92,7 +92,7 @@ struct esp_sdio_context { struct esp_adapter *adapter; struct sdio_func *func; enum context_state state; - struct sk_buff_head tx_q; + struct sk_buff_head tx_q[MAX_PRIORITY_QUEUES]; u32 rx_byte_count; u32 tx_buffer_count; }; diff --git a/host/linux/host_driver/esp32/spi/esp_spi.c b/host/linux/host_driver/esp32/spi/esp_spi.c index c354e72eac..87ae8c72c5 100644 --- a/host/linux/host_driver/esp32/spi/esp_spi.c +++ b/host/linux/host_driver/esp32/spi/esp_spi.c @@ -26,8 +26,8 @@ #define SPI_INITIAL_CLK_MHZ 10 #define NUMBER_1M 1000000 -#define TX_MAX_PENDING_COUNT 500 -#define TX_RESUME_THRESHOLD (TX_MAX_PENDING_COUNT - (TX_MAX_PENDING_COUNT/5)) +#define TX_MAX_PENDING_COUNT 100 +#define TX_RESUME_THRESHOLD (TX_MAX_PENDING_COUNT/5) /* ESP in sdkconfig has CONFIG_IDF_FIRMWARE_CHIP_ID entry. * supported values of CONFIG_IDF_FIRMWARE_CHIP_ID are - */ @@ -44,7 +44,7 @@ static void adjust_spi_clock(u8 spi_clk_mhz); volatile u8 data_path = 0; static struct esp_spi_context spi_context; static char hardware_type = 0; -static u32 tx_pending = 0; +static atomic_t tx_pending; static struct esp_if_ops if_ops = { .read = read_packet, @@ -55,7 +55,7 @@ static DEFINE_MUTEX(spi_lock); static void open_data_path(void) { - tx_pending = 0; + atomic_set(&tx_pending, 0); msleep(200); data_path = OPEN_DATAPATH; } @@ -101,7 +101,11 @@ static struct sk_buff * read_packet(struct esp_adapter *adapter) context = adapter->if_context; if (context->esp_spi_dev) { - skb = skb_dequeue(&(context->rx_q)); + skb = skb_dequeue(&(context->rx_q[PRIO_Q_SERIAL])); + if (!skb) + skb = skb_dequeue(&(context->rx_q[PRIO_Q_BT])); + if (!skb) + skb = skb_dequeue(&(context->rx_q[PRIO_Q_OTHERS])); } else { printk (KERN_ERR "%s: Invalid args\n", __func__); return NULL; @@ -113,6 +117,7 @@ static struct sk_buff * read_packet(struct esp_adapter *adapter) static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) { u32 max_pkt_size = SPI_BUF_SIZE - sizeof(struct esp_payload_header); + struct esp_payload_header *payload_header = (struct esp_payload_header *) skb->data; if (!adapter || !adapter->if_context || !skb || !skb->data || !skb->len) { printk (KERN_ERR "%s: Invalid args\n", __func__); @@ -132,16 +137,23 @@ static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) return -EPERM; } - if (tx_pending >= TX_MAX_PENDING_COUNT) { - esp_tx_pause(); - dev_kfree_skb(skb); - return -EBUSY; - } /* Enqueue SKB in tx_q */ - skb_queue_tail(&spi_context.tx_q, skb); - - tx_pending++; + if (payload_header->if_type == ESP_SERIAL_IF) { + skb_queue_tail(&spi_context.tx_q[PRIO_Q_SERIAL], skb); + } else if (payload_header->if_type == ESP_HCI_IF) { + skb_queue_tail(&spi_context.tx_q[PRIO_Q_BT], skb); + } else { + if (atomic_read(&tx_pending) >= TX_MAX_PENDING_COUNT) { + esp_tx_pause(); + dev_kfree_skb(skb); + if (spi_context.spi_workqueue) + queue_work(spi_context.spi_workqueue, &spi_context.spi_work); + return -EBUSY; + } + skb_queue_tail(&spi_context.tx_q[PRIO_Q_OTHERS], skb); + atomic_inc(&tx_pending); + } if (spi_context.spi_workqueue) queue_work(spi_context.spi_workqueue, &spi_context.spi_work); @@ -149,20 +161,8 @@ static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) return 0; } -static void process_capabilities(u8 cap) -{ - printk (KERN_INFO "ESP peripheral capabilities: 0x%x\n", cap); - - /* Reset BT */ - esp_deinit_bt(spi_context.adapter); - - if ((cap & ESP_BT_SPI_SUPPORT) || (cap & ESP_BT_SDIO_SUPPORT)) { - msleep(200); - esp_init_bt(spi_context.adapter); - } -} -static void process_init_event(u8 *evt_buf, u8 len) +void process_init_event(u8 *evt_buf, u8 len) { u8 len_left = len, tag_len; u8 *pos; @@ -195,43 +195,6 @@ static void process_init_event(u8 *evt_buf, u8 len) } } -static void process_event(u8 *evt_buf, u16 len) -{ - struct esp_priv_event *event; - - if (!evt_buf || !len) - return; - - event = (struct esp_priv_event *) evt_buf; - - if (event->event_type == ESP_PRIV_EVENT_INIT) { - printk (KERN_INFO "Received INIT event from ESP32 peripheral"); - process_init_event(event->event_data, event->event_len); - } else { - printk (KERN_WARNING "Drop unknown event"); - } -} - -static void process_priv_communication(struct sk_buff *skb) -{ - struct esp_payload_header *header; - u8 *payload; - u16 len; - - if (!skb || !skb->data) - return; - - header = (struct esp_payload_header *) skb->data; - - payload = skb->data + le16_to_cpu(header->offset); - len = le16_to_cpu(header->len); - - if (header->priv_pkt_type == ESP_PACKET_TYPE_EVENT) { - process_event(payload, len); - } - - dev_kfree_skb(skb); -} static int process_rx_buf(struct sk_buff *skb) { @@ -269,16 +232,17 @@ static int process_rx_buf(struct sk_buff *skb) /* Trim SKB to actual size */ skb_trim(skb, len); - if (header->if_type == ESP_PRIV_IF) { - process_priv_communication(skb); - return 0; - } if (!data_path) return -EPERM; /* enqueue skb for read_packet to pick it */ - skb_queue_tail(&spi_context.rx_q, skb); + if (header->if_type == ESP_SERIAL_IF) + skb_queue_tail(&spi_context.rx_q[PRIO_Q_SERIAL], skb); + else if (header->if_type == ESP_HCI_IF) + skb_queue_tail(&spi_context.rx_q[PRIO_Q_BT], skb); + else + skb_queue_tail(&spi_context.rx_q[PRIO_Q_OTHERS], skb); /* indicate reception of new packet */ esp_process_new_packet_intr(spi_context.adapter); @@ -292,17 +256,29 @@ static void esp_spi_work(struct work_struct *work) struct sk_buff *tx_skb = NULL, *rx_skb = NULL; u8 *rx_buf; int ret = 0; - int trans_ready, rx_pending; + volatile int trans_ready, rx_pending; mutex_lock(&spi_lock); trans_ready = gpio_get_value(HANDSHAKE_PIN); rx_pending = gpio_get_value(SPI_DATA_READY_PIN); - if (trans_ready) { - if (data_path) - tx_skb = skb_dequeue(&spi_context.tx_q); + if (data_path) { + tx_skb = skb_dequeue(&spi_context.tx_q[PRIO_Q_SERIAL]); + if (!tx_skb) + tx_skb = skb_dequeue(&spi_context.tx_q[PRIO_Q_BT]); + if (!tx_skb) + tx_skb = skb_dequeue(&spi_context.tx_q[PRIO_Q_OTHERS]); + if (tx_skb) { + if (atomic_read(&tx_pending)) + atomic_dec(&tx_pending); + + if (atomic_read(&tx_pending) < TX_RESUME_THRESHOLD) { + esp_tx_resume(); + } + } + } if (rx_pending || tx_skb) { memset(&trans, 0, sizeof(trans)); @@ -319,11 +295,6 @@ static void esp_spi_work(struct work_struct *work) /* Configure TX buffer if available */ if (tx_skb) { - tx_pending--; - - if (tx_pending < TX_RESUME_THRESHOLD) - esp_tx_resume(); - trans.tx_buf = tx_skb->data; } else { tx_skb = esp_alloc_skb(SPI_BUF_SIZE); @@ -469,6 +440,7 @@ static int spi_reinit_spidev(int spi_clk_mhz) static int spi_init(void) { int status = 0; + uint8_t prio_q_idx = 0; spi_context.spi_workqueue = create_workqueue("ESP_SPI_WORK_QUEUE"); @@ -480,8 +452,11 @@ static int spi_init(void) INIT_WORK(&spi_context.spi_work, esp_spi_work); - skb_queue_head_init(&spi_context.tx_q); - skb_queue_head_init(&spi_context.rx_q); + for (prio_q_idx=0; prio_q_idxif_type; - buf_handle.if_num = payload_header->if_num; - buf_handle.payload = rxbuff + offset; - - if (pdTRUE != xQueueSend(from_slave_queue, - &buf_handle, portMAX_DELAY)) { - printf("Failed to send buffer\n\r"); - goto done; + rx_checksum = le16toh(payload_header->checksum); + payload_header->checksum = 0; + checksum = compute_checksum(rxbuff, len+offset); + if (checksum == rx_checksum) { + buf_handle.priv_buffer_handle = rxbuff; + buf_handle.free_buf_handle = free; + buf_handle.payload_len = len; + buf_handle.if_type = payload_header->if_type; + buf_handle.if_num = payload_header->if_num; + buf_handle.payload = rxbuff + offset; + + if (pdTRUE != xQueueSend(from_slave_queue, + &buf_handle, portMAX_DELAY)) { + printf("Failed to send buffer\n\r"); + goto done; + } + } else { + if (rxbuff) { + free(rxbuff); + rxbuff = NULL; + } } } @@ -560,6 +570,7 @@ static stm_ret_t spi_transaction_esp32s2(uint8_t * txbuff) struct esp_payload_header *payload_header; uint16_t len, offset; HAL_StatusTypeDef retval = HAL_ERROR; + uint16_t rx_checksum = 0, checksum = 0; /* Allocate rx buffer */ rxbuff = (uint8_t *)malloc(MAX_SPI_BUFFER_SIZE); @@ -568,7 +579,7 @@ static stm_ret_t spi_transaction_esp32s2(uint8_t * txbuff) if(!txbuff) { /* Even though, there is nothing to send, - * valid resetted txbuff is needed for SPI driver + * valid reseted txbuff is needed for SPI driver */ txbuff = (uint8_t *)malloc(MAX_SPI_BUFFER_SIZE); assert(txbuff); @@ -613,18 +624,29 @@ static stm_ret_t spi_transaction_esp32s2(uint8_t * txbuff) osDelay(0); } else { - - buf_handle.priv_buffer_handle = rxbuff; - buf_handle.free_buf_handle = free; - buf_handle.payload_len = len; - buf_handle.if_type = payload_header->if_type; - buf_handle.if_num = payload_header->if_num; - buf_handle.payload = rxbuff + offset; - - if (pdTRUE != xQueueSend(from_slave_queue, - &buf_handle, portMAX_DELAY)) { - printf("Failed to send buffer\n\r"); - goto done; + rx_checksum = le16toh(payload_header->checksum); + payload_header->checksum = 0; + + checksum = compute_checksum(rxbuff, len+offset); + + if (checksum == rx_checksum) { + buf_handle.priv_buffer_handle = rxbuff; + buf_handle.free_buf_handle = free; + buf_handle.payload_len = len; + buf_handle.if_type = payload_header->if_type; + buf_handle.if_num = payload_header->if_num; + buf_handle.payload = rxbuff + offset; + + if (pdTRUE != xQueueSend(from_slave_queue, + &buf_handle, portMAX_DELAY)) { + printf("Failed to send buffer\n\r"); + goto done; + } + } else { + if (rxbuff) { + free(rxbuff); + rxbuff = NULL; + } } } @@ -820,9 +842,9 @@ static uint8_t * get_tx_buffer(uint8_t *is_valid_tx_buf) payload_header->offset = htole16(sizeof(struct esp_payload_header)); payload_header->if_type = buf_handle.if_type; payload_header->if_num = buf_handle.if_num; - payload_header->reserved1 = 0; - memcpy(payload, buf_handle.payload, min(len, MAX_PAYLOAD_SIZE)); + payload_header->checksum = htole16(compute_checksum(sendbuf, + sizeof(struct esp_payload_header)+len));; } done: