I have a question about Balena wifi-connect. What changes need to be made to wifi-connect to make an access point when where is no familiar wifi network around ?
also there is a code that start wifi-connect at every orange pi zero start-up.
To your first question, balena WiFi Connect is designed to do exactly what you are asking for. Upon startup it will try to connect to one of the known networks. If it can’t, it will create the AP to allow you connect and access the captive portal to configure a new access to the visible networks. This way, if no known network is visible, you should be able to see in your phone (or any other device nearby) a WiFi SSID with the WiFI Connect AP.
As my colleague highlighted, it would be best to try one of the ways highlighted with the link for creating a startup boot script. The reason there are a couple of methods is all distros have slightly diff services bundled; so you might want to confirm what is armbian OS coming with.
Let us know how it goes or if you run into any errors while running this.
So I made some a script that starts wifi-connect on boot.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
(sleep 10;python /root/.local/New directory/wifi.py)
exit 0
But script starts every time orange pi zero starts. So I want it to start if there is no active connection. Maybe do someone has a suggestion how to do it ?
It looks like you should be able to use wget to check the current internet connectivity and run wifi-connect accordingly. Here is an example script that you can try pulling from what is in the repo linked above (replace freq=120 with whatever check frequency you want in seconds):
#!/bin/sh -e
freq=120
sleep 10
while [[ true ]]; do
echo "Checking internet connectivity ..."
wget --spider --no-check-certificate 1.1.1.1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Your device is already connected to the internet."
echo "Skipping setting up Wifi-Connect Access Point. Will check again in $freq seconds"
else
echo "Your device is not connected to the internet."
echo "Starting up Wifi-Connect.\n Connect to the Access Point and configure the SSID and Passphrase for the network to connect to."
python /root/.local/New directory/wifi.py # this could also probably be just `wifi-connect` instead of calling the python wrapper
fi
sleep $freq
done
I saw that you are using armbian, and I wonder if it has all of the dependancies required to run wifi connect? Does it have NetworkManager do you know?
So this code works, but something is not right. It can’t create a wifi-hotspot.
#!/bin/sh -e
freq=120
sleep 10
while true; do
echo "Checking internet connectivity ..."
wget --spider --no-check-certificate 1.1.1.1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Your device is already connected to the internet."
echo "Skipping setting up Wifi-Connect Access Point. Will check again i>
else
echo "Your device is not connected to the internet."
echo "Starting up Wifi-Connect.\n Connect to the Access Point and confi>
python3 /home/wifi.py # this could also probably be just `wifi-connect`>
fi
sleep $freq
done
But If code is written like this hotspot works.
#!/bin/sh -e
freq=120
sleep 10
while true; do
echo "Checking internet connectivity ..."
wget --spider --no-check-certificate 1.1.1.1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Your device is already connected to the internet."
echo "Skipping setting up Wifi-Connect Access Point. Will check again i>
python3 /home/wifi.py
else
echo "Your device is not connected to the internet."
echo "Starting up Wifi-Connect.\n Connect to the Access Point and confi>
fi
sleep $freq
done
log:
Checking internet connectivity …
Your device is already connected to the internet.
Skipping setting up Wifi-Connect Access Point. Will check again in 120 seconds