Toggle button configuration for Mesh Gen OnOff model

I`m using Ble Mesh Light and Light Switch examples (Gen OnOff models) in two nrf52840 Dongles. The default configuration of the button is that when I pressed the button in the Light Switch Dongle the LED in the Light Dongle turns on. When I take my finger off the button the LED in Light Dongle is still on, but I want it to turn off when I am not pressing the button (toggle button I think).

I have change the flags in gpio_pin_interrupt_configure in the dk_buttons_and_leds.c to GPIO_INT_EDGE_BOTH but nothing has changed.

Do you know how I could do it?.

Parents
  • Hi,

    If this project is developed in nRF Connect SDK (NCS), you may use the polling method. Exercise 1 in Lesson 2 in the NCS fundamentals course on our academy pages illustrates how to do this through dissecting the blinky sample, which you should be able to port over to the 52840 Dongle with relative ease!

    Kind regards,
    Andreas

  • Hi!, I have been trying the polling method, but I don't get how to integrate it with the button_handler_cb from the ligth _switch example.

    How would you do it?

    Another thing to keep in mind is that I want to used it in a battery powered device, so it should not consume much battery. With the polling mehtod I would be sending a set message all the time to the server and I supose It would kill my battery very fast.

    Do you thing It would be posible to do it with an interrupt with GPIO_INT_EDGE_BOTH configuration?.

    Pd: I'm using SDK 1.8

  • Hi,

    Carlos Galiana said:
    Another thing to keep in mind is that I want to used it in a battery powered device, so it should not consume much battery. With the polling mehtod I would be sending a set message all the time to the server and I supose It would kill my battery very fast.

    Yes, you are correct in that assumption. The polling method would increase the current consumption. A better option is to follow the method in exercise 2 of the same topic: https://academy.nordicsemi.com/topic/exercise-2-3/, which uses GPIO interrupts instead of polling, but still toggles the light when the button is active (GPIO_INT_EDGE_TO_ACTIVE), and untoggles it when it is low. Its similar to what you suggested with the exception of not using GPIO_INT_EDGE_BOTH

    Could you check out that exercise (and/or download the solution and try it), and see if its easier to integrate that sample to the button handler callback in the light switch sample?

    Kind regards,
    Andreas

Reply
  • Hi,

    Carlos Galiana said:
    Another thing to keep in mind is that I want to used it in a battery powered device, so it should not consume much battery. With the polling mehtod I would be sending a set message all the time to the server and I supose It would kill my battery very fast.

    Yes, you are correct in that assumption. The polling method would increase the current consumption. A better option is to follow the method in exercise 2 of the same topic: https://academy.nordicsemi.com/topic/exercise-2-3/, which uses GPIO interrupts instead of polling, but still toggles the light when the button is active (GPIO_INT_EDGE_TO_ACTIVE), and untoggles it when it is low. Its similar to what you suggested with the exception of not using GPIO_INT_EDGE_BOTH

    Could you check out that exercise (and/or download the solution and try it), and see if its easier to integrate that sample to the button handler callback in the light switch sample?

    Kind regards,
    Andreas

Children
No Data
Related