How to Use Timeslots and Radio HAL to Send Time-Sync Packets in Mesh

Application Info:

I am working on developing a synchronized mesh network of low power sensors. I am trying to maintain an average power consumption of 100's of µW while still broadcasting data about once every 5 minutes and going to sleep. To be able to realize this I need some high-resolution (<10µs) time synchronization which will be updated frequently. For now I am starting with a single-hop time-sync protocol which I will later expand, but I need a foundation. I'm using an nrf52840 with the S140 soft device.
SDK v16.0.0
MESH v3.2.0

What I want to do:

I am attempting to write a piece of firmware such that I can:

  • Send hf-clock value right when I capture it (or with reliable delay)
  • Send this message only as single-hop (TTL = 1)
  • Take advantage of mesh features like encryption, opcodes, and addressing (virtual, group, etc..)
  • Be able to capture the hf-clock value at this message's time of arrival on receiving end

What I think I should do:

From my investigation into the problem I have been convinced that I need to use the timeslot api to be able to send a ble packet with reliable time-delay. In order to minimize the time delay and also in interest of consistency, I wish to use the Radio HAL api to be able to trigger a tx task on an event. Before I can send this message as a mesh message I need to construct my message with the relevant metadata (destination address, source address, TTL, keys, etc.) Then I should encrypt the message (assuming no segmentation is needed) and then use this encrypted payload as my tx-data for my manual radio transmission.

I found this blog post, which has greatly helped me understand what must go into a good time-sync protocol in the case of BLE, but I am having great difficulty figuring out how to translate it usefully to Mesh. I'm not sure how my choice of bearer (ADV) affects the formatting of the message, or how I should go about encrypting my payload. I am not an experienced developer, and have even less experience in BT/Mesh but I am determined to finding a solution. I would also like advise on improving my approach to solving this problem.

Parents Reply Children