KeyboardStream example from BLE_HID
Dependencies: BLE_API BLE_HID mbed nRF51822
This example is currently copied as-is from the github development repo.
examples_common.h@3:2f64c208af3a, 2016-04-03 (annotated)
- Committer:
- Jean-Philippe Brucker
- Date:
- Sun Apr 03 22:09:25 2016 +0100
- Revision:
- 3:2f64c208af3a
- Parent:
- 0:1484ce3a8cdf
v0.4 - small change to enable Win10 support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jean-Philippe Brucker |
0:1484ce3a8cdf | 1 | /* mbed Microcontroller Library |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 2 | * Copyright (c) 2015 ARM Limited |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 3 | * |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 5 | * you may not use this file except in compliance with the License. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 6 | * You may obtain a copy of the License at |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 7 | * |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 9 | * |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 10 | * Unless required by applicable law or agreed to in writing, software |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 13 | * See the License for the specific language governing permissions and |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 14 | * limitations under the License. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 15 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 16 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 17 | #ifndef HID_EXAMPLES_COMMON_H_ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 18 | #define HID_EXAMPLES_COMMON_H_ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 19 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 20 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 21 | * Functions and configuration common to all HID demos |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 22 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 23 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 24 | #include "ble/BLE.h" |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 25 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 26 | #include "HIDServiceBase.h" |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 27 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 28 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 29 | * IO capabilities of the device. During development, you most likely want "JustWorks", which means |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 30 | * no IO capabilities. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 31 | * It is also possible to use IO_CAPS_DISPLAY_ONLY to generate and show a pincode on the serial |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 32 | * output. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 33 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 34 | #ifndef HID_SECURITY_IOCAPS |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 35 | #define HID_SECURITY_IOCAPS (SecurityManager::IO_CAPS_NONE) |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 36 | #endif |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 37 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 38 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 39 | * Security level. MITM disabled forces "Just Works". If you require MITM, HID_SECURITY_IOCAPS must |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 40 | * be at least IO_CAPS_DISPLAY_ONLY. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 41 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 42 | #ifndef HID_SECURITY_REQUIRE_MITM |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 43 | #define HID_SECURITY_REQUIRE_MITM false |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 44 | #endif |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 45 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 46 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 47 | * Disable debug messages by setting NDEBUG |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 48 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 49 | #ifndef NDEBUG |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 50 | #define HID_DEBUG(...) printf(__VA_ARGS__) |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 51 | #else |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 52 | #define HID_DEBUG(...) |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 53 | #endif |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 54 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 55 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 56 | * Initialize security manager: set callback functions and required security level |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 57 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 58 | void initializeSecurity(BLE &ble); |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 59 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 60 | /** |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 61 | * - Initialize auxiliary services required by the HID-over-GATT Profile. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 62 | * - Initialize common Gap advertisement. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 63 | * |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 64 | * Demos only have to set a custom device name and appearance, and their HID |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 65 | * service. |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 66 | */ |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 67 | void initializeHOGP(BLE &ble); |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 68 | |
Jean-Philippe Brucker |
0:1484ce3a8cdf | 69 | #endif /* !BLE_HID_COMMON_H_ */ |