BLE_API for nRF51

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
chiang404
Date:
Wed May 18 11:21:11 2016 +0000
Parent:
833:d494ad3e87bd
Commit message:
Security UART

Changed in this revision

ble/services/UARTService.h Show annotated file Show diff for this revision Revisions of this file
--- a/ble/services/UARTService.h	Tue Sep 29 09:54:19 2015 +0100
+++ b/ble/services/UARTService.h	Wed May 18 11:21:11 2016 +0000
@@ -59,9 +59,12 @@
         txCharacteristic(UARTServiceTXCharacteristicUUID, receiveBuffer, 1, BLE_UART_SERVICE_MAX_DATA_LEN,
                          GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
         rxCharacteristic(UARTServiceRXCharacteristicUUID, sendBuffer, 1, BLE_UART_SERVICE_MAX_DATA_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
+        /* Protect MITM */
+        txCharacteristic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM);
+        rxCharacteristic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM);
+        
         GattCharacteristic *charTable[] = {&txCharacteristic, &rxCharacteristic};
         GattService         uartService(UARTServiceUUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
-
         ble.addService(uartService);
         ble.onDataWritten(this, &UARTService::onDataWritten);
     }