-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
Hello,
I am running this code on my peripheral that sends battery level periodically. But I am not able to get it.
A simple read_val also does not work. Please help.
Ubuntu 18.04
import gatt
from argparse import ArgumentParser
class AnyDevice(gatt.Device):
def services_resolved(self):
super().services_resolved()
battery_information_service = next(
s for s in self.services
if s.uuid == '00001801-0000-1000-8000-00805f9b34fb')
for c in battery_information_service.characteristics:
c.enable_notifications(True)
print("Reading Battery")
def characteristic_value_updated(self, characteristic, value):
print("Battery level:", value.decode("utf-8"))
arg_parser = ArgumentParser(description="GATT Read Firmware Version Demo")
arg_parser.add_argument('mac_address', help="MAC address of device to connect")
args = arg_parser.parse_args()
manager = gatt.DeviceManager(adapter_name='hci0')
device = AnyDevice(manager=manager, mac_address=args.mac_address)
device.connect()
manager.run()
Metadata
Metadata
Assignees
Labels
No labels