Project

General

Profile

Actions

Feature #815

closed

Add headless mode

Added by Hammel about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Immediate
Assignee:
Start date:
20 Feb 2021
Due date:
% Done:

100%

Estimated time:
Severity:
01 - Critical

Description

See RM #743

  1. Add cli option for headless mode (-H)
  2. Don't use GUI - switch to glib main loop
    1. Exit on signals only: SIGQUIT, SIGTERM, SIGHUP and SIGINT.
  3. Add gpio monitor thread using libgpiod (API docs).
    1. See also: GPIO Programming: exploring libgpiod
    2. Add momentary button to RPi
    3. Add an led to RPi
  4. Momentary button causes SIGUSR1 or SIGUSR2 depending on toggle state
    1. Requires debounce handling (don't allow toggling to fast).
    2. Probably requires synchronization with network startup in debounce handling.
  5. Signal handler
    1. SIGUSR1 starts imwww for network config
    2. SIGUSR2 stops imwww and restarts network
  6. LEDs are flashed depending on state
    1. 1 second (500ms on/500ms off) blink: imwww is active.
    2. 2 200ms flashes/second: network is restarting.
    3. 2s solid followed by 10 200ms flashes followed by no light: normal mode is now active.
    4. A second LED could be used to show camera active state.

Related issues

Blocks PiBox - Feature #743: Add PiSentry system: a webcam meta buildClosedHammel29 Feb 2020

Actions
Blocks PiBox - Action Item #768: Add PiBox FileServer meta buildClosedHammel21 Jun 2020

Actions
Actions #1

Updated by Hammel about 3 years ago

  • Description updated (diff)
Actions #2

Updated by Hammel about 3 years ago

  • Description updated (diff)
Actions #3

Updated by Hammel about 3 years ago

  • Severity changed from 03 - Medium to 01 - Critical
Actions #4

Updated by Hammel about 3 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:
  1. Check if gpioset/gpioget/gpiomon can be used to test without real gpio hw connected.
  2. Build w/o -H and verify pinet still works as before in piplayer.
  3. Build w/ -H and manually start pinet.
    1. Verify pinet starts AP if pushbutton is pressed once.
    2. Verify pinet stops AP and restarts network if pushbutton pressed again.
      1. Verify pinet is still running after network restart.
    3. Verify start / stop / start / stop (repeated operations)
    4. Verify debounce
    5. Verify LED states
      1. AP on
      2. Restarting
      3. Return to Normal Mode
      4. Off
Actions #5

Updated by Hammel about 3 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.

Actions #6

Updated by Hammel about 3 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.

Actions #7

Updated by Hammel about 3 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.

Actions #8

Updated by Hammel about 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.

Actions

Also available in: Atom PDF