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

Mesh light switch example controlling multiple LED

Hi all, I am working on light switch example and I want to perform different LEDs have their own switch, i.e. button 1 control LED 1, button 2 control LED 2. The problem is how to let server know which button I have pressed. As I found that generic_onoff_set_params_t only send bool onoff and tid, if I don't want to do tricks on tid, is there any other way for me to let the server know which button did the client press? Thank you.

Parents
  • Hi,

    Essentially, you would need to have separate Element for each LED, so you have to create two elements with one generic on off server model each.

    As for the client, you also need two elements with one generic on off client model each. This is already done in our client example so you don't have to worry about this. You need to modify the buttons on the client to publish to the correct element on the server. Also if you want to turn the LED both on and off with one switch you need to modify a little bit. Since in our example, buttons 1 & 3 are used to turn the app state on, whereas buttons 2 & 4 turn the app state off.

    This post might be helpful.

    MLai said:
    Another question is would there be any problem if I modify the tid as I want? i.e pressing the button each time and add tid by 4, not as the example by 1. As tid is only 256 bit, it will be quicker to resume to 0. Does this cause any problem?

    I don't think it will cause any problem.

  • Thank you for your answer. As I am still new to mesh, I want to ask is that changing the APP_ONOFF_ELEMENT_INDEX can add new element? Or I need to add new APP_ONOFF_SERVER_DEF?

Reply Children
No Data
Related