Ejemplo n.º 1
0
EddystoneService::EddystoneError_t EddystoneService::startConfigService(void)
{
    if (operationMode == EDDYSTONE_MODE_CONFIG) {
        /* Nothing to do, we are already in config mode */
        return EDDYSTONE_ERROR_NONE;
    } else if (advConfigInterval == 0) {
        /* Nothing to do, the advertisement interval is 0 */
        return EDDYSTONE_ERROR_INVALID_ADVERTISING_INTERVAL;
    }

    if (operationMode == EDDYSTONE_MODE_BEACON) {
        ble.shutdown();
        stopBeaconService();
    }

    if (!ble.hasInitialized()) {
        operationMode = EDDYSTONE_MODE_CONFIG;
        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_CONFIG;
    setupConfigService();
    return EDDYSTONE_ERROR_NONE;
}
Ejemplo n.º 2
0
EddystoneService::EddystoneError_t EddystoneService::stopCurrentService(void)
{
    switch (operationMode) {
    case EDDYSTONE_MODE_NONE:
        return EDDYSTONE_ERROR_INVALID_STATE;
    case EDDYSTONE_MODE_BEACON:
        ble.shutdown();
        stopBeaconService();
        break;
    case EDDYSTONE_MODE_CONFIG:
        ble.shutdown();
        freeConfigCharacteristics();
        break;
    default:
        /* Some error occurred */
        error("Invalid EddystonService mode");
        break;
    }
    operationMode = EDDYSTONE_MODE_NONE;
    /* Currently on some platforms, the BLE stack handles power management,
     * so we should bring it up again, but not configure it.
     * Once the system sleep without BLE initialised is fixed, remove this
     */
    ble.init(this, &EddystoneService::bleInitComplete);

    return EDDYSTONE_ERROR_NONE;
}
Ejemplo n.º 3
0
EddystoneService::EddystoneError_t EddystoneService::startConfigService(void)
{
    if (operationMode == EDDYSTONE_MODE_CONFIG) {
        /* Nothing to do, we are already in config mode */
        return EDDYSTONE_ERROR_NONE;
    } else if (advConfigInterval == 0) {
        /* Nothing to do, the advertisement interval is 0 */
        return EDDYSTONE_ERROR_INVALID_ADVERTISING_INTERVAL;
    }

    if (operationMode == EDDYSTONE_MODE_BEACON) {
        ble.shutdown();
        stopBeaconService();
        operationMode = EDDYSTONE_MODE_CONFIG;
        ble.init(this, &EddystoneService::bleInitComplete);
        return EDDYSTONE_ERROR_NONE;
    }

    operationMode = EDDYSTONE_MODE_CONFIG;
    setupConfigService();
    return EDDYSTONE_ERROR_NONE;
}