This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertising and Scanning in one Device

Hi,

I'm programming nRF52833 for my application. I have done to configure my device and it advertised and scanned sequentially. For my application, I advertise and also scan in channel 37. Now, I want to manage the time it advertise and scanning strictly. Does the BLE device take time to switch from advertiser to Scanner and from Scanner to Advertiser? In my main code I wrote like this:

    advertising_start();
    scan_start();

So that means the BLE device will start advertising in channel 37 and after advertising in T(ms) it starts scanning in Scan_Window(ms), right?? 

Thanks,

Best regards, 

Parents
  • Hi,

    I have started looking into this. I might need to get back to you over the weekend if I am not able to figure this out right away.

    I had a brief chat with a more experienced colleague. It was suggested a shorter scan window allows for a more effective scheduling of advertising and scanning.

    Now, I want to manage the time it advertise and scanning strictly.

    Switching between advertising and scanning might take less than a millisecond but I have not checked yet. What is it you want to achieve? Please keep i mind that the Bluetooth LE spec requires the advertising to add a random delay to your advertising intervals(unless you are doing directed advertising(which is more complicated), for more details please see the Bluetooth Core Specification 5.2, Vol. 6, Part B, 4.4.2)).

    You may monitor the delays in various ways. Let us know what you want to do and we might be able to guide you in some way.

    Best Regards,

    Håkon

  • Hi, 

    Thanks for your reply. In my application, I want that in a period of 100ms, my device have to scan and advertise. So that I want to manage advertising and scanning time. Another question, I know that BLE spec requires a random delay, but how can we add that number? We use nrf_delay_ms or are there any APIs to do that for me?

    Thanks,

    Best regards,

  • Hi,

    The random delay is handled by the softdevice, so you only need to set the intervals and windows for scanning and advertising.

    I discussed this with a colleague and he suggested perhaps you could set the scan window the same as the scan interval, and not set the scan interval to big. Perhaps 50ms will be suitable. You could then set the advertising interval low, like 20ms. The power consumption will be high due to the long scan window.

    The scheduler will dedicate the whole interval for one activity, then it will dedicate the whole interval for the other activity. As mentioned, the random delay will be added automatically.

    If you want to investigate what is going on, you could monitor TX and RX by connecting IOs to an oscilloscope. You could also investigate the power consumption to see what is going on, for example with our Power Profiling Kit.

    Best Regards,

    Håkon

Reply
  • Hi,

    The random delay is handled by the softdevice, so you only need to set the intervals and windows for scanning and advertising.

    I discussed this with a colleague and he suggested perhaps you could set the scan window the same as the scan interval, and not set the scan interval to big. Perhaps 50ms will be suitable. You could then set the advertising interval low, like 20ms. The power consumption will be high due to the long scan window.

    The scheduler will dedicate the whole interval for one activity, then it will dedicate the whole interval for the other activity. As mentioned, the random delay will be added automatically.

    If you want to investigate what is going on, you could monitor TX and RX by connecting IOs to an oscilloscope. You could also investigate the power consumption to see what is going on, for example with our Power Profiling Kit.

    Best Regards,

    Håkon

Children
Related