This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use GET to retrieve the value of 3 variables - Mesh SDK 2.0.1

Hi,

I'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 "SET" I'm done (except for the status_reply).

Now I want to be able to use the "GET" to know the actual value of the 3 variables on the server side.

I modified the reply_status function as follow:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
static void reply_status(const simple_on_off_server_t * p_server,
const access_message_rx_t * p_message,
uint8_t current_red_dt_cycle, uint8_t current_green_dt_cycle, uint8_t current_blue_dt_cycle)
{
simple_on_off_msg_status_t status;
//status.present_on_off = present_on_off ? 1 : 0;
status.current_red_dt_cycle = current_red_dt_cycle;
status.current_green_dt_cycle = current_green_dt_cycle;
status.current_blue_dt_cycle = current_blue_dt_cycle;
access_message_tx_t reply;
reply.opcode.opcode = SIMPLE_ON_OFF_OPCODE_STATUS;
reply.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
reply.p_buffer = (const uint8_t *) &status;
reply.length = sizeof(status);
reply.force_segmented = false;
reply.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
(void) access_model_reply(p_server->model_handle, p_message, &reply);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Accordingly I modified the simple_on_off_msg_status_t struct in simple_on_off_common.h:

Fullscreen
1
2
3
4
5
6
typedef struct __attribute((packed))
{
uint8_t current_red_dt_cycle;
uint8_t current_green_dt_cycle; /**< Current state. */
uint8_t current_blue_dt_cycle;
} simple_on_off_msg_status_t;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Now, my problem is that I couldn't figure out how to pass the 3 variable values when calling the reply_status function on the handle_get_cb, and also how the get_cb works...



Another question is how will I return the 3 values on the main.c when executing the on_off_server_get_cb function?

BR,
Paulo Zacarias