<?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 SDK light switch example combining client and server</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79514/mesh-sdk-light-switch-example-combining-client-and-server</link><description>Hi All: 
 We are using nRF52840 SDK with BLE Mesh sdk5.0 to develop bluetooth mesh and we can use light_sw_client to control the LED1 state on the light_sw_sever via BLE Mesh APP and nRF52840_DK. 
 Now we hope to integrated the ight_sw_client and light_sw_sever</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Sep 2021 06:32:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79514/mesh-sdk-light-switch-example-combining-client-and-server" /><item><title>RE: Mesh SDK light switch example combining client and server</title><link>https://devzone.nordicsemi.com/thread/329713?ContentTypeID=1</link><pubDate>Thu, 16 Sep 2021 06:32:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8034586e-577c-40fd-a8d7-735197abce59</guid><dc:creator>shenghua</dc:creator><description>&lt;p&gt;&lt;span&gt;Dea&lt;/span&gt;&lt;span&gt;r&amp;nbsp;&lt;a title="" href="https://devzone.nordicsemi.com/members/mttrinh" rel="noopener noreferrer" target="_blank"&gt;&lt;span style="color:#000000;"&gt;Mttrinh&lt;/span&gt;&lt;/a&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;It is right.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;we hope add&amp;nbsp;&lt;/span&gt;&lt;span&gt;two client models into sever model to implement a control model&amp;nbsp;&lt;/span&gt;&lt;span&gt;on the same node.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;After adding enough elements to the node in the &amp;quot;nrf_mesh_conf_app.h&amp;quot;, we can the &amp;quot;run mesh_init()&amp;quot; function successfully.&lt;/div&gt;
&lt;div&gt;The &amp;quot;nrf_mesh_conf_app.h&amp;quot; was modified as the following.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/div&gt;
&lt;div&gt;//#define ACCESS_MODEL_COUNT (/* Element 0: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 + /* Config Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 + /* Health Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 + /* Generic OnOff Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 + /* Default Transition Time Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 + /* Scene Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; /* Scene Setup Server (extends Scene Server) &amp;nbsp; &amp;nbsp;*/)&lt;br /&gt;&lt;br /&gt;#if 1&lt;br /&gt;//2021.0916&amp;nbsp; .....add Generic OnOff client model ......&lt;br /&gt;&lt;span style="color:#0b5394;"&gt;#define ACCESS_MODEL_COUNT (/* Element 0: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + /* Config Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + /* Health Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + /* Generic OnOff Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + /* Default Transition Time Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + /* Scene Server &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; */ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + &amp;nbsp;/* Scene Setup Server (extends Scene Server) &amp;nbsp; */ \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; /* Generic OnOff client (2 groups) */)&lt;/span&gt;&lt;br /&gt;#endif&lt;br /&gt;/**&lt;br /&gt;&amp;nbsp;* The number of elements in the application.&lt;br /&gt;&amp;nbsp;*&lt;br /&gt;&amp;nbsp;* @warning If the application is to support _multiple instances_ of the _same_ model, these instances&lt;br /&gt;&amp;nbsp;* cannot be in the same element and a separate element is needed for each new instance of the same model.&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;//2021.0916 ......update element count .....&lt;br /&gt;//#define ACCESS_ELEMENT_COUNT (1)&lt;br /&gt;&lt;span style="color:#073763;"&gt;#define ACCESS_ELEMENT_COUNT (3)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//#define ACCESS_ELEMENT_COUNT (1 + CLIENT_MODEL_INSTANCE_COUNT) /* One element per Generic OnOff client instance */&lt;/div&gt;
&lt;div&gt;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Then we ran the &amp;quot;BLE Mesh APP&amp;quot; to add a node in the cell phone and found the elements of &amp;quot;Generic_on_off_client&amp;quot; had been add into the node as below.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/node-Configuration_2800_nrf52840_2900_.jpg" alt=" " /&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best Regards,&lt;/div&gt;
&lt;div&gt;Sheng-Hua&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh SDK light switch example combining client and server</title><link>https://devzone.nordicsemi.com/thread/329594?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 11:45:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:017d5793-be28-4a48-a1be-fa954842de97</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to clarify, you want two client models on the same node?&lt;/p&gt;
&lt;p&gt;I suspect that not enough elements have been added to the node so when you try to initiate the model in the inputted element index it will return invalid element index. Can you check that you also have added the correct amount of elements to the node?&lt;/p&gt;
&lt;p&gt;Note that if you want multiple instances of the same model, these instances cannot be in the same element and a separate element is needed for each new instance of the same model.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh SDK light switch example combining client and server</title><link>https://devzone.nordicsemi.com/thread/329296?ContentTypeID=1</link><pubDate>Tue, 14 Sep 2021 04:12:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da70b018-5f9c-4a80-8549-2dd194c81286</guid><dc:creator>shenghua</dc:creator><description>&lt;p&gt;Dear Mttrinh:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks your support.&lt;/p&gt;
&lt;p&gt;We integrated the following codes of l&lt;span&gt;ight_sw_client to&amp;nbsp;light_sw_sever in&amp;nbsp;models_init_cb function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In debug procedure, we found that&amp;nbsp;the element_index is 1 and 2 in the &amp;quot;generic_onoff_client_init&amp;quot;; and the&amp;nbsp;element_index&amp;nbsp;is 1 in &amp;quot;generic_onoff_server_init&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Sheng-Hua&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;// ..... adding client models .&lt;/span&gt;...///////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Initializing and adding client models\n&amp;quot;);&lt;/p&gt;
&lt;p&gt;for (uint32_t i = 0; i &amp;lt; CLIENT_MODEL_INSTANCE_COUNT; ++i)&lt;br /&gt;{&lt;br /&gt;m_clients[i].settings.p_callbacks = &amp;amp;client_cbs;&lt;br /&gt;m_clients[i].settings.timeout = 0;&lt;br /&gt;m_clients[i].settings.force_segmented = APP_FORCE_SEGMENTATION;&lt;br /&gt;m_clients[i].settings.transmic_size = APP_MIC_SIZE;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;ERROR_CHECK(generic_onoff_client_init(&amp;amp;m_clients[i], i + 1));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;
&lt;p&gt;&lt;span&gt;/***********************************************************************************************&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;uint32_t&lt;span style="color:#ff0000;"&gt; generic_onoff_client_init&lt;/span&gt;(generic_onoff_client_t * p_client, uint8_t element_index)&lt;br /&gt;{&lt;br /&gt; if (p_client == NULL ||&lt;br /&gt; p_client-&amp;gt;settings.p_callbacks == NULL ||&lt;br /&gt; p_client-&amp;gt;settings.p_callbacks-&amp;gt;onoff_status_cb == NULL ||&lt;br /&gt; p_client-&amp;gt;settings.p_callbacks-&amp;gt;periodic_publish_cb == NULL)&lt;br /&gt; {&lt;br /&gt; return NRF_ERROR_NULL;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;if (p_client-&amp;gt;settings.timeout == 0)&lt;br /&gt; {&lt;br /&gt; p_client-&amp;gt;settings.timeout= MODEL_ACKNOWLEDGED_TRANSACTION_TIMEOUT;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;access_model_add_params_t add_params =&lt;br /&gt; {&lt;br /&gt; .model_id = ACCESS_MODEL_SIG(GENERIC_ONOFF_CLIENT_MODEL_ID),&lt;br /&gt; .element_index&lt;span style="background-color:#ffffff;"&gt; = &lt;span style="color:#ff6600;"&gt;element_index,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; .p_opcode_handlers = &amp;amp;m_opcode_handlers[0],&lt;br /&gt; .opcode_count = ARRAY_SIZE(m_opcode_handlers),&lt;br /&gt; .p_args = p_client,&lt;br /&gt; .publish_timeout_cb = p_client-&amp;gt;settings.p_callbacks-&amp;gt;periodic_publish_cb&lt;br /&gt; };&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff0000;"&gt;uint32_t status = access_model_add(&amp;amp;add_params, &amp;amp;p_client-&amp;gt;model_handle);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;if (status == NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; status = access_model_subscription_list_alloc(p_client-&amp;gt;model_handle);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;return status;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;span&gt;************************************************************************************************/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;/**********************************************************************************************/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;uint32_t app_onoff_init(app_onoff_server_t * p_app, uint8_t element_index)&lt;br /&gt;{&lt;br /&gt; uint32_t status = NRF_ERROR_INTERNAL;&lt;/p&gt;
&lt;p&gt;if (p_app == NULL)&lt;br /&gt; {&lt;br /&gt; return NRF_ERROR_NULL;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;p_app-&amp;gt;server.settings.p_callbacks = &amp;amp;m_onoff_srv_cbs;&lt;br /&gt; if ( (p_app-&amp;gt;onoff_get_cb == NULL) ||&lt;br /&gt; ( (p_app-&amp;gt;onoff_set_cb == NULL) &amp;amp;&amp;amp;&lt;br /&gt; (p_app-&amp;gt;onoff_transition_cb == NULL) ) )&lt;br /&gt; {&lt;br /&gt; return NRF_ERROR_NULL;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;status = &lt;span style="color:#ff0000;"&gt;generic_onoff_server_init&lt;/span&gt;(&amp;amp;p_app-&amp;gt;server, &lt;span style="background-color:#ffffff;color:#339966;"&gt;element_index);&lt;/span&gt;&lt;br /&gt; if (status != NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; return status;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;/* Set the default state.&lt;br /&gt; */&lt;br /&gt; status = generic_onoff_mc_open(&amp;amp;p_app-&amp;gt;server.state_handle);&lt;br /&gt; if (status != NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; return status;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;****************************************************************************************************/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh SDK light switch example combining client and server</title><link>https://devzone.nordicsemi.com/thread/329175?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 09:57:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aea611f5-3e07-453d-b2fd-4be14e40bdd9</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Getting Mesh error 5 (&lt;span&gt;NRF_ERROR_NOT_FOUND)&amp;nbsp;&lt;/span&gt;from&amp;nbsp;&lt;span&gt;generic_onoff_client_init() function means invalid access element index. Can you check that the element index is correct?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>