BLE FOTA (SMP) on nRF52840 connected to Gateway via Azure IotHub

Hi,

I am looking for information on how write a custom SMP client implementation for doing FOTA on a nrf52840 using BLE. I cant use the mcumgr CLI tool as my BLE device is connected to a thirdparty gateway and I only communicate with my BLE device through Azure IotHub using a custom API.

Here is a simple flow chart of my setup:

 | BLE device | <--> | Gateway | <--> | Azure IotHub | <--> | C# FOTA application |

I can do FOTA using the nRF app so my SMP server implementation is working.

Can you point me in the right direction?

SDK: nRF Connect v 2.1.0

Thank you

  • Hi,

    We do not have any SMP client implementation for doing DFU from other devices so that is something that is up to you, and also the cloud part. I don't know anything about your Gateway, but it would make sense to see if you can use mcumgr on it, or some other SMP server implementation with image management support.

  • Thanks for the answer. I´m trying to write my own SMP client implementation. I have a couple of issues that you might be able to help me with.

    Prerequisites: BLE device is connected and is setup to support SMP. I have verified OTA transfer in the nRF iOS app.

    Next step is to prepare my signed firmware file for uploading. Each packet has an 8 byte SMP header that looks like this:

    {

       (byte)  2 //Op code MGMT_OP_WRITE,

       (byte) 0 // Flags, always 0,

      (uint16) (n) //Data length,depends on mtu size and payload

      (uint16) 1 // image management group

      (byte) (n) // Sequence, is increment +1 for each packet

      (byte) 1 // Image group command ImageUpload

    }

    After that the CBOR data is added to this packet. The first CBOR packet looks like this:

    {

      "image": 1, // the not active image on my ble device

      "len": (n), // total size of my firmware binary

      "sha": (n), //sha 256 on the fw binary

      "upgrade": false,

      "off": 0

      "data": (n) contains as much data as I can fit within the CBOR. In first packet this is 160 bytes

    }

    After sending this packet to the device I get this response:

    SMP header:

    OpCode: MgmtOpWriteRsp (3)
        DataLength: 12
        GroupId: IMAGE group
        Sequence: 0
        CommandId: 1

    CBOR:
    {"rc": 0, "off": 160}

    I then continue sending the next packet with offset 160 that looks like this (it has the same SMP header as the first one):

    {

      "off": 160,

      "data": (n), // in this case it´s 222 bytes

    }

    After this I dont get any response from the device. I continue sending packets and after around 4 packets i receive the initial packet once again {"rc": 0, "off": 160}.

    I have´nt been able to figure this out. Maybe you see something obvious i´m doing wrong, or maybe you have an idea of where to look for issues?

    Thanks

  • Hi,

    I don't see anything obvious. Perhaps you can log or sniff the data and compare the traces from your implementation with a reference implementation and see where there are differences so know were to look closer?

Related