Skip to content

Commit 4ea80a3

Browse files
committed
Merge branch 'master' of https://github.com/lab11/socitrack
2 parents 5de2277 + c2fb579 commit 4ea80a3

2 files changed

Lines changed: 41 additions & 7 deletions

File tree

software/firmware/tests/peripherals/test_ranging_radio.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,19 @@ void delayed_write_test(void)
7474
assert(dwt_starttx(DWT_START_TX_DELAYED) == DWT_SUCCESS);
7575

7676
// Sleep for 5 seconds
77-
am_hal_delay_us(5000000);
77+
am_hal_delay_us(1000000);
7878
}
7979

80-
void read_test(void)
80+
void read_test(int antenna, int channel)
8181
{
82+
printf("read_test, antenna %d (%s), channel (%d)\n",
83+
antenna,
84+
antenna == 0 ? "left" : antenna == 1 ? "top" : "right",
85+
channel);
86+
8287
// Enable packet reception
83-
ranging_radio_choose_antenna(0);
84-
ranging_radio_choose_channel(5);
88+
ranging_radio_choose_antenna(antenna);
89+
ranging_radio_choose_channel(channel);
8590
ranging_radio_rxenable(DWT_START_RX_IMMEDIATE);
8691

8792
// Sleep for 60 seconds
@@ -104,7 +109,9 @@ int main(void)
104109
//regular_sleep_test();
105110
//deep_sleep_test();
106111
//delayed_write_test();
107-
read_test();
112+
read_test(0, 5);
113+
read_test(1, 5);
114+
read_test(2, 5);
108115
}
109116

110117
// Should never reach this point

software/management/dashboard/parse.py

100644100755
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,34 @@
66

77

88
def process_tottag_data(data, experiment_start_time):
9+
"""
10+
Parses and processes raw binary data read from .ttg files.
11+
The processed sensor log is saved to a file named 'converted.pkl'.
12+
IMU data is currently skipped.
13+
14+
Parameters:
15+
data (bytes): Raw binary byte stream read from .ttg files.
16+
experiment_start_time (float): 10-digit Unix timestamp (in seconds).
17+
18+
Returns:
19+
List[dict]: A list of timestamped dict of data. Each dictionary has:
20+
- 't': Absolute timestamp (float)
21+
- 'v' (Voltage):
22+
Indicates the battery voltage of the device in millivolts.
23+
- 'c' (Charging Event):
24+
Encodes battery charging status as one of several predefined states, such as
25+
charging, full, or discharging. The values are mapped via `BATTERY_CODES`.
26+
- 'm' (Motion):
27+
A boolean value indicating whether motion was detected at the time.
28+
`True` means motion is detected; `False` indicates stillness.
29+
- 'r' (Ranges):
30+
A dictionary mapping device UIDs (unique IDs) to measured distances (in millimeters).
31+
These distances represent proximity to neighboring devices. Only values.
32+
below `MAX_RANGING_DISTANCE_MM` are included.
33+
- 'b' (BLE Scan Results):
34+
A list of device UIDs detected during a Bluetooth Low Energy scan. These IDs represent.
35+
nearby TotTags.
36+
"""
937
i = 0
1038
log_data = defaultdict(dict)
1139
while i + 5 < len(data):
@@ -64,7 +92,6 @@ def process_tottag_data(data, experiment_start_time):
6492
pickle.dump(log_data, file, protocol=pickle.HIGHEST_PROTOCOL)
6593
return log_data
6694

67-
6895
if __name__ == "__main__":
6996

7097
if len(sys.argv) != 3:
@@ -73,4 +100,4 @@ def process_tottag_data(data, experiment_start_time):
73100

74101
experiment_start_time = int(sys.argv[2])
75102
with open(sys.argv[1], mode="rb") as file:
76-
process_tottag_data(file.read(), experiment_start_time)
103+
process_tottag_data(file.read(), experiment_start_time)

0 commit comments

Comments
 (0)