Skip to content
Snippets Groups Projects
Commit 66a27534 authored by schneider's avatar schneider
Browse files

ecg: Add 16 bit sample counter to BLE stream

parent b9f35c42
No related branches found
No related tags found
No related merge requests found
...@@ -25,3 +25,5 @@ ECG samples characteristic ...@@ -25,3 +25,5 @@ ECG samples characteristic
List of 16 bit samples (big endian). Enable notifications to List of 16 bit samples (big endian). Enable notifications to
receive a stream of samples while the ECG app is open. receive a stream of samples while the ECG app is open.
The first 16 bit are a sample counter (big endian).
...@@ -85,6 +85,7 @@ class ECG: ...@@ -85,6 +85,7 @@ class ECG:
self.disp.backlight(20) self.disp.backlight(20)
else: else:
self.ble_streaming = True self.ble_streaming = True
self.ble_sample_count = 0
if not config.get_option("BLE Disp"): if not config.get_option("BLE Disp"):
self.disp.backlight(0) self.disp.backlight(0)
...@@ -173,10 +174,12 @@ class ECG: ...@@ -173,10 +174,12 @@ class ECG:
def callback_ecg(self, datasets): def callback_ecg(self, datasets):
if self.ble_streaming: if self.ble_streaming:
self.ble_sample_count += len(datasets)
self.b.gatts_notify( self.b.gatts_notify(
1, 1,
self.ecg_data_handle, self.ecg_data_handle,
struct.pack(">" + ("h" * len(datasets)), *datasets), struct.pack(">h", self.ble_sample_count & 0xFFFF)
+ struct.pack(">" + ("h" * len(datasets)), *datasets),
) )
# Don't update the screen if it should be off during a connection # Don't update the screen if it should be off during a connection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment