Hello,
I'm trying to make an app that will change the BLE name on command
this is what I have done:
then i get this exeption:
I'm trying to make an app that will change the BLE name on command
this is what I have done:
"""Example of how to create a Peripheral device/GATT Server""" " https://github.com/ukBaz/python-bluezero/issues " # Standard modules import sys sys.stdout.flush() import logging import random # Bluezero modules from bluezero import async_tools from bluezero import adapter from bluezero import peripheral from bluezero import dbus_tools from bluezero import constants from bluezero import eddystone_beacon from gpiozero import CPUTemperature # websocket import time import asyncio import websockets def ChangeBLE(adapter_address, Sample): try: Unit_Name = peripheral.Peripheral(adapter_address, local_name=Sample, appearance=1344) except Exception as e : print(e) else: print('Change the name to : ', Sample) async def BLEServer(websocket, path): NewName= await websocket.recv() print('New Data is ' + NewName) ChangeBLE(MAC_Addresss, NewName) print('finsih changing') await asyncio.sleep(5) print ('BLE App in now UP - can start searching for me :-) ') MAC_Addresss = list(adapter.Adapter.available())[0].address print('Device MAC is ' + MAC_Addresss) start_server = websockets.serve(BLEServer, '192.168.20.0.100',123456) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever()it's only working for the first time I get a websocket
then i get this exeption:
pi@raspberrypi:~ $ sudo python3 BlueTooth/BLE_Line.py BLE App in now UP - can start searching for me :-) Device MAC is DC:A6:32:75:54:15 New Data is hello Change the name to: hello finsih changing New Data is Alfred "Can't register the object-path handler for '/ukBaz/bluezero': there is already a handler" finsih changing New Data is Danny "Can't register the object-path handler for '/ukBaz/bluezero': there is already a handler" finsih changing New Data is Test "Can't register the object-path handler for '/ukBaz/bluezero': there is already a handler" finsih changingcan someone help me understand the problem?