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

Re-run ext adv after completion (IDFGH-9373) #10747

Closed
wants to merge 1 commit into from
Closed

Re-run ext adv after completion (IDFGH-9373) #10747

wants to merge 1 commit into from

Conversation

kevinhikaruevans
Copy link
Contributor

Both extended and normal advertising should be reran when complete in this Nimble example. Without this, only a single BLE client is able to connect when CONFIG_EXAMPLE_EXTENDED_ADV=1

@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 10, 2023
@github-actions github-actions bot changed the title Re-run ext adv after completion Re-run ext adv after completion (IDFGH-9373) Feb 10, 2023
@rahult-github
Copy link
Collaborator

sha=35926387738ba28c0c84d29c6e803ed15c5a8ae7

@rahult-github rahult-github added the PR-Sync-Merge Pull request sync as merge commit label Feb 11, 2023
@rahult-github
Copy link
Collaborator

Hi @kevinhikaruevans ,

I found some issue with the patch. If connection was success , for extended adv , adv complete event is posted by stack. If we restart the ext adv here, then when the connection is disconnected, it will again try to restart ext_adv as it will invoke ext_bleprph_advertise in original code. . This results in crash since the previous instance of ext adv was already started by the new function call introduced in this patch. This may need more handling , i can check later. Have you not observed any issue in your testing ?

`I (595) NimBLE_BLE_PRPH: BLE Host Task Started
I (605) NimBLE: Device Address:
I (605) NimBLE: 60:55:f9:f6:05:4a
I (615) NimBLE:

I (625) uart: queue free spaces: 8
I (635) main_task: Returned from app_main()
I (5075) NimBLE: connection established; status=0
I (5075) NimBLE: handle=1 our_ota_addr_type=0 our_ota_addr=
I (5085) NimBLE: 60:55:f9:f6:05:4a
I (5085) NimBLE: our_id_addr_type=0 our_id_addr=
I (5095) NimBLE: 60:55:f9:f6:05:4a
I (5095) NimBLE: peer_ota_addr_type=1 peer_ota_addr=
I (5105) NimBLE: 45:40:e1:10:0f:73
I (5105) NimBLE: peer_id_addr_type=1 peer_id_addr=
I (5115) NimBLE: 45:40:e1:10:0f:73
I (5115) NimBLE: conn_itvl=36 conn_latency=0 supervision_timeout=500 encrypted=0 authenticated=0 bonded=0

I (5125) NimBLE:

I (5135) NimBLE: advertise complete; reason=0
I (7035) NimBLE: encryption change event; status=1292
I (7035) NimBLE: handle=1 our_ota_addr_type=0 our_ota_addr=
I (7045) NimBLE: 60:55:f9:f6:05:4a
I (7045) NimBLE: our_id_addr_type=0 our_id_addr=
I (7045) NimBLE: 60:55:f9:f6:05:4a
I (7055) NimBLE: peer_ota_addr_type=1 peer_ota_addr=
I (7055) NimBLE: 45:40:e1:10:0f:73
I (7065) NimBLE: peer_id_addr_type=1 peer_id_addr=
I (7065) NimBLE: 45:40:e1:10:0f:73
I (7075) NimBLE: conn_itvl=36 conn_latency=0 supervision_timeout=500 encrypted=0 authenticated=0 bonded=0

I (7085) NimBLE:

I (10055) NimBLE: disconnect; reason=531
I (10055) NimBLE: handle=1 our_ota_addr_type=0 our_ota_addr=
I (10055) NimBLE: 60:55:f9:f6:05:4a
I (10055) NimBLE: our_id_addr_type=0 our_id_addr=
I (10065) NimBLE: 60:55:f9:f6:05:4a
I (10065) NimBLE: peer_ota_addr_type=1 peer_ota_addr=
I (10075) NimBLE: 45:40:e1:10:0f:73
I (10075) NimBLE: peer_id_addr_type=1 peer_id_addr=
I (10085) NimBLE: 45:40:e1:10:0f:73
I (10085) NimBLE: conn_itvl=36 conn_latency=0 supervision_timeout=500 encrypted=0 authenticated=0 bonded=0

I (10095) NimBLE:

assert failed: ext_bleprph_advertise main.c:116 (rc == 0)
Stack dump detected
Core 0 register dump:
MEPC : 0x408005fa RA : 0x4080919a SP : 0x4081b6c0 GP : 0x4080edf0
0x408005fa: panic_abort at /esp-idf/components/esp_system/panic.c:452

0x4080919a: __ubsan_include at /esp-idf/components/esp_system/ubsan.c:313

TP : 0x40804eec T0 : 0x37363534 T1 : 0x7271706f T2 : 0x33323130
0x40804eec: ble_lll_sched_insert_after at ??:?

S0/FP : 0x0000008e S1 : 0x00000001 A0 : 0x4081b6fc A1 : 0x4080f7d5
A2 : 0x00000001 A3 : 0x00000029 A4 : 0x00000001 A5 : 0x40811000
A6 : 0x00000000 A7 : 0x76757473 S2 : 0x00000009 S3 : 0x4081b809
S4 : 0x4080f7d4 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x6e6d6c6b T4 : 0x6a696867 T5 : 0x66656463 T6 : 0x62613938
MSTATUS : 0x00001881 MTVEC : 0x40800001 MCAUSE : 0x00000007 MTVAL : 0x00000000
0x40800001: _vector_table at ??:?

MHARTID : 0x00000000

Backtrace:

panic_abort (details=details@entry=0x4081b6fc "assert failed: ext_bleprph_advertise main.c:116 (rc == 0)") at /esp-idf/components/esp_system/panic.c:452
452 *((volatile int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
#0 panic_abort (details=details@entry=0x4081b6fc "assert failed: ext_bleprph_advertise main.c:116 (rc == 0)") at /esp-idf/components/esp_system/panic.c:452
#1 0x4080919a in esp_system_abort (details=details@entry=0x4081b6fc "assert failed: ext_bleprph_advertise main.c:116 (rc == 0)") at /esp-idf/components/esp_system/port/esp_system_chip.c:77
#2 0x4080d4e6 in __assert_func (file=file@entry=0x420635ed "", line=line@entry=116, func=, func@entry=0x42063be4 <func.2> "", expr=expr@entry=0x420635dc "") at /esp-idf/components/newlib/assert.c:81
#3 0x42006cb4 in ext_bleprph_advertise () at ../main/main.c:116
#4 0x42006f10 in bleprph_gap_event (event=0x4081b8a0, event@entry=, arg=) at ../main/main.c:308
`

@kevinhikaruevans
Copy link
Contributor Author

kevinhikaruevans commented Feb 13, 2023

Hi @rahult-github, I see the crash now. I was previously checking if the device was busy in ext_bleprph_advertise, but this is probably not a good way to handle this. This is what I was including in my test code:

    rc = ble_gap_ext_adv_configure(instance, &params, NULL,
                                   bleprph_gap_event, NULL);
    
    if (rc == BLE_HS_EBUSY) {
        return;
    }

Just wondering, are you able to run multiple ble clients with ext adv without the patch?

@rahult-github
Copy link
Collaborator

Hi @kevinhikaruevans ,

Please help check if attached patch works for you
0001-Nimble-Updated-bleprph-example-to-enable-ext-adv-aft.txt

@kevinhikaruevans
Copy link
Contributor Author

@rahult-github Thank you! Yes, that patch worked for me. I've updated the PR with that patch.

@rahult-github
Copy link
Collaborator

sha=0b921fda149c69510258ba879e34cbeb1829cce0

@rahult-github rahult-github added PR-Sync-Update Pull request sync fetch new changes and removed PR-Sync-Merge Pull request sync as merge commit labels Feb 15, 2023
@rahult-github
Copy link
Collaborator

Hi @kevinhikaruevans ,

I have below suggestions:

  1. Can you please merge the two commits and make one. You can have the commit in your name as contributor.
  2. Please rebase to latest master

@kevinhikaruevans
Copy link
Contributor Author

Hi @rahult-github

  1. I've squashed the two commits
  2. I've rebased the branch with master

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Mar 9, 2023
@rahult-github
Copy link
Collaborator

Changes part of master tree . Thanks for your contribution.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: In Progress Work is in progress labels Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Sync-Update Pull request sync fetch new changes Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants