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

NRF52832 SDK 17 NUS LESC problem


Hi.

NRF52832 is used as central for connecting with phones as peripheral.
NUS service is used. Lesc is used too.

SDK 17
SoftDevice S132 V7.0.1

I have sometimes crash of application.
I suppose it is crash of softdevice.
there aren't any logs in that time.
Application is just restarting in random times (every 1 - 15 minutes).
Breakpoint on NVIC_SystemReset() doesn't catches too.
Size of stack was increased. So i think perhaps sd has crashed in that time.

How can i find cause of that?
Thanks for any suggestions.

Another strange thing is that after resetting chip in this cases
resolving of private resolved address doesn't work (im_address_resolve).
(it is usually actual for one phone from two. phone1 is connecting successfully, another phone has not resolved address.)

Parents
  • Try to add DEBUG to your preprocessor definitions, and monitor the log.

    If you aren't sure how to add preprocessor definitions, please let me know what IDE you are using. Segger Embedded Studio? Keil?

    If you are not sure how to monitor or enable the log, let me know.

    Best regards,

    Edvin

  • Hi!

    DEBUG was present in preprocessor directives.
    Reset problem is solved now. (It is described above)

    I have another question.
    When chip as central is connected with phone ( as peripheral)
    disconnection appears sometimes:

    <info> app: ble_nus_c_evt_handler(): conn_handle=0x0, evt_type=0x2
    <info> app: BLE_NUS_C_EVT_DISCONNECTED: 0x0
    <info> app: BLE_GAP_EVT_DISCONNECTED: 1 , reason=0x13

    0x13 means:
    #define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */


    It happens on old phone (BQ-5001L ble 4.0).
    I seem that another phone (more modern) doesn't has this issue.

    What may be caused of that disconnection?

  • You still don't know who initiated the disconnect, but either the nRF or the phone decided to disconnect. Check all the places in your application that can call sd_ble_gap_disconnect, and try to set breakpoints. Alternatively, you can try to capture a sniffer trace and see which device that sends the disconnect packet. 

  • Hello!

    Breakpoint at this place is catched sometimes.

    case BLE_GATTC_EVT_TIMEOUT:
    // Disconnect on GATT Client timeout event.
    NRF_LOG_INFO("BLE_GATTC_EVT_TIMEOUT: %d ", conn_handle);
    err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    break;


    but it is rarely.
    So i hesitate that it is cause.

    Breakpoints work strange sometimes.
    May be so that breakpoints catch not all times?

  • Breakpoints should catch, but the order of things may behave weird if optimization is enabled. Try to disable it. Let me knoe what IDE you are using if you are not sure how to do this.

    Another thing with breakpoints: If you have hit a breakpoint, you may try to step a few steps, but the softdevice will after a while realize that it missed some time critical events, and assert. So basically, this means that you need to reset the application after a breakpoint is hit.

    BR,

    Edvin

Reply
  • Breakpoints should catch, but the order of things may behave weird if optimization is enabled. Try to disable it. Let me knoe what IDE you are using if you are not sure how to do this.

    Another thing with breakpoints: If you have hit a breakpoint, you may try to step a few steps, but the softdevice will after a while realize that it missed some time critical events, and assert. So basically, this means that you need to reset the application after a breakpoint is hit.

    BR,

    Edvin

Children
  • I use IAR 8

    Optimisation is switched off now.

    Disconnections are observed periodically.
    Connection is set up. Data exchange is processed some seconds. And after that disconnect is following:
    <info> app: ble_nus_c_evt_handler(): conn_handle=0x2000, evt_type=0x2
    <info> app: BLE_GAP_EVT_DISCONNECTED: 1 , reason=0x13

    break points on sd_ble_gap_disconnect doesn't catch.

    Is it means that phone makes disconnect?


    I try to sniff rf logs by wireshark.
    But i don't understand how to setup filter to catch interesting devices.
    I enter passkey
    But addresses are changing on every connect (they are random)

  • DmitrySol said:
    I try to sniff rf logs by wireshark.
    But i don't understand how to setup filter to catch interesting devices.
    I enter passkey
    But addresses are changing on every connect (they are random)

     You need to select the advertising device from this dropdown menu:

    In IAR you disable optimization here:

  • Good day! Edvin.

    Thanks for your helping.

    The matter is - when disconnections appears, that is cycling every few seconds.
    So I can't catch address in list of wireshark.

    Could I set address of central device as not private random (for debugging). and use it for filtering in wireshark?
    If is it possible, how can i set that?

    And the next question:
    Could you advice a variant of self testing for factory testing.
    I mean testing RF part, accuracy of quartz. Perhaps do you have application note for that?


    Thanks!

  • Hello,

    It is not possible to filter on a central device, unfortunately.

    I assume you want to use the sniffer trace to figure out what's wrong. Please be aware that when the link is encrypted using LESC, the sniffer will not be able to sniff the connection anyway, since sniffer devices can't keep up with LESC, because of it's nature. It could keep up for some time (with undecrypted packages), but eventually it can't keep up with the channel switching, so it will loose the connection. 

    My advice to you is to try to debug the application. 

     

    I have sometimes crash of application.
    I suppose it is crash of softdevice.
    there aren't any logs in that time.

     Do you have logging enabled in your application at all? Are you sure it doesn't say something like "fatal error"?

    Is there some way for me to replicate this on a DK?

    Is it the nRF that crashes? What do you see on the phone? Does it just disconnect? Have you tried connecting via nRF Connect for Android/iOS? Does it give a disconnect reason?

    Do you see any disconnect reason on the nRF? Does the disconnect event occur at all?

    Best regards,

    Edvin

  • My advice to you is to try to debug the application. 

    Ok. I see.

    have sometimes crash of application.

    It is solved. I wrote above. External reset signal on the reset pin was the cause.

    Disconnections on old phone is another problem.

    Do you see any disconnect reason on the nRF?

    app: BLE_GAP_EVT_DISCONNECTED: 1 , reason=0x13

    And the next question:
    Could you advice a variant of self testing for factory testing.
    I mean testing RF part, accuracy of quartz. Perhaps do you have application note for that?

Related