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

How does the Mesh SDK use the Timeslot API through advertising & scanning interval?

Hi guys,

I'm struggling over some basic concepts related to the Mesh SDK, specifically with the Bearer layer and why the Mesh SDK uses the Timeslot API. I'll try to explain what's not clear to me below.

  • Why does the Mesh SDK use the TimeSlot API? : As I understand from the documentation, this is to be able to talk with non-BLE devices while also being able to support Mesh SDK in the same application. In the long run, this is handy to give support for the GATT bearer. I'm not really sure if the Mesh SDK itself uses other code from inside the SoftDevice to offer concepts as advertising, scanning ... or if the Mesh stack implements this in his own way, using the resources becoming available for use via the TimeSlot API (Radio, Timer, etc.)?
  • Why do advertiser.c and scanner.c still need advertising & scanner interval respectively? : It's also not fully clear to me why these two still need such intervals if they clearly are not used. I tried setting both of them pretty high but I don't see any significant timing changes in measuring the communication in my mesh network.

Specifically in advertiser.c, I see that sending a packet is done via the method schedule_first_time(timer_event_t * p_timer_evt, uint32_t max_delay), where the second parameter is set with the advertisement interval. In the method itself, it seems that a kind of random back-off mechanism is used to schedule the packet to be send over the radio (probably to try and avoid collisions) and that the advertising interval or thus max_delay is used as modulus (upper limit, or thus maximum delay for the packet to be send). Is this the only way the advertising interval is being used (and thus not in the way normal BLE uses it)?

Specifically in scanner.c, here it seems that scan interval & window are being used as they are in normal BLE. But I don't understand how this is possible, if the TimeSlot API is being used. Because then for example continuous scanning isn't possible because you don't always have a timeslot? Or is the SoftDevice itself used for scanning (without TimeSlot API)?

Thank you in advance.

Kind regards,

Mathias

  • Hi Mathias,

    1 . Currently Mesh stack requires the Timeslot mechanism from softdevice to work. However, there is no BLE function from the softdevice is needed or used. So actually requesting and staying in timeslot is the main state (99% if not 100% of the time) of the Mesh device.

    The main purpose of using timeslot is to support GATT bearer in the future as well as other applications that requires BLE. I don't think supporting "non-BLE devices while also being able to support Mesh SDK" is the main purpose, even though it's possible. Could you point me to the documentation you got that information ?

    Mesh SDK doesn't use any BLE feature from the softdevice for advertising and scanning.

    2 .Why do you think advertising interval is not needed ? This interval decide how often a node broadcast a message. By spec there shouldn't be more than 100 messages per 10 seconds.

    Same with scan interval and scan windows. By default scan window = scan interval (continuous scanning, except when advertising), however it's possible to change that using the configuration so that we can do something else with the radio or to save power consumption.

    If the timeslot can't be guaranted at 100% (because we have normal BLE application for example) I believe the scheduler will simply won't schedule the scan window for that period.

    1. Sorry, I meant non-BLE mesh applications or thus normal BLE applications. For example being able to be both a BLE beacon and a node in a mesh at the same time.

    2. For normal BLE this is indeed needed, as I understand. But does the mesh stack also use these intervals? Or is it just via timeslots? And thus scanning being done at 100 % as long as timeslot is not done? And advertising being done as soon as a timeslot is allocated to advertise the message?

    Thank you for your time!

  • 1 . Yes, correct. However in our beacon example in the Mesh SDK, we also don't use the Softdevice advertising function, but advertise directly using the Radio, inside timeslot.

    2 . Yes the mesh stack use those interval. You can think of timeslot is the normal state, and the mesh stack running inside that state 99% (maximum timeslot can be extended to is 10seconds I believe, then the Mesh will request another timeslot right after). I don't know how exactly the scheduler works with Mesh SDK but my understanding is that the scheduler will prioritize advertising over scanning and scheduler will not schedule scanner period if it collides with advertising period.

    1. Ok, I understand.
    2. Aha, so if I understand correctly, I can actually "forget" that the concept of timeslots is being used underlying as long as I only do mesh operation, because then the timeslots will always be granted and for the longest period (10 seconds then as you say)? And then just view the mesh communication like advertising & scanning in normal BLE (thus with advertising interval, scanning interval and scan window) but then with the scheduler prioritizing advertising over scanning if they should collide and advertising should take place in that advertising event?

    Thank you!

  • It's just that in the bearer layer libraries, specifically in the advertiser.h file, I can see the method "schedule_first_time" being used by the light_switch_example. And in there, I see that a kind of offset value (after which sending starts?) is calculated randomly, bordered by the advertisement interval? But I don't understand how this compares to normal BLE advertising?

Related