mattlongman / Hassio-Access-Point

Hass.io addon to let you create a WiFi access point, perfect for using WiFi devices on off-grid installations.
MIT License
81 stars 63 forks source link

Access point fails to start with USB wifi adapter #35

Open GHJebus opened 1 year ago

GHJebus commented 1 year ago

This plugin emits several errors and fails to put the USB wifi adapter into AP mode when started. It appears to be similar to other hostapd related errors (see: https://askubuntu.com/questions/472794/hostapd-error-nl80211-could-not-configure-driver-mode)

  1. Connect a nl80211 driver based USB device to a RPi3 running Home Assistant OS (in my case a TP-Link TL-WN823N adapter)
  2. Configure Hassio Access Point to use that new device
  3. Save the configuration change and restart the add-on
  4. Observe that the SSID is never advertised
  5. Observe the following errors in the add-on log:

Starting Hass.io Access Point Addon Add custom DNS: dhcp-option=6,192.168.1.1 nl80211: Could not configure driver mode 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

This happens if the USB device is using wlan1 (on-board wifi still enabled) or wlan0 (on-board wifi disabled). The on-board wifi adapter does not have this issue, but does have range/connectivity issues which is why I am attempting to use an external device.

Edit: nmcli reports the usb adapter is of the rtl8xxxu family.

mattlongman commented 1 year ago

Hi @GHJebus - I haven't tested for external Wi-Fi interfaces as when I last tested, I wasn't able to get the drivers to work. If anyone with knowledge of this is able to contribute, I'd be more than happy to test.

legnad commented 1 year ago

I have the exact same issue as OP.

Starting Hass.io Access Point Addon Add DNS: dhcp-option=6,192.168.2.5 nl80211: Could not configure driver mode nl80211: deinit ifname=wlan1 disabled_11b_rates=0 nl80211 driver initialization failed. wlan1: interface state UNINITIALIZED->DISABLED wlan1: AP-DISABLED wlan1: CTRL-EVENT-TERMINATING hostapd_free_hapd_data: Interface wlan1 wasn't started

Raspberry Pi 3b, HAOS; wlan0 is connected to the router, wlan1 should be AP. I am using ASUS USB-N10 Nano wifi adapter.

Would be great getting this to work.

GHJebus commented 1 year ago

From the original link I posted, this is the workaround for the problem:

sudo nmcli nm wifi off sudo rfkill unblock wlan

sudo ifconfig wlan0 10.15.0.1/24 up sleep 1 sudo service isc-dhcp-server restart sudo service hostapd restart

The first two lines stop wlan from network manager, and then unblocks the interface, so ifconfig can work.

UPDATE: But if for the first command you get the error message Error: Object 'nm' is unknown then use this instead:

sudo nmcli radio wifi off

However, I'm not savvy enough with hassio containers to find the one that housed the implementation for this add-on to try those commands. In the end I purchased a USB to Ethernet adapter and wireless access point. Probably better that way for my use case as usb adapters aren't very strong either.

legnad commented 1 year ago

I tried switching the interfaces, so that the external wifi dongle is now connected to my router, whereas the internal RPi 3b wifi would serve as an AP via this Addon. However, I am still running into the same issue.

I ssh'd into my home assistant instance and tried to docker exec into this container like you said, but I'm also not savvy enough to do stuff. I did manage to find out the name of the container with docker ps which is addon_30e576d0_hassio-access-point but it only lasts for a few seconds because the Addon is stopped after the OP error.