<?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>thingy91 - lwm2m Client Resource Instance Creation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96891/thingy91---lwm2m-client-resource-instance-creation</link><description>Good day 
 I am currently trying to adapt the lwm2m client sample from Zephyr and was wondering if there was a way to create multiple resource instances for the generic sensor object without changing the library. Also , I was able to create multiple instances</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Mar 2023 12:38:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96891/thingy91---lwm2m-client-resource-instance-creation" /><item><title>RE: thingy91 - lwm2m Client Resource Instance Creation</title><link>https://devzone.nordicsemi.com/thread/413250?ContentTypeID=1</link><pubDate>Fri, 03 Mar 2023 12:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e8e93d8-5e90-41ad-8b14-c6e667303a04</guid><dc:creator>SeppoTakalo</dc:creator><description>&lt;p&gt;Hi Hassan,&lt;br /&gt;&lt;br /&gt;I think there is now misunderstanding about LwM2M specification.&lt;br /&gt;&lt;br /&gt;First, you need to check whether the object in fact support multiple resource instances of given resource or not.&lt;br /&gt;For example IPSO Generic sensor has only a single instance of&amp;nbsp;&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Object ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Generic Sensor&lt;/td&gt;
&lt;td&gt;3300&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Resource definitions&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ID&lt;/td&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;td&gt;Instances&lt;/td&gt;
&lt;td&gt;Mandatory&lt;/td&gt;
&lt;td&gt;Type&lt;/td&gt;
&lt;td&gt;Range or Enumeration&lt;/td&gt;
&lt;td&gt;Units&lt;/td&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5700&lt;/td&gt;
&lt;td&gt;Sensor Value&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;span style="color:#ff0000;"&gt;Single&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mandatory&lt;/td&gt;
&lt;td&gt;Float&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Last or Current Measured Value from the Sensor.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5701&lt;/td&gt;
&lt;td&gt;Sensor Units&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;Single&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;String&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Measurement Units Definition.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;(Rest of the resources left out from the table above)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you can see from above the&amp;nbsp;&lt;strong&gt;Sensor Value&lt;/strong&gt; resource is marked as a single instance. So by the definition, you cannot create multiple instances of it.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, for example object that do support multiple resource instances, lets take example of Device object&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Object ID&lt;/td&gt;
&lt;td&gt;Object Version&lt;/td&gt;
&lt;td&gt;LWM2M Version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Device&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;1.1&lt;/td&gt;
&lt;td&gt;1.1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;h3 id="mcetoc_1gqjnfv450"&gt;Resource Definitions&lt;/h3&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ID&lt;/td&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;td&gt;Instances&lt;/td&gt;
&lt;td&gt;Mandatory&lt;/td&gt;
&lt;td&gt;Type&lt;/td&gt;
&lt;td&gt;Range or Enumeration&lt;/td&gt;
&lt;td&gt;Units&lt;/td&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Manufacturer&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;Single&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;String&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Human readable manufacturer name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Available Power Sources&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;Multiple&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;Integer&lt;/td&gt;
&lt;td&gt;0..7&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;0: DC power&lt;br /&gt;1: Internal Battery&lt;br /&gt;2: External Battery&lt;br /&gt;3: Fuel Cell&lt;br /&gt;4: Power over Ethernet&lt;br /&gt;5: USB&lt;br /&gt;6: AC (Mains) power&lt;br /&gt;7: Solar&lt;br /&gt;The same Resource Instance ID MUST be used to associate a given Power Source (Resource ID:6) with its Present Voltage (Resource ID:7) and its Present Current (Resource ID:8)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Power Source Voltage&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;Multiple&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;Integer&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Present voltage for each Available Power Sources Resource Instance. The unit used for this resource is in mV.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Left out some uninteresting resources. You can see that resources 6 and 7 are marked as supporting multipple instances.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now the object it self, when it defines all the resources, must tell LwM2M engine that those resources are multi-instance and how many instances can be created. See example of creating those resources here:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/e1e2228e9cc4dcebaba31da6d8e4681aa0ae33b0/subsys/net/lib/lwm2m/lwm2m_obj_device.c#L235-L240"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/e1e2228e9cc4dcebaba31da6d8e4681aa0ae33b0/subsys/net/lib/lwm2m/lwm2m_obj_device.c#L235-L240&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I see that you tried to create more resources using those macros, but that is wrong. When the object is defined, and registered to engine, it should not be altered anymore. So if any changes to it are required, you need to modify the object source code itself.&lt;/p&gt;
&lt;p&gt;Then when the engine knows how many of those resources are supported, in our application code, we use following LwM2M API&amp;nbsp;&lt;a title="lwm2m_create_res_inst()" href="https://docs.zephyrproject.org/latest/doxygen/html/group__lwm2m__api.html#gac69c40474180fe14c3761185b2db1c0c"&gt;lwm2m_create_res_inst()&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;See example of its use from:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/net/lwm2m_client/src/lwm2m-client.c#L137-L149"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/net/lwm2m_client/src/lwm2m-client.c#L137-L149&lt;/a&gt;&amp;nbsp;which creates the resources introduced in the table above.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps you to get going.&lt;br /&gt;Conclusion is that if you need multiple sensor values, you should create multiple sensor object instances.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: thingy91 - lwm2m Client Resource Instance Creation</title><link>https://devzone.nordicsemi.com/thread/412161?ContentTypeID=1</link><pubDate>Mon, 27 Feb 2023 08:01:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c677e8c-ad68-4341-97c7-be4e14b1b879</guid><dc:creator>Hkhan7861</dc:creator><description>&lt;p&gt;HI Amanda&lt;/p&gt;
&lt;p&gt;Apologies I don&amp;#39;t think I was clear enough in my post.&amp;nbsp; I am referring to a resource instance.&amp;nbsp; I am asking about creating multiple resource instances&amp;nbsp;(e.g sensor value ) inside one object instance.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Hassan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: thingy91 - lwm2m Client Resource Instance Creation</title><link>https://devzone.nordicsemi.com/thread/411174?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 16:01:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c10d7240-3c00-497d-b028-d25446aa7277</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user=""]was wondering if there was a way to create multiple resource instances for the generic sensor object without changing the library.[/quote]
&lt;p&gt;My colleague Didrik already showed you in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/94534/lwm2m---initialization-issues-lwm2m-client-sample/399497"&gt;this post&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;With a modem trace, you can see what the device sends, which might give some hints. If you use DTLS, see how to decode the packets here: &lt;a title="https://academy.nordicsemi.com/topic/lesson-7-exercise-2/" href="https://academy.nordicsemi.com/topic/lesson-7-exercise-2/" rel="noopener noreferrer" target="_blank"&gt;https://academy.nordicsemi.com/topic/lesson-7-exercise-2/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Regards,&lt;br /&gt;Amanda H.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>