From e754ecf3aacfa3e6270dea1c09b5cb9131793041 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Sat, 16 Jan 2016 17:29:46 +0000 Subject: [PATCH] microbit: Setting of default BLE transmission power level Added configuration option in MicroBitConfig to allow the default power level to be defined. Based on experiments undertaken by the BBC and subsequent policies defined by the BBC's child protection panel, to is set by default it's lowest level (0), in order to protect children's privacy. It should be noted that this is 30dB below the device's default setting, so will inevitably leave the device more susceptible to interference, and therefore significantly reduce the reliability of the device. This will likely present itself through increased packet loss, reduced thorughout, lost data and connection drop outs. The normal BLE power level on commercial devices translates to power level of 6. The author has witnessed an inability to connect to a micro:bit from a distance of 40cm under domestic conditions using a Samsung S5 mini running Android 4.4.2. --- inc/MicroBitConfig.h | 8 ++++++++ source/ble-services/MicroBitBLEManager.cpp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/inc/MicroBitConfig.h b/inc/MicroBitConfig.h index 6755986..5e27682 100644 --- a/inc/MicroBitConfig.h +++ b/inc/MicroBitConfig.h @@ -157,6 +157,14 @@ #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0 #endif +// Defines default power level of the BLE radio transmitter. +// Valid values are in the range 0..7 inclusive, with 0 being the lowest power and 7 the highest power. +// Based on trials undertaken by the BBC, the radio is normally set to its lowest power level +// to best protect children's privacy. +#ifndef MICROBIT_BLE_DEFAULT_TX_POWER +#define MICROBIT_BLE_DEFAULT_TX_POWER 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 8356994..6ec9130 100644 --- a/source/ble-services/MicroBitBLEManager.cpp +++ b/source/ble-services/MicroBitBLEManager.cpp @@ -154,6 +154,9 @@ void MicroBitBLEManager::init(ManagedString deviceName, ManagedString serialNumb ble->gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_FILTER_CONN_REQS); #endif + // Configure the radio at our default power level + setTransmitPower(MICROBIT_BLE_DEFAULT_TX_POWER); + // Bring up any configured auxiliary services. #if CONFIG_ENABLED(MICROBIT_BLE_DFU_SERVICE) new MicroBitDFUService(*ble);