Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MicroBitDALImageRewrite by
Diff: MicroBit.cpp
- Revision:
- 5:8bf639bbedb5
- Parent:
- 4:f998ee705a20
--- a/MicroBit.cpp Fri May 15 22:23:17 2015 +0000 +++ b/MicroBit.cpp Sat May 16 22:28:56 2015 +0000 @@ -1,8 +1,6 @@ #include "inc/MicroBit.h" #include "URIBeaconConfigService.h" -extern void dfuCallbackFn(); - char MICROBIT_BLE_DEVICE_NAME[] = "BBC MicroBit Prototype"; char MICROBIT_BLE_MANUFACTURER[] = "The Cast of W1A"; char MICROBIT_BLE_MODEL[] = "Microbit SB2"; @@ -19,14 +17,22 @@ MicroBit::MicroBit() //:display(MICROBIT_ID_DISPLAY, 5, 5) //leftButton(MICROBIT_ID_LEFT_BUTTON,MICROBIT_PIN_LEFT_BUTTON) //i2c(MICROBIT_PIN_SDA, MICROBIT_PIN_SCL) -{ - display = new MicroBitDisplay(MICROBIT_ID_DISPLAY, 5, 5); +{ +} - // Set up BLE stack. +void MicroBit::initDisplay() +{ + // Set up LED Matrix Display. + display = new MicroBitDisplay(MICROBIT_ID_DISPLAY, 5, 5); + display->startDisplay(); +} +void MicroBit::initBLE() +{ + // Set up BLE stack. ble = new BLEDevice(); ble->init(); - + /* Setup auxiliary services. */ ble_firmware_update_service = new DFUService(*ble); ble_device_information_service = new DeviceInformationService(*ble, MICROBIT_BLE_MANUFACTURER, MICROBIT_BLE_MODEL, MICROBIT_BLE_SERIAL, MICROBIT_BLE_HARDWARE_VERSION, MICROBIT_BLE_FIRMWARE_VERSION, MICROBIT_BLE_SOFTWARE_VERSION); @@ -34,10 +40,7 @@ /* Setup advertising. */ ble->accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)MICROBIT_BLE_DEVICE_NAME, sizeof(MICROBIT_BLE_DEVICE_NAME)); - //ble.setDeviceName(reinterpret_cast<uint8_t *>(&MICROBIT_BLE_DEVICE_NAME)); ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); - ble->setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000)); - - ble->startAdvertising(); + ble->startAdvertising(); }