Cannot initialize metawear board in Linux

Hi,

I am trying to do a very simple program to communicate with a metawear board. Whatever I do, I always get MBL_MW_STATUS_ERROR_TIMEOUT when initializing the board.

I have followed the documentation and that is what I am doing (note that not all code is included):

  // ... bluetooth connection with the device ...

  // Create a BLE connection with GATT write and read callbacks.
  MblMwBtleConnection btle_conn = { write_gatt_char, read_gatt_char };

  // Instantiate a MblMwMetaWearBoard.
  m_board = mbl_mw_metawearboard_create(&btle_conn);

  // Initialize MblMwMetaWearBoard internal state.
  mbl_mw_metawearboard_initialize(m_board, init);

I have even tried to increase the timeout for responses using mbl_mw_metawearboard_set_time_for_response and the result is the same.

I receive the following metawear library callbacks during the initialization:

read_gatt_char => 2a2600001000 800000805f9b34fb (value 0x312e332e33 "1.3.3") => mbl_mw_metawearboard_char_read
read_gatt_char => 22a2400001000 800000805f9b34fb (value 0x35) => mbl_mw_metawearboard_char_read
write_gatt_char => 326a900185cb9195 d9dd464cfbbae75a (value 0x0180)

Result of mbl_mw_metawearboard_is_initialized is 0, and if I try to perform any operation over the board, the programs abort with std::out_of_range.

The problem is I do not know what is supposed to be read/written during initialization, and a timeout error tells me nothing.

Is there something I am losing during initialization? How can I get more information about the error?

Thanks,
Marc

Comments

  • Did you enable characteristic changes and forward them to the API?

  • Hi Eric,

    Thanks. It seems that was my problem. I can now communicate with the board.

    Just to confirm how it works, documentation says:

    "Enable notifications on that characteristic and call
    mbl_mw_metawearboard_notify_char_changed
    whenever the MetaWear notification characteristic changes."

    I can enable characteristic changes on METAWEAR_SERVICE_NOTIFY_CHAR by writing 0x100 / 0x300 to handler 0x20.

    a) Is this the correct way?
    b) Is this characteristic used to notify changes for any characteristic?

    Thanks,
    Marc
  • a) I'm not sure what handler 0x20 refers to; presumably it is some assigned ID from your BLE library.  Since you can communicate with the board, it's safe to assume what you did is correct.

    b) No, as per the documentation for for that characteristic, which is linked in your post, it defines the UUIDs for the MetaWear notify characteristic.
This discussion has been closed.