From e042a55522242fb0030613c3ae5290764985ffd5 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Fri, 11 Dec 2015 01:38:22 +0000 Subject: [PATCH] microbit: Added compile time option to enabe support for BLE private resolvable addresses. Introduced MICROBIT_BLE_PRIVATE_ADDRESSES configuration option. Disabled by default, as it did not resolve binds correctly on Android 4.4.2 --- inc/MicroBitConfig.h | 6 ++++++ source/ble-services/MicroBitBLEManager.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/inc/MicroBitConfig.h b/inc/MicroBitConfig.h index aace015..e9ab9b5 100644 --- a/inc/MicroBitConfig.h +++ b/inc/MicroBitConfig.h @@ -138,6 +138,12 @@ #define MICROBIT_BLE_BLUEZONE 1 #endif +// Enable/Disable the use of private resolvable addresses. +// Set '1' to enable. +#ifndef MICROBIT_BLE_PRIVATE_ADDRESSES +#define MICROBIT_BLE_PRIVATE_ADDRESSES 0 +#endif + // Enable/Disable BLE Service: MicroBitDFU // This allows over the air programming during normal operation. // Set '1' to enable. diff --git a/source/ble-services/MicroBitBLEManager.cpp b/source/ble-services/MicroBitBLEManager.cpp index 399cf24..60c4477 100644 --- a/source/ble-services/MicroBitBLEManager.cpp +++ b/source/ble-services/MicroBitBLEManager.cpp @@ -126,6 +126,11 @@ void MicroBitBLEManager::init(ManagedString deviceName, ManagedString serialNumb opt.enable = 1; sd_ble_opt_set(BLE_COMMON_OPT_RADIO_CPU_MUTEX, (const ble_opt_t *)&opt); +#if CONFIG_ENABLED(MICROBIT_BLE_PRIVATE_ADDRESSES) + // Configure for private addresses, so kids' behaviour can't be easily tracked. + ble->setAddress(Gap::ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE, NULL); +#endif + // Setup our security requirements. ble->securityManager().onPasskeyDisplay(passkeyDisplayCallback); ble->securityManager().onSecuritySetupCompleted(securitySetupCompletedCallback);