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