HID-over-GATT implementation with the BLE API. This library allows to create devices such as mouse, keyboard or joystick, over Bluetooth Low Energy.

Dependents:   MtConnect04S_Gesture_HID

Fork of BLE_HID by Jean-Philippe Brucker

Committer:
bcc6
Date:
Tue Jan 17 03:48:12 2017 +0000
Revision:
5:dc4e6dbcb79b
Parent:
1:7a6c2e2c9371
Add PNP_ID in DeviceInformationService; Add bootKeyboardInputReportCharacteristic, bootKeyboardOutputReportCharacteristic in HIDServiceBase

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jean-Philippe Brucker 1:7a6c2e2c9371 1 /* mbed Microcontroller Library
Jean-Philippe Brucker 1:7a6c2e2c9371 2 * Copyright (c) 2015 ARM Limited
Jean-Philippe Brucker 1:7a6c2e2c9371 3 *
Jean-Philippe Brucker 1:7a6c2e2c9371 4 * Licensed under the Apache License, Version 2.0 (the "License");
Jean-Philippe Brucker 1:7a6c2e2c9371 5 * you may not use this file except in compliance with the License.
Jean-Philippe Brucker 1:7a6c2e2c9371 6 * You may obtain a copy of the License at
Jean-Philippe Brucker 1:7a6c2e2c9371 7 *
Jean-Philippe Brucker 1:7a6c2e2c9371 8 * http://www.apache.org/licenses/LICENSE-2.0
Jean-Philippe Brucker 1:7a6c2e2c9371 9 *
Jean-Philippe Brucker 1:7a6c2e2c9371 10 * Unless required by applicable law or agreed to in writing, software
Jean-Philippe Brucker 1:7a6c2e2c9371 11 * distributed under the License is distributed on an "AS IS" BASIS,
Jean-Philippe Brucker 1:7a6c2e2c9371 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Jean-Philippe Brucker 1:7a6c2e2c9371 13 * See the License for the specific language governing permissions and
Jean-Philippe Brucker 1:7a6c2e2c9371 14 * limitations under the License.
Jean-Philippe Brucker 1:7a6c2e2c9371 15 */
Jean-Philippe Brucker 1:7a6c2e2c9371 16
Jean-Philippe Brucker 0:cfd70fa91663 17 #include "mbed.h"
Jean-Philippe Brucker 0:cfd70fa91663 18 #include "HIDServiceBase.h"
Jean-Philippe Brucker 0:cfd70fa91663 19
Jean-Philippe Brucker 0:cfd70fa91663 20 HIDServiceBase::HIDServiceBase(BLE &_ble,
Jean-Philippe Brucker 0:cfd70fa91663 21 report_map_t reportMap,
Jean-Philippe Brucker 0:cfd70fa91663 22 uint8_t reportMapSize,
Jean-Philippe Brucker 0:cfd70fa91663 23 report_t inputReport,
Jean-Philippe Brucker 0:cfd70fa91663 24 report_t outputReport,
Jean-Philippe Brucker 0:cfd70fa91663 25 report_t featureReport,
Jean-Philippe Brucker 0:cfd70fa91663 26 uint8_t inputReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 27 uint8_t outputReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 28 uint8_t featureReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 29 uint8_t inputReportTickerDelay) :
Jean-Philippe Brucker 0:cfd70fa91663 30 ble(_ble),
Jean-Philippe Brucker 0:cfd70fa91663 31 connected (false),
Jean-Philippe Brucker 0:cfd70fa91663 32 reportMapLength(reportMapSize),
Jean-Philippe Brucker 0:cfd70fa91663 33
Jean-Philippe Brucker 0:cfd70fa91663 34 inputReport(inputReport),
Jean-Philippe Brucker 0:cfd70fa91663 35 outputReport(outputReport),
Jean-Philippe Brucker 0:cfd70fa91663 36 featureReport(featureReport),
Jean-Philippe Brucker 0:cfd70fa91663 37
Jean-Philippe Brucker 0:cfd70fa91663 38 inputReportLength(inputReportLength),
Jean-Philippe Brucker 0:cfd70fa91663 39 outputReportLength(outputReportLength),
Jean-Philippe Brucker 0:cfd70fa91663 40 featureReportLength(featureReportLength),
Jean-Philippe Brucker 0:cfd70fa91663 41
Jean-Philippe Brucker 0:cfd70fa91663 42 protocolMode(REPORT_PROTOCOL),
Jean-Philippe Brucker 0:cfd70fa91663 43
Jean-Philippe Brucker 0:cfd70fa91663 44 inputReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_REPORT_REFERENCE,
Jean-Philippe Brucker 0:cfd70fa91663 45 (uint8_t *)&inputReportReferenceData, 2, 2),
Jean-Philippe Brucker 0:cfd70fa91663 46 outputReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_REPORT_REFERENCE,
Jean-Philippe Brucker 0:cfd70fa91663 47 (uint8_t *)&outputReportReferenceData, 2, 2),
Jean-Philippe Brucker 0:cfd70fa91663 48 featureReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_REPORT_REFERENCE,
Jean-Philippe Brucker 0:cfd70fa91663 49 (uint8_t *)&featureReportReferenceData, 2, 2),
Jean-Philippe Brucker 0:cfd70fa91663 50
Jean-Philippe Brucker 0:cfd70fa91663 51 protocolModeCharacteristic(GattCharacteristic::UUID_PROTOCOL_MODE_CHAR, &protocolMode, 1, 1,
Jean-Philippe Brucker 0:cfd70fa91663 52 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
Jean-Philippe Brucker 0:cfd70fa91663 53 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
Jean-Philippe Brucker 0:cfd70fa91663 54
Jean-Philippe Brucker 0:cfd70fa91663 55 inputReportCharacteristic(GattCharacteristic::UUID_REPORT_CHAR,
Jean-Philippe Brucker 0:cfd70fa91663 56 (uint8_t *)inputReport, inputReportLength, inputReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 57 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
Jean-Philippe Brucker 0:cfd70fa91663 58 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY
Jean-Philippe Brucker 0:cfd70fa91663 59 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE,
Jean-Philippe Brucker 0:cfd70fa91663 60 inputReportDescriptors(), 1),
Jean-Philippe Brucker 0:cfd70fa91663 61
Jean-Philippe Brucker 0:cfd70fa91663 62 outputReportCharacteristic(GattCharacteristic::UUID_REPORT_CHAR,
Jean-Philippe Brucker 0:cfd70fa91663 63 (uint8_t *)outputReport, outputReportLength, outputReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 64 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
Jean-Philippe Brucker 0:cfd70fa91663 65 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE
Jean-Philippe Brucker 0:cfd70fa91663 66 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE,
Jean-Philippe Brucker 0:cfd70fa91663 67 outputReportDescriptors(), 1),
Jean-Philippe Brucker 0:cfd70fa91663 68
Jean-Philippe Brucker 0:cfd70fa91663 69 featureReportCharacteristic(GattCharacteristic::UUID_REPORT_CHAR,
Jean-Philippe Brucker 0:cfd70fa91663 70 (uint8_t *)featureReport, featureReportLength, featureReportLength,
Jean-Philippe Brucker 0:cfd70fa91663 71 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
Jean-Philippe Brucker 0:cfd70fa91663 72 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE,
Jean-Philippe Brucker 0:cfd70fa91663 73 featureReportDescriptors(), 1),
Jean-Philippe Brucker 0:cfd70fa91663 74
bcc6 5:dc4e6dbcb79b 75 bootKeyboardInputReportCharacteristic(GattCharacteristic::UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR,
bcc6 5:dc4e6dbcb79b 76 (uint8_t *)inputReport, inputReportLength, inputReportLength,
bcc6 5:dc4e6dbcb79b 77 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
bcc6 5:dc4e6dbcb79b 78 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY
bcc6 5:dc4e6dbcb79b 79 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE),
bcc6 5:dc4e6dbcb79b 80
bcc6 5:dc4e6dbcb79b 81 bootKeyboardOutputReportCharacteristic(GattCharacteristic::UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR,
bcc6 5:dc4e6dbcb79b 82 (uint8_t *)outputReport, outputReportLength, outputReportLength,
bcc6 5:dc4e6dbcb79b 83 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
bcc6 5:dc4e6dbcb79b 84 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE
bcc6 5:dc4e6dbcb79b 85 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE),
bcc6 5:dc4e6dbcb79b 86
Jean-Philippe Brucker 0:cfd70fa91663 87 /*
Jean-Philippe Brucker 0:cfd70fa91663 88 * We need to set reportMap content as const, in order to let the compiler put it into flash
Jean-Philippe Brucker 0:cfd70fa91663 89 * instead of RAM. The characteristic is read-only so it won't be written, but
Jean-Philippe Brucker 0:cfd70fa91663 90 * GattCharacteristic constructor takes non-const arguments only. Hence the cast.
Jean-Philippe Brucker 0:cfd70fa91663 91 */
Jean-Philippe Brucker 0:cfd70fa91663 92 reportMapCharacteristic(GattCharacteristic::UUID_REPORT_MAP_CHAR,
Jean-Philippe Brucker 0:cfd70fa91663 93 const_cast<uint8_t*>(reportMap), reportMapLength, reportMapLength,
Jean-Philippe Brucker 0:cfd70fa91663 94 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
Jean-Philippe Brucker 0:cfd70fa91663 95
Jean-Philippe Brucker 0:cfd70fa91663 96 HIDInformationCharacteristic(GattCharacteristic::UUID_HID_INFORMATION_CHAR, HIDInformation()),
Jean-Philippe Brucker 0:cfd70fa91663 97 HIDControlPointCharacteristic(GattCharacteristic::UUID_HID_CONTROL_POINT_CHAR,
Jean-Philippe Brucker 0:cfd70fa91663 98 &controlPointCommand, 1, 1,
Jean-Philippe Brucker 0:cfd70fa91663 99 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
Jean-Philippe Brucker 0:cfd70fa91663 100
Jean-Philippe Brucker 0:cfd70fa91663 101 reportTickerDelay(inputReportTickerDelay),
Jean-Philippe Brucker 0:cfd70fa91663 102 reportTickerIsActive(false)
Jean-Philippe Brucker 0:cfd70fa91663 103 {
Jean-Philippe Brucker 0:cfd70fa91663 104 static GattCharacteristic *characteristics[] = {
Jean-Philippe Brucker 0:cfd70fa91663 105 &HIDInformationCharacteristic,
Jean-Philippe Brucker 0:cfd70fa91663 106 &reportMapCharacteristic,
Jean-Philippe Brucker 0:cfd70fa91663 107 &protocolModeCharacteristic,
Jean-Philippe Brucker 0:cfd70fa91663 108 &HIDControlPointCharacteristic,
Jean-Philippe Brucker 0:cfd70fa91663 109 NULL,
Jean-Philippe Brucker 0:cfd70fa91663 110 NULL,
Jean-Philippe Brucker 0:cfd70fa91663 111 NULL,
Jean-Philippe Brucker 0:cfd70fa91663 112 NULL,
Jean-Philippe Brucker 0:cfd70fa91663 113 NULL
Jean-Philippe Brucker 0:cfd70fa91663 114 };
Jean-Philippe Brucker 0:cfd70fa91663 115
Jean-Philippe Brucker 0:cfd70fa91663 116 unsigned int charIndex = 4;
Jean-Philippe Brucker 0:cfd70fa91663 117 /*
Jean-Philippe Brucker 0:cfd70fa91663 118 * Report characteristics are optional, and depend on the reportMap descriptor
Jean-Philippe Brucker 0:cfd70fa91663 119 * Note: at least one should be present, but we don't check that at the moment.
Jean-Philippe Brucker 0:cfd70fa91663 120 */
Jean-Philippe Brucker 0:cfd70fa91663 121 if (inputReportLength)
Jean-Philippe Brucker 0:cfd70fa91663 122 characteristics[charIndex++] = &inputReportCharacteristic;
Jean-Philippe Brucker 0:cfd70fa91663 123 if (outputReportLength)
Jean-Philippe Brucker 0:cfd70fa91663 124 characteristics[charIndex++] = &outputReportCharacteristic;
Jean-Philippe Brucker 0:cfd70fa91663 125 if (featureReportLength)
Jean-Philippe Brucker 0:cfd70fa91663 126 characteristics[charIndex++] = &featureReportCharacteristic;
bcc6 5:dc4e6dbcb79b 127 if (inputReportLength)
bcc6 5:dc4e6dbcb79b 128 characteristics[charIndex++] = &bootKeyboardInputReportCharacteristic;
bcc6 5:dc4e6dbcb79b 129 if (outputReportLength)
bcc6 5:dc4e6dbcb79b 130 characteristics[charIndex++] = &bootKeyboardOutputReportCharacteristic;
Jean-Philippe Brucker 0:cfd70fa91663 131
Jean-Philippe Brucker 0:cfd70fa91663 132 /* TODO: let children add some more characteristics, namely boot keyboard and mouse (They are
Jean-Philippe Brucker 0:cfd70fa91663 133 * mandatory as per HIDS spec.) Ex:
Jean-Philippe Brucker 0:cfd70fa91663 134 *
Jean-Philippe Brucker 0:cfd70fa91663 135 * addExtraCharacteristics(characteristics, int& charIndex);
Jean-Philippe Brucker 0:cfd70fa91663 136 */
Jean-Philippe Brucker 0:cfd70fa91663 137
Jean-Philippe Brucker 0:cfd70fa91663 138 GattService service(GattService::UUID_HUMAN_INTERFACE_DEVICE_SERVICE,
Jean-Philippe Brucker 0:cfd70fa91663 139 characteristics, charIndex);
Jean-Philippe Brucker 0:cfd70fa91663 140
Jean-Philippe Brucker 1:7a6c2e2c9371 141 ble.gattServer().addService(service);
Jean-Philippe Brucker 0:cfd70fa91663 142
Jean-Philippe Brucker 1:7a6c2e2c9371 143 ble.gap().onConnection(this, &HIDServiceBase::onConnection);
Jean-Philippe Brucker 1:7a6c2e2c9371 144 ble.gap().onDisconnection(this, &HIDServiceBase::onDisconnection);
Jean-Philippe Brucker 1:7a6c2e2c9371 145
Jean-Philippe Brucker 1:7a6c2e2c9371 146 ble.gattServer().onDataSent(this, &HIDServiceBase::onDataSent);
Jean-Philippe Brucker 0:cfd70fa91663 147
Jean-Philippe Brucker 0:cfd70fa91663 148 /*
Jean-Philippe Brucker 0:cfd70fa91663 149 * Change preferred connection params, in order to optimize the notification frequency. Most
Jean-Philippe Brucker 0:cfd70fa91663 150 * OSes seem to respect this, even though they are not required to.
Jean-Philippe Brucker 0:cfd70fa91663 151 *
Jean-Philippe Brucker 0:cfd70fa91663 152 * Some OSes don't handle reconnection well, at the moment, so we set the maximum possible
Jean-Philippe Brucker 0:cfd70fa91663 153 * timeout, 32 seconds
Jean-Philippe Brucker 0:cfd70fa91663 154 */
Jean-Philippe Brucker 0:cfd70fa91663 155 uint16_t minInterval = Gap::MSEC_TO_GAP_DURATION_UNITS(reportTickerDelay / 2);
Jean-Philippe Brucker 0:cfd70fa91663 156 if (minInterval < 6)
Jean-Philippe Brucker 0:cfd70fa91663 157 minInterval = 6;
Jean-Philippe Brucker 0:cfd70fa91663 158 uint16_t maxInterval = minInterval * 2;
Jean-Philippe Brucker 0:cfd70fa91663 159 Gap::ConnectionParams_t params = {minInterval, maxInterval, 0, 3200};
Jean-Philippe Brucker 0:cfd70fa91663 160
Jean-Philippe Brucker 0:cfd70fa91663 161 ble.gap().setPreferredConnectionParams(&params);
Jean-Philippe Brucker 0:cfd70fa91663 162
Jean-Philippe Brucker 0:cfd70fa91663 163 SecurityManager::SecurityMode_t securityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM;
Jean-Philippe Brucker 0:cfd70fa91663 164 protocolModeCharacteristic.requireSecurity(securityMode);
Jean-Philippe Brucker 0:cfd70fa91663 165 reportMapCharacteristic.requireSecurity(securityMode);
Jean-Philippe Brucker 0:cfd70fa91663 166 inputReportCharacteristic.requireSecurity(securityMode);
Jean-Philippe Brucker 0:cfd70fa91663 167 outputReportCharacteristic.requireSecurity(securityMode);
Jean-Philippe Brucker 0:cfd70fa91663 168 featureReportCharacteristic.requireSecurity(securityMode);
bcc6 5:dc4e6dbcb79b 169 bootKeyboardInputReportCharacteristic.requireSecurity(securityMode);
bcc6 5:dc4e6dbcb79b 170 bootKeyboardOutputReportCharacteristic.requireSecurity(securityMode);
Jean-Philippe Brucker 0:cfd70fa91663 171 }
Jean-Philippe Brucker 0:cfd70fa91663 172
Jean-Philippe Brucker 0:cfd70fa91663 173 void HIDServiceBase::startReportTicker(void) {
Jean-Philippe Brucker 0:cfd70fa91663 174 if (reportTickerIsActive)
Jean-Philippe Brucker 0:cfd70fa91663 175 return;
Jean-Philippe Brucker 0:cfd70fa91663 176 reportTicker.attach_us(this, &HIDServiceBase::sendCallback, reportTickerDelay * 1000);
Jean-Philippe Brucker 0:cfd70fa91663 177 reportTickerIsActive = true;
Jean-Philippe Brucker 0:cfd70fa91663 178 }
Jean-Philippe Brucker 0:cfd70fa91663 179
Jean-Philippe Brucker 0:cfd70fa91663 180 void HIDServiceBase::stopReportTicker(void) {
Jean-Philippe Brucker 0:cfd70fa91663 181 reportTicker.detach();
Jean-Philippe Brucker 0:cfd70fa91663 182 reportTickerIsActive = false;
Jean-Philippe Brucker 0:cfd70fa91663 183 }
Jean-Philippe Brucker 0:cfd70fa91663 184
Jean-Philippe Brucker 0:cfd70fa91663 185 void HIDServiceBase::onDataSent(unsigned count) {
Jean-Philippe Brucker 0:cfd70fa91663 186 startReportTicker();
Jean-Philippe Brucker 0:cfd70fa91663 187 }
Jean-Philippe Brucker 0:cfd70fa91663 188
Jean-Philippe Brucker 0:cfd70fa91663 189 GattAttribute** HIDServiceBase::inputReportDescriptors() {
Jean-Philippe Brucker 0:cfd70fa91663 190 inputReportReferenceData.ID = 0;
Jean-Philippe Brucker 0:cfd70fa91663 191 inputReportReferenceData.type = INPUT_REPORT;
Jean-Philippe Brucker 0:cfd70fa91663 192
Jean-Philippe Brucker 0:cfd70fa91663 193 static GattAttribute * descs[] = {
Jean-Philippe Brucker 0:cfd70fa91663 194 &inputReportReferenceDescriptor,
Jean-Philippe Brucker 0:cfd70fa91663 195 };
Jean-Philippe Brucker 0:cfd70fa91663 196 return descs;
Jean-Philippe Brucker 0:cfd70fa91663 197 }
Jean-Philippe Brucker 0:cfd70fa91663 198
Jean-Philippe Brucker 0:cfd70fa91663 199 GattAttribute** HIDServiceBase::outputReportDescriptors() {
Jean-Philippe Brucker 0:cfd70fa91663 200 outputReportReferenceData.ID = 0;
Jean-Philippe Brucker 0:cfd70fa91663 201 outputReportReferenceData.type = OUTPUT_REPORT;
Jean-Philippe Brucker 0:cfd70fa91663 202
Jean-Philippe Brucker 0:cfd70fa91663 203 static GattAttribute * descs[] = {
Jean-Philippe Brucker 0:cfd70fa91663 204 &outputReportReferenceDescriptor,
Jean-Philippe Brucker 0:cfd70fa91663 205 };
Jean-Philippe Brucker 0:cfd70fa91663 206 return descs;
Jean-Philippe Brucker 0:cfd70fa91663 207 }
Jean-Philippe Brucker 0:cfd70fa91663 208
Jean-Philippe Brucker 0:cfd70fa91663 209 GattAttribute** HIDServiceBase::featureReportDescriptors() {
Jean-Philippe Brucker 0:cfd70fa91663 210 featureReportReferenceData.ID = 0;
Jean-Philippe Brucker 0:cfd70fa91663 211 featureReportReferenceData.type = FEATURE_REPORT;
Jean-Philippe Brucker 0:cfd70fa91663 212
Jean-Philippe Brucker 0:cfd70fa91663 213 static GattAttribute * descs[] = {
Jean-Philippe Brucker 0:cfd70fa91663 214 &featureReportReferenceDescriptor,
Jean-Philippe Brucker 0:cfd70fa91663 215 };
Jean-Philippe Brucker 0:cfd70fa91663 216 return descs;
Jean-Philippe Brucker 0:cfd70fa91663 217 }
Jean-Philippe Brucker 0:cfd70fa91663 218
Jean-Philippe Brucker 0:cfd70fa91663 219
Jean-Philippe Brucker 0:cfd70fa91663 220 HID_information_t* HIDServiceBase::HIDInformation() {
Jean-Philippe Brucker 0:cfd70fa91663 221 static HID_information_t info = {HID_VERSION_1_11, 0x00, 0x03};
Jean-Philippe Brucker 0:cfd70fa91663 222
Jean-Philippe Brucker 0:cfd70fa91663 223 return &info;
Jean-Philippe Brucker 0:cfd70fa91663 224 }
Jean-Philippe Brucker 0:cfd70fa91663 225
Jean-Philippe Brucker 0:cfd70fa91663 226 ble_error_t HIDServiceBase::send(const report_t report) {
bcc6 5:dc4e6dbcb79b 227 if (protocolMode == REPORT_PROTOCOL) {
bcc6 5:dc4e6dbcb79b 228 return ble.gattServer().write(
bcc6 5:dc4e6dbcb79b 229 inputReportCharacteristic.getValueHandle(),
bcc6 5:dc4e6dbcb79b 230 report,
bcc6 5:dc4e6dbcb79b 231 inputReportLength
bcc6 5:dc4e6dbcb79b 232 );
bcc6 5:dc4e6dbcb79b 233 } else {
bcc6 5:dc4e6dbcb79b 234 return ble.gattServer().write(
bcc6 5:dc4e6dbcb79b 235 bootKeyboardInputReportCharacteristic.getValueHandle(),
bcc6 5:dc4e6dbcb79b 236 report,
bcc6 5:dc4e6dbcb79b 237 inputReportLength
bcc6 5:dc4e6dbcb79b 238 );
bcc6 5:dc4e6dbcb79b 239 }
Jean-Philippe Brucker 0:cfd70fa91663 240 }
Jean-Philippe Brucker 0:cfd70fa91663 241
Jean-Philippe Brucker 0:cfd70fa91663 242 ble_error_t HIDServiceBase::read(report_t report) {
Jean-Philippe Brucker 0:cfd70fa91663 243 // TODO. For the time being, we'll just have HID input reports...
Jean-Philippe Brucker 0:cfd70fa91663 244 return BLE_ERROR_NOT_IMPLEMENTED;
Jean-Philippe Brucker 0:cfd70fa91663 245 }
Jean-Philippe Brucker 0:cfd70fa91663 246
Jean-Philippe Brucker 1:7a6c2e2c9371 247 void HIDServiceBase::onConnection(const Gap::ConnectionCallbackParams_t *params)
Jean-Philippe Brucker 1:7a6c2e2c9371 248 {
Jean-Philippe Brucker 1:7a6c2e2c9371 249 this->connected = true;
Jean-Philippe Brucker 1:7a6c2e2c9371 250 }
Jean-Philippe Brucker 1:7a6c2e2c9371 251
Jean-Philippe Brucker 1:7a6c2e2c9371 252 void HIDServiceBase::onDisconnection(const Gap::DisconnectionCallbackParams_t *params)
Jean-Philippe Brucker 1:7a6c2e2c9371 253 {
Jean-Philippe Brucker 1:7a6c2e2c9371 254 this->connected = false;
Jean-Philippe Brucker 1:7a6c2e2c9371 255 }