<?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>Mesh Generic Location Server -Not configured state values +C-type implicit conversions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117657/mesh-generic-location-server--not-configured-state-values-c-type-implicit-conversions</link><description>Mesh 1.1 Generic Location Server defines special values for long/lat and north/east when unconfigured. Current code doesn&amp;#39;t appear to support/use these special values, instead using zero as defaults. This looks like a bug. 
 When attempting to fix the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Jan 2025 11:03:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117657/mesh-generic-location-server--not-configured-state-values-c-type-implicit-conversions" /><item><title>RE: Mesh Generic Location Server -Not configured state values +C-type implicit conversions</title><link>https://devzone.nordicsemi.com/thread/517660?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2025 11:03:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:667bd555-e48c-418f-b45a-60dc08e6f2a4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erik,&amp;nbsp;&lt;br /&gt;I forward the reply from our developer here:&amp;nbsp;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I reworked casting from &lt;code&gt;double&lt;/code&gt; to &lt;code&gt;int32_t&lt;/code&gt; and back. There is no &lt;code&gt;uint32_t&lt;/code&gt; usage anymore.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;int32_t&lt;/code&gt; is cast to double, I&amp;#39;m quite sure there are no any problems in this in C. Converting from &lt;code&gt;double&lt;/code&gt; to &lt;code&gt;int32_t&lt;/code&gt; happens after &lt;code&gt;floor&lt;/code&gt; function. Despite &lt;code&gt;floor&lt;/code&gt; returns &lt;code&gt;double&lt;/code&gt;type actually it is always integer due to floor nature. There is no issue in this conversion either. Please take a look: &lt;a title="https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-93b6cb0c6a59cd1e1d680c085e4b132ad47e2ef3653d3370964dc08cb1c0e794r22-r54" href="https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-93b6cb0c6a59cd1e1d680c085e4b132ad47e2ef3653d3370964dc08cb1c0e794R22-R54" rel="noopener noreferrer" target="_blank"&gt;https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-93b6cb0c6a59cd1e1d680c085e4b132ad47e2ef3653d3370964dc08cb1c0e794R22-R54&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;netbuf functionality doesn&amp;#39;t perform any mathematic, comparison and etc. The functions just copy absolute value from one memory to another. Until the size of memory cells are equal, the type doesn&amp;#39;t matter.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding Local North and Local East, there might be issues if decoded &lt;code&gt;int16_t&lt;/code&gt; values are compared against digit constants. I fixed the issue too. All &lt;code&gt;int16_t&lt;/code&gt; constants are explicitly converted to it. Please take a look here: &lt;a title="https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-bb6be1467e3276dafc1329e8f1f3e949ea486bbfdb8a989a24b606ef12d73152r34-r42" href="https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-bb6be1467e3276dafc1329e8f1f3e949ea486bbfdb8a989a24b606ef12d73152R34-R42" rel="noopener noreferrer" target="_blank"&gt;https://github.com/nrfconnect/sdk-nrf/pull/19757/files#diff-bb6be1467e3276dafc1329e8f1f3e949ea486bbfdb8a989a24b606ef12d73152R34-R42&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hm... I&amp;#39;m not sure how `floor` can behave nondeterministic. Is it possible at all? Seems the floor algorithm has been determined quite definitely.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh Generic Location Server -Not configured state values +C-type implicit conversions</title><link>https://devzone.nordicsemi.com/thread/517021?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2025 14:19:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:453a8423-2280-4c2b-8941-6a17a3aaa131</guid><dc:creator>erik</dc:creator><description>&lt;p&gt;Hi Hung,&lt;br /&gt;Thx for bug ack as to default values.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;For casting, the concern is when encoding the calculation occurs using double and then casts this to net_buf uint32. MshMdl1.1 states that it is sent as int32. I couldn&amp;#39;t find where such a type casting is defined. Is it specific to gcc, or defined in C99 and later standards?&lt;br /&gt;&lt;br /&gt;Similarly when decode long/lat from netbuf, how is the value recognized as an int32 and not an uint32?&lt;br /&gt;&lt;br /&gt;Local north, local east and altitude are also sent as int16. Unclear how the sign bit is carried over during encode/decode. Is this handled automatically by C99 integer promotion rules? Before dividing with the floating point constant I want to check whether the int16 value in msg equals special value 0x7FFF. If decode netbuf into a local int16 will this always work?&lt;br /&gt;&lt;br /&gt;Ps: When storing in settings subsys we use the same compact format as in the msg. It is a problem if floor function isn&amp;#39;t deterministic, since could result in a new FLASH write every time settings_save is called.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh Generic Location Server -Not configured state values +C-type implicit conversions</title><link>https://devzone.nordicsemi.com/thread/516992?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2025 13:13:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:217ef2b5-b583-43af-b605-30bbd31fa400</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erik,&amp;nbsp;&lt;br /&gt;The team acknowleded that it&amp;#39;s a bug. We will work on it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is some additional information (and question) could you take a look?&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div dir="auto"&gt;
&lt;p&gt;&lt;em&gt;Conversion from&amp;nbsp;&lt;code&gt;double&lt;/code&gt;&amp;nbsp;type of latitude\longitude is done over precalculated constants that adds more inaccuracy to the final result. However, almost always it is not possible to restore the same value as it was encoded since&amp;nbsp;&lt;code&gt;floor&lt;/code&gt;&amp;nbsp;function adds inaccuracy by self. (formulas in Mesh Model 1.1 in&amp;nbsp;&lt;code&gt;3.1.7.1 Global Latitude&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;3.1.7.2 Global Longitude&lt;/code&gt;&amp;nbsp;chapters).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Furthermore, it is possible to use custom ranges for latitude and longitude. Conversion from&amp;nbsp;&lt;code&gt;int&lt;/code&gt;&amp;nbsp;to&amp;nbsp;&lt;code&gt;uint&lt;/code&gt;&amp;nbsp;and back during packing\unpacking from\to buffer (net_buf_simple_add_lexx\net_buf_simple_pull_lexx) will not add any errors.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;If we are talking about casting during encoding\decoding, it will be nice to get clarification which casting customer assumes.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh Generic Location Server -Not configured state values +C-type implicit conversions</title><link>https://devzone.nordicsemi.com/thread/516704?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2025 20:21:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3c789f8-1cbb-4169-aa07-a8eeed40f9f1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erik,&amp;nbsp;&lt;br /&gt;I have reported this internally. I will get back to you when we have an update.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>