ble nano hid over gatt
Dependencies: BLE_API mbed-dev nRF51822
Revision 55:f01a31103685, committed 2016-08-30
- Comitter:
- cho45
- Date:
- Tue Aug 30 14:05:56 2016 +0000
- Parent:
- 54:899fc2b0a76b
- Child:
- 56:e1d90e2c7402
- Commit message:
- apple ? productid ???????????????????????????????
Changed in this revision
--- a/DeviceInformationService.h Tue Aug 30 13:18:00 2016 +0000 +++ b/DeviceInformationService.h Tue Aug 30 14:05:56 2016 +0000 @@ -19,6 +19,17 @@ #include "ble/BLE.h" +// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.pnp_id.xml +#pragma pack(push, 1) +typedef struct { + uint8_t vendorID_source; + uint16_t vendorID; + uint16_t productID; + uint16_t productVersion; +} PnPID_t; +#pragma pack(pop) + + /** * @class DeviceInformationService * @brief BLE Device Information Service @@ -52,7 +63,8 @@ const char *serialNumber = NULL, const char *hardwareRevision = NULL, const char *firmwareRevision = NULL, - const char *softwareRevision = NULL) : + const char *softwareRevision = NULL, + const PnPID_t *pnpID = NULL) : ble(_ble), manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR, (uint8_t *)manufacturersName, @@ -83,7 +95,8 @@ (uint8_t *)softwareRevision, (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */ (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */ - GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) + GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), + pnpIDCharacteristic(GattCharacteristic::UUID_PNP_ID_CHAR, const_cast<PnPID_t*>(pnpID)) { static bool serviceAdded = false; /* We only add the information service once. */ if (serviceAdded) { @@ -91,19 +104,15 @@ } // required for OS X bonding - SecurityManager::SecurityMode_t securityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM; - manufacturersNameStringCharacteristic.requireSecurity(securityMode); - modelNumberStringCharacteristic.requireSecurity(securityMode); - serialNumberStringCharacteristic.requireSecurity(securityMode); - hardwareRevisionStringCharacteristic.requireSecurity(securityMode); - firmwareRevisionStringCharacteristic.requireSecurity(securityMode); + pnpIDCharacteristic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM); GattCharacteristic *charTable[] = {&manufacturersNameStringCharacteristic, &modelNumberStringCharacteristic, &serialNumberStringCharacteristic, &hardwareRevisionStringCharacteristic, &firmwareRevisionStringCharacteristic, - &softwareRevisionStringCharacteristic}; + &softwareRevisionStringCharacteristic, + &pnpIDCharacteristic}; GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); @@ -141,6 +150,7 @@ * BLE characterising to allow BLE peers access to the software revision string. */ GattCharacteristic softwareRevisionStringCharacteristic; + ReadOnlyGattCharacteristic<PnPID_t> pnpIDCharacteristic; }; #endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/ \ No newline at end of file
--- a/HIDController_BLE.cpp Tue Aug 30 13:18:00 2016 +0000 +++ b/HIDController_BLE.cpp Tue Aug 30 14:05:56 2016 +0000 @@ -13,6 +13,12 @@ static const char HARDWARE_REVISION[] = "0.1"; static const char FIRMWARE_REVISION[] = "0.1"; static const char SOFTWARE_REVISION[] = "0.0"; +static const PnPID_t PNPID = { + 2, + 0x05ac, + 0x0267, + 0x50 +}; static const uint8_t DEVICE_NAME[] = "Keble"; // static const uint8_t SHORT_DEVICE_NAME[] = "Keble"; @@ -132,7 +138,7 @@ // DEBUG_PRINTF_BLE("new KeyboardService\r\n"); keyboardService = new KeyboardService(ble); // DEBUG_PRINTF_BLE("new DeviceInformationService\r\n"); - deviceInformationService = new DeviceInformationService(ble, "lowreal.net", MODEL_NAME, SERIAL_NUMBER, HARDWARE_REVISION, FIRMWARE_REVISION, SOFTWARE_REVISION); + deviceInformationService = new DeviceInformationService(ble, "lowreal.net", MODEL_NAME, SERIAL_NUMBER, HARDWARE_REVISION, FIRMWARE_REVISION, SOFTWARE_REVISION, &PNPID); // DEBUG_PRINTF_BLE("new BatteryService\r\n"); batteryService = new BatteryService(ble, 100); /** TODO
--- a/HIDServiceBase.cpp Tue Aug 30 13:18:00 2016 +0000 +++ b/HIDServiceBase.cpp Tue Aug 30 14:05:56 2016 +0000 @@ -49,8 +49,6 @@ (uint8_t *)&outputReportReferenceData, 2, 2), featureReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_REPORT_REFERENCE, (uint8_t *)&featureReportReferenceData, 2, 2), - batteryServiceExternalReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_EXTERNAL_REPORT_REFERENCE, - (uint8_t *)&UUID_BATTERY_LEVEL_CHAR, 2, 2, false), protocolModeCharacteristic(GattCharacteristic::UUID_PROTOCOL_MODE_CHAR, &protocolMode, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ @@ -84,7 +82,7 @@ reportMapCharacteristic(GattCharacteristic::UUID_REPORT_MAP_CHAR, const_cast<uint8_t*>(reportMap), reportMapLength, reportMapLength, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ, - reportMapDescriptors(), 1), + reportMapDescriptors(), 0), HIDInformationCharacteristic(GattCharacteristic::UUID_HID_INFORMATION_CHAR, HIDInformation()), HIDControlPointCharacteristic(GattCharacteristic::UUID_HID_CONTROL_POINT_CHAR, @@ -204,10 +202,11 @@ } GattAttribute** HIDServiceBase::reportMapDescriptors() { + return 0;/* static GattAttribute * descs[] = { &batteryServiceExternalReportReferenceDescriptor, }; - return descs; + return descs;*/ } HID_information_t* HIDServiceBase::HIDInformation() {
--- a/HIDServiceBase.h Tue Aug 30 13:18:00 2016 +0000 +++ b/HIDServiceBase.h Tue Aug 30 14:05:56 2016 +0000 @@ -180,7 +180,7 @@ GattAttribute inputReportReferenceDescriptor; GattAttribute outputReportReferenceDescriptor; GattAttribute featureReportReferenceDescriptor; - GattAttribute batteryServiceExternalReportReferenceDescriptor; + // GattAttribute batteryServiceExternalReportReferenceDescriptor; // Optional gatt characteristics: GattCharacteristic protocolModeCharacteristic;