cjimti / iotwifi

Raspberry Pi (arm) wifi configuration container. Configure and control wifi connectivity with a JSON based REST api.
https://imti.co/iot-wifi/
MIT License
303 stars 124 forks source link

Troubleshooting when uap0 isn't created #24

Closed ki9us closed 5 years ago

ki9us commented 6 years ago

Report a bug or get help

$ docker run --rm --privileged --net host -v /home/keith/wificfg.json:/cfg/wificfg.json cjimti/iotwifi
{"hostname":"raspberrypi","level":30,"msg":"Starting IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.364Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HTTP Listening on 8080","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.368Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"Loading IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.366Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"Starting Hostapd.","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.374Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"Hostapd CFG: interface=uap0\nssid=mypiwifi\nhw_mode=g\nchannel=6\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=secretpassword\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.427Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: random: Trying to read entropy from /dev/random","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.44Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: Configuration file: /dev/stdin","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.441Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: Could not read interface uap0 flags: No such device","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.465Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211: Driver does not support authentication/association or connect commands","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.466Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211: deinit ifname=uap0 disabled_11b_rates=0","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.468Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211: Remove monitor interface: refcount=0","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.469Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: netlink: Operstate: ifindex=0 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.47Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: Could not read interface uap0 flags: No such device","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.482Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211: Set mode ifindex 0 iftype 2 (STATION)","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.484Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211: Failed to set interface 0 to mode 2: -19 (No such device)","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.485Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: nl80211 driver initialization failed.","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.486Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit_free(0x76f9c010)","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.488Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit_free: num_bss=1 conf-\u003enum_bss=1","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.489Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit(0x76f9c010)","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.49Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: uap0: interface state UNINITIALIZED-\u003eDISABLED","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.491Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_bss_deinit: deinit bss uap0","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.492Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: uap0: AP-DISABLED ","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.493Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_cleanup(hapd=0x76f9c500 (uap0))","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.494Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"Hostapd DISABLED","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.494Z","v":0}
{"hostname":"raspberrypi","level":30,"msg":"HOSTAPD GOT: hostapd_free_hapd_data: Interface uap0 wasn't started","name":"iotwifi","pid":0,"time":"2018-09-22T22:53:10.495Z","v":0}
...

Then running ifconfig doesn't show uap0.

$ ifconfig                                        
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500                
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255  
        ether 02:42:fd:ca:9a:45  txqueuelen 0  (Ethernet)   
        RX packets 0  bytes 0 (0.0 B)            
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)           
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enxb827eb4e0d5e: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.42.0.92  netmask 255.255.255.0  broadcast 10.42.0.255
        inet6 fe80::dfb5:5699:ddf2:30b  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:4e:0d:5e  txqueuelen 1000  (Ethernet)
        RX packets 4105  bytes 258381 (252.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3878  bytes 1613147 (1.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:27:eb:1b:58:0b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlx00e04c1a7f2d: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:4c:1a:7f:2d  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I have two wireless interfaces, if that could be part of the problem.

$ sudo lshw -C network
  *-network:0               
       description: Ethernet interface
       physical id: 2
       logical name: docker0
       serial: 02:42:fd:ca:9a:45
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=no multicast=yes
  *-network:1
       description: Ethernet interface
       physical id: 3
       logical name: enxb827eb4e0d5e
       serial: b8:27:eb:4e:0d:5e
       size: 100Mbit/s
       capacity: 100Mbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=smsc95xx driverversion=22-Aug-2005 duplex=full firmware=smsc95xx USB 2.0 Ethernet ip=10.42.0.92 link=yes multicast=yes port=MII speed=100Mbit/s
  *-network:2
       description: Wireless interface
       physical id: 4
       bus info: usb@1:1.3
       logical name: wlx00e04c1a7f2d
       serial: 00:e0:4c:1a:7f:2d
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rtl8192eu multicast=yes wireless=unassociated
  *-network:3
       description: Wireless interface
       physical id: 5
       logical name: wlan0
       serial: b8:27:eb:1b:58:0b
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=brcmfmac driverversion=7.45.98.38 firmware=01-e58d219f multicast=yes wireless=IEEE 802.11
  1. See above

See above

Making it work?

See above

cjimti commented 6 years ago

@keith24 Sorry I have been traveling a lot for work lately and have not had much time to check up on this project. Have you tried disconnecting the other interface? Are you able to manually create virtual interfaces?

ki9us commented 6 years ago

@cjimti No problem... I've been travelling myself and finally got a decent wifi connection to try this out.

I physically disconnected the dongle and saw it disappear from ifconfig. But when I ran the docker container uap0 was still not created.

I rebooted with the dongle detached and then it worked, creating uap0.

I plugged it back in and restarted. Then I was able to create a new virtual interface based on wlan0 as well as the external dongle:

$ sudo ifconfig wlan0:0 10.43.0.1
$ ifconfig wlan0:0
wlan0:0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.43.0.1  netmask 255.0.0.0  broadcast 10.255.255.255
        ether b8:27:eb:1b:58:0b  txqueuelen 1000  (Ethernet)
$ sudo reboot
$ sudo ifconfig wlx00e04c1a7f2d:0 10.43.0.1
$ ifconfig wlx00e04c1a7f2d:0
wlx00e04c1a7f2d: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.43.0.1  netmask 255.0.0.0  broadcast 10.255.255.255
        ether 00:e0:4c:1a:7f:2d  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

At least I have a workaround: I can boot with the dongle unplugged, then plug it in after iotwifi starts up.

ki9us commented 6 years ago

At least, that's the command I got when I googled "Add a virtual interface linux"

I see in iotwifi/commands.go#L39 that the command iotwifi uses is iw phy phy0 interface add uap0 type __ap. So let's try that after rebooting with the dongle unplugged:

$ sudo iw phy phy0 interface add uap0 type __ap
$

And plugged in:

$ sudo iw phy phy0 interface add uap0 type __ap
command failed: No such device (-19)

So I guess there's the issue. Wish I could help more but I don't know what's going on at all.

ki9us commented 5 years ago

Haven't tested yet (and I won't be able to for a minute), but according to the iw manpage, it might work to use iw phy#0 instead of iw phy phy0, if I'm reading it correctly.

cjimti commented 5 years ago

@keith24 Thank you for researching this. I have not encountered this problem, but it does look like you are using a much newer version of Raspian. Looking forward to your test results. Also if you would like to submit a pull request I am open to any contributions.

ki9us commented 5 years ago

OK. I made the change. What docker build flags should I use? I'm new to docker.

cjimti commented 5 years ago

@keith24 to test the build simply docker build -t somename . if you want to put it on hub.docker.com you will need to tag it something like USERNAME/iotwifi:VERSION then do a docker push USERNAME/iotwifi:VERSION

ki9us commented 5 years ago

OK, it still didn't create uap0. And I could have probably saved time by just running

$ sudo iw phy+0 interface add uap0 type __ap

right in the shell. I did that and still got the same error, command failed: No such device (-19).

The first google results for the error yielded this answer on superuser SE, which inspired me to check if virtual interfaces are supported by my device:

$ iw list | grep 'interface combinations'
        valid interface combinations:
        interface combinations are not supported

So it sounds like it'll never work with this dongle. :disappointed: