tryna get bluetooth to work

This commit is contained in:
2026-03-07 09:15:45 +11:00
parent b19ad3ce82
commit 0f6cdabd25
4 changed files with 22 additions and 2 deletions

View File

@@ -24,16 +24,23 @@ class BluetoothHandler:
self.ble.active(True)
self.ble.irq(self.irq)
self.mac_address = self._get_mac_address()
print(f"Mac Address: {self.mac_address}")
((self.tx_handle, self.rx_handle),) = self.ble.gatts_register_services((SERVICE,))
self.connections = set()
self.advertise()
def _get_mac_address(self):
mac = self.ble.config("mac")[1]
return ':'.join('{:02X}'.format(b) for b in mac)
def advertise(self):
print("Advertising Bluetooth...")
# note: \x02\x01\x06\x0C\x09 is the BLE header that tells other devices we're BLE only and discoverable
self.ble.gap_advertise(100_000, b"\x02\x01\x06\x0C\x09MeshConnectorNode")
self.ble.gap_advertise(100_000, b"\x02\x01\x06\x0C\x09NODE-" + self.mac_address.encode())
def irq(self, event, data):
print(f"BLUETOOTH IRQ | EVENT: {event}, DATA: {data}")

View File

@@ -15,7 +15,9 @@ def main():
if LORA_ENABLED:
lora_handler = LoRaHandler()
print("Halting Pico...")
while True:
pass
if __name__ == "__main__":