This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI transfert stuck

Hi,

I'm communicate with my sensor by using TWI ( i2c) driver. Most of the time, no problem.

But yesterday , i was debugging, and and ble disconnect event happen ( it print in the console). After that, i was surprised to see that my programmin were stuck somewhere.

It was in this communication sensor function where i'm waiting for transfert to be complete : 

      m_xfer_done = false;
      err_code = nrf_drv_twi_tx(&m_twi, slaveAddr, &cmd, 4, REPEAT_START_CONDITION);
      APP_ERROR_CHECK(err_code);
      while (m_xfer_done == false);

I don't know why the transfert didn't fully finished, but i need a way to not stay stuck here. Is there handler or timeout mecanism to use may be to avoid this issue please with TWI module ?

Thank you !

  • HI Jared ,

    Our connexion latency is solved ( it was linked to our system).

    I will open dedicated topics for other issue i have , and there is ... Smiley

  • Hi,

    Ok. Just want to comment that you need to start capturing before the link is decrypted. The sniffer trace doesn't fully show the communication as the link is encrypted. You have either turn off pairing or capture a trace when they pair so that the key can be sniffed by the sniffer and so that it can decrypt the link.

    regards

    Jared 

  • You point exactly the probleme i'm faced at the moment: 

    I was working on pairing because i have this strange issue:

    My program is based on hrs example + dfu merging.

    I was thinking that, by using pairing protection with 6 digit fixed pathkey( no other choice cause no IO), i would not be able to read/write my characteriqtics. But with nrfConnect, if you are fast enough, when bounding window pops up , and you click cancel and really fast after, you are able to click on the row to read a characteristics, the connexion is maintained and you have access to all , without been securly paired !!! 

    I know i can protect each caracteristic by using : BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM , what i did. 

    But a side effect appears: after first pairing on the phone by writing the 6 digit passkey, the same windows pops up FOR EACH characteristic you read ( only the first time) ... so it s a bit anoying because you have the feeling to have paired at connexion step , but in fact it has absolutely no impact on security.

    If you click cancel you are still connected and if fast enough you can even have access to all. If you paired successfully, you will have to enter this same path key for each characteristic you have protected, what give a strange effect to the final user, he has the feeling that first pairing didn't worked.

    What i need is : ask pairing after connect. If android user enter correct path kay , no more ask user to enter pathkey. If no or cancel, close connexion or retry but doesn't give access. Only paired device should have access.

    But now i get this error when i want to enter the passkey on android phone:

    <debug> nrf_sdh_ble: BLE event: 0x12.
    <debug> nrf_sdh_ble: BLE event: 0x13.
    <error> peer_manager_sm: Could not perform security procedure. smd_params_reply() or smd_link_secure() returned NRF_ERROR_INVALID_ADDR. conn_handle: 0
    <error> peer_manager_handler: Unexpected fatal error occurred: error: NRF_ERROR_INVALID_ADDR
    <error> peer_manager_handler: Asserting.
    <error> app: ERROR 16 [NRF_ERROR_INVALID_ADDR] at C:\nordic\nRF5SDK160098a08e2\components\ble\peer_manager\peer_manager_handler.c:294
    

  • Hi,

    My understanding is that the original problem regarding the TWI has been solved. We are happy to help you with the issue regarding pairing but would prefer that you made a new ticket for it. That makes it easier for other users on this forum to follow this thread when they have a similar twi problem etc.. 

    best regards

    Jared

  • I agree , i understand , i already move quiet a lot from original subject, new ticket is already created , thanks a lot !

Related