I have to travel between my home and my ship, which makes it inconvenient to have to find a way to switch between wlan networks during my travels. I've been attempting to create shell scripts that would allow me to enter DTMF commands from my radio in order to make it easier to change wireless networks. I have tried changing script permissions to be executable by asterisk, but I am still not able to get the scripts to work. I can execute them from the Terminal, but the whole purpose of what I am doing is to avoid having to go through the Terminal. When I leave home and join my ship, the Rpi5 is still looking for my home network SSID, which is obviously not available at my work location. I am well aware that 99.99% of users do this the "normal" way, but I am part of the 0.01% who need to be able to change wlan networks without having to connect a monitor, keyboard and mouse to the Pi. I am by no means an expert at Linux-based computing, and there has got to be a way to issue nmcli-related commands from the radio.
I used the Cockpit WiFi Manager when I was setting up my various wireless connections, but I am trying to make a quick and easy task of changing wireless networks on the fly. When I leave the house my node is still set to join the home network, so when I pack up and leave for the ship I have to stay in a hotel for a day until I join the ship. That requires me to use my phone as a WAP. Then after I board the ship, there is yet another network that I need to switch the node to. I am trying to make this an easy way to switch networks by using DTMF commands from the radio. It was a piece of cake when I was using HAMVOIP prior to the release of ASL3. However, that era is long gone for me since network connections are now managed by nmcli.
Edit the /etc/sudoers file and give the asterisk user the ability to run nmcli without a password. Then you can have CMDs from DTMFs execute scripts that call nmcli via sudo.
I'm able to successfully change my network connection using the Terminal and executing each script, but for some reason I am still not able to execute via DTMF. How do I edit the sudoers file (where in the file, and what is the correct syntax)?
After typing visudo, I placed this:
User privilege specification
root ALL=(ALL:ALL) ALL
asterisk ALL=(ALL:ALL) NOPASSWD: ALL
I'm still extremely green with Linux-based stuff...
If you have already added the WiFi networks with the Cockpit WiFi Manager (or with nmcli / nmtui) then you shouldn't need any scripts to switch from one network to another. All should "just work".
My recommendation would be to define your home network and one from another location and confirm that all works from both locations. Then, only if all doesn't work would you need to go down the path of creating DTMF commands to switch networks that was needed on other/old-OS's.
The one exception might be if more than one network is available when the device is looking for a network to join ... and it didn't pick the one that you prefer.
This is getting far too frustrating. I have double-checked all permissions, I "think" that I have placed the proper entry in the sudoers file, I can execute all the scripts from the command line in Terminal, but nothing I have tried will allow rpt.conf to execute the scripts from DTMF inputs from my radio. Linux clearly requires a masters degree....
This is what I do super easy works perfectly. Configure your hotspot on your phone to be the same as the Ship Wifi, Same at home... Most wifi routers have a Guest network, make it the same as your Ship and Hotspot. Then no matter where you are at, the Node will only be looking for ONE network!
One question to ask is what user are you using when you are executing your script(s) from the command line? Are you doing this as a non-priv user? as the root user? with sudo ...?
Assuming that you are using a /etc/asterisk/local/test.sh script, here's a trick you can use to exec that script with the same permissions as asterisk :
sudo -u asterisk /etc/asterisk/local/test.sh a b c
I use "sudo -s" to log in as root. There are clearly some file and/or directory permissions problems because DTMF is not causing those scripts to be executed. My scripts are in /etc/asterisk/local. If I am understanding correctly, asterisk needs permissions to execute those scripts. I have no idea how or what do do when I edit the sodoers file. All the information I have found regarding the sodoers file is assuming that the reader is intimately familiar with Linux, and therefore it is completely over my head. I just need to know what to enter and where to enter it, when I edit sodoers after using the "visodu" command. I also need to know the correct commands to set the permissions of those scripts so asterisk can execute them.
Wait, why are you trying to change config on the the fly in the first place? Maybe I'm reading this wrong or missing something, but can Debian not store more than one wireless network...? You don't have to manually change networks on any other computer, phone, etc, why is this any different?
I spend several months at a time aboard a container ship. I moved recently and to stay in touch with friends, I put my node in my car when I need to drive to town. Unfortunately, it does not auto-connect to the first available WAP. That is why I need to be able to change networks on the fly.
Did you configure the car's Wi-Fi network using either the Cockpit WiFi Manager or with nmcli / nmtui?
Also, what type of Raspberry Pi are you using? and what type of Wi-Fi network are you trying to join (2.4 GHz vs. 5 GHz)? ... and I'm asking because some RPi's only support 2.4 GHz networks
No need for scripting, DTMF, or anything like that for this scenario. NetworkManager already handles multiple saved wireless connections out of the box. Every wireless network is saved after the first initial connection, and NetworkManager connects to whichever network is currently available. The same as any modern smartphone. You can just move the Pi around without needing to script or manually control anything.
What @WA3WCO is asking about 2.4GHz vs 5GHz still applies, though.
But it is not working the way that it should. When I leave the house and drive far enough down the road to get out of range of my home network WAP, the node does not connect to my phone's wireless hotspot. Same with arriving on the ship- booting up the node will not automatically connect to the ship's crew network WAP. This is why I'm trying to do this. Network Manager does have all three networks set up. The node simply does not auto-connect to the first available WAP.
Furthermore, even if it did auto-connect, when we are in port and the crew have cellular data, I unplug our StarLink router from the network switch to save data usage, so while the shipboard WAPs are still active broadcasting their SSIDs, there is no Internet connection. I need to be able to force the node to change to a different AP. Upon bootup, my node attempts to connect to the last available active connection, and if it does not find it, I am force to connect a monitor and keyboard to the Pi5 and manually change it, and that is simply not practical when travelling in my car. This is rediculous.
First off, check that you have all of your Wi-Fi networks configured :
nmcli connection show
For each of the connections, exec :
nmcli connection show "<connection name>" | grep 802-11-wireless.ssid:
nmcli connection show "<connection name>" | grep connection.autoconnect:
The first of these commands should report the SSID, the latter should report "yes".
Also, in your efforts to setup DTMF wifi selection did you make ANY changes to the network configuration files? If so, what instructions were you following?
You mentioned that the node doesn't connect to your phone's hotspot in the car. Are you using an iPhone? If so, you have to open the Wi-Fi hotspot app for things to see it. Literally need to be looking at it. I don't know why it doesn't work on the ship. Are you saying you unplug the Internet from the main router to save Starlink data? Doesn't that make strange behavior when one's phone has both a dead Wi-Fi and a live data connection?
The connection.autoconnect flags do show "yes", however I am seeing that it only attempts to reconnect with the last network it was connected to. If that network is not available, there is no attempt to find the next network in the list. I can understand the security concerns regarding which "user" can do what, but the "asterisk" user being blocked from executing some scripts simply doesn't make sense. I don't have personal data of any kind on my node; it is only being used as a communications device. This is the main reason why I am considering going back to HAMVOIP, since it was easy to create and execute network connection changes using DTMF commands.
I am guessing the problem he is witnessing is where you have a wifi connection list.
Whereas it will start with the last connection and proceed through the list one at a time.
That takes time for a longer list. I don't know what the timeout is but when I did this long ago it was taking 4min+ for each to timeout..
Just to test this, I installed ASL3 on a Pi 4, connected to 2 different WAPs, and disabled the WAPs individually. Each time I disabled the WAP that the Pi was connected to, it flawlessly failed over to the other WAP in less than a minute.
As far as your frustrations with Linux permissions and user management... it can be a learning curve - but it has nothing to do with ASL. Asterisk is the core program that was updated to run as its own user instead of root years ago. This is basic, bare minimum permissions and user management practice on any modern computing system.