version 3 final working real BT
This commit is contained in:
parent
2970ad4c5a
commit
67fa1d6288
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
> vite
|
> vite
|
||||||
|
|
||||||
|
|
||||||
VITE v7.1.10 ready in 216 ms
|
VITE v7.1.10 ready in 107 ms
|
||||||
|
|
||||||
➜ Local: http://localhost:5173/
|
➜ Local: http://localhost:5173/
|
||||||
➜ Network: use --host to expose
|
➜ Network: use --host to expose
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Port 5173 is in use, trying another one...
|
Port 5173 is in use, trying another one...
|
||||||
|
|
||||||
VITE v7.1.10 ready in 218 ms
|
VITE v7.1.10 ready in 110 ms
|
||||||
|
|
||||||
➜ Local: http://localhost:5174/
|
➜ Local: http://localhost:5174/
|
||||||
➜ Network: use --host to expose
|
➜ Network: use --host to expose
|
||||||
|
|||||||
@ -1,133 +0,0 @@
|
|||||||
✓ Loaded configuration from wristband_config.yaml
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
VitalLink System Initialization
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
✓ Backend is running at http://localhost:8000
|
|
||||||
➕ Added real band VitalLink-5CB3 (BLE: CF:1C:C7:CB:5C:B3)
|
|
||||||
➕ Added real band VitalLink-REAL2 (BLE: CF:1C:C7:CB:5C:B5)
|
|
||||||
➕ Added simulated band MOCK-SIM1 (stable)
|
|
||||||
➕ Added simulated band MOCK-SIM2 (mild_anxiety)
|
|
||||||
➕ Added simulated band MOCK-SIM3 (deteriorating)
|
|
||||||
➕ Added simulated band MOCK-SIM4 (sepsis)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
WRISTBAND INVENTORY
|
|
||||||
================================================================================
|
|
||||||
🔵 VitalLink-5CB3 | AVAILABLE
|
|
||||||
🔵 VitalLink-REAL2 | AVAILABLE
|
|
||||||
🟢 MOCK-SIM1 | AVAILABLE
|
|
||||||
🟢 MOCK-SIM2 | AVAILABLE
|
|
||||||
🟢 MOCK-SIM3 | AVAILABLE
|
|
||||||
🟢 MOCK-SIM4 | AVAILABLE
|
|
||||||
================================================================================
|
|
||||||
Total: 6 | Real: 2 | Simulated: 4 | Active: 0
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
VitalLink System Running
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
✓ Monitoring for new patients from kiosk check-ins
|
|
||||||
✓ Auto-assigning wristbands (prefer real: False)
|
|
||||||
|
|
||||||
Press Ctrl+C to stop
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
🔍 Monitoring for new patient check-ins...
|
|
||||||
[Status] Active: 0 monitoring | Available: 6 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 0 monitoring | Available: 6 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 0 monitoring | Available: 6 bands | Real: 2 | Sim: 4
|
|
||||||
|
|
||||||
🆕 New patient detected: P100001 (abc abc)
|
|
||||||
✓ VitalLink-5CB3 assigned to patient P100001
|
|
||||||
✓ Assigned VitalLink-5CB3 (real)
|
|
||||||
🔵 Connecting to real wristband VitalLink-5CB3 at CF:1C:C7:CB:5C:B3...
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
❌ Failed to connect to VitalLink-5CB3: Device with address CF:1C:C7:CB:5C:B3 was not found.
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
[Status] Active: 1 monitoring | Available: 5 bands | Real: 2 | Sim: 4
|
|
||||||
Binary file not shown.
@ -160,22 +160,54 @@ class RealWristband(BaseWristband):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client = BleakClient(self.ble_address)
|
self.client = BleakClient(self.ble_address, timeout=20.0)
|
||||||
await self.client.connect()
|
await self.client.connect()
|
||||||
|
|
||||||
|
if not self.client.is_connected:
|
||||||
|
raise Exception("Connection failed")
|
||||||
|
|
||||||
print(f"✓ Connected to {self.band_id}")
|
print(f"✓ Connected to {self.band_id}")
|
||||||
|
|
||||||
|
# Subscribe to notifications
|
||||||
await self.client.start_notify(CHAR_UUID, self._notification_handler)
|
await self.client.start_notify(CHAR_UUID, self._notification_handler)
|
||||||
print(f"✓ Subscribed to notifications from {self.band_id}")
|
print(f"✓ Subscribed to notifications from {self.band_id}")
|
||||||
|
|
||||||
|
# CRITICAL: Keep connection alive!
|
||||||
|
print(f" Monitoring {self.band_id}... (will stay connected)")
|
||||||
|
while self.client.is_connected and self.status == WristbandStatus.IN_USE:
|
||||||
|
await asyncio.sleep(1.0) # Keep alive loop
|
||||||
|
|
||||||
|
print(f" Connection to {self.band_id} closed")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Failed to connect to {self.band_id}: {e}")
|
print(f"❌ Error with {self.band_id}: {e}")
|
||||||
|
print(f" Type: {type(e).__name__}")
|
||||||
|
print(f" Details: {str(e)}")
|
||||||
self.status = WristbandStatus.MAINTENANCE
|
self.status = WristbandStatus.MAINTENANCE
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# Clean disconnect
|
||||||
|
if self.client and self.client.is_connected:
|
||||||
|
try:
|
||||||
|
await self.client.stop_notify(CHAR_UUID)
|
||||||
|
await self.client.disconnect()
|
||||||
|
print(f" Disconnected from {self.band_id}")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def _notification_handler(self, sender, data: bytearray):
|
def _notification_handler(self, sender, data: bytearray):
|
||||||
decoded = self.decoder.decode(bytes(data))
|
decoded = self.decoder.decode(bytes(data))
|
||||||
if decoded:
|
if decoded:
|
||||||
self.last_packet = decoded
|
self.last_packet = decoded
|
||||||
self.packet_count += 1
|
self.packet_count += 1
|
||||||
|
|
||||||
|
# Print to console (for debugging)
|
||||||
|
print(
|
||||||
|
f"🔵 [{self.band_id}] Packet #{self.packet_count}: "
|
||||||
|
f"HR={decoded['hr_bpm']} SpO2={decoded['spo2']}% "
|
||||||
|
f"Temp={decoded['temp_c']:.1f}°C"
|
||||||
|
)
|
||||||
|
|
||||||
asyncio.create_task(self._send_to_backend(decoded))
|
asyncio.create_task(self._send_to_backend(decoded))
|
||||||
|
|
||||||
async def _send_to_backend(self, decoded: dict):
|
async def _send_to_backend(self, decoded: dict):
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user