bristlemouth / bm_protocol

Primary Bristlemouth firmware repository
https://www.bristlemouth.org/
Apache License 2.0
10 stars 7 forks source link

Fix/node position #104

Closed victorsowa12 closed 4 months ago

victorsowa12 commented 4 months ago

I recently updated the Node position code such that it only updates every once in a while. What I forgot is that the softSubCallback function is a static function and therefore called by all SoftSensor class objects. I had made the node_position variable a static variable within the softSubCallback thinking that each class object had its own softSubCallback. But what this really meant was that the node_position for one node was being used by every node. So in this PR I made the node_position and last_timestamp part of the Soft_t, RbrCoda_t, and Aanderaa_t classes so that each subscription tracks its own data.

Here is an example of lines in a log captured during a test where we have a node_position for one node override every other nodes positions:

48d57401250b4d7c,1,soft,678,0.000,0.000,22.351
246f92446ac231c3,2,soft,673,0.000,0.000,22.356
48d57401250b4d7c,2,soft,1198,0.000,0.000,22.351
246f92446ac231c3,2,soft,1193,0.000,0.000,22.356
48d57401250b4d7c,2,soft,1718,0.000,0.000,22.351
246f92446ac231c3,2,soft,1713,0.000,0.000,22.356
48d57401250b4d7c,2,soft,2238,0.000,0.000,22.351
246f92446ac231c3,2,soft,2233,0.000,0.000,22.356
48d57401250b4d7c,2,soft,2758,0.000,0.000,22.351
246f92446ac231c3,2,soft,2753,0.000,0.000,22.356
48d57401250b4d7c,2,soft,3278,0.000,0.000,22.351
246f92446ac231c3,2,soft,3273,0.000,0.000,22.356
48d57401250b4d7c,2,soft,3798,0.000,0.000,22.351
29bdebdc1e7268a2,4,soft,3798,0.000,0.000,22.337
497cd89f0feecac3,3,soft,3798,0.000,0.000,22.335
246f92446ac231c3,3,soft,3793,0.000,0.000,22.356
48d57401250b4d7c,3,soft,4318,0.000,0.000,22.351
29bdebdc1e7268a2,3,soft,4318,0.000,0.000,22.337

Here is an example of it working after these changes: We get the node_position on the first sample for both nodes and we can see in the following lines that the node_positions stay 1 and 2 for the respective nodes.

Screenshot 2024-03-07 at 2 22 59 PM

Here we can see after I unplugged the nodes from the bridge that we detect a time difference of > 500ms and we update the node positions.

Screenshot 2024-03-07 at 2 22 13 PM

https://app.shortcut.com/sofar/story/199921/node-position-sticks-between-sensors