Hi @matthewcroughan, you can check out balenaDash or balena-fin-examples as examples of using WiFi connect in a multicontainer application. They both include the io.balena.features.firmware: '1' label as well as network_mode: host. I hope this helps!
This also kills the device and means I have to Reflash BalenaOS as the supervisor is no longer responsive. balena ssh still works, but I cannot kill the AP container.
@matthewcroughan it’s worth pursuing the error message that port 80 is already in use. I can see from the list of containers you’ve posted, you have a grafana container which is bound to port 80 and hence preventing WiFi connect binding to that port.
You seem to have a lot of containers running on your device when you should only have the supervisor and one other if all you’re trying to use is WiFi connect, unless you did not share the full docker-compose.yml file and these other services listed are in fact correct, in which case the port 80 conflict is valid and you’ll need to reconfigure Grafana to run on a different port.
Of course, I just realised this 10 minutes ago, I’m a complete idiot!
However, the supervisor indeed doesn’t like this and it does leave the device in a state wherein I cannot ever use it again until I reflash the card, which is still in some way a failing of the balena engine, it shouldn’t be able to end up in this state.
After resolving this and reflashing the disk, it’s all fine.
@chrisys Now that it’s working, I wanted to have this script determine whether or not the AP should be created.
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
However, I think there’s a bug in the Balena Engine, because it cannot kill or restart this container.
However, if I enter the container and issue kill -9 to the PID of wifi-connect it will succeed.
No other method by the supervisor can kill the AP service, though I can enter it and kill it manually. Any advice on how to solve this now without waiting for a fix in the balena engine?
Actually, no matter what I do here it seems that the AP just destroys the state of the device, no longer able to push things to it as it just stalls and pretends nothing is happening.
Actually, no matter what I do here it seems that the AP just destroys the state of the device, no longer able to push things to it as it just stalls and pretends nothing is happening.
Nothing in the app should ever cause the supervisor to fail/stop responding/require a reflash of the image.
A way to check if the supervisor is running is to check its logs from the HostOS.
journalctl -u resin-supervisor. It’ll show some error messages I guess.
I note the supervisor version v9.11.3. The OS is somewhere around v2.31.5 I guess. For new work, I’d recommend updating to a new OS.
Now that it’s working, I wanted to have this script determine whether or not the AP should be created.
I’m a bit unclear about which container is running the script. And where this environment variable is being set/unset from?