Always receiving TIMEOUT on disconnect event recording

Hi there,

we have a problem with one of our sensors, in that we can't setup a handler for disconnect events on the board.
During our board setup routine we have the following snippet:

mbl_mw_settings_set_connection_parameters(m_metawear_board, 7.5, 7.5, 0, 6000);
const MblMwDeviceInformation* dev_info = mbl_mw_metawearboard_get_device_information(m_metawear_board);
firmware_version_string = std::string(dev_info->firmware_revision);
mbl_mw_memory_free((void *) dev_info);

m_logger.debug("Setting up disconnect event");
disconnect_promise = std::promise<bool>();
auto disconnect_future = disconnect_promise.get_future();

MblMwEvent *dc_event = mbl_mw_settings_get_disconnect_event(m_metawear_board);
mbl_mw_event_record_commands(dc_event);
mbl_mw_debug_reset(m_metawear_board);
mbl_mw_event_end_record(dc_event, nullptr, [](void *context, MblMwEvent *event, int32_t status) {
    if (status == MBL_MW_STATUS_OK) {
        C_MWC::this_->m_logger.debug("disconnect commands recorded!");
        C_MWC::this_->disconnect_promise.set_value(true);
    } else {
        if (status == MBL_MW_STATUS_ERROR_TIMEOUT) C_MWC::this_->m_logger.debug("[TIMEOUT]");
        C_MWC::this_->m_logger.debug("error recording disconnect commands: " + std::to_string(status));
        C_MWC::this_->disconnect_promise.set_value(false);
    }
});

bool disconnect_setup_done = disconnect_future.get();
m_logger.debug("disconnect setup done");
if (!disconnect_setup_done) {
    m_logger.warn("Was not able to setup disconnect handler!");
    return false;
}

Consistently, but only for this one sensor, we get the following log outputs:

15.02.2019 15:29:14.041 [debug] MetaWearDevice initialization callback called! Status: 0
15.02.2019 15:29:14.041 [debug] MetaWearDevice board initialized successfully
15.02.2019 15:29:14.041 [debug] MetaWearDevice setup board...
15.02.2019 15:29:14.041 [debug] MetaWearDevice Setting up disconnect event
15.02.2019 15:29:14.841 [debug] MetaWearDevice [TIMEOUT]
15.02.2019 15:29:14.841 [debug] MetaWearDevice error recording disconnect commands: 16
15.02.2019 15:29:14.841 [debug] MetaWearDevice disconnect setup done
15.02.2019 15:29:14.841 [ warn] MetaWearDevice Was not able to setup disconnect handler!
15.02.2019 15:29:14.841 [ warn] MetaWearDevice Was not able to setup board! Disconnecting!

Can you think of any explanation for this behaviour?
Might the sensor just be defective?

Thank you,
Marcus

Comments

  • edited February 2019

    Monitor the the BT adpater and post a log of it's activity leading up to the error.

    Also,

    • Are other boards exhibiting the same behavior?
    • What other events are you programming?
    • Is the board in question starting from a clean state?
  • Hi Eric,

    I attached a pcap and a pcapng (both have the same data, I just wasn't sure which format is better for you) from Wireshark. Is this okay as a activity log? Or do you need something else?
    During the recording I searched for sensors and connected the sensor with the timeout errors. Then I repeated this.

    Regarding your other questions:

    • No, it's the only one of our sensors (that we tested so far) that shows this behaviour
    • Normally we have the following events on the board: the disconnect event and two timers that periodically read datasignals (battery and fusion calibration state); in addition we have some dataprocessors (one fuser, one accounter, two time)
    • The first thing we did with the sensor was a firmware flash, so yes, the board should start from a clean state. I also just issued a "Reset" from the MetaBase app, but this didn't change anything.
  • Looking at the event dump, you can see in the log (event 839 and 840) that the update request is received and processed while it was setting up the event disconnect handler.

    Add a delay after setting the connection parameters so ensure that the update is acknowledged before setting up the disconnect handler.

  • Hi Eric,
    thank you for your answer.

    I tried to introduce delays during the setup process, but that did actually not solve the problem.

    But I actually found the culprit:
    In my original snippet I omitted some lines I thought were not relevant

    mbl_mw_settings_set_connection_parameters(m_metawear_board, 7.5, 7.5, 0, 6000);
    const MblMwDeviceInformation* dev_info = mbl_mw_metawearboard_get_device_information(m_metawear_board);
    firmware_version_string = std::string(dev_info->firmware_revision);
    mbl_mw_memory_free((void *) dev_info);
    
    /* I omitted these lines here*/
    
    solid_led(false, true, false);
        buzz();
    
    /* until here*/
    
    m_logger.debug("Setting up disconnect event");
    disconnect_promise = std::promise<bool>();
    auto disconnect_future = disconnect_promise.get_future();
    

    The methods solid_led and buzz call mbl_mw_led_* and mbl_mw_haptic_start_buzzer to set the LED color and vibrate.

    The problem was actually resolved by removing the buzz() call (that is just a call to mbl_mw_haptic_start_buzzer).
    I had a look on the board and there was a small lead between the soldering pads (+3V and HCD) of the motor on the backside, so assume the call shorted something and that resulted in the timeout.
    After just scraping that lead away the boards works as intended (including haptic feedback), just like all the others.

Sign In or Register to comment.