I am not sure to understand what you mean. When you execute the config_anafi_ip.sh script above, you are already connected to the drone(s) wifi access point(s) (Anafi-XXXXXXX). The ANAFI has always the 192.168.42.1/24 address assigned to its wifi interface. So once you are connected to the drone access point there is nothing more to discover. The drone runs a DHCP server but you are free to assign a static IP to your wifi interface instead. This is actually just what the script above is doing: ignore any previously (DHCP assigned) IP address and configure the 192.168.42.254 IP address instead.
I’ll try to clarify this script usage below.
The network configuration script above is merely a trick to disambiguate the 192.168.42.1 drone IP address that your linux box will see on every wifi interface once connected to multiple drones.
As far as the drone is concerned, it always has the 192.168.42.1 IP address and will respond to any DHCP request with an IP address in the 192.168.42.0/24 subnet.
Let’s say you are connected to three drones whose SSID are Anafi-0001, Anafi-0002 and Anafi-0003 respectively on your wlan0, wlan1 and wlan2 wifi interfaces. If you setup your interfaces like this:
./config_anafi_ip.sh setup wlan0 192.168.44.1 201
./config_anafi_ip.sh setup wlan1 192.168.45.1 202
./config_anafi_ip.sh setup wlan2 192.168.46.1 203
You end up with the following configuration:
| Drones | | Linux box |
[Anafi-0001 192.168.42.1]<------>| wlan0 - 192.168.42.254 |
| - 192.168.44.1 |
[Anafi-0002 192.168.42.1]<------>| wlan1 - 192.168.42.254 |
| - 192.168.45.1 |
[Anafi-0003 192.168.42.1]<------>| wlan2 - 192.168.42.254 |
| - 192.168.46.1 |
- 192.168.44.1 is routed/NATed to Anafi-0001 192.168.42.1 over wlan0
- 192.168.45.1 is routed/NATed to Anafi-0002 192.168.42.1 over wlan1
- 192.168.46.1 is routed/NATed to Anafi-0003 192.168.42.1 over wlan2
Now, if you use the 192.168.44.1, 192.168.45.1 and 192.168.46.1 IP address to connect to your drones, everything is fine.
However, if you try to connect to 192.168.42.1 there is no way to tell which interface/drone will be selected.