Add GATT Peripheral example for Pico W

I've added a PR that demo the usage of Bluetooth for Embedded Swift. Adds a Pico W example to enable Bluetooth advertisements and GATT Peripheral functionality, advertising as an iBeacon in addition to its name and Bluetooth address. A custom GATT service and characteristic is exposed as read and write which toggles the GPIO LED state.

2 Likes

I had to deal with multiple obscure Swift compiler crashes and errors to get this working on the Pico W.

  • Synthesized Equatable conformance for enum with associated values (e.g. BluetoothUUID) somehow relies on String comparison and Unicode data tables. I made sure my code was not relying on Unicode and it turns out the synthesized code was emitting those dependencies. An explicit Equatable implementation or removing the protocol conformance fixes this.
  • A mutating subscript with private(set) just crashes the compiler at hasValidSignatureForEmbedded(). I had to change my subscript to a method.

When I have time I'll file the appropriate Swift bugs for these. @rauhul

3 Likes

Please do file issues for these 2 bugs! They are both extremely unexpected. cc @kubamracek

@rauhul @kubamracek

3 Likes