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 + "]" -
The error is probably in:
"lastcommand[" + lastcommand + "]"
Try:
"lastcommand[" + str(lastcommand) + "]"instead
-
Problem..solved due to your suggestion!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login