avoid "Already advertising" error

This commit is contained in:
yswallow 2022-03-18 02:57:35 +09:00 committed by Kyle Brown
parent 1a7d1d53f6
commit d12f9a18f1

View File

@ -314,10 +314,11 @@ class BLEHID(AbstractHID):
_bleio.adapter.erase_bonding() _bleio.adapter.erase_bonding()
def start_advertising(self): def start_advertising(self):
advertisement = ProvideServicesAdvertisement(self.hid) if not self.ble.advertising:
advertisement.appearance = self.BLE_APPEARANCE_HID_KEYBOARD advertisement = ProvideServicesAdvertisement(self.hid)
advertisement.appearance = self.BLE_APPEARANCE_HID_KEYBOARD
self.ble.start_advertising(advertisement) self.ble.start_advertising(advertisement)
def stop_advertising(self): def stop_advertising(self):
self.ble.stop_advertising() self.ble.stop_advertising()