RESET command value via bluetooth

Hello,

I'm new to the Nordic world, so please have mercy Slight smile

I'm developing a React Native mobile app for my client which needs a feature to send a RESET command to the device.

I saw on the nRF Connect Android app that there's the option to send this command and it works.

I read the value from the app logger and it's 0x0200000200000005BFFF and as the app log says it's composed in this way:

Flags: 0
Length: 2
Group Id: 0 (OS)
Sequence Num: 0
Command Id: 5 (RESET)
Message: {}" sent

I'm using react-native-ble-plx to communicate with the Development Kit board.


As the library documentation says, It needs a Base64 string of the value to be sent to the board in order to work, but if I try to send the Base64 of the HEX value, nothing happens. 

My question is:

Which is the correct value to send to the relative service in order to execute a RESET operation?

Thanks, 

Francesco

Parents Reply Children
  • Hi Francesco,

    The specification for the SMP commands can be found here: SMP Protocol Specification — Zephyr Project documentation (nRF Connect SDK) (nordicsemi.com).

    As far as I can see, the value from the nRF Connect App for Android that you noted down looks correct.

    A thing to note is that, as noted in the protocol specification, the Sequence Number is supposed to increment with each subsequent command.
    In my tests, I see that it doesn't seem to matter, so it might not explain your setup not working. Nonetheless, please try to increment the Sequence Number appropriately in your future attempts.

    Finally, the Data is a CBOR encoded, and is just empty. The encoding library used in the app simply encodes empty data, {} as a BF FF, with a Data Length of 2. You can keep it as is.

    So, the command you will want is:

    02-00-00-02-00-00-<Sequence Number>-05-BF-FF


    I am not familiar with the react-native-ble-plx library. If you really want someone to join you looking into it, I can. As of right now, I can only make these suggestions:

    • Please see if it is possible to enable logging to see what the library tries to send to the device.
    • Please check if the byte order is handled differently in that library.
      • For a quick test, you can try to get it to talk with the Nordic UART Service instead. This service handles notifications as ASCII strings.

    For the device end, you can configure the following Kconfig to get logging from the BLE Transport of the SMP module:

    CONFIG_MCUMGR_TRANSPORT_LOG_LEVEL_DBG=y
    CONFIG_LOG_MAX_LEVEL=4
    
    # Need immediate logging or the device will reset 
    # before the hex dump of the command is printed
    # For debugging purpose only
    CONFIG_LOG_MODE_IMMEDIATE=y
    
    # Set SMP Transport work queue stack size unreasonably large 
    # to prevent stack overflow due to immediate logging
    # For debugging purpose only
    CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=8192
    
    # Optionally switching logging backend to UART
    CONFIG_LOG_BACKEND_RTT=n 
    CONFIG_LOG_BACKEND_UART=y

    With that, I was able to log that the device reset at the same command you found:

  • Thank you very much!
    After some tries I finally managed it! 
    I was encoding the payload in the wrong way, but your guide has been very helpful with this, very appreciate.

    Best,

    Francesco

  • It's great to know that you got it. Please feel free to close this ticket at your convenience then Slight smile

    Regards,

    Hieu

Related