1

I am using a datalogger with the path "Meas/HR" to record data. Start the datalogger with a double tap, and the session begins without issue. Double-tapping the sensor again will end the session and save the data. Nevertheless, if I use the path "/Meas/Acc/104," the datalogger starts successfully with a double-tap. However, the issue arises when trying to stop the session by double-taping on the sensor, as it doesn't work in this scenario.

Subscribe or Unsubscribe to DOUBLETAP detection


bool DataLoggerClient::startModule()
{
    mModuleState = WB_RES::ModuleStateValues::STARTED;

    setShutdownTimer();

    // Subscribe to DOUBLETAP detection
    asyncSubscribe(WB_RES::LOCAL::SYSTEM_STATES_STATEID(), AsyncRequestOptions::Empty, WB_RES::StateIdValues::DOUBLETAP);

    return true;
}

void DataLoggerClient::stopModule()
{

    wb::ResourceProvider::stopTimer(mTimer);

    mTimer = wb::ID_INVALID_TIMER;

    // Unsubscribe DOUBLETAP detection
    asyncUnsubscribe(WB_RES::LOCAL::SYSTEM_STATES_STATEID(), AsyncRequestOptions::Empty, WB_RES::StateIdValues::DOUBLETAP);

    mModuleState = WB_RES::ModuleStateValues::STOPPED;
}

we are set internal resister in DoubleTAPConfig();


void DataLoggerClient::onSubscribeResult(wb::RequestId requestId,
                                         wb::ResourceId resourceId,
                                         wb::Result resultCode,
                                         const wb::Value& rResultData)
{
    DEBUGLOG("DataLoggerClient::onSubscribeResult() called.");
    switch (resourceId.localResourceId)
    {
    case WB_RES::LOCAL::SYSTEM_STATES_STATEID::LID: {
        if (resultCode == whiteboard::HTTP_CODE_OK)
        {
            DEBUGLOG("DoubleTAPConfig()");
            // set internal resistor value for DataLoggerClient mode
            DoubleTAPConfig();
        }
        break;
    }
    }
}

we are get notification in that section.


void DataLoggerClient::onNotify(wb::ResourceId resourceId, const wb::Value& value, const wb::ParameterList& parameters)
{

    DEBUGLOG("DataLoggerClient::onNotify");

    switch (resourceId.localResourceId)
    {

    case WB_RES::LOCAL::SYSTEM_STATES_STATEID::LID: {

        const WB_RES::StateChange& stateChange = value.convertTo<const WB_RES::StateChange&>();

        if (stateChange.stateId == WB_RES::StateIdValues::DOUBLETAP)
        {
            DEBUGLOG("Lead state updated. newState: %d", stateChange.newState);
            DoubleTAPEnabled = !DoubleTAPEnabled;
        }
        break;
    }
    }
}

this is our main fuction in ontimer


void DataLoggerClient::startDataLoggerAcc()
{
    DEBUGLOG(" startDataLogger ");

    WB_RES::DataEntry entry;
    entry.path = "/Meas/Acc/13";

    WB_RES::DataLoggerConfig dataLoggerConfig;
    WB_RES::DataEntry entries[] = {entry};
    dataLoggerConfig.dataEntries.dataEntry = wb::MakeArray<WB_RES::DataEntry>(entries, 1);

    wb::Result configureResult = asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_CONFIG(),           AsyncRequestOptions::Empty, dataLoggerConfig);

    if (!wb::RETURN_OK(configureResult))
    {
        DEBUGLOG("Datalogger configuring failed: %u", configureResult);
        // return false;
    }

    wb::Result stateResult = asyncPut(
        WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty,
        WB_RES::DataLoggerStateValues::Type::DATALOGGER_LOGGING);

    if (wb::RETURN_OK(stateResult))
    {
        DEBUGLOG("Datalogger enabling success: %u", stateResult);

        // return false;
    }
    if (!wb::RETURN_OK(stateResult))
    {
        DEBUGLOG("Datalogger enabling failed: %u", stateResult);
        // return false;
    }
    // return true;
}

we are succsefully work dataloger start or stop with doubletap in this path "Meas/HR" but i am unable to stop datalogger in this path "/Meas/Acc/104"

i am try with "/Meas/HR" start or stop using doubletap its work fine but i am only session start in "/Meas/Acc/13" and i am unable to stop session using doubletap.

i am expecting datalogger start or stop using doubletap in this path "/Meas/Acc/13".

1 Answers1

0

The double tap detection requires that the acc runs with at least 52 Hz sampling rate or it won't be able to recognize the event. You can add "dummy" subscription to /Meas/Acc/52 before the datalogger start which forces the 52 Hz mode.

PetriL
  • 1,211
  • 1
  • 7
  • 11