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

Parents
  • 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. 


Reply
  • 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. 


Children
No Data
Related