{"id":20596542,"url":"https://github.com/tcoppex/mbed-ble-hid","last_synced_at":"2025-10-10T05:14:34.917Z","repository":{"id":43201360,"uuid":"268852856","full_name":"tcoppex/mbed-ble-hid","owner":"tcoppex","description":":raising_hand: Implement Human Interface Device over Bluetooth Low Energy on a Mbed stack (Arduino nano 33 BLE).","archived":false,"fork":false,"pushed_at":"2022-11-01T08:21:56.000Z","size":107,"stargazers_count":55,"open_issues_count":10,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-16T20:51:55.217Z","etag":null,"topics":["arduino","arduino-library","ble","bluetooth-low-energy","hid","mbed","nano33ble"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcoppex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-02T16:30:42.000Z","updated_at":"2025-05-14T06:47:53.000Z","dependencies_parsed_at":"2022-08-31T14:20:53.083Z","dependency_job_id":null,"html_url":"https://github.com/tcoppex/mbed-ble-hid","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tcoppex/mbed-ble-hid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoppex%2Fmbed-ble-hid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoppex%2Fmbed-ble-hid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoppex%2Fmbed-ble-hid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoppex%2Fmbed-ble-hid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcoppex","download_url":"https://codeload.github.com/tcoppex/mbed-ble-hid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoppex%2Fmbed-ble-hid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002796,"owners_count":26083468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-library","ble","bluetooth-low-energy","hid","mbed","nano33ble"],"created_at":"2024-11-16T08:17:32.133Z","updated_at":"2025-10-10T05:14:34.897Z","avatar_url":"https://github.com/tcoppex.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"```diff\n⚠️ Important\n- This version is currently deprecated.\n```\n\n# Mbed BLE HID\n\nThis 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**). \n\nIt was designed for the **Arduino nano 33 BLE** and tested with _GNU/Linux, Android 8.0, iOS, and Windows 10_.\n\n## Environment\n\nOn 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 \u003e Boards \u003e Boards manager.._\").\n\nAlternatively you can use [platformio](https://github.com/platformio) [Deviot](https://github.com/platformio/Deviot) [_Recommended_].\n\n\n## Getting started\n\nThe header `Nano33BleHID.h` defines three basic HID ready to use : Mouse, Keyboard, and Gamepad.\n\n```cpp\n#include \"Nano33BleHID.h\"\n\n// Alias to Nano33BleHID\u003cHIDGamepadService\u003e\nNano33BleGamepad pad(\"SuperAwesome Pad\");\n\nvoid setup() {\n    // initialize the ble HID.\n    pad.initialize();\n\n    // Launch the eventqueue thread.\n    MbedBleHID_RunEventThread();\n}\n\nvoid loop() {\n    // Retrieve the HID service handle.\n    auto *hid = pad.hid();\n\n    // Update internal values.\n    float theta = PI * (random(255) / 255.0);\n    hid-\u003emotion(cos(theta), sin(theta));\n\n    // Send them !\n    hid-\u003eSendReport();\n}\n```\n\n## Creating a custom HID\n\nA bluetooth HID is defined by *at least* three services :\n * a *Device Information* service,\n * a *Battery* service,\n * a *HID* service.\n\nThis library defines the *device information* and *battery* services for you, as well as basic HID services for mouse, keyboard, and gamepad (**HIDMouseService**, **HIDKeyboardService**, and **HIDGamepadService** respectively).\n\nTo develop your own HID you will need to derive the **HIDService** class and define a `report descriptors` as described in referenced documentations. A _report descriptor_ is defined by a markup-like language that maps input values to standard interface, like a pointer motion or a key pressed.\n\nOnce you have written your HID service you have two options :\n\n1) If your service has a single parameter constructor you can directly use the *Nano33BleHID\u003cT\u003e* wrapper template to create your bluetooth HID :\n```cpp\n#include \"Nano33BleHID.h\"\n\nclass HIDSampleService : HIDService {\n  public:\n    HIDSampleService(BLE \u0026_ble);\n\n    // Implement this method to describe how your HID \n    // is perceived by other BLE managers.\n    ble::adv_data_appearance_t appearance() override; \n};\n\nNano33BleHID\u003cHIDSampleService\u003e sampleHID;\n```\n\n2) Alternatively you can derive your HID from the base class `MbedBleHID` for more complex cases :\n```cpp\n#include \"MbedBleHID.h\"\n\nclass SampleHID : MbedBleHID {\n  public:\n    SampleHID() : MbedBleHID(\"A Sample HID in the wild\") {/**/}\n\n    // This should return the polymorphic shared_ptr of your service.\n    std::shared_ptr\u003cHIDService\u003e CreateHIDService(BLE \u0026ble) override;\n\n    // [ Add some fancy stuff here \u0026 there ]\n};\n\nSampleHID sampleHID;\n```\n\n\n## Example\n\n### ble_mouse\n\nThis 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*.\n\nBy default the sample is set to demo mode and will output random motions for a few seconds after pairing.\n\nTo disable demo mode you can set the macro definition **DEMO_ENABLE_RANDOM_INPUT** to 0.\n\n### ble_shining_kb\n\nSimulate a ghost writer repeating a sentence over and over again.\n\nBy default the keyboard layout is set to **LAYOUT_US_INTERNATIONAL**, you can change it by uncommenting the desired layout in [*src/services/keylayouts.h*](https://github.com/tcoppex/mbed-ble-hid/blob/master/src/services/keylayouts.h).\n\n## Known limitations\n\n*Boot protocol*, which allows mouses and keyboards to be used on a boot level, is laid out but not implemented.\n\n## Acknowledgment\n\nThis project has benefited from the following resources :\n\n* mbed Microcontroller Library samples,\n* [Nordic semiconductor SDK 16](http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v16.x.x/),\n* [BLEKeyboard](https://github.com/bitbank2/BLE_Keyboard) by bitbank2,\n* [BLE_HID](https://github.com/jpbrucker/BLE_HID) by jpbrucker.\n\nYou might want to look at jpbrucker's implementation for a well documented but deprecated alternative.\n\nThe file `keylayouts.h` is a slightly modified version from @PaulStoffregen [teensyduino](https://github.com/PaulStoffregen/cores/blob/master/teensy/keylayouts.h) project.\n\n## References\n\n* *Bluetooth HUMAN INTERFACE DEVICE PROFILE 1.1*\n* *Bluetooth HID OVER GATT PROFILE SPECIFICATION v10*\n* *USB Device Class Definition for Human Interface Devices (HID) v1.11* \n* *USB HID Usage Table v1.12*\n\n## License\n\n_**Mbed BLE HID**_ is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcoppex%2Fmbed-ble-hid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcoppex%2Fmbed-ble-hid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcoppex%2Fmbed-ble-hid/lists"}