From 41e18622f430bc224c0a26db9ced3986d56fa876 Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Tue, 10 Mar 2015 08:09:25 +0000 Subject: [PATCH] URIBeaconConfigService: Pull out the advertisement switch from the 'service' class. This can be left in main.cpp for the application developer. --- services/URIBeaconConfigService.h | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/services/URIBeaconConfigService.h b/services/URIBeaconConfigService.h index 2c279f3..de265ef 100644 --- a/services/URIBeaconConfigService.h +++ b/services/URIBeaconConfigService.h @@ -54,7 +54,6 @@ class URIBeaconConfigService { static const uint8_t TX_POWER_MODE_HIGH = 3; /*!< High TX power mode */ static const unsigned int NUM_POWER_MODES = 4; /*!< Number of Power Modes defined */ - static const int CONFIG_ADVERTISING_TIMEOUT_SECONDS = 60; // Seconds after power-on that config service is available. static const int ADVERTISING_INTERVAL_MSEC = 1000; // Advertising interval for config service. static const int SERVICE_DATA_MAX = 31; // Maximum size of service data in ADV packets @@ -99,7 +98,6 @@ class URIBeaconConfigService { defaultAdvPowerLevels(defaultAdvPowerLevelsIn), initSucceeded(false), resetFlag(), - configAdvertisementTimeoutTicker(), lockedStateChar(UUID_LOCK_STATE_CHAR, &lockedState), lockChar(UUID_LOCK_CHAR, ¶ms.lock), uriDataChar(UUID_URI_DATA_CHAR, params.uriData, 0, URI_DATA_MAX, @@ -148,10 +146,7 @@ class URIBeaconConfigService { ble.addService(configService); ble.onDataWritten(this, &URIBeaconConfigService::onDataWrittenCallback); - /* Start out by advertising the configService for a limited time after - * startup; and switch to the normal non-connectible beacon functionality - * afterwards. */ - setupURIBeaconConfigAdvertisements(); + setupURIBeaconConfigAdvertisements(); /* Setup advertising for the configService. */ initSucceeded = true; } @@ -169,9 +164,6 @@ class URIBeaconConfigService { ble.clearAdvertisingPayload(); - // Stops advertising the UriBeacon Config Service after a delay - configAdvertisementTimeoutTicker.attach(this, &URIBeaconConfigService::timeout, CONFIG_ADVERTISING_TIMEOUT_SECONDS); - ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); // UUID is in different order in the ADV frame (!) @@ -231,19 +223,6 @@ class URIBeaconConfigService { serviceData[serviceDataLen++] = uriData[j]; } ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, serviceData, serviceDataLen); - - ble.startAdvertising(); - } - - // After advertising timeout, stop config and switch to UriBeacon - void timeout(void) - { - Gap::GapState_t state; - state = ble.getGapState(); - if (state.advertising) { - setupURIBeaconAdvertisements(); - configAdvertisementTimeoutTicker.detach(); /* disable the timeout Ticker. */ - } } private: @@ -359,7 +338,6 @@ class URIBeaconConfigService { uint8_t lockedState; bool initSucceeded; uint8_t resetFlag; - Ticker configAdvertisementTimeoutTicker; ReadOnlyGattCharacteristic lockedStateChar; WriteOnlyGattCharacteristic lockChar;