예제 #1
0
EddystoneService::EddystoneError_t EddystoneService::startBeaconService(void)
{
    if (operationMode == EDDYSTONE_MODE_BEACON) {
        /* Nothing to do, we are already in beacon mode */
        return EDDYSTONE_ERROR_NONE;
    } else if (!urlFramePeriod && !uidFramePeriod && !tlmFramePeriod) {
        /* Nothing to do, the period is 0 for all frames */
        return EDDYSTONE_ERROR_INVALID_ADVERTISING_INTERVAL;
    }

    if (operationMode == EDDYSTONE_MODE_CONFIG) {
        ble.shutdown();
        /* Free unused memory */
        freeConfigCharacteristics();
    }

    if (!ble.hasInitialized()) {
        operationMode = EDDYSTONE_MODE_BEACON;
        ble.init(this, &EddystoneService::bleInitComplete);
        /* Set the device name once more */
        ble.gap().setDeviceName(reinterpret_cast<const uint8_t *>(deviceName));
        return EDDYSTONE_ERROR_NONE;
    }

    operationMode = EDDYSTONE_MODE_BEACON;
    setupBeaconService();

    return EDDYSTONE_ERROR_NONE;
}
예제 #2
0
/* When changing modes, we shutdown and init the BLE instance, so
 * this is needed to complete the initialisation task.
 */
void EddystoneService::bleInitComplete(BLE::InitializationCompleteCallbackContext* initContext)
{
    if (initContext->error != BLE_ERROR_NONE) {
        /* Initialisation failed */
        return;
    }

    switch (operationMode) {
    case EDDYSTONE_MODE_CONFIG:
        setupConfigService();
        break;
    case EDDYSTONE_MODE_BEACON:
        setupBeaconService();
        break;
    default:
        /* Some error occurred */
        error("Invalid EddystonService mode");
        break;
    }
}
예제 #3
0
EddystoneService::EddystoneError_t EddystoneService::startBeaconService(void)
{
    if (operationMode == EDDYSTONE_MODE_BEACON) {
        /* Nothing to do, we are already in beacon mode */
        return EDDYSTONE_ERROR_NONE;
    } else if (!urlFramePeriod && !uidFramePeriod && !tlmFramePeriod) {
        /* Nothing to do, the period is 0 for all frames */
        return EDDYSTONE_ERROR_INVALID_BEACON_PERIOD;
    }

    if (operationMode == EDDYSTONE_MODE_CONFIG) {
        ble.shutdown();
        /* Free unused memory */
        freeConfigCharacteristics();
        operationMode = EDDYSTONE_MODE_BEACON;
        ble.init(this, &EddystoneService::bleInitComplete);
        return EDDYSTONE_ERROR_NONE;
    }

    operationMode = EDDYSTONE_MODE_BEACON;
    setupBeaconService();

    return EDDYSTONE_ERROR_NONE;
}