Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NimBLE: error setting advertisement data; rc=8" issue while using spp_server code from esp-idf/examples (IDFGH-12862) #13826

Open
3 tasks done
BestBot7 opened this issue May 21, 2024 · 12 comments
Labels
Status: Opened Issue is new

Comments

@BestBot7
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

I have taken the spp_server template code of nimble stack from esp-idf/examples.

I have build and flashed on esp32c3 to verify BLE advertisement and connection feature.
The number of BLE concurrent connections is set to 5 in the component config under menuconfig BLE feature.
The extended advertising under Enable BLE 5 feature is also enabled with number of instances to 4.

I have tried with esp-idf version 5.2.1, 5.1.1, and 5.1.2 and got the error saying "NimBLE: error setting advertisement data; rc=8". What exactly is this error and how to resolve this?

@espressif-bot espressif-bot added the Status: Opened Issue is new label May 21, 2024
@github-actions github-actions bot changed the title "NimBLE: error setting advertisement data; rc=8" issue while using spp_server code from esp-idf/examples "NimBLE: error setting advertisement data; rc=8" issue while using spp_server code from esp-idf/examples (IDFGH-12862) May 21, 2024
@rahult-github
Copy link
Collaborator

Hi @BestBot7 , Please disable BT_NIMBLE_EXT_ADV and use.

@BestBot7
Copy link
Author

Hi @rahult-github, I have tried both enabling and disable and ended up with the same error.

@rahult-github
Copy link
Collaborator

Hi @BestBot7 ,

I quickly tried on esp32c3 on 5.2.1 and i see it working ok.

I (234) cpu_start: App version: v5.2.1-dirty
I (240) cpu_start: Compile time: May 22 2024 10:37:56
I (246) cpu_start: ELF file SHA256: 3d90e430b...
I (251) cpu_start: ESP-IDF: v5.2.1-dirty
I (256) cpu_start: Min chip rev: v0.3
I (261) cpu_start: Max chip rev: v1.99
I (266) cpu_start: Chip rev: v0.3
I (271) heap_init: Initializing. RAM available for dynamic allocation:
I (278) heap_init: At 3FC97020 len 00028FE0 (163 KiB): RAM
I (284) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (291) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (298) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (305) spi_flash: detected chip: generic
I (309) spi_flash: flash io: dio
W (313) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (326) sleep: Configure to isolate all GPIO pins in sleep state
I (333) sleep: Enable automatic switching of GPIO sleep configuration
I (340) coexist: coex firmware version: 77cd7f8
I (345) coexist: coexist rom version 9387209
I (350) main_task: Started on CPU0
I (350) main_task: Calling app_main()
I (360) BLE_INIT: BT controller compile version [30b57c4]
I (360) BLE_INIT: Bluetooth MAC: 7c:df:a1:a2:9b:f2
I (370) phy_init: phy_version 1150,7c3c08f,Jan 24 2024,17:32:21
I (410) NimBLE: BLE server UART_task started
I (410) NimBLE: BLE Host Task Started
I (410) NimBLE: GAP procedure initiated: stop advertising.
I (410) NimBLE: Device Address:
I (410) NimBLE: 7c:df:a1:a2:9b:f2
I (420) NimBLE:
I (420) NimBLE: GAP procedure initiated: advertise;
I (430) NimBLE: disc_mode=2
I (430) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (440) NimBLE:
I (440) main_task: Returned from app_main()

Can you please help share your sdkconfig ?

@rahult-github
Copy link
Collaborator

Hi @BestBot7

I have taken the spp_server template code of nimble stack from esp-idf/examples

I have assumed you are running the ble_spp/spp_server example from IDF. If not, then can you please try the IDF example to confirm it works ?

@BestBot7
Copy link
Author

BestBot7 commented May 22, 2024

Now try to connect with nrf connect mobile app and disconnect it. You will find the error. Anyway please find the attached sdkconfig.

sdkconfig.zip

@rahult-github
Copy link
Collaborator

Hi @BestBot7 ,

In sdkconfig shared:

CONFIG_BT_NIMBLE_EXT_ADV=y

Extended Advertising is enabled.

Please disable BT_NIMBLE_EXT_ADV and use.

Please do this.

@rahult-github
Copy link
Collaborator

The way to disable EXT_ADV is :

Component config → Bluetooth → NimBLE Options → Enable BLE 5 feature and ensure Enable extended advertising is not selected

@BestBot7
Copy link
Author

I have disabled the extended advertisement and here are the error log image and the corresponding sdkconfig file attached.
image
sdkconfig.zip

@rahult-github
Copy link
Collaborator

rahult-github commented May 23, 2024

Hi @BestBot7 , your original issue was advertising data not being set because ext adv was enabled. As seen in above logs, that issue is resolved.

But now a new issue is observed on your side where attempt to enable advertising fails since advertising is already in progress.

Update:

So in log we see :

image

Advertising is started
Connection is done
Again advertising is started

Is this some extra application code from your side ? This is why the new attempt to start advertising fails, since one advertising is already in progress.

@BestBot7
Copy link
Author

BestBot7 commented May 23, 2024

Hi @rahult-github, this is the template code from idf examples. I have changed nothing in it, except that the number of concurrent connections set to 5. My aim is to verify the multiconnection in esp32c3 bluetooth and hence I configured the number of concurrent connections to 5. After connecting and disconnecting from a single device, the error is logged as I mentioned. So, please help me with what all should I be careful while enabling multiple BLE connections.

@rahult-github
Copy link
Collaborator

Hi @BestBot7 ,

I see. The example ble_spp is suited for single connection / legacy adv . If the use case is for multiconnection, then i suggest to look at the example ble_multi_conn .

@BestBot7
Copy link
Author

Hi @rahult-github, Even after using the example code ble_multi_conn, the issue still persists. I have disabled the ext adv and tried and found no difference. On boot we don't get this error. Only on disconnecting after connection we find this log. Can you suggest some way on how to use this feature properly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants