Open Grandpa-G opened 8 years ago
You can do this to see what wifi is calling out to.
scheme = # ...
print(' '.join(['/sbin/ifup'] + self.as_args()))
Then you can run that command manually. Then can you post that output here?
Thanks,
I am no longer using wifi
On fully updated Jessie I run the following code after boot:
from wifi import Cell, Scheme
for scheme in Scheme.all():
scheme.delete()
cell = Cell.all("wlan0")[0]
scheme = Scheme.for_cell('wlan0', "nox1203", cell, passkey="pass")
scheme.save()
scheme.activate()
and get the following:
Traceback (most recent call last):
File "test.py", line 8, in <module>
scheme.activate()
File "/usr/local/lib/python2.7/dist-packages/wifi/scheme.py", line 176, in activate
return self.parse_ifup_output(ifup_output)
File "/usr/local/lib/python2.7/dist-packages/wifi/scheme.py", line 183, in parse_ifup_output
raise ConnectionError("Failed to connect to %r" % self)
wifi.exceptions.ConnectionError: Failed to connect to Scheme(interface='wlan0', name='nox1203', options={'wpa-psk': 'fdd89aca0489ddf5b88286c495371ecd695b1b341a3d1263f90e34277f02852a', 'wpa-ssid': u'nox1203', 'wireless-channel': 'auto'}
But if I run the same code one more time it connects to the wifi. Please request additional data if needed.
hmm, that's weird.
Can you do this:
scheme = # ...
print(' '.join(['/sbin/ifup'] + self.as_args()))
and paste the output here?
Thanks,
Added print statement. I changed self.as_args() to scheme.as_args(). I got this:
/sbin/ifup wlan0=wlan0-nox1203 -o wpa-psk=fdd89aca0489ddf5b88286c495371ecd695b1b341a3d1263f90e34277f02852a -o wpa-ssid=nox1203 -o wireless-channel=auto
It is identical on both runs.
Can you try running that command directly and post the output here?
On Fri, Jul 15, 2016 at 4:40 AM nox1203 notifications@github.com wrote:
Added print statement. I changed self.as_args() to scheme.as_args(). I got this:
/sbin/ifup wlan0=wlan0-nox1203 -o wpa-psk=fdd89aca0489ddf5b88286c495371ecd695b1b341a3d1263f90e34277f02852a -o wpa-ssid=nox1203 -o wireless-channel=auto
It is identical on both runs.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockymeza/wifi/issues/102#issuecomment-232785510, or mute the thread https://github.com/notifications/unsubscribe/AABVGF7XR7Dshh0e65MdDrWSN1mbaThBks5qVp6mgaJpZM4Ia6_n .
-Rocky
pi@raspberrypi:~ $ sudo /sbin/ifup wlan0=wlan0-nox1203 -o wpa-psk=fdd89aca0489ddf5b88286c495371ecd695b1b341a3d1263f90e34277f02852a -o wpa-ssid=nox1203 -o wireless-channel=auto /sbin/ifup: interface wlan0 already configured
ifconfig says:
wlan0 Link encap:Ethernet HWaddr 00:c1:41:31:0b:b3
inet6 addr: fe80::15ca:99a6:a787:2c0f/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
oh, you were already connected. Can you disconnect and then run this command?
I was not connected. There is no inet ip for wlan. nmap 192.168.1.* does not give anything for raspberry pi.
oh sorry, I mean, your interface was already up. Can you turn off the interface first? /sbin/ifdown wlan0
On Fri, Jul 15, 2016 at 6:01 AM nox1203 notifications@github.com wrote:
I was not connected. There is no inet ip for wlan. nmap 192.168.1.* does not give anything for raspberry pi.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockymeza/wifi/issues/102#issuecomment-232805664, or mute the thread https://github.com/notifications/unsubscribe/AABVGHHkRL0nWMGJM2G4wA3F3yvBdRwSks5qVrHNgaJpZM4Ia6_n .
-Rocky
pi@raspberrypi:~ $ sudo /sbin/ifdown wlan0 pi@raspberrypi:~ $ sudo /sbin/ifup wlan0=wlan0-nox1203 -o wpa-psk=fdd89aca0489ddf5b88286c495371ecd695b1b341a3d1263f90e34277f02852a -o wpa-ssid=nox1203 -o wireless-channel=auto Internet Systems Consortium DHCP Client 4.3.1 Copyright 2004-2014 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/00:c1:41:31:0b:b3 Sending on LPF/wlan0/00:c1:41:31:0b:b3 Sending on Socket/fallback DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4 DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 10 DHCPREQUEST on wlan0 to 255.255.255.255 port 67 DHCPOFFER from 192.168.1.1 DHCPACK from 192.168.1.1 bound to 192.168.1.109 -- renewal in 34477 seconds.
I'm having a similar issue, I need to run the command 2-3 times before it connects to the network. Any fixes for this? I'm on Jessie too
Hi, rockymeza! Few days ago I found and tried to use your library at the Raspberry Pi and got same issue. As you recomended, I added line:
print subprocess.check_output(["ifdown", IF_WLAN])
before call to activate() and it looks like now I get successful connection.
And few details probably will be useful for you:
P.S. IF_WLAN is constant with name of my WLAN interface
I was about to report a new issue, but I think this is related. Basically there is a small bug I believe in line 172 in scheme.py
subprocess.check_output(['/sbin/ifdown', self.interface], stderr=subprocess.STDOUT)
For interface names like wlan0-foobar, this would fail. A simple change fixes it. self.interface should be replaced with self.iface
That solved my problem.
Same thing happening here! I follow @rockymeza advice but the same error is appearing! It's even worst for me, I could not connect once!!
I am using a very simple script based on @nox1203 commentary and adding the ifdown command before calling activate(). Any idea?
I am using wifi class in python (indentation not showing here, changed password).
When it gets to activate, the pi disconnects my xrdp session, can't be pinged, and I have to restart it to get another wifi connection by default reboot.
my interfaces file at the end looks like:
The normal connection wifi entry is
Am I doing something wrong? Does the wpa_supplicant.conf format still work with your scheme format? Ideas?