wiced_bt_mesh_model_light_lc_client_send_light_onoff_set(p_event, &set_data);

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NICK_NL
Level 1
Level 1
First reply posted First question asked Welcome!

Hi All,

I am working with the  board CYBT213043 kit .  

Mesh-Demo-213043MESH.light_smart  is working properly

Mesh-Demo-213043MESH.switch_smart is working properly

a combination of above 2 is working properly ( adding a sensor into the light_smart)

For a function of overide with button,  the demo of  Mesh-Snip-213043MESH.mesh_light_lc_client is used.  The goal is set the Light LC onoff with a button. 

First  having problem with create event.  After setting as below the event is created. 

wiced_bt_mesh_event_t *p_event = wiced_bt_mesh_create_event(0,MESH_COMPANY_ID_BT_SIG,WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_SRV, 0xffff, 0xffff);

Now the problem is that the light_smart LC model can not be set by the  funtion below.

wiced_bt_mesh_model_light_lc_client_send_light_onoff_set(p_event, &set_data);

From MeshClient on windows, the light_smart LC model can be set properly.

Do hope someone may help me out.  Thanks.

0 Likes
1 Solution
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

Could you please try to create mesh event with destination 0. It will get the info from publication. 

wiced_bt_mesh_create_event(0,MESH_COMPANY_ID_BT_SIG,WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_SRV, 0, 0);

 

Also, I see setting LC is already defined in the process_button_push in https://github.com/Infineon/mtb-example-btsdk-mesh-demo-switch-smart. This is on_off_switch.c. Please check.

Thanks,

-Dheeraj.P.K

View solution in original post

0 Likes
3 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

Could you please try to create mesh event with destination 0. It will get the info from publication. 

wiced_bt_mesh_create_event(0,MESH_COMPANY_ID_BT_SIG,WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_SRV, 0, 0);

 

Also, I see setting LC is already defined in the process_button_push in https://github.com/Infineon/mtb-example-btsdk-mesh-demo-switch-smart. This is on_off_switch.c. Please check.

Thanks,

-Dheeraj.P.K

0 Likes
Dear Dheeraj.P.K,


 


Thanks for your advice.


I have to make one correction here:


 


"Mesh-Demo-213043MESH.switch_smart is working properly" means the sensor control function working properly. The button control is never worked.


I integrated "Mesh-Demo-213043MESH.light_smart" with the sensor part of "Mesh-Demo-213043MESH.switch_smart" and made a new lamp. 


The new lamp works well . By grouping they controls each other by motion sensor.  Now I need a switch , it may override the LC. It means the switch may 


turn on the lamp and keeps it on untill switching off.  By using Mesh-Demo-213043MESH.on_off_switch, the lamp can be switched on and off. However


the LC mode is set to 0.  I need to set the LC mode to 1 again. Before using command to set the LC mode,  I try to set the LC onoff status because it is already


in the demo and it is easy to modifiy later. 


Now it comes the situation I am facing .  


Mesh-Demo-213043MESH.switch_smart is now working properly by press button. I could see that in meshcontrol app.


I tried to implement such a switch by using Mesh-Snip-213043MESH.mesh_light_lc_client. It doesn't work too.  I have read 2 most relative thread about 


the issue of creating event and tried the parameter setting of dst and app key idx . With all possible combination as below:


 


0,0


0xffff,0


0,0xffff


0xffff,0xffff


 


The only one seems the event is not NULL is the last combination : 0xffff and 0xffff.


 


Identify if the event is not NULL:


 


Original :


 


wiced_bt_mesh_event_t *p_event = wiced_bt_mesh_create_event(element_idx, MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_CLNT, 0, 0);

    if (p_event == NULL)

        return;


 


 


Modefied by inserting led_control.c and led_control.h, using the led indicating if the event is NULL.


 


led_control_set_onoff(onoff_state);


wiced_bt_mesh_event_t *p_event = wiced_bt_mesh_create_event(element_idx, MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_CLNT, 0, 0);

    if (p_event == NULL)

{


    onoff_state ^= 1;


        return;


}


 


The resualt :  only when parameter set as 0xffff,0xffff , the led will not turned on and off . I suppose the event is not NULL. 


 


I thought the issue could be solved. Unfortunately it is not.  I still can not set the onoff status of LC. 


 


Please kindly advise me . Thanks.


 


Nick


 


 


 


 


 
0 Likes
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Update:

Please use the latest SDK - v3.3. When i tested the switch smart application the switch control is working fine. If we configure the publication of smart switch and light properly, we can control the LED of the light smart using the  button of switch smart app.

 

If my understanding is correct about the requirement, I guess what you need is the same code inside process_button_push() function which will create a mesh event and send light LC on/off to the light smart. Please check the code. If you copy it to the appropriate place for example, e93196_int_proc, mesh_sensor_presence_detected_timer_callback or mesh_sensor_value_changed, I guess, you can achieve the goal you have described.

 

Example Code:

static uint8_t onoff_state = 0;

wiced_bt_mesh_light_lc_light_onoff_set_data_t set_data;

wiced_bt_mesh_event_t *p_event = wiced_bt_mesh_create_event(element_idx, MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_LIGHT_LC_CLNT, 0, 0);
if (p_event == NULL)
return;

if (WICED_BT_MESH_IS_UNICAST_ADDR(p_event->dst))
{
p_event->reply = WICED_TRUE;
}

set_data.light_onoff = (onoff_state == 1) ? 0 : 1;
set_data.transition_time = WICED_BT_MESH_TRANSITION_TIME_DEFAULT;
set_data.delay = 0;

WICED_BT_TRACE("onoff set target:%d\n", set_data.light_onoff);

wiced_bt_mesh_model_light_lc_client_send_light_onoff_set(p_event, &set_data);

// If we do not receive status from the bulb, we will just toggle between on and off.
// If we receive status, the state will be updated. For example, if the bulb is the
// light controller, it may execute state machine and go off on timeout. Then this
// application will receive the state Off and will send On again on the button push.
onoff_state ^= 1;

0 Likes