BLE Error



  • Why would i be getting error on BLUE callack as below...

    Unhandled exception in callback handler
    Traceback (most recent call last):
    File "main.py", line 202, in char1_cb_handler
    TypeError: unsupported types for add: 'str', 'bytes'

    def char1_cb_handler(chr):
    logger("BLEADVERTISE::Read\Write request...")    
    global char1_read_counter
    global c_ssid
    global c_pwd
    global devicename
    global lastcommand
    events = chr.events()
    if  events & Bluetooth.CHAR_WRITE_EVENT:
        print("Write request[",char1_read_counter,"] with value = ",chr.value())
        if char1_read_counter==0:
            devicename=chr.value()
        elif char1_read_counter==1:
            c_ssid=chr.value()
        elif char1_read_counter==2:
            c_pwd=chr.value()
        elif char1_read_counter==5:
            lastcommand=chr.value()
            commander(chr.value().decode('utf-8'))
    else:
        char1_read_counter += 1
        if char1_read_counter > 5:
            char1_read_counter=0
        if char1_read_counter==0:
            return "devicename[" + devicename + "]"
        elif char1_read_counter==1:
            return "ssid[" + c_ssid + "]"
        elif char1_read_counter==2:
            return "pwd[" + c_pwd + "]"
        elif char1_read_counter==3:
            return "pwd[" + c_pwd + "]"
        elif char1_read_counter==4:
            if wl.isconnected():
                return "IP[" + wl.ifconfig()[0] + "]"  
            else:
                return "not connected"  #LINE 202 ERROR AS ABOVE
        elif char1_read_counter==5:
            return "lastcommand[" + lastcommand	+ "]"


  • Problem..solved due to your suggestion!



  • @misterlisty

    The error is probably in:

    "lastcommand[" + lastcommand + "]"

    Try:

    "lastcommand[" + str(lastcommand) + "]"

    instead


Log in to reply
 

Pycom on Twitter