mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-03-24 07:00:48 +00:00
organize and improve examples
This commit is contained in:
@@ -10,6 +10,7 @@ class NotificationListener:
|
||||
BATTERY_UPDATED = 0x01
|
||||
ANC_UPDATED = 0x02
|
||||
EAR_DETECTION_UPDATED = 0x03
|
||||
UNKNOWN = 0x00
|
||||
|
||||
def __init__(self, socket: BluetoothSocket, callback: callable):
|
||||
self.socket = socket
|
||||
@@ -25,11 +26,14 @@ class NotificationListener:
|
||||
break
|
||||
if self.BatteryNotification.isBatteryData(data):
|
||||
self.BatteryNotification.setBattery(data)
|
||||
self.callback(self.BATTERY_UPDATED)
|
||||
self.callback(self.BATTERY_UPDATED, data)
|
||||
pass
|
||||
if self.EarDetectionNotification.isEarDetectionData(data):
|
||||
self.EarDetectionNotification.setEarDetection(data)
|
||||
self.callback(self.EAR_DETECTION_UPDATED)
|
||||
self.callback(self.EAR_DETECTION_UPDATED, data)
|
||||
else:
|
||||
self.callback(self.UNKNOWN, data)
|
||||
pass
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class Notifications:
|
||||
BATTERY_UPDATED = NotificationListener.BATTERY_UPDATED
|
||||
ANC_UPDATED = NotificationListener.ANC_UPDATED
|
||||
EAR_DETECTION_UPDATED = NotificationListener.EAR_DETECTION_UPDATED
|
||||
|
||||
UNKNOWN = NotificationListener.UNKNOWN
|
||||
def __init__(self, socket: bluetooth.BluetoothSocket, callback: callable):
|
||||
self.socket = socket
|
||||
self.notificationListener = NotificationListener(self.socket, callback)
|
||||
|
||||
Reference in New Issue
Block a user