diff --git a/preload/apps/ecg/__init__.py b/preload/apps/ecg/__init__.py index 43eed2d6715b5d2db066ba6e71b329e8477eaaab..b9bad34dba7f9cc7f36b63cc35ff2a3e8867b5a8 100644 --- a/preload/apps/ecg/__init__.py +++ b/preload/apps/ecg/__init__.py @@ -177,13 +177,18 @@ class ECG: def callback_ecg(self, datasets): if self.ble_streaming: + try: + self.b.gatts_notify( + 1, + self.ecg_data_handle, + struct.pack(">h", self.ble_sample_count & 0xFFFF) + + struct.pack(">" + ("h" * len(datasets)), *datasets), + ) + except OSError: + pass + + # We count all samples, even if we failed to send them self.ble_sample_count += len(datasets) - self.b.gatts_notify( - 1, - self.ecg_data_handle, - 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 if not config.get_option("BLE Disp"):