microbit: Updates to enable anonymous advertising during normal operation

Changes to default BLE name. During normal operation, all micro:bits now have the same name: BBC micro:bit
When pairing mode (AKA BLUEZONE) is entered, device name details re appended as before, to give BBC micro:bit [<name>]

This is to provide a degree of anonymity to users, to make tracking of kids more difficult.
This commit is contained in:
Joe Finney 2015-12-11 02:09:31 +00:00
parent e042a55522
commit 5a9f5d42bd
2 changed files with 14 additions and 3 deletions

View file

@ -93,6 +93,7 @@ void MicroBit::init()
#if CONFIG_ENABLED(MICROBIT_BLE_ENABLED)
// Start the BLE stack.
bleManager.init(this->getName(), this->getSerial());
ble = bleManager.ble;
#endif

View file

@ -106,9 +106,7 @@ void MicroBitBLEManager::onDisconnectionCallback()
*/
void MicroBitBLEManager::init(ManagedString deviceName, ManagedString serialNumber)
{
ManagedString prefix("BBC micro:bit [");
ManagedString postfix("]");
ManagedString BLEName = prefix + deviceName + postfix;
ManagedString BLEName("BBC micro:bit");
this->deviceName = deviceName;
@ -218,9 +216,21 @@ void MicroBitBLEManager::pairingComplete(bool success)
*/
void MicroBitBLEManager::bluezone(MicroBitDisplay &display)
{
ManagedString namePrefix("BBC micro:bit [");
ManagedString namePostfix("]");
ManagedString BLEName = namePrefix + deviceName + namePostfix;
ManagedString prefix("BLUEZONE:");
ManagedString msg = prefix + deviceName;
// Update the advertised name of this micro:bit to include the device name
ble->clearAdvertisingPayload();
ble->accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)BLEName.toCharArray(), BLEName.length());
ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble->setAdvertisingInterval(200);
ble->startAdvertising();
// Stop any running animations on the display
display.stopAnimation();
display.scroll(msg);