Thanks for your reply.
This command returns the SSID only when the wifi network is active. I need to get the SSID when the wifi network is disconnected. Of course, the wifi network is the one where the Pi was connected until it was broken.
Out of interest, why do you need to retrieve the SSID? Even if the router is powered off the device that has been configured using wifi-connect should reconnect to it automatically once powers back on again.
Yes, you’re right. I also know it. And I understand that you wonder why I want to know it.
Let me explain it in detail.
In my application, wifi-connect app is automatically run by python daemon script when the network connection is broken, This script runs wifi-connect when the network connection is disconnected.
This script is running in a web container.
There are two cases of disconnection. The first case is when the user requested it on the web page.
In that case, I deactivate and delete the current wifi network connection using nmcli down and nmcli delete command. Then the network connection is broken, so wifi-connect is automatically executed by the daemon script.
The second case is when the strength of the wifi signal is very weak or the router is off. In that case, I don’t want to run wifi-connect, but my script runs it because the network connection is disconnected.
Therefore, I need to accurately distinguish between the two cases in my daemon script. If it’s the second case, wifi-connect shouldn’t run.
The only difference in two cases is that in the first case the connection is deactivated and deleted by programming in the web server code. The reason of deactivating and deleting is to see all wifi networks in ap list of balena app and choose one I want to connect to. In the first case, I though I couldn’t find the last network ssid because I already deleted the connection.
In the second case, there is no any logic related to wifi connection. So in this case, I thought that the last network credentials will remain somewhere. If I get it, I will know the disconnection is due to the second case.
Does it make sense?
I’ve tired most nmcli commands to get it, but I couldn’t find any solution.
When the balena app reruns, it always shows only the last network ssid in AP list. So I think there is a way to get the ssid even if the connection is lost.
Otherwise, is it a function of the mobile app side?