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

ecg: handle ble inactive exception

parent 94cc9f71
Branches
Tags
1 merge request!493feat(ecg): Experimental streaming of ECG samples via BLE
......@@ -8,9 +8,9 @@ import math
import struct
import itertools
import bluetooth
from ecg.settings import *
import ecg.settings
config = ecg_settings()
config = ecg.settings.ecg_settings()
WIDTH = 160
HEIGHT = 80
......@@ -89,6 +89,7 @@ class ECG:
self.disp.backlight(0)
def __init__(self):
try:
self.b = bluetooth.BLE()
self.b.active(True)
self.b.irq(self.ble_irq)
......@@ -106,6 +107,9 @@ class ECG:
# Disable streaming by default
self.ble_streaming = False
self.b.gatts_write(self.ecg_cccd_handle, "\x00\x00")
except OSError:
self.ble_streaming = False
pass
leds.dim_top(1)
......@@ -169,15 +173,11 @@ class ECG:
def callback_ecg(self, datasets):
if self.ble_streaming:
# try:
if 1:
self.b.gatts_notify(
1,
self.ecg_data_handle,
struct.pack(">" + ("h" * len(datasets)), *datasets),
)
# except:
pass
# Don't update the screen if it should be off during a connection
if not config.get_option("BLE Disp"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment