66
77
88def 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-
6895if __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