msolters / rpi-softap

Browser-friendly Linux service that makes it easy for users to get headless Raspberry Pis onto their own WiFi
43 stars 18 forks source link

rpi-softap throws an error #10

Open mrWheel opened 8 years ago

mrWheel commented 8 years ago

Hi Mark,

First of all: thanks for this software. It is just what I need to connect my headless Raspberry Zero. I have installed the latest version (as of feb. 2016) Debian Jessie. When I run rpi-softap.js I get an error as soon as I connect to the webserver with the /scan or /configure command. See attached file.

err.txt

Can you please help me?

Regards, Willem

msolters commented 8 years ago

Hey Willem,

The error is this command:

sudo iw dev wlan0 scan

It seems to be saying there is no such thing as wlan0. Try running that from the command line before rpi-softap starts, and see what the output is. In addition, what is the output of iwconfig?

mrWheel commented 8 years ago

Hallo Mark, Maybe the problem has to do with changes in the WiFi setup with Debian Jessie. The "interfaces" file now has a "wpa-conf" entry where the SSID and PSK values used to be.

Also the "iw" command seems to be changed (?) iw.txt

With the RPI-SOFTAP setup: iwscan.txt

If I setup the wlan0 the way Jessie wants it, I have a WiFi connection that does work: wlan.txt

I hope you can solve this with the output a provide you. If not, please tell me what more you need.

It would really be great if you can get this to work now we have the Raspberry Zero with only one USB port...

Thanks in advance, Regards Willem

msolters commented 8 years ago

Well, for starters, it seems I did include a generic /etc/network/interfaces file in the source: https://github.com/msolters/rpi-softap/blob/master/config/interfaces

It's just not put into place by the install script (for obvious reasons, don't want to overwrite a custom config).

That being said, it definitely seems that although your interface is being loaded and enumerated by some tools, iw is having a hard time with it. It may be a driver-specific issue.

What kind of wireless card is it? And what is the output of lsusb?

Finally, I actually developed this application on a Raspberry Pi Zero. I've never used it on anything else to be honest. So I know it can work that way.

mrWheel commented 8 years ago

Hi Mark,

The USB dongle is a TP-LINK model TL-WN725N

root@raspZero:/home/pi# lsusb
Bus 001 Device 004: ID 0bda:8179 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@raspZero:/home/pi#

So, I also have an other WiFi dongle. If I use that one the output of lsusb is:

pi@raspZero:~ $ lsusb
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter /  SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspZero:~ $

.. and, it get's even better:

iwok.txt

So, have I wasted your time on this one?

I will check if everything works now and then I'll come back to you.

msolters commented 8 years ago

On my end, I have used a RT5370 dongle while developing this app and I know it works. If it works for you too, then I think that pretty much confirms this is a driver issue specific to the TP-Link dongle & iw: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=29752&start=100

msolters commented 8 years ago

I'm not sure there's much I can do where drivers are concerned except for including a section in the Readme which covers a) what drivers work, and b) installation instructions for other specific drivers.

mrWheel commented 8 years ago

I do understand! A bit of a warning would be nice, but even then I think I would have overlooked it (as the "wrong" dongle does work in "normal" operations :-( ) I will keep you posted if I have a working rpi-softap setup! Thanks again!!

msolters commented 8 years ago

Sure thing! As I've indicated I know that RT5370 works with this software.

One thing that I want to stress is to make sure you are in fact not asking the wlan0 interface to use wpa_conf or wpa_roam or anything in your /etc/networking/interfaces file. Try using the one provided in the package, and reboot. If you allow the those kind of directives to control the interface, you will run into trouble as the daemons try to force control over the interface when the rpi-softap logic switches modes etc. If you are using the interfaces file in this package, and using an RT5370 chipset, I'd expect this to work.

mrWheel commented 8 years ago

Ok, so far so good ;-)

if I point my browser to the web server (http://192.168.42.1:80) I get this:

[SoftAP]:   HTTP server received unrecognized command: /

If I add /scan to it I get:

[{"said":"AandeWiFi5","security":true,"signal":-35},   
{"said":"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00","security":true,"signal":-69},
{"said":"AandeWiFi5","security":true,"signal":-73},{"said":"Ziggo","security":true,"signal":-81},
{"said":"REMOTE28mpdr","security":true,"signal":-77},
{"said":"H368NAE46B7","security":true,"signal":-77},{"said":"KPN-
VGV751908264C","security":true,"signal":-69},{"said":"UPC4607797","security":true,"signal":-77}]

So looks to me that the acces point is working but that there is something wrong with the web server.. Any ideas?

W.

msolters commented 8 years ago

No, there is no problem here. If you look at the server source, it only defines 2 URLs:

So http://192.168.42.1:80/ has no route defined, and so the server replies with the default case, which is "unrecognized command" (line 237).

In other words, this tool does not actually expose a front end. It only exposes these two REST resources on the backend which are all that's needed to use the tool. My expectation was that people would want to write their own frontends.

Regarding /scan, I think it's obvious enough how that can be parsed as JSONic data, e.g. with a JSON.parse() in JS for instance. This is a resource that is meant to be obtained via an HTTP GET request.

For /configure, you need to use an HTTP POST request. The content payload should be a JSON object that looks like:

{
  "ssid": "Your selected SSID",
  "password": "the psk passphrase"
}

The password key-value pair is optional and may be omitted. Posting that content to the /configure URL will cause the payload to be processed into a wpa_conf file as you can see here: https://github.com/msolters/rpi-softap/blob/master/rpi-softap.js#L172

mrWheel commented 8 years ago

Pffff.... Well, thats a little bit "over my head"! I'm old school (COBOL) programmer. Trying to teach myself jQuery but I have no idea how to program that node.js thingy :-( Are there people you know of who has programmed that front end? Would be a wast to leave it at this ... But thanks for all the help! Regards, Willem

msolters commented 8 years ago

Yes, I have made a front end. I've been meaning to make another repository that contains it as an example. Unfortunately, it's written in Meteor.

Meteor is a JavaScript framework based on Node.JS, though, so I'm not sure it would be that much more helpful to you. I've also been toying with the idea of building a web interface that is internally served up at http://192.168.42.1/ -- in fact I've already logged an issue for that here.

I've simply not gotten around to that because I am very busy with other projects.

mrWheel commented 8 years ago

Mark,

I DO understand. The work that is done by you and other Open Source developers is stoning!

I will keep an eye on this repository and wait for more great things to happen ;-)

Thanks