<?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>publish and subscribe address set and get function not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88797/publish-and-subscribe-address-set-and-get-function-not-working</link><description>Hello 
 I try to write functions to modify the publish and the subscribe addresses. Unfortunately not all is working, attached you will find my code. 
 Problems: 
 1.pubish set function: 
 I can&amp;#39;t set the address back to 0 (unassigned). 
 2.subscribe</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Jun 2022 06:47:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88797/publish-and-subscribe-address-set-and-get-function-not-working" /><item><title>RE: publish and subscribe address set and get function not working</title><link>https://devzone.nordicsemi.com/thread/373823?ContentTypeID=1</link><pubDate>Thu, 23 Jun 2022 06:47:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f205c6fe-80dc-4e08-aa1c-ec0409676328</guid><dc:creator>Michael Moser</dc:creator><description>&lt;p&gt;Thanks with this function it works.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: publish and subscribe address set and get function not working</title><link>https://devzone.nordicsemi.com/thread/372088?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 10:49:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e548cfec-3def-4d61-8406-8f30b43d338b</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;For 1, depending on how the publish address was set, there might be some internal state not being cleared up, or there might be conflict with already scheduled publications. You should consider &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v5.0.0%2Fgroup__ACCESS__CONFIG__MODEL.html&amp;amp;anchor=gaf3b9f367b029f5ff2fc3550d78c9207b"&gt;access_model_publication_stop()&lt;/a&gt; for your use case, which cleans up both dsm and internal access layer state. (Removing the public address without stopping poublications may lead to other errors, but access_model_publication_stop() makes sure to put the device in a state where publicataions will not be attempted.)&lt;/p&gt;
&lt;p&gt;Please note that for normal configuration, adding and removing publish addresses etc. is done through the configuration server model on the node, from a provisioner. Use of functions such as access_model_publish_address_set() is for when you want the device to auto-configure without the need of configuring it from a provisioner. Further, those functions are considered to be an internal API, hence why they may be difficult to use (and lead to undefined or bad states if used incorrectly.)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: publish and subscribe address set and get function not working</title><link>https://devzone.nordicsemi.com/thread/372024?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 07:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff11f02c-44b9-4cfe-bbf0-38fabe4d1d5e</guid><dc:creator>Michael Moser</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;1. I don&amp;#39;t get a error value.&lt;br /&gt;When i added a publish address (eg. 0xC001) only to one model it is possible to clear the value again.&lt;br /&gt;As soon as i publish the same address to different models i can&amp;#39;t remove them anymore.&lt;/p&gt;
&lt;p&gt;2. With your modification the problem is solved.&lt;/p&gt;
&lt;p&gt;3. I can&amp;#39;t reproduce the issue again. Maybe it was some mistake from my side.&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: publish and subscribe address set and get function not working</title><link>https://devzone.nordicsemi.com/thread/371915?ContentTypeID=1</link><pubDate>Fri, 10 Jun 2022 13:03:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b7908a0-f1e2-422a-89c4-53472d861a93</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;p&gt;1.pubish set function:&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t set the address back to 0 (unassigned).&lt;/p&gt;[/quote]
&lt;p&gt;What happens when you try, do you get an error value, does it silently not work, or other?&lt;/p&gt;
[quote user=""]2.subscribe get function&lt;br /&gt; give me sometimes wrong addresses back when the address is not set 0[/quote]
&lt;p&gt;I suggest initializing subscribe_address to DSM_HANDLE_INVALID before the call to access_model_subscriptions_get(), so that it will not contain a bogus value when the number of handles written by access_model_subscriptions_get() is 0, and instead of checking for DSM_HANDLE_INVALID after the call to access_model_subscriptions_get(), to check if 0 == count instead.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint16_t common_ble_mesh_init_sub_addr_get(access_model_handle_t model)
{
	uint32_t status = NRF_SUCCESS;
	dsm_handle_t subscribe_address = DSM_HANDLE_INVALID;
	uint16_t count = 1;

    if(model == NULL)   return 0;

	status = access_model_subscriptions_get(model, &amp;amp;subscribe_address, &amp;amp;count);

	if (status || subscribe_address == DSM_HANDLE_INVALID || 0 == count)
	{
		return 0;
	}
(...)&lt;/pre&gt;&lt;/p&gt;
[quote user=""]3. subscribe set function&lt;br /&gt; sometimes i can&amp;#39;t set a subscribe address[/quote]
&lt;p&gt;What happens when you try, do you get an error value, does it silently not work, or other?&lt;/p&gt;
&lt;p&gt;In general I recommend adding ERROR_CHECK() around error return values, as is done throughout the mesh SDK libraries and examples. It will call the app error handler on non-NRF_SUCCESS values, so you get the error code and location for debugging. If there are return values that you can handle programmatically or safely ignore, then check for those and use ERROR_CHECK on the value otherwise.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>