Unhandled exception in callback handler using Bluetooth



  • Hi, I'm trying to send data via Bluetooth from a mobile device to my wipy board, this has been working for a while, but upon updating to the latest firmware I now get the following error when writing a value to a characteristic

    Unhandled exception in callback handler
    TypeError: function takes 1 positional arguments but 2 were given
    

    This is the version:

    Pycom MicroPython 1.20.2.rc6 [v1.11-01f49f7] on 2020-02-28; WiPy with ESP32
    

    This is the code:

    bluetooth.init()
        bluetooth.set_advertisement(name="Client_Name", service_uuid=serUUID)
        bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
        bluetooth.advertise(True)
        srv = bluetooth.service(uuid=serUUID, isprimary=True, nbr_chars=1)
        chr1 = srv.characteristic(uuid=ssidUUID, properties=Bluetooth.PROP_READ | Bluetooth.PROP_WRITE, value='None')
        chr1.callback(trigger=Bluetooth.CHAR_WRITE_EVENT, handler=char1_cb)
    

    And the callback is:

    def char1_cb(chr):
        print(chr)
    

    Thanks

    Lloyd



  • @aasodisen Add a second argument, e.g.

    def char1_cb(chr, arg1=None):
        print(chr)
    

    This should work.

    Best regards



  • @Lloydy Same in using GPY


Log in to reply
 

Pycom on Twitter