Add headless mode
See RM #743
- Add cli option for headless mode (-H)
- Don't use GUI - switch to glib main loop
- Exit on signals only: SIGQUIT, SIGTERM, SIGHUP and SIGINT.
- Add gpio monitor thread using libgpiod (API docs).
- Momentary button causes SIGUSR1 or SIGUSR2 depending on toggle state
- Requires debounce handling (don't allow toggling to fast).
- Probably requires synchronization with network startup in debounce handling.
- Signal handler
- SIGUSR1 starts imwww for network config
- SIGUSR2 stops imwww and restarts network
- LEDs are flashed depending on state
- 1 second (500ms on/500ms off) blink: imwww is active.
- 2 200ms flashes/second: network is restarting.
- 2s solid followed by 10 200ms flashes followed by no light: normal mode is now active.
- A second LED could be used to show camera active state.
- Status changed from New to In Progress
- % Done changed from 0 to 50
Initial implementation is ready for testing. Headless mode is built with -H option to cross.sh. Both modes build cleanly.Testing:
- Check if gpioset/gpioget/gpiomon can be used to test without real gpio hw connected.
- Build w/o -H and verify pinet still works as before in piplayer.
- Build w/ -H and manually start pinet.
- Verify pinet starts AP if pushbutton is pressed once.
- Verify pinet stops AP and restarts network if pushbutton pressed again.
- Verify pinet is still running after network restart.
- Verify start / stop / start / stop (repeated operations)
- Verify debounce
- Verify LED states
- AP on
- Return to Normal Mode
The pushbutton will use gpio 23 (pin 16) and the LED will use gpio 24 (pin 18). This allows the pushbutton to use the 3v3 line (pin 17) directly across from gpio 24 while the LED uses the ground pin directly adjacent to it (pin 20).
See the Raspberry Pi GPIO pinout diagram.
- Status changed from In Progress to Closed
- % Done changed from 50 to 100
This is now implemented and has been tested on hardware. I've also regression tested the UI mode.
Build is updated so cross.sh supports -H option for a headless build.
There is a caveat with this implementation: it has a static pw for the AP. There is an idea in the comments on how to make this less static, but this release isn't going to worry about it for now.
Code committed and pushed.