project for eddystone
Dependencies: BLE_API mbed nRF51822
Fork of BLE_URIBeacon by
Diff: main.cpp
- Revision:
- 11:c77cc2b74101
- Parent:
- 9:e7f47bec97b8
- Child:
- 13:b82d8db73633
--- a/main.cpp Fri Dec 12 14:19:53 2014 +0000 +++ b/main.cpp Wed Jan 21 10:14:04 2015 +0000 @@ -16,42 +16,35 @@ #include "mbed.h" #include "BLEDevice.h" -#include "URIBeaconConfigService.h" +#include "nrfURIBeaconConfigService.h" +#include "DFUService.h" +#include "DeviceInformationService.h" BLEDevice ble; -URIBeaconConfigService *uriBeaconConfig; -/*If beacon gets disconnected start advertising again */ void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { ble.startAdvertising(); } -/* -* The main loop. -* Here we will configure the URI Beacon and start advertising -*/ int main(void) { - /* Initialize BLE base layer*/ ble.init(); ble.onDisconnection(disconnectionCallback); - /* Set the BLE device to be a URI Beacon, set advertising payload - the address after the preamble (www.) can be 17bytes at most.*/ - uriBeaconConfig = new URIBeaconConfigService(ble, "http://www.developer.mbed.org"); - - /*Check that the URI Beacon started successfully.*/ - if (!uriBeaconConfig->configuredSuccessfully()) { + nrfURIBeaconConfigService uriBeaconConfig(ble, "http://www.mbed.org"); + if (!uriBeaconConfig.configuredSuccessfully()) { error("failed to accommodate URI"); } - /* optional use of the API offered by URIBeaconConfigService */ const int8_t powerLevels[] = {-20, -4, 0, 10}; - uriBeaconConfig->setTxPowerLevels(powerLevels); // Set TX power levels, Lowest(-20), Low(-4), Medium(0), High(10) - uriBeaconConfig->setTxPowerMode(URIBeaconConfigService::TX_POWER_MODE_LOW); // Initialize tranmition in Low power mode + uriBeaconConfig.setTxPowerLevels(powerLevels); + uriBeaconConfig.setTxPowerMode(URIBeaconConfigService::TX_POWER_MODE_LOW); - /*Start advertising the URI Beacon*/ + /* Setup auxiliary services. */ + DFUService dfu(ble); /* To allow over-the-air firmware udpates. optional. */ + DeviceInformationService deviceInfo(ble, "ARM", "URIBeacon2", "SN1", "hw-rev1", "fw-rev1", "soft-rev1"); /* optional */ + ble.startAdvertising(); while (true) {