Ejemplo n.º 1
0
static void bleInitComplete(BLE::InitializationCompleteCallbackContext* initContext)
{
    BLE         &ble  = initContext->ble;
    ble_error_t error = initContext->error;

    if (error != BLE_ERROR_NONE) {
        onBleInitError(initContext);
        return;
    }

    ble.gap().onDisconnection(disconnectionCallback);

#ifdef TARGET_NRF51822
    EddystoneService::EddystoneParams_t params;
    if (loadEddystoneServiceConfigParams(&params)) {
        eddyServicePtr = new EddystoneService(ble, params, radioPowerLevels, advConfigInterval);
    } else {
        initializeEddystoneToDefaults(ble);
    }
#else
    #warning "EddystoneService is not configured to store configuration data in non-volatile memory"
    initializeEddystoneToDefaults(ble);
#endif

    /*
     * Set the custom device name. The device name is not stored in persistent
     * storage, so we need to set it manually every time the device is reset
     */
    eddyServicePtr->setCompleteDeviceName(deviceName);

    /* Start Eddystone in config mode */
    eddyServicePtr->startConfigService();

    minar::Scheduler::postCallback(timeout).delay(minar::milliseconds(CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS * 1000));
}
Ejemplo n.º 2
0
static void bleInitComplete(BLE::InitializationCompleteCallbackContext* initContext)
{
    BLE         &ble  = initContext->ble;
    ble_error_t error = initContext->error;

    if (error != BLE_ERROR_NONE) {
        onBleInitError(initContext);
        return;
    }

    ble.gap().onDisconnection(disconnectionCallback);

#ifdef TARGET_NRF51822
    EddystoneService::EddystoneParams_t params;
    if (loadEddystoneServiceConfigParams(&params)) {
        eddyServicePtr = new EddystoneService(ble, params, defaultAdvPowerLevels, radioPowerLevels, advConfigInterval);
    } else {
        initializeEddystoneToDefaults(ble);
    }
#else
    initializeEddystoneToDefaults(ble);
#endif

    /* Start Eddystone in config mode */
    eddyServicePtr->startConfigService();

    minar::Scheduler::postCallback(timeout).delay(minar::milliseconds(CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS * 1000));
}