nrf desktop - how to add soft power off

Hi,

I'm using nRF Connect v2.1.0.

How can I add a soft power off to nrf_desktop with a gpio interrupt wakeup? It looks like all of the demo hardware uses disconnecting switches, where I have a dedicated GPIO input with a momentary button for powering on/off.

I used the simple button example to add power button detection to board.c, and I used the code from the system_off example to shut it down from within my button callback, but it just reboots and turns right back on. I also tried creating and submitting a power_down_event to send to the power manager (I tried both "power_down_event" and "force_power_down_event"), with the same result. I also tried calling the turn_board_off() function that was already in board.c, which didn't do much.

I thought maybe it was failing because I was shutting down from within my button ISR so I added a worker function that I kick off with k_work_reschedule from the ISR, and then submit the powerdown event from the worker function, but I get the same result. It turns off and right back on.

Thanks,

Glen

Related