SynAckFin / TuyOTA

Flashing Tuya devices with Tasmota firmware.
GNU General Public License v3.0
90 stars 13 forks source link

Access Point has shutdown #17

Open crazyman143 opened 5 years ago

crazyman143 commented 5 years ago

Hi here,

I am trying to run your script for my plug on an Ubuntu 18 computer. Is it compatible, or does it have to be Raspian?

The issue seems to be a problem controlling wlan0, as I'm getting the "Access point has shutdown" message immediately after it attempts to start its SSID. I used sudo and also tried running directly as root.

root@ubuntu:/home/usre/Desktop/TuyOTA-master# ./tuyota.pl -s 'xxx' -p 'xxx'
Getting interface into stable state
RTNETLINK answers: Cannot assign requested address
Done
Using WiFi device wlan0 for Access Point
Starting Access Point with SSID ZAGDU-789
Giving Access Point IP address 10.44.57.1, pid is 6270
***** Access Point has Shutdown *****
DHCP Discover 00:10:18:bb:13:f1 10.44.57.226
Shutting down...
Setting up IP Address 192.168.4.2 for Final Stages
Getting interface into stable state
RTNETLINK answers: Cannot assign requested address
Done
Setting up wifi scan
Setting up listener for FinalStage
wlan0     Interface doesn't support scanning : Device or resource busy

Shutting down...
Getting interface into stable state
RTNETLINK answers: Cannot assign requested address
Done
Finished
Exiting....
Shutting down...
SynAckFin commented 5 years ago

You might have something else controlling the wlan0 interface. Have a look to see if wpa_supplicant is running.

crazyman143 commented 5 years ago

I wasn't able to follow the part of the walkthrough about adding denyinterfaces wlan0 to the dhcpcd.conf (file doesn't exist) but I did run systemctl stop wpa_supplicant to turn it off first.

SynAckFin commented 5 years ago

That doesn't doesn't always stop wpa_supplicant. If you run the following: ps -fu root | grep wpa_supplicant and it finds any processes then wpa_supplicant is running.

crazyman143 commented 5 years ago

I checked that too but the only thing returned is, I believe, the grep process itself:

root@ubuntu:~# ps -fu root | grep wpa_supplicant
root      4953  4277  0 13:32 pts/2    00:00:00 grep --color=auto wpa_supplicant

Also, when I run the script, I checked syslog and the following is recorded:

Jan 24 13:38:06 ubuntu wpa_supplicant[4864]: wlan0: CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-53 noise=9999 txrate=1000
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Withdrawing address record for 10.44.57.1 on wlan0.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 10.44.57.1.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Interface wlan0.IPv4 no longer relevant for mDNS.
Jan 25 13:38:01 ubuntu kernel: [ 4477.587467] iwlwifi 0000:02:00.0: Radio type=0x1-0x3-0x1
Jan 25 13:38:01 ubuntu kernel: [ 4477.821931] iwlwifi 0000:02:00.0: Radio type=0x1-0x3-0x1
Jan 25 13:38:01 ubuntu kernel: [ 4477.904523] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Joining mDNS multicast group on interface wlan0.IPv4 with address 10.44.57.1.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: New relevant interface wlan0.IPv4 for mDNS.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Registering new address record for 10.44.57.1 on wlan0.IPv4.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Interface wlan0.IPv4 no longer relevant for mDNS.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 10.44.57.1.
Jan 25 13:38:01 ubuntu kernel: [ 4477.932544] iwlwifi 0000:02:00.0: Radio type=0x1-0x3-0x1
Jan 25 13:38:01 ubuntu kernel: [ 4478.169625] iwlwifi 0000:02:00.0: Radio type=0x1-0x3-0x1
Jan 25 13:38:01 ubuntu kernel: [ 4478.252932] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Withdrawing address record for 10.44.57.1 on wlan0.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Joining mDNS multicast group on interface wlan0.IPv4 with address 10.44.57.1.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: New relevant interface wlan0.IPv4 for mDNS.
Jan 25 13:38:01 ubuntu avahi-daemon[579]: Registering new address record for 10.44.57.1 on wlan0.IPv4.

I noticed that wpa_supplicant shows up in there, so maybe it really is running still? If so, I'm not sure on how to kill it. Sorry, I'm probably just being a n00b here.

SynAckFin commented 5 years ago

wpa_supplicant is probably being spawned by another process. The access point will fail to start as long as this is happening. An alternative to tuyota that may work better for you is tuya-convert try it out.

crazyman143 commented 5 years ago

Thanks for the suggestion, but I have a different set of issues with them. Also tried yours on kali linux and with a new wifi adapter, but still can't get past the same issue.

sylvandb commented 5 years ago

ubuntu uses networkmanager. it is probably trying to take control. You can tell networkmanager to ignore wlan0 (but I don't remember how).

I was successful on ubuntu 18.04 using a previous version of the script that worked with networkmanager, but that version wouldn't work on systems without networkmanager. Maybe we need both :)

crazyman143 commented 5 years ago

I ended up procuring a raspberry pi. I installed a fresh copy of Raspian, and I still am running into the same issue. I followed the walkthrough to the letter. I tried a handful of USB wifi adapters with the pi as well. I'm really not sure what else to try.

SynAckFin commented 5 years ago

How long after starting is it before the ***** Access Point has Shutdown ***** message appears?

Run the following command, with your device switched on, and let me know what the output is.

nc -u -l -k -p 6666 | strings

Try running the following (in the tuyota directory) and paste the output here:

hostapd hostapd.conf
NdK73 commented 5 years ago

I think I have the same issue. nc shows two other devices, but not the one I'm trying to flash (Digoo NX-SP202). Flashing one of the other two devices works. I'd say that if nc does not report the device, flashing will fail... But the reverse is not always true: my Teckin SP22 shows up in nc, but flashing fails.