diff --git a/README.md b/README.md index 11abbca..fdccba5 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ This project provides a simple library to implement *Human Interface Device* (**HID**) for *Bluetooth Low Energy* (**BLE**) on a Mbed stack using the *HID Over GATT Profile* (**HOGP**). -It was designed for the **Arduino nano 33 BLE** and tested with _GNU/Linux, Android 8.0, and Windows 10_. +It was designed for the **Arduino nano 33 BLE** and tested with _GNU/Linux, Android 8.0, iOS, and Windows 10_. ## Environment -On the Arduino IDE you will need the **Arduino mbed-enabled Boards** with version **1.3.1** or higher (In the menu bar click on "_Tools > Boards > Boards manager.._"). +On the Arduino IDE you will need the **Arduino Mbed X Boards** package, where *X* is the name of your board (eg. *OS Nano*), with version **2.0.0** ot higher (In the menu bar click on "_Tools > Boards > Boards manager.._"). -Alternatively you can use [platformio](https://github.com/platformio) [Deviot](https://github.com/platformio/Deviot). +Alternatively you can use [platformio](https://github.com/platformio) [Deviot](https://github.com/platformio/Deviot) [_Recommended_]. ## Getting started @@ -85,7 +85,7 @@ class SampleHID : MbedBleHID { // [ Add some fancy stuff here & there ] }; -SampleHID mySampleHID; +SampleHID sampleHID; ``` @@ -93,11 +93,11 @@ SampleHID mySampleHID; ### ble_mouse -This sample emulate a simple two-buttons mouse (motion and button states), using an `Arduino nano 33 BLE` and an `analog 2-axis joystick` with its X axis (*respectively Y*) set to analog input **6** (*respectively 7*) and its push button set to digital input **2**. +This sample emulate a simple two-buttons mouse (motion and button states), using an `Arduino nano 33 BLE` and an `analog 2-axis joystick` with its X axis (respectively Y) set to analog input *6* (respectively *7*) and its push button set to digital input *2*. -By default the sample is set to *demo mode* and will output random motions for a few seconds after pairing. +By default the sample is set to demo mode and will output random motions for a few seconds after pairing. -To disable *demo mode* you can set the macro definition **DEMO_ENABLE_RANDOM_INPUT** to 0. +To disable demo mode you can set the macro definition **DEMO_ENABLE_RANDOM_INPUT** to 0. ### ble_shining_kb diff --git a/library.properties b/library.properties index 37bf271..18f5d33 100644 --- a/library.properties +++ b/library.properties @@ -1,11 +1,11 @@ name=Mbed BLE HID -version=1.2.0 +version=1.3.0 author=Thibault Coppex maintainer=Thibault Coppex sentence=A Library to implement Human Interface Device with Bluetooth on a Mbed stack (Arduino Nano 33 BLE). paragraph=Provide ready to use HID (mouse, keyboard, gamepad) and customization classes. category=Communication url=https://github.com/tcoppex/mbed-ble-hid -architectures=mbed +architectures=mbed_nano, mbed includes=Mbed_BLE_HID.h, Nano33BleHID.h diff --git a/src/Mbed_BLE_HID.cpp b/src/Mbed_BLE_HID.cpp index 71f7151..337de3e 100644 --- a/src/Mbed_BLE_HID.cpp +++ b/src/Mbed_BLE_HID.cpp @@ -102,6 +102,9 @@ void MbedBleHID::postInitialization(BLE &ble) Gap &gap = ble.gap(); gap.setEventHandler(this); + // Allows the application to accept or reject a connection parameters update request. + gap.manageConnectionParametersUpdateRequest(true); + // GAP Advertising parameters. { using namespace ble; @@ -159,4 +162,24 @@ void MbedBleHID::onDisconnectionComplete(const ble::DisconnectionCompleteEvent & startAdvertising(); } +void MbedBleHID::onUpdateConnectionParametersRequest(const ble::UpdateConnectionParametersRequestEvent &event) +{ + // BLE::Instance().gap().acceptConnectionParametersUpdate( + // event.getConnectionHandle(), + // event.getMinConnectionInterval(), + // event.getMaxConnectionInterval(), + // event.getSlaveLatency(), + // event.getSupervisionTimeout() + // ); + + BLE::Instance().gap().rejectConnectionParametersUpdate( + event.getConnectionHandle() + ); +} + +void MbedBleHID::onConnectionParametersUpdateComplete(const ble::ConnectionParametersUpdateCompleteEvent &event) +{ + +} + /* -------------------------------------------------------------------------- */ diff --git a/src/Mbed_BLE_HID.h b/src/Mbed_BLE_HID.h index bcd71ce..bbe5c88 100644 --- a/src/Mbed_BLE_HID.h +++ b/src/Mbed_BLE_HID.h @@ -64,6 +64,12 @@ class MbedBleHID : Gap::EventHandler /** Callback when the ble device disconnected from another device. */ void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &event) override; + /** Callback when the peer request connection parameters updates. */ + void onUpdateConnectionParametersRequest(const ble::UpdateConnectionParametersRequestEvent &event) override; + + /** Callback when connection parameters have been updated. */ + void onConnectionParametersUpdateComplete(const ble::ConnectionParametersUpdateCompleteEvent &event) override; + protected: const std::string kDeviceName_; const std::string kManufacturerName_;