Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostapd_free_hapd_data: Interface wlan0 wasn't started #659

Closed
mocarela opened this issue May 3, 2024 · 5 comments
Closed

hostapd_free_hapd_data: Interface wlan0 wasn't started #659

mocarela opened this issue May 3, 2024 · 5 comments

Comments

@mocarela
Copy link

mocarela commented May 3, 2024

I'm trying to cut off from the cloud my "tuya-generic-s18-ir-repeater", but failing on the last step (at least as far as I understand the whole thing).

~/tuya-cloudcutter# ./tuya-cloudcutter.sh -r -w wlan0
Building cloudcutter docker image
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  3.216MB
Step 1/10 : FROM python:3.9.18-slim-bullseye AS base
 ---> 83b8dddc8bfb
Step 2/10 : RUN apt-get -qq update && apt-get install -qy --no-install-recommends git hostapd rfkill dnsmasq build-essential libssl-dev iproute2 mosquitto
 ---> Using cache
 ---> 8e5f6ae9ef90
Step 3/10 : FROM base AS python-deps
 ---> 8e5f6ae9ef90
Step 4/10 : RUN pip install --upgrade pipenv
 ---> Using cache
 ---> 4358d26ea583
Step 5/10 : COPY src/Pipfile /src/
 ---> Using cache
 ---> fd92944fc2e9
Step 6/10 : COPY src/Pipfile.lock /src/
 ---> Using cache
 ---> b80db5632f67
Step 7/10 : RUN cd /src && PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
 ---> Using cache
 ---> 1288d75a31b2
Step 8/10 : FROM python-deps AS cloudcutter
 ---> 1288d75a31b2
Step 9/10 : COPY src /src
 ---> Using cache
 ---> 31d655193e9a
Step 10/10 : WORKDIR /src
 ---> Using cache
 ---> 62b6c2b28d9c
Successfully built 62b6c2b28d9c
Successfully tagged cloudcutter:latest
Successfully built docker image
1) Detach from the cloud and run Tuya firmware locally
2) Flash 3rd Party Firmware
[?] Select your desired operation [1/2]: 1
Detaching requires an SSID and Password, please enter each at the following prompt
In order to provide secure logging, the values you type for your password will not show on screen
If you make a mistake, you can run the detach process again
You can also pass credentials via the -s command line option, see './tuya-cloudcutter.sh -h' for more information'
Please enter your SSID: myaccesspoint
Please enter your Password:
Loading options, please wait...
[?] How do you want to choose the device?: From device-profiles (i.e. custom profile)
   By manufacturer/device name
   By firmware version and name
 > From device-profiles (i.e. custom profile)

[?] Select device profile: tuya-generic-s18-ir-repeater
 > tuya-generic-s18-ir-repeater


Performing safety checks to make sure all required ports are available
Checking UDP port 53... Available.
Checking UDP port 67... Available.
Checking TCP port 80... Available.
Checking TCP port 443... Available.
Checking TCP port 1883... Available.
Checking TCP port 8886... Available.
Safety checks complete.

Selected Device Slug: tuya-generic-s18-ir-repeater
Selected Profile: oem-bk7231n-irbox-mol-ty-2.0.0-sdk-2.3.1-40.00

================================================================================
Place your device in AP (slow blink) mode.  This can usually be accomplished by either:
Power cycling off/on - 3 times and wait for the device to fast-blink, then repeat 3 more times.  Some devices need 4 or 5 times on each side of the pause
Long press the power/reset button on the device until it starts fast-blinking, then releasing, and then holding the power/reset button again until the device starts slow-blinking.
See https://support.tuya.com/en/help/_detail/K9hut3w10nby8 for more information.
================================================================================

Wiping NetworkManager configs
Scanning for open Tuya SmartLife AP

Found access point name: "A-FC52", trying to connect...
Device 'wlan0' successfully activated with 'd2b1adb6-225a-45d4-97ba-8f4bf5bcce47'.
Connected to access point.
Waiting 1 sec to allow device to set itself up...
Running initial exploit toolchain...
Exploit run, saved device config too!
output=/work/configured-devices/bDmo5GMRUnti.deviceconfig
Saved device config in /work/configured-devices/bDmo5GMRUnti.deviceconfig

================================================================================
Power cycle and place your device in AP (slow blink) mode again.  This can usually be accomplished by either:
Power cycling off/on - 3 times and wait for the device to fast-blink, then repeat 3 more times.  Some devices need 4 or 5 times on each side of the pause
Long press the power/reset button on the device until it starts fast-blinking, then releasing, and then holding the power/reset button again until the device starts slow-blinking.
See https://support.tuya.com/en/help/_detail/K9hut3w10nby8 for more information.
================================================================================

Wiping NetworkManager configs
Scanning for open Tuya SmartLife AP
......
Found access point name: "A-FC52", trying to connect...
Device 'wlan0' successfully activated with '7714ba4a-e1d5-481c-a1e1-56223ccfcad6'.
Connected to access point.
Configured device to connect to 'cloudcutterflash'
Device is connecting to 'cloudcutterflash' access point. Passphrase for the AP is 'abcdabcd' (without ')
Cutting device off from cloud...

================================================================================
Wait for up to 10-120 seconds for the device to connect to 'cloudcutterflash'. This script will then show the activation requests sent by the device, and tell you whether local activation was successful.
================================================================================

Using WLAN adapter: wlan0
RTNETLINK answers: Operation not permitted
Configuration file: /dev/stdin
Could not set interface wlan0 flags (UP): Operation not permitted
nl80211: Could not set interface 'wlan0' UP
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED
wlan0: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlan0 wasn't started

If I start wlan0 manually just before dnsmasq, then execution continues, the device connects to the "'cloudcutterflash'" AP (I can ping it), but it doesn't go much further.

~/tuya-cloudcutter# ./tuya-cloudcutter.sh -r -s myaccesspoint XXXXXXXX -w wlan0 -p tuya-generic-s18-ir-repeater -v
Building cloudcutter docker image
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  3.218MB
Step 1/10 : FROM python:3.9.18-slim-bullseye AS base
 ---> 83b8dddc8bfb
Step 2/10 : RUN apt-get -qq update && apt-get install -qy --no-install-recommends git hostapd rfkill dnsmasq build-essential libssl-dev iproute2 mosquitto
 ---> Using cache
 ---> 8e5f6ae9ef90
Step 3/10 : FROM base AS python-deps
 ---> 8e5f6ae9ef90
Step 4/10 : RUN pip install --upgrade pipenv
 ---> Using cache
 ---> 4358d26ea583
Step 5/10 : COPY src/Pipfile /src/
 ---> Using cache
 ---> fd92944fc2e9
Step 6/10 : COPY src/Pipfile.lock /src/
 ---> Using cache
 ---> b80db5632f67
Step 7/10 : RUN cd /src && PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
 ---> Using cache
 ---> 1288d75a31b2
Step 8/10 : FROM python-deps AS cloudcutter
 ---> 1288d75a31b2
Step 9/10 : COPY src /src
 ---> Using cache
 ---> 7630508ae0c4
Step 10/10 : WORKDIR /src
 ---> Using cache
 ---> 7557f0052631
Successfully built 7557f0052631
Successfully tagged cloudcutter:latest
Successfully built docker image
Loading options, please wait...

Performing safety checks to make sure all required ports are available
Checking UDP port 53... Available.
Checking UDP port 67... Available.
Checking TCP port 80... Available.
Checking TCP port 443... Available.
Checking TCP port 1883... Available.
Checking TCP port 8886... Available.
Safety checks complete.

Selected Device Slug: tuya-generic-s18-ir-repeater
Selected Profile: oem-bk7231n-irbox-mol-ty-2.0.0-sdk-2.3.1-40.00

================================================================================
Place your device in AP (slow blink) mode.  This can usually be accomplished by either:
Power cycling off/on - 3 times and wait for the device to fast-blink, then repeat 3 more times.  Some devices need 4 or 5 times on each side of the pause
Long press the power/reset button on the device until it starts fast-blinking, then releasing, and then holding the power/reset button again until the device starts slow-blinking.
See https://support.tuya.com/en/help/_detail/K9hut3w10nby8 for more information.
================================================================================

Wiping NetworkManager configs
Scanning for open Tuya SmartLife AP
....
Found access point name: "A-FC52", trying to connect...
Device 'wlan0' successfully activated with '672946c8-50b0-4533-b096-5d4d77e72834'.
Connected to access point.
Waiting 1 sec to allow device to set itself up...
Running initial exploit toolchain...
Exploit run, saved device config too!
output=/work/configured-devices/ovMu5D3hYQyI.deviceconfig
Saved device config in /work/configured-devices/ovMu5D3hYQyI.deviceconfig

================================================================================
Power cycle and place your device in AP (slow blink) mode again.  This can usually be accomplished by either:
Power cycling off/on - 3 times and wait for the device to fast-blink, then repeat 3 more times.  Some devices need 4 or 5 times on each side of the pause
Long press the power/reset button on the device until it starts fast-blinking, then releasing, and then holding the power/reset button again until the device starts slow-blinking.
See https://support.tuya.com/en/help/_detail/K9hut3w10nby8 for more information.
================================================================================

Wiping NetworkManager configs
Scanning for open Tuya SmartLife AP
..............
Found access point name: "A-FC52", trying to connect...
Device 'wlan0' successfully activated with '42b58984-10c3-4d1c-bda6-175646e8d781'.
Connected to access point.
Configured device to connect to 'cloudcutterflash'
Device is connecting to 'cloudcutterflash' access point. Passphrase for the AP is 'abcdabcd' (without ')
Cutting device off from cloud...

================================================================================
Wait for up to 10-120 seconds for the device to connect to 'cloudcutterflash'. This script will then show the activation requests sent by the device, and tell you whether local activation was successful.
================================================================================

Using WLAN adapter: wlan0
RTNETLINK answers: Operation not permitted
waiting 20s
May  3 15:27:06 dnsmasq[16]: started, version 2.85 cachesize 150
May  3 15:27:06 dnsmasq[16]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptohash DNSSEC loop-detect inotify dumpfile
May  3 15:27:06 dnsmasq-dhcp[16]: DHCP, IP range 10.42.42.10 -- 10.42.42.40, lease time 12h
May  3 15:27:06 dnsmasq-dhcp[16]: DHCP, sockets bound exclusively to interface wlan0
May  3 15:27:06 dnsmasq[16]: read /etc/hosts - 12 addresses
Configuration file: /dev/stdin
Using interface wlan0 with hwaddr a4:3e:a0:52:cd:9a and ssid "cloudcutterflash"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
May  3 15:27:12 dnsmasq-dhcp[16]: 842012285 available DHCP range: 10.42.42.10 -- 10.42.42.40
May  3 15:27:12 dnsmasq-dhcp[16]: 842012285 client provides name: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPDISCOVER(wlan0) 18:de:50:bc:fc:52
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 tags: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPOFFER(wlan0) 10.42.42.32 18:de:50:bc:fc:52
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 requested options: 1:netmask, 3:router, 28:broadcast, 6:dns-server
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 next server: 10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  1 option: 53 message-type  2
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 54 server-identifier  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 51 lease-time  12h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 58 T1  6h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 59 T2  10h30m
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  1 netmask  255.255.255.0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 28 broadcast  10.42.42.255
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  3 router  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  6 dns-server  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 available DHCP range: 10.42.42.10 -- 10.42.42.40
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 client provides name: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPDISCOVER(wlan0) 18:de:50:bc:fc:52
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 tags: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPOFFER(wlan0) 10.42.42.32 18:de:50:bc:fc:52
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 requested options: 1:netmask, 3:router, 28:broadcast, 6:dns-server
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 next server: 10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  1 option: 53 message-type  2
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 54 server-identifier  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 51 lease-time  12h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 58 T1  6h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 59 T2  10h30m
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  1 netmask  255.255.255.0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 28 broadcast  10.42.42.255
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  3 router  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  6 dns-server  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 available DHCP range: 10.42.42.10 -- 10.42.42.40
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 client provides name: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPREQUEST(wlan0) 10.42.42.32 18:de:50:bc:fc:52
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 tags: wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 DHCPACK(wlan0) 10.42.42.32 18:de:50:bc:fc:52 wlan0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 requested options: 1:netmask, 3:router, 28:broadcast, 6:dns-server
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 next server: 10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  1 option: 53 message-type  5
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 54 server-identifier  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 51 lease-time  12h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 58 T1  6h
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 59 T2  10h30m
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  1 netmask  255.255.255.0
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option: 28 broadcast  10.42.42.255
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  3 router  10.42.42.1
May  3 15:27:15 dnsmasq-dhcp[16]: 842012285 sent size:  4 option:  6 dns-server  10.42.42.1
[15:27:16.690331 MQTT] Connected

Any idea what's wrong in my case?

@Cossid
Copy link
Member

Cossid commented May 3, 2024

Your device is having issues finishing the DHCP request in time and gets stuck. You can restart the network join process;

https://github.com/tuya-cloudcutter/tuya-cloudcutter/wiki/FAQ#my-device-gets-stuck-after-dhcp-what-can-i-do

@mocarela
Copy link
Author

mocarela commented May 4, 2024

Thanks for the help... it worked! I should have read that. :$

May I ask another question, since I'm quite new in this IoT universe. After I have cut it off, it still works with the Tuya fw, thus I have to use kind of LocalTuya integration in HA right? And because it looks it doesn't support it, I will have to flush it also.

What fw do you recommend? I would just need to learn IR codes (of other remotes) and transmit them (either manually or with automations). Beside included ESPHome and OpenBeken, do I have any other alternatives that can be flashed OTA using tuya-cloudcutter?

@Cossid
Copy link
Member

Cossid commented May 4, 2024

After I have cut it off, it still works with the Tuya fw, thus I have to use kind of LocalTuya integration in HA right?

Yes, you would use LocalTuya for integration into HA.

And because it looks it doesn't support it, I will have to flush it also.

I don't understand what you're asking here. You could possibly open an issue with LocalTuya to ask for support for your devices. I'm not sure what you mean by flush it.

What fw do you recommend?

Personally, I mostly use ESPHome, but it does have a high learning curve. I know both have some form of IR support, but don't have much experience with IR on either yet.

Beside included ESPHome and OpenBeken, do I have any other alternatives that can be flashed OTA using tuya-cloudcutter?

I'm not aware of any other firmware that supports Beken yet.

@Cossid Cossid closed this as completed May 4, 2024
@mocarela
Copy link
Author

mocarela commented May 5, 2024

And because it looks it doesn't support it, I will have to flush it also.

I don't understand what you're asking here. You could possibly open an issue with LocalTuya to ask for support for your devices. I'm not sure what you mean by flush it.

I meant flash it, since local tuya doesn't support it.

Beside included ESPHome and OpenBeken, do I have any other alternatives that can be flashed OTA using tuya-cloudcutter?

I'm not aware of any other firmware that supports Beken yet.

Does ESPHome support it at all?

@Cossid
Copy link
Member

Cossid commented May 5, 2024

Does ESPHome support it at all?

Yes, ESPHome supports Beken at the core level. IR seems to be mostly working, though there may be some bugs remaining, I'm not certain, I haven't followed the latest changes there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants