You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
Activity
abhatikar commentedon Jan 30, 2021
Please let me know if I am missing something
abhatikar commentedon Jan 30, 2021
gatttool utility seems to work. Please help how to use this library. Thanks in advance,
[-]read characteristic[/-][+]read characteristic value[/+]retorik commentedon Jul 27, 2021
Hi, same issue for me ! Have you found a solution ? Thx Jeremy
abhatikar commentedon Jul 27, 2021
I didn't use the gatt-python. I wrote a C application to interact with BLE device.