Button initiated config service
Dependencies: BLE_API_EddystoneConfigService_2 mbed nRF51822
Fork of BLE_EddystoneBeaconConfigService_3 by
Diff: main.cpp
- Revision:
- 39:2c73bc1ff4f5
- Parent:
- 38:8fdb16f67e7c
- Child:
- 40:6f39aee31205
--- a/main.cpp Wed Sep 09 22:00:54 2015 +0000 +++ b/main.cpp Thu Sep 10 17:06:18 2015 +0000 @@ -22,6 +22,7 @@ BLE ble; EddystoneConfigService *EddystoneBeaconConfig; +EddystoneConfigService::Params_t params; /** * URIBeaconConfig service can operate in two modes: a configuration mode which @@ -54,8 +55,15 @@ */ void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { - ble.gap().startAdvertising(); - printf("disconnect CB\r\n"); + if (true == params.isConfigured){ + // end advertising, the beacon is configured + timeout(); + } + else{ + // eddystone is not configured, keep advertising + ble.gap().startAdvertising(); + printf("disconnect CB\r\n"); + } } int main(void) @@ -71,7 +79,6 @@ * get copied out to persistent storage before switching to normal URIBeacon * operation. */ - EddystoneConfigService::Params_t params; bool fetchedFromPersistentStorage = loadURIBeaconConfigParams(¶ms); EddystoneConfigService::UIDNamespaceID_t uidNamespaceID = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99}; // 10Byte Namespace UUID EddystoneConfigService::UIDInstanceID_t uidInstanceID = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; // 6Byte Instance ID @@ -80,7 +87,7 @@ /* Initialize a EddystoneBeaconConfig service providing config params, default URI, and power levels. */ static EddystoneConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels EddystoneBeaconConfig = new EddystoneConfigService(ble, params, !fetchedFromPersistentStorage, defaultAdvPowerLevels, "http://mbed.org", &uidNamespaceID, &uidInstanceID, tlmVersion); - if (!EddystoneBeaconConfig->configuredSuccessfully()) { + if (!EddystoneBeaconConfig->initSuccessfully()) { error("failed to accommodate URI"); } configAdvertisementTimeout.attach(timeout, CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS);