DynamicDevices / ming-original

Balena.io/Docker-compose repo for a containerised #MING (Mosquitto, InfluxDB, NodeRed, Grafana) stack
33 stars 20 forks source link

12-wifi-hotspot #13

Closed MatthewCroughan closed 4 years ago

MatthewCroughan commented 4 years ago

DO NOT MERGE UNTIL 9-JUPYTER-LAB IS MERGED

This PR adds support for an optional wifi access point to be greated when the service variable MING_AP is set to 1 via this start script.

Grafana has been moved to port 3000 since we need to reserve port 80 for the AP captive portal. This is necessary since BalenaEngine doesn't support conditional container starting/stopping yet for docker-compose files.

MING_AP=0

# If MING_AP is set and equal to 1 then create an access point.
# Otherwise echo the fact that it has not been set to the console.

# We should endeavour to make this do-able from the captive portal

if [[ "$MING_AP" == 1 ]]; then
  ./wifi-connect -s MING -u /usr/src/app/ui
elif [[ "$MING_AP" == 0 ]]
then
  echo "Wifi AP has not been enabled in service variables"
fi

Ideally in the future we should modify the source for the captive portal so that the the AP can be enabled or disabled from there. Since the AP will remove wifi internet connectivity, there'll be no way out unless you plug in an ETH cable, which is acceptable for now just so we can test usage. The next step is to have avahi give things proper mDNS hostnames so mqtt.local is pingable in this AP mode.

MatthewCroughan commented 4 years ago

@ajlennon Hold off on merging this until I give the go ahead, had some stability issues testing today relating to BalenaEngine bugs.

MatthewCroughan commented 4 years ago

@ajlennon Been testing this on and off, turning the hotspot on and off via the WIFI_AP variable on the balena dashboard, seems to work flawlessly on all pi2, pi3 and pi4. This applies to both 64 and 32 bit OS's. Merge #10 prior to merging this, as I'm not sure if this is all concatenated by github automatically. Thanks!