Skip to content

Commit

Permalink
Merge pull request #12 from tcoppex/bug-ios-pairing
Browse files Browse the repository at this point in the history
Update arduino board package.
  • Loading branch information
tcoppex authored Nov 2, 2021
2 parents 39dd7cf + 3e28f97 commit 697431b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,19 +85,19 @@ class SampleHID : MbedBleHID {
// [ Add some fancy stuff here & there ]
};

SampleHID mySampleHID;
SampleHID sampleHID;
```
## Example
### 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
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=Mbed BLE HID
version=1.2.0
version=1.3.0
author=Thibault Coppex
maintainer=Thibault Coppex <[email protected]>
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

23 changes: 23 additions & 0 deletions src/Mbed_BLE_HID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{

}

/* -------------------------------------------------------------------------- */
6 changes: 6 additions & 0 deletions src/Mbed_BLE_HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit 697431b

Please sign in to comment.