Wifi Web Interface Authentication

Related to the development libraries, released by Curt Binder
Post Reply
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi Web Interface Authentication

Post by binder »

Since we've got a topic going about the authentication string (and several developers involved), I'll add some comments that I've noticed. I've not had a chance to really do much more testing on things with the authentication though.

While adding in some new commands, I noticed some not working properly. When I added in the /w command for the water change, it screwed up the /wifi command. Using serial communications things worked just fine and the commands were processed as they came through without a problem. Using the web interface, /wifi never worked once I added in the /w command. I noticed that the serial interface brings in an entire string at once and the web interface goes through 1 char at a time.
What this means is that when we issue a command, such as GET /wifi, with the serial interface it's processed 1 time as "GET /wifi". With the web interface, it's processed multiple times with the comparison checks like this:
G
GE
GET
GET /
GET /w
GET /wi
GET /wif
GET /wifi

So as you can see, if there is a /w command, that will match before /wifi. The processing loop will go through numerous times before it matches properly. This could very well be what is happening with the authentication as well. It's trying to process the string as it gets it in and it's erroring out numerous times before it actually completes and successfully authenticates. That could be a long enough delay that the commands don't get processed properly thus resulting in a "less than perfect" success rate.

Like I said, I have not had a chance to really dive into the situation yet. It's looking to me like we may need to improve the way that we read the data from the serial interface and wait for a group/string of characters instead of it only reading 1 char and the processing the string, read another, process string, etc. This scenario only seems to happen with the web interface and not the true serial interface which makes it even more difficult to test and track down.

Side Note: I was able to notice this action the best when I was using the controller with the builtin wifi so I could communicate via the wifi interface AND have the serial monitor open on the other serial interface.

Anyways, that's my comments so far. If anybody has suggestions or ideas on things to try out, I'm open for suggestions. I should be able to work on this more hopefully later this week or into the weekend.

curt
dedvalson
Posts: 140
Joined: Tue Oct 04, 2011 5:49 am

Re: Wifi Web Interface Authentication

Post by dedvalson »

Curt,

You are completely right about what was happening. When I sent the GET /WIFI I wound up in water change mode and the next command was ignored.

This gave me an idea.

Perhaps we should modify the protocol to include a command terminator. For Instance, every command would end with something like </GET> or even just a single & or other unused character.

This would stop all of this quite easily.

To maintain compatability with older clients this could be a modal thing. The Client would send a command like GET /pv2 which would mean "Switch to protocol version 2" and then we would start ignoring input till we get the terminator.

Just a thought.

Don
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi Web Interface Authentication

Post by rimai »

I'll look into why the authentication is not working.
The protocol used by the wifi is actually HTTP protocol. So, we can't just terminate with </GET>, but the HTTP header always ends in double CRLF.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi Web Interface Authentication

Post by binder »

rimai wrote:I'll look into why the authentication is not working.
The protocol used by the wifi is actually HTTP protocol. So, we can't just terminate with </GET>, but the HTTP header always ends in double CRLF.
Yeah, I was thinking something about reading until we get the CRLF and then processing it accordingly. Like I said, more testing to figure it out. :)

curt
jemw
Posts: 41
Joined: Sat Oct 08, 2011 9:21 am

Re: Wifi Web Interface Authentication

Post by jemw »

When not using the Client Suite 2.2 (authentication does not work in Client Suite), I have had no problems accessing my controller using authentication. I have the following entry in my .pde file:
ReefAngel.Init(); //Initialize controller
WifiAuthentication("xxxx:yyyyyyyyy");

Where xxxx is the user name and yyyyyyyyy is the password.


To use the Client Suite, I just comment out the WifiAuthentication and download
_____
Jim
Post Reply