Hi,
Is there any example of a Central device which is able to connect to a peripheral and update it ? Im guessing the bluetooth_central_dfu_smp sample is probably the closest one to what I want.
Thank you!
Hi,
Is there any example of a Central device which is able to connect to a peripheral and update it ? Im guessing the bluetooth_central_dfu_smp sample is probably the closest one to what I want.
Thank you!
Yes, that is the closest official sample.
A colleague and me have created this unofficial one which is the bluetooth_central_dfu_smp with some addes features.
Disclaimer:
This code/configuration is not thoroughly tested or qualified and should be considered provided “as-is”. Please test it with your application and let me know if you find any issues.
Regards,
Sigurd Hellesvik
Sigurd Hellesvik Hi,
Hope you are doing well!
A few question regarding the example. Im basically trying the send_upload and would like to know:
Thanks and hope you can give me some lights on this one
Miguel Ferreira said:How did you find the zcbor package format to send ? It was based on this doc https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/device_mgmt/smp_groups/smp_group_1.html
Honestly, it was my colleague who did most of the zcbor decoding, and he is out of office.
But yes, the docs you link do is a good place to look.
Also have a look how the official SMP Client example does things I guess?
Some official work is being done on a SMP Client, but it is not done yet. See https://github.com/zephyrproject-rtos/zephyr/pull/56934.
Maybe you can get some hints on how to work with zcbor from how it is done in the PR?
Miguel Ferreira said:Im getting no errors on bt_dfu_smp_command, but it enters in the if conditional anyway: "bt_dfu_smp_command failed with 0" Did you have something like this during your tests ?
It is a little while since I tested this last, but I can not remember this specific error.
Which version of the nRF Connect SDK do you use?
Which board?
If you give these, I can try to see if I get the same.
It is odd that it fails with 0 though, as it is if(err). Which line is this on?
Miguel Ferreira said:Final question, the above says it fails but the command seems to run because I have the following reply: Error in image upload response: 3.
From SMP Error codes, 3 = "Invalid value; a request contains an invalid value."
If I had to guess I would say you had either formatted zcbor wrong, or put some wrong data in the request or header.
Regards,
Sigurd Hellesvik
Thanks for the reply and for pointing me some useful stuff!
So basically I'm using the NRF52840DK and NRF Connect 2.2.0.
Im trying to send a 259395 bytes binary file - the update bin. In order to do it, im sending 64 bytes chunks to my peripheral. My encode is the following:
zse->constant_state->stop_on_error = true;
zcbor_map_start_encode(zse, 20); // I think this is only used if you enable ZCBOR_CANONICAL
zcbor_tstr_put_lit(zse, "image");
zcbor_int64_put(zse, 0); // Image slot
zcbor_tstr_put_lit(zse, "data"); // Data
zcbor_bstr_put_lit(zse, (const char*)data); // 64 bytes chunk
if (first) {
zcbor_tstr_put_lit(zse, "len");
zcbor_uint64_put(zse, (uint64_t)0x3F543); // Image size 259395 bytes
}
zcbor_tstr_put_lit(zse, "off");
zcbor_uint64_put(zse, off); // Offset off+=64 each time
if(first) {
zcbor_tstr_put_lit(zse, "sha");
zcbor_bstr_put_lit(zse, "12345");
}
zcbor_tstr_put_lit(zse, "upgrade");
zcbor_bool_put(zse, false);
zcbor_map_end_encode(zse, 20); // Ditto as above
Do you notice anything wrong here ?
Thanks again will also take a look at the PR
Thanks for the reply and for pointing me some useful stuff!
So basically I'm using the NRF52840DK and NRF Connect 2.2.0.
Im trying to send a 259395 bytes binary file - the update bin. In order to do it, im sending 64 bytes chunks to my peripheral. My encode is the following:
zse->constant_state->stop_on_error = true;
zcbor_map_start_encode(zse, 20); // I think this is only used if you enable ZCBOR_CANONICAL
zcbor_tstr_put_lit(zse, "image");
zcbor_int64_put(zse, 0); // Image slot
zcbor_tstr_put_lit(zse, "data"); // Data
zcbor_bstr_put_lit(zse, (const char*)data); // 64 bytes chunk
if (first) {
zcbor_tstr_put_lit(zse, "len");
zcbor_uint64_put(zse, (uint64_t)0x3F543); // Image size 259395 bytes
}
zcbor_tstr_put_lit(zse, "off");
zcbor_uint64_put(zse, off); // Offset off+=64 each time
if(first) {
zcbor_tstr_put_lit(zse, "sha");
zcbor_bstr_put_lit(zse, "12345");
}
zcbor_tstr_put_lit(zse, "upgrade");
zcbor_bool_put(zse, false);
zcbor_map_end_encode(zse, 20); // Ditto as above
Do you notice anything wrong here ?
Thanks again will also take a look at the PR
Miguel Ferreira said:Do you notice anything wrong here ?
I do not see anything, but it is hard to stare at code until an error pops out.
Sigurd Hellesvik said:If you give these, I can try to see if I get the same.
Aha, I now realize that my example works, but not your custom one.
Then it is a bit hard to test myself.
But I will help you debug it instead.
Sigurd Hellesvik said:From SMP Error codes, 3 = "Invalid value; a request contains an invalid value."
I might be a bit wrong here. Error 3 could also mean ESRCH 3 /**< No such context */.
Can you check which part of bt_dfu_smp_command() returns the error?
And then maybe even which part of its sub-functions return the error also?
Regards,
Sigurd Hellesvik
Hi again Sigurd,
Thanks for helping me on this. So I figure out the issue and I can send the data correctly. Seems that on the first chunk (where you send the image size and sha) I have to wait some seconds before start sending the data. Was getting error -16 (Timeout).
Now Im on the point of sending a confirm messages for the peripheral , so it can use the new image when it reboots. Im taking a look at the PR you mentioned, really useful! Have you tried to do this also ?
Thanks a lot!
I think my sample on git also can send "test" and "confirm":
Sigurd Hellesvik said:github.com/.../quote]But the PR is probably doing it in a more elegant way.
Regards,
Sigurd Hellesvik
Meanwhile I created the command myself and its working :)
Thanks a lot for your help Sigurd Hellesvik !