How to notify other BLE devices from Wipy



  • I have a bluetooth device to which I need to send notification.

    I have connected to a particular service and listed all the characteristic of that service.

    chars = service.characteristics()
    for char in chars:
    if (char.properties() & Bluetooth.PROP_READ):
    print('char if {} value = {}'.format(char.uuid(), char.read()))
    if (char.properties() and Bluetooth.PROP_NOTIFY):
    Need to send notification in this part
    char.write("b'\x01\x18'")

    I would like to know how to notify a device. When using .write I am getting an OSError.

    OSError: the requested operation failed



  • @jmahesh
    You are connecting to GATT Server as client, so what you can do is request the server send you notifications. You can't send notifications as a client. Bluetooth.PROP_NOTIFY means you can request notifications on that characteristic.

    I'm guessing that characteristic is not writable (read only) hence you get that error?

    If what you want is to be notified by the Server (e.g. when the value changes) use the char.callback(trigger=Bluetooth.CHAR_NOTIFY_EVENT, handler=YourHandlerFunct, arg=YourOptionalArgument)


 

Pycom on Twitter