Currently, I am trying to use extended advertisements for sending and receiving 1650 bytes of data from one ESP32-S3 to another.
For the sender, I am using code from this example:
https://github.com/espressif/esp-idf/bl ... adv_demo.c
commenting out periodic advertisement logic and generating a 1650-byte array for an adv packet.
For the receiver, I am using code from this example:
https://github.com/espressif/esp-idf/bl ... ync_demo.c
In this code, I added ESP_GAP_BLE_EXT_ADV_REPORT_EVT case in gap_event_handler for processing extended advertisement packets and printing caught data into logs.
As a result, I was able to receive chained extended advertisements in the following way:
Code: Select all
I (13526) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13526) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13526) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13536) EXTENDED_ADVERTISEMENT: Advertising Data: 0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5
I (13586) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 13 ----
I (13586) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13596) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13606) EXTENDED_ADVERTISEMENT: Advertising Data: E6E7E8E9EAEBECEDEEEFF0F1F2
I (13616) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13616) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13626) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13636) EXTENDED_ADVERTISEMENT: Advertising Data: F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8
I (13676) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 19 ----
I (13686) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13686) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13696) EXTENDED_ADVERTISEMENT: Advertising Data: D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEB
I (13706) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13716) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13716) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13726) EXTENDED_ADVERTISEMENT: Advertising Data: ECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1
I (13776) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 19 ----
I (13776) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13786) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13796) EXTENDED_ADVERTISEMENT: Advertising Data: D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4
I (13806) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13806) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13816) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13826) EXTENDED_ADVERTISEMENT: Advertising Data: E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CA
I (13866) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 19 ----
I (13876) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13886) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13886) EXTENDED_ADVERTISEMENT: Advertising Data: CBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDD
I (13896) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13906) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13906) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13916) EXTENDED_ADVERTISEMENT: Advertising Data: DEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3
I (13966) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 19 ----
I (13966) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (13976) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (13986) EXTENDED_ADVERTISEMENT: Advertising Data: C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6
I (13996) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 229 ----
I (13996) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (14006) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (14016) EXTENDED_ADVERTISEMENT: Advertising Data: D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBC
I (14056) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 19 ----
I (14066) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (14076) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 1
I (14076) EXTENDED_ADVERTISEMENT: Advertising Data: BDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF
I (14086) EXTENDED_ADVERTISEMENT: ---- Packet caught, size: 168 ----
I (14096) EXTENDED_ADVERTISEMENT: esp_ble_gap_adv_type_t: 0
I (14096) EXTENDED_ADVERTISEMENT: esp_ble_gap_ext_adv_data_status_t: 0
I (14106) EXTENDED_ADVERTISEMENT: Advertising Data: D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778
https://github.com/espressif/esp-idf/bl ... _ble_api.h
and BLE 5.0 chained extended advertisements documentation I concluded, that the logic of receiving several packets and composing them together into a final one after receiving all chained packages is supported neither on the controller nor on the host level.
Still, I don’t understand why I have such strange packet sizes. Firstly – why maximum size of one extended advertisement packet I managed to reach is 229, but not 251 as it is allocated in esp_ble_gap_ext_adv_reprot_t.adv_data (esp_gap_ble_api.h). Secondly – why do I have small packets with not consistent size at the start and bigger ones mixed with them? For example, the first packet is 229, then 13, then 229 again, then 19, and so on.
My current guesses are that I didn’t configure properly esp_ble_gap_ext_adv_params_t in the sender code or/and extended advertisement packets need to be properly formatted. Also, this behavior may be related to specifics of Bluedroid implementation in the ESP32 library.
Can you provide me with any information that can clarify, why I am getting such a behavior and how I can send and receive chained extended advertisement packets properly?