<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100402/smp-command-using-zcbor-command-line-and-cddl-file</link><description>Hello ! 
 We would like to implement a SMP client code as described in https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html . In Zephyr we can use the zcbor lib that you implemented: https://github.com/NordicSemiconductor/zcbor</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Aug 2023 14:24:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100402/smp-command-using-zcbor-command-line-and-cddl-file" /><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/442614?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 14:24:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15290986-6269-4357-bc98-f2456d06147e</guid><dc:creator>Depraz</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I re-implemented the logic on a device (not nrf52 based) to do the upload image using SMP. The target was an nrf52 device.&lt;br /&gt;With the cddl file shared above, I get the &amp;quot;encode&amp;quot; and &amp;quot;decode&amp;quot; functions from the zcbor command line.&lt;/p&gt;
&lt;p&gt;Here is the cddl to do the upload of the payload (encode, decode).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SmpImageUploadReq = {
  ? &amp;quot;len&amp;quot; =&amp;gt; uint,
  ? &amp;quot;sha&amp;quot;  =&amp;gt; bstr,
  &amp;quot;off&amp;quot; =&amp;gt; uint,
  &amp;quot;data&amp;quot; =&amp;gt; bstr,
  ? &amp;quot;image&amp;quot; =&amp;gt; uint,
  ? &amp;quot;upgrade&amp;quot; =&amp;gt; bool,
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;We faced such issue when trying to decode from python cbor library but it was because we did not use the proper data structure&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/442594?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 13:43:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fae8fef-790d-48bf-bce5-ec48b4db252c</guid><dc:creator>fr_adv</dc:creator><description>&lt;p&gt;Hello Depraz,&lt;/p&gt;
&lt;p&gt;Did you manage to make this work ? How did you register a specific SMP group ID ? I&amp;#39;m trying to do something very similar : use a cddl file to generate the encode / decode functions, then send data on SMP over BLE with a specific group ID. I would like to read and write data in CBOR over SMP, for now I focus on the sending only.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;registered a new mcu mgr handler, with read and write callbacks with the following macro :&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;MCUMGR_HANDLER_DEFINE(my_handler, my_handler_init);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and I&amp;#39;m very close to encode correctly the data in CBOR before sending them on BLE, but I&amp;#39;m facing the issue that in the Zephyr file smp.c, the characters to start a map and end a map are automatically added :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	if (handler_fn) {
		*handler_found = true;

        /***** HERE, this add a character to start a map in CBOR *****/
		zcbor_map_start_encode(cbuf-&amp;gt;writer-&amp;gt;zs, CONFIG_MGMT_MAX_MAIN_MAP_ENTRIES);

        /***** my custom function, where I encore data in CBOR as a map *****/
		MGMT_CTXT_SET_RC_RSN(cbuf, NULL);
		rc = handler_fn(cbuf);

		/* End response payload. */
        /***** HERE, this add a character to end a map in CBOR *****/
		if (!zcbor_map_end_encode(cbuf-&amp;gt;writer-&amp;gt;zs, CONFIG_MGMT_MAX_MAIN_MAP_ENTRIES) &amp;amp;&amp;amp;
		    rc == 0) {
			rc = MGMT_ERR_EMSGSIZE;
		}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;therefore, two consecutive &amp;quot;map start&amp;quot; (0xBF) &amp;amp; &amp;quot;map end&amp;quot; (0xFF) are sent on the BLE link, and the data is not correct according to the playground cbor.me&lt;/p&gt;
&lt;p&gt;Since the&amp;nbsp;nRF Connect SDK&amp;nbsp;spec says :&amp;nbsp;&lt;em&gt;The payload for above groups, except for user groups (&lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;64&lt;/span&gt;&lt;/code&gt;&amp;nbsp;and above) is always CBOR encoded. The group&amp;nbsp;&lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;64&lt;/span&gt;&lt;/code&gt;, and above can define their own scheme for data communication. &lt;/em&gt;I think this should be possible to use the SMP over BLE link without having the mcumgr adding any CBOR encoding, but I don&amp;#39;t know how to do that.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m interested to know how you did to work around this issue !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/429768?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 12:24:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8962818c-ba3b-4ed1-b83c-a1d14082734d</guid><dc:creator>Depraz</dc:creator><description>&lt;p&gt;We could figure out the proper cddl to use:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Image = {
  ? &amp;quot;image&amp;quot; =&amp;gt; uint,
  &amp;quot;slot&amp;quot; =&amp;gt; uint,
  &amp;quot;version&amp;quot; =&amp;gt; tstr,
  ? &amp;quot;hash&amp;quot;  =&amp;gt; bstr,
  ? &amp;quot;bootable&amp;quot; =&amp;gt; bool,
  ? &amp;quot;pending&amp;quot; =&amp;gt; bool,
  ? &amp;quot;confirmed&amp;quot; =&amp;gt; bool,
  ? &amp;quot;active&amp;quot; =&amp;gt; bool,
  ? &amp;quot;permanent&amp;quot; =&amp;gt; bool,
}

Images = {
  &amp;quot;images&amp;quot; =&amp;gt; [0*2 Image],
  ? &amp;quot;splitStatus&amp;quot; =&amp;gt; uint
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/429338?ContentTypeID=1</link><pubDate>Mon, 05 Jun 2023 13:49:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8493e9eb-1d51-4407-a0d9-0b5fe9b8bbe1</guid><dc:creator>Depraz</dc:creator><description>&lt;p&gt;The ZCBOR repository contains a command line tool to generate code for encoding/decoding a message in C.&lt;br /&gt;It can be done using the following command line (deduced from the README)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;zcbor -c cbor.cddl --no-prelude&amp;#160; --default-max-qty 2 code -t MultiList --encode --output-cmake imageslot&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;where the cbor.cddl is the description of the message that can be encoded/decoded. It gives multiple files:&lt;/p&gt;
&lt;p&gt;-&amp;nbsp;imageslot_decode.c: to decode a buffer to a structure&lt;br /&gt;- imageslot_encode.c: to encode a structure and get the corresponding buffer&lt;br /&gt;- imageslot_types.h: containing the structures in C of the corresponding .cddl description&lt;/p&gt;
&lt;p&gt;I want to implement an SMP client to get the image state and upload an image on a BLE device as described in&amp;nbsp;&lt;a id="" href="https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html"&gt;https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I generate the code using the .cddl I shared, it adds the field &amp;quot;image&amp;quot;:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;	bool tmp_result = (((zcbor_map_start_decode(state) &amp;amp;&amp;amp; (((((zcbor_tstr_expect(state, ((tmp_str.value = (uint8_t *)&amp;quot;image&amp;quot;, tmp_str.len = sizeof(&amp;quot;image&amp;quot;) - 1, &amp;amp;tmp_str)))))
	&amp;amp;&amp;amp; (zcbor_uint32_decode(state, (&amp;amp;(*result)._map_image))))
	&amp;amp;&amp;amp; ((decode_Image(state, (&amp;amp;(*result)._images_map__Image))))) || (zcbor_list_map_end_force_decode(state), false)) &amp;amp;&amp;amp; zcbor_map_end_decode(state))));
&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;which is not expected in the payload: where I have only the fields &amp;quot;images&amp;quot;, &amp;quot;slot&amp;quot;, &amp;quot;version&amp;quot;, &amp;quot;hash&amp;quot;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;bf 66 69 6d 61 67 65 73  9f bf 64 73 6c 6f 74 00 |.fimages ..dslot.
67 76 65 72 73 69 6f 6e  65 30 2e 30 2e 33 64 68 |gversion e0.0.3dh
61 73 68 58 20 90 70 cc  23 30 17 54 06 a8 ce 15 |ashX .p. #0.T....
28 63 3e 9c f4 19 a7 4a  ec 7e ca ce 10 24 c4 af |(c&amp;gt;....J .~...$..
48 68 e1 2c c7 68 62 6f  6f 74 61 62 6c 65 f5 67 |Hh.,.hbo otable.g
70 65 6e 64 69 6e 67 f4  69 63 6f 6e 66 69 72 6d |pending. iconfirm
65 64 f5 66 61 63 74 69  76 65 f5 69 70 65 72 6d |ed.facti ve.iperm
61 6e 65 6e 74 f4 ff ff  6b 73 70 6c 69 74 53 74 |anent... ksplitSt
61 74 75 73 00 ff                                |atus..&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Is there a .cddl file you can share that would generate the code to decode the SMP request/response&amp;nbsp;(CBOR) ?&lt;/div&gt;
&lt;div&gt;If not, how can I write such file so that I can generate the C code using ZCBOR CLI to decode/encode SMP messages?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Thanks&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/429295?ContentTypeID=1</link><pubDate>Mon, 05 Jun 2023 12:30:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d633665-1000-4216-ab1f-4ca68dba09d6</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Can you please elaborate your question? I have talked to two developers now, and they are both confused about what you are asking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SMP command using ZCBOR command line and CDDL file</title><link>https://devzone.nordicsemi.com/thread/429218?ContentTypeID=1</link><pubDate>Mon, 05 Jun 2023 09:16:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a49f985a-e731-4c56-bf56-4e965f756aca</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have asked the developer, and I will let you know when he replies.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>