<?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>Use GET to retrieve the value of 3 variables - Mesh SDK 2.0.1</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35708/use-get-to-retrieve-the-value-of-3-variables---mesh-sdk-2-0-1</link><description>Hi, I&amp;#39;m using a modified version of the light_switch example to control a RGB led on Mesh SDK 2.0.1. I already managed to control the led by using 3 variables for each color (red, green and blue). So, from the &amp;quot;SET&amp;quot; I&amp;#39;m done (except for the status_reply</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 02 Jul 2018 10:32:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35708/use-get-to-retrieve-the-value-of-3-variables---mesh-sdk-2-0-1" /><item><title>RE: Use GET to retrieve the value of 3 variables - Mesh SDK 2.0.1</title><link>https://devzone.nordicsemi.com/thread/138480?ContentTypeID=1</link><pubDate>Mon, 02 Jul 2018 10:32:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2185d36e-8655-4b56-bcf7-2d66ab6bb7e9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok. I understand.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should change your reply_status, and the status of the different LEDs should be stored in the reply and status.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You must change your model&amp;#39;s status from simple_on_off_msg_status_t, which currently only holds one uint8_t present_on_off, to hold one uint8_t for each.&lt;/p&gt;
&lt;p&gt;Then change the reply_status:&lt;/p&gt;
&lt;p&gt;status.red = red;&lt;/p&gt;
&lt;p&gt;status.green = green;&lt;/p&gt;
&lt;p&gt;status.blue = blue;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you need to change the callback function, which is currently named the on_off_server_get_cb().&lt;/p&gt;
&lt;p&gt;The get_cb() function call is a typedef, declared on line 63 in simple_on_off_server.h:&lt;/p&gt;
&lt;p&gt;typedef bool (*simple_on_off_get_cb_t)(const simple_on_off_server_t * p_self);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to add arguments to this, add it after (const simple_on_off_server_t * p_self, uint8_t * value 1 ...)&lt;/p&gt;
&lt;p&gt;You also need to create the variables current_red/green/blue_dt_cycle; variables. These can be stored in your simple_on_off_server.c/h files.&lt;/p&gt;
&lt;p&gt;These will be the ones that you use in&amp;nbsp;reply_status:&lt;/p&gt;
&lt;p&gt;status.red = current_red_dt_cycle;&lt;/p&gt;
&lt;p&gt;status.green = current_green_dt_cycle;&lt;/p&gt;
&lt;p&gt;status.blue = current_blue_dt_cycle;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that this is only changing the pointers handed to the on_off_server_get_cb(), and not returning them. You need to change the on_off_server_get_cb to be a void function (or simply return true or false, and ignore the return value).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am sorry if this was a bit messy. But to sum up, my suggestion is the following:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;in main.c: on_off_server_get_cb: use the implementation that you attached now, and add return true; at the end, or change static bool to void.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;in simple_on_off_common.h:&amp;nbsp; change:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** Message format for the Simple OnOff Status message. */
typedef struct __attribute((packed))
{
    uint8_t present_on_off; /**&amp;lt; Current state. */
} simple_on_off_msg_status_t;

to

/** Message format for the Simple OnOff Status message. */
typedef struct __attribute((packed))
{
    uint8_t current_red; /**&amp;lt; Current state. */
    uint8_t current_green; /**&amp;lt; Current state. */
    uint8_t current_blue; /**&amp;lt; Current state. */
} simple_on_off_msg_status_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;in simple_on_off_server.h: on line 63: change:&lt;/p&gt;
&lt;p&gt;typedef bool (*simple_on_off_get_cb_t)(const simple_on_off_server_t * p_self);&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;typedef bool (*simple_on_off_get_cb_t)(const simple_on_off_server_t * p_self, uint8_t * current_red_dt_cycle, ...); (the same as your on_off_server_get_cb() function) The values from these pointers must be accessible from reply_status() in simple_on_off_server.c.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;in simple_on_off_server.c: change status,present_on_off = present_on_off ? 1 : 0;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;status.red = red;&lt;/p&gt;
&lt;p&gt;status.green = green;&lt;/p&gt;
&lt;p&gt;status.blue = blue;&lt;/p&gt;
&lt;p&gt;where red green and blue are the values in the pointers that you change in get_cb.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use GET to retrieve the value of 3 variables - Mesh SDK 2.0.1</title><link>https://devzone.nordicsemi.com/thread/138376?ContentTypeID=1</link><pubDate>Sat, 30 Jun 2018 11:12:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd9e5cf1-1c0b-4291-8d1e-b07fab346f36</guid><dc:creator>Paulo.Zacarias</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;br /&gt;&lt;br /&gt;Thank you for your reply.&lt;br /&gt;&lt;br /&gt;Regarding your questions:&lt;br /&gt;&lt;br /&gt;1. &lt;em&gt;I assume that you modified the on_off_model, and didn&amp;#39;t add another model with the RGB values, is that correct?&lt;br /&gt;&lt;br /&gt;&lt;/em&gt;Yes, so far I just modified the on_off_model, I haven&amp;#39;t added any other model.&lt;/p&gt;
&lt;p&gt;2. &lt;em&gt;I assume that you haven&amp;#39;t modified the access_model_reply() function?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;No, I haven&amp;#39;t modified the access_model_reply() function.&lt;/p&gt;
&lt;p&gt;3. &lt;em&gt;Can you check what access_model_reply() returns?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t been able even to build the solution. I&amp;#39;m still struggling with the &lt;strong&gt;reply_status&lt;/strong&gt; function and the &lt;strong&gt;get_cb&lt;/strong&gt; on the &lt;strong&gt;handle_get_cb&lt;/strong&gt;...&lt;/p&gt;
&lt;p&gt;I tried to use pointers to return 3 parameters in the &lt;strong&gt;main.cb&lt;/strong&gt;, as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static bool on_off_server_get_cb(const simple_on_off_server_t * p_server, uint8_t * current_red_dt_cycle, uint8_t * current_green_dt_cycle, uint8_t * current_blue_dt_cycle)
{
    //return hal_led_pin_get(LED_PIN_NUMBER);
    * current_red_dt_cycle = red_duty_cycle;
    * current_green_dt_cycle = green_duty_cycle;
    * current_blue_dt_cycle = blue_duty_cycle;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But I still don&amp;#39;t know how to modify the &lt;strong&gt;get_cb&lt;/strong&gt; &lt;strong&gt;&lt;/strong&gt;to accept 3 parameters (I can&amp;#39;t even find where&amp;nbsp;&lt;strong&gt;get_cb&lt;/strong&gt; is defined):&lt;br /&gt;&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1530357020240v1.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;So, until I figure out how to solve this, I can&amp;#39;t run it and check what &lt;strong&gt;access_model_reply() &lt;/strong&gt;returns.&lt;br /&gt;&lt;br /&gt;Any directions on how to proceed? Thank you in advance!&lt;br /&gt;&lt;br /&gt;BR,&lt;/p&gt;
&lt;p&gt;Paulo Zacarias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use GET to retrieve the value of 3 variables - Mesh SDK 2.0.1</title><link>https://devzone.nordicsemi.com/thread/137706?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 13:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e6d17fa-227b-4378-9096-a1b9e0500eb4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am sorry, I have been trying to set up a separate module in the Mesh light_switch example, but I have not yet finished. I have some problem with the provisioning.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding returning 3 parameters, that is not possible in C. You have to put them in a struct and return a pointer to them. Exactly how to send this out on the Mesh network, I am not yet sure. This is what I am looking into. I will get back to you if I figure something out.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume that you modified the on_off_model, and didn&amp;#39;t add another model with the RGB values, is that correct?&lt;/p&gt;
&lt;p&gt;I assume that you haven&amp;#39;t modified the access_model_reply() function?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you check what access_model_reply() returns?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;try:&lt;/p&gt;
&lt;p&gt;uint32_t err_code = access_model_reply();&lt;/p&gt;
&lt;p&gt;ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;And set a breakpoint on the ERROR_CHECK(err_code); line and see what it returns.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>