NordicPlayground / nRF51-ble-bcast-mesh

Other
324 stars 121 forks source link

How does a node with BLE_Gateway example actually rebroadcast data? #87

Closed rifatmahmud closed 7 years ago

rifatmahmud commented 8 years ago

When handle value is updated in mesh_gatt service, I see a call to vh_local_update. I assume, this broadcast the incoming data to mesh.

But, on main.c of BLE_Gateway example, I can't see any call to rbc_mesh_value_set on new value or update value events.

To rebroadcast the incoming data(updated via both gatt service or mesh itself), should I call the function rbc_mesh_value_set on new value and updated value events?

trond-snekvik commented 8 years ago

The GATT-service sort of sneaks in the backdoor. The gatt-module works alongside rbc_mesh_value_set, but doesn't use it directly. This is to get an event back to the application that something happened, and still get the version++ thing done in vh_local_update. From the application's point of view, getting an update over gatt is the same as getting it over the mesh - it's already in the system, being retransmitted by the time you get the event - you don't have to do anything :) From the version-handler's point of view, the gatt-update is the same as getting an update from the application.

rifatmahmud commented 8 years ago

Thanks for the response Can you please point to the code where this is happening.(Rebroadcasting after update from mesh). I need to make some changes there? Thank you again. :)

trond-snekvik commented 8 years ago

Depending on which functionality you want to alter, the local update triggers two code paths: First, the cache-task to just store the new value, to make it eligible for retransmissions, then the retransmit-code triggering on timeouts, to push the data to the radio. The second code path does not differentiate between local updates and mesh updates - it just reads out timeout-values and packets from the cache and sends all packets that should have been retransmitted at the current timestamp (or earlier).