Feature #815
closedAdd headless mode
100%
Description
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).
- See also: GPIO Programming: exploring libgpiod
- Add momentary button to RPi
- Add an led to RPi
- 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.
Related issues
Updated by Hammel almost 4 years ago
- Severity changed from 03 - Medium to 01 - Critical
Updated by Hammel almost 4 years ago
- 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
- Restarting
- Return to Normal Mode
- Off
Updated by Hammel almost 4 years ago
I need conditional compilation of the gpio bits in headless mode. Using "-with-headless" (or similar) will compile the gpio.c and link against libgpiod. Without it the build skips those two bits.
See Conditional Sources and Usage of Conditionals in the automake guide for how to do this.
Updated by Hammel almost 4 years ago
Tested the UI build and it works as expected. The headless mode starts up okay but I need to build the push button and LED in order to test it. I tried using gpioset but that doesn't work while pinet is running since it has the pins "open" already.
Updated by Hammel almost 4 years ago
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.
Updated by Hammel over 3 years ago
- 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.
Closing issue.