Advertising failed to start (err -120)

I am running into an issue (title), where I am attempting to switch the advertising interval to a slower interval after a set period of advertising in order to save power. Advertising is being successfully started the first time, I then start a timer. In the timer expiration handler, I call bt_le_adv_stop(), and then initialize advertising again, this time with a different set of min and max intervals. The second time around, bt_le_adv_start() returns -120 (EALREADY). I have tried adding a delay in between the stop and start functions in case it takes longer than expected for advertising to stop, but this did not change the outcome. Also, bt_le_adv_stop() is returning 0 which I believes implies the action was successful. Any help would be appreciated, thanks!

I am using:
NCS v2.6
nRF52832

  • Hello,

    Is the behavior consistent, meaning does the EALREADY return every time you test this (the second time you try to start advertising)? Or only from time to time?

    I suspect it has to do with scheduling. From where do you call advertising stop and advertising start? Is it possible to upload the application so that I can build it and run it on an nRF52832 DK?

    Best regards,

    Edvin

  • Hi Edvin,

    EALREADY returns every time bt_le_adv_start() is called beyond the initial instance. The initial bt_le_adv_start() call occurs before the infinite loop in main. The bt_le_adv_stop() and subsequent bt_le_adv_start() calls occur in a timer timeout handler. 

    I also turned on more detailed logs and it is printing the following immediately after returning err -120
    Advertising failed to start (err -120)
    [00:00:14.666,625] <err> os: ***** USAGE FAULT *****
    [00:00:14.666,625] <err> os: Unaligned memory access
    [00:00:14.666,656] <err> os: r0/a1: 0x00414643 r1/a2: 0x0000002c r2/a3: 0x2000bd18
    [00:00:14.666,656] <err> os: r3/a4: 0x00000040 r12/ip: 0x00000000 r14/lr: 0x0002dc73
    [00:00:14.666,687] <err> os: xpsr: 0x21000000
    [00:00:14.666,687] <err> os: Faulting instruction address (r15/pc): 0x0002dc5c
    [00:00:14.666,717] <err> os: >>> ZEPHYR FATAL ERROR 31: Unknown error on CPU 0
    [00:00:14.666,748] <err> os: Current thread: 0x20003040 (unknown)

    The function at 0x0002dc5c as shown in the debugger memory tool is sys_dlist_remove()


    I will work on uploading the application here shortly. 


  • Below is the project and board files. The board file has been modified to work with nrf52dk. 
    RES-BPB-TEST.zip
    6505.centurion_anywhere_button.zip

  • Hello,

    I am strugglnig a bit with the custom board setup. Is it possible to send an application that I can build for the board nrf52dk_nrf52832? If it complains a lot about peripherals and gpios, it should be possible to either add it to the nrf52dk_nrf52832.overlay, or you can just exclude those parts from the application. It shouldn't matter much for the BLE part of the application.

    Alternatively, just take the BLE part of your application and add it to any of the BLE samples in NCS.

    BR,

    Edvin

  • What part of the custom board setup isn't working for you? The project was developed with an nRF52dk using the custom board files as the only difference between the custom hardware and the DK are the button and LED pins which should not be relevant for this bug. 


    I can work on putting the problem portion of the code into one of the examples and make sure the issue is replicable before sending it over.

Related