Skip to content

Commit

Permalink
Start advertising again when connection lost
Browse files Browse the repository at this point in the history
  • Loading branch information
furbrain committed Nov 9, 2024
1 parent dbb513f commit b07af79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions firmware/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def bt_connection_monitor(self):
while True:
await asyncio.sleep(0.5)
self.display.set_bt_connected(self.devices.bt.connected)
self.devices.bt.advertise_if_idle()
self.display.set_bt_pending_count(self.devices.bt.pending_count())

async def bt_quit_now(self):
Expand Down
7 changes: 5 additions & 2 deletions firmware/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ def __init__(self):
logger.debug(self.ble.connections)
self.ble.name = version.get_short_name()
logger.debug(f"BLE name is {self.ble.name}")
self.advertise_if_idle()

def advertise_if_idle(self):
if not self.ble.connected and not self.ble.advertising:
if sys.platform=='nRF52840':
if sys.platform == 'nRF52840':
logger.debug("BLE advertising high power")
self.ble._adapter.start_advertising(bytes(self.advertisement),tx_power=8)
self.ble._adapter.start_advertising(bytes(self.advertisement), tx_power=8)
else:
logger.debug("BLE advertising")
self.ble.start_advertising(BluetoothServices.advertisement)
Expand Down

0 comments on commit b07af79

Please sign in to comment.