电源循环后无法从 AP 切换到 wpa

电源循环后无法从 AP 切换到 wpa

我正在使用 Jessie (Raspberry Pi),启动后它会进入 AP 模式。然后在 python 代码中,我运行以下命令将其切换到 WPA 客户端模式:

sudo /etc/init.d/networking stop
sudo systemctl stop wpa_supplicant.service
sudo systemctl stop hostapd.service
sudo systemctl stop udhcpd.service
sudo systemctl start wpa_supplicant.service
sudo /etc/init.d/networking start
sudo wpa_action wlan0 stop
sudo /etc/network/if-down.d/resolvconf
sudo /etc/network/if-down.d/upstart
sudo /etc/network/if-down.d/wpasupplicant
sudo dhclient -v -r -pf /run/dhclient.wlan0.pid -lf /var/lib/dhcp/dhclient.wlan0.leases wlan0
sudo ip link set dev wlan0 down
sudo /etc/network/if-post-down.d/avahi-daemon
sudo /etc/network/if-post-down.d/hostapd
sudo /etc/network/if-post-down.d/wireless-tools
sudo /etc/network/if-post-down.d/wpasupplicant
sudo wpa_action wlan0 stop
sudo ifup wlan0

如果它有时连接到我的 Wifi,那么我对 RPi 进行电源循环超过 5 分钟,下次启动时它将无法再次连接到我的 Wifi(当使用这些命令的 python 时)。

我究竟做错了什么?

相关内容