arduino / arduino/ArduinoCore-API

BLE central API

Open
#7 41 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
306
Forks
150
PR merge metrics
No merged PRs in 30d

Description

Based on the outcome of the API meeting, I've added a first draft of a BLE central API in the [api/BLE/central](https://github.com/arduino/ArduinoCore-API/tree/master/api/BLE/central) folder.

It's probably best to review the examples in the following order:
- [scan.ino](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/examples/scan/scan.ino): Starts scanning for peripherals and prints out advertisement info. of discovered peripheral
- [scan_callback.ino](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/examples/scan_callback/scan_callback.ino): Similar to `scan.ino` but callback style
- [led_control.ino](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/examples/led_control/led_control.ino): Controls the LED on the [101 BLE LED example](https://github.com/01org/corelibs-arduino101/blob/master/libraries/CurieBLE/examples/LED/LED.ino) using a local button
- [sensortag_button.ino](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/examples/sensortag_button/sensortag_button.ino): Listens to simple key notifications from a TI SensorTag and prints out events to the serial monitor. Similar to Tom's [Node.js sensorTagSlideshow example](https://github.com/tigoe/BluetoothLE-Examples/tree/master/sensorTag/sensorTagSlideshow).
- [peripheral_explorer.ino](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/examples/peripheral_explorer/peripheral_explorer.ino): Connects to a peripheral and prints out it's services, characteristics, and descriptors. Similar to Tom's [Node.js exploreAsync example](https://github.com/tigoe/BluetoothLE-Examples/blob/master/noble/exploreAsync/explore.js).

Other item's to discuss:
1. Are there too many API's to access attributes of a peripheral? I've added a few to cater for various use cases, however I understand this might make documentation more difficult.
2. Is there a nicer way to handle reading and writing attributes with values (characteristics and descriptors). See [BLERemotePeripheralAttributeWithValue.h](https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/central/BLERemotePeripheralAttributeWithValue.h). Maybe we can re-use the [UDP](https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Udp.h) style, with `beginWrite`, `Print` API's, and `endWrite`.
3. Class names, they are long now, mostly to avoid clashes with the BLEPeripheral API. In case there are use cases for using both peripheral and central mode at the same time in the future.

cc/ @tigoe @damellis @cmaglie @agdl

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the draft in api/BLE/central and the examples in scan.ino, scan_callback.ino, led_control.ino, sensortag_button.ino, and peripheral_explorer.ino. Start by reading the examples and BLERemotePeripheralAttributeWithValue.h, then resolve the open API, attribute read/write, and class-naming questions. Done means the central API design is agreed and the draft reflects that decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.