print("Hello, Pi Pico W!")
import sys
import bluetooth
import machine
import aioble
import uasyncio as asyncio
from micropython import const
def uid():
""" Return the unique id of the device as a string """
return "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}".format(
*machine.unique_id())
MANUFACTURER_ID = const(0x02A29)
MODEL_NUMBER_ID = const(0x2A24)
SERIAL_NUMBER_ID = const(0x2A25)
HARDWARE_REVISION_ID = const(0x2A26)
BLE_VERSION_ID = const(0x2A28)
led = machine.Pin("LED", machine.Pin.OUT)
_DEVICE_INFO_UUID = bluetooth.UUID(0x180A) # Device Information
_GENERIC = bluetooth.UUID(0x1848)
_BUTTON_UUID = bluetooth.UUID(0x2A6E)
_ROBOT = bluetooth.UUID(0x1800)
_BLE_APPEARANCE_GENERIC_REMOTE_CONTROL = const(384)
ADV_INTERVAL_MS = 250_000
device_info = aioble.Service(_DEVICE_INFO_UUID)
connection = None
# Create Characteristic for device info
aioble.Characteristic(device_info, bluetooth.UUID(MANUFACTURER_ID), read=True, initial="Infitech Robotics")
aioble.Characteristic(device_info, bluetooth.UUID(MODEL_NUMBER_ID), read=True, initial="1.0")
aioble.Characteristic(device_info, bluetooth.UUID(SERIAL_NUMBER_ID), read=True, initial=uid())
aioble.Characteristic(device_info, bluetooth.UUID(HARDWARE_REVISION_ID), read=True, initial=sys.version)
aioble.Characteristic(device_info, bluetooth.UUID(BLE_VERSION_ID), read=True, initial="1.0")
remote_service = aioble.Service(_GENERIC)
button_characteristic = aioble.Characteristic(
remote_service, _BUTTON_UUID, read=True, notify=True)
print("Registering services")
aioble.register_services(remote_service, device_info)
connected = False