Understanding the Wifi module
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Understanding the Wifi module
So I am trying to figure out how the wifi module works. I just setup a new Reef Angel at work and I am looking to figure out, how I can read the response after a SendPortal is sent I see the two \n\n. Does that instruct the wifi module to send the data? I am not 100% clear on how that works. I think by reading the response if it times out, I can send a reset command to the wifi module to force it to reboot. this should keep it humming along for as long as possible.
Re: Understanding the Wifi module
It is a UART to TCP converter.
Whatever comes into the UART side is transmitted to the TCP side and whatever comes in from the TCP side is transmitted to the UART side.
Whatever comes into the UART side is transmitted to the TCP side and whatever comes in from the TCP side is transmitted to the UART side.
Roberto.
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Re: Understanding the Wifi module
So looking at the wifi code that is there... I am not sure how I would get the response back of a http request made from the reef angel.
Re: Understanding the Wifi module
What kind of response?
You want to initiate a request and parse the response within RA?
If so, you can't.
For one, the wifi attachment only works in a single host (right now it is www.reefangel.com), which means it can only initiate requests to that particular host.
Then, even if you change that to another 3rd party server, we don't have any parser implemented within our libraries.
If you would like to try creating a parser, we would really appreciate it
Just keep in mind that we have very limited memory.
You want to initiate a request and parse the response within RA?
If so, you can't.
For one, the wifi attachment only works in a single host (right now it is www.reefangel.com), which means it can only initiate requests to that particular host.
Then, even if you change that to another 3rd party server, we don't have any parser implemented within our libraries.
If you would like to try creating a parser, we would really appreciate it
Just keep in mind that we have very limited memory.
Roberto.
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Re: Understanding the Wifi module
A simple JSON parser should not take up much memory... I can't even figure out how to just read the entire body of a response, once I get there. i can figure out how to parse it. But speaking of memory. How does one know how much memory they are consuming?
Re: Understanding the Wifi module
It has to be done inside the libraries right now.
But if you want to test it without the libraries, use a simple sketch and send serial data to the wifi attachment.
If you send for example "GET / " to the serial port, you will get the HTML response from www.reefangel.com home page.
But if you want to test it without the libraries, use a simple sketch and send serial data to the wifi attachment.
If you send for example "GET / " to the serial port, you will get the HTML response from www.reefangel.com home page.
Roberto.
Re: Understanding the Wifi module
For memory used, try these:
http://playground.arduino.cc/Code/AvailableMemory
http://forum.arduino.cc/index.php?topic ... #msg204010
http://playground.arduino.cc/Code/AvailableMemory
http://forum.arduino.cc/index.php?topic ... #msg204010
Roberto.
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Re: Understanding the Wifi module
OK another question. How many requests can the module take in a minute. It seems if I tried polling any more frequently than once per say 15 seconds, the controller/wifi stopped responding.
Re: Understanding the Wifi module
You can do multiple requests per minute. The problem you will face will be the internet latency.
The module can only handle one request at a time. So, if you send a request and it takes 5 seconds to go through the internet and reach the wifi and you send a second request in less than 5 seconds and it hits the wifi while it's processing the 1st one, the second one will time out.
But, maybe you have more knowledge on the server side to maintain the socket open, so you don't have to keep polling. If you can maintain the socket open on the server side and can create some sort of relay service, we can forget about port forwarding and have a dedicated channel of communication with the controller.
We would need to come up with some sort of API key for security.
The module can only handle one request at a time. So, if you send a request and it takes 5 seconds to go through the internet and reach the wifi and you send a second request in less than 5 seconds and it hits the wifi while it's processing the 1st one, the second one will time out.
But, maybe you have more knowledge on the server side to maintain the socket open, so you don't have to keep polling. If you can maintain the socket open on the server side and can create some sort of relay service, we can forget about port forwarding and have a dedicated channel of communication with the controller.
We would need to come up with some sort of API key for security.
Roberto.
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Re: Understanding the Wifi module
Agreed... But I think I need your help on getting the Wifi module to like sockets.
Re: Understanding the Wifi module
Looking at the manual, I think we can set the protocol to tcp client only and use idle timer 0.
This should create a permanent link with your server.
The problem is that when you make this change, no other apps will be able to communicate with the attachment, since it can only handle one connection and it will be connected to your server.
So, we will need some sort of API to make remote calls that would in turn be routed to the controller through the established socket.
Does it make sense?
The commands would be:
If you want to put it back to what we are using, we use:
Just keep in mind that the wifi attachment will be changed to client only, which means it will not accept any incoming connection. It will only establish a connection with an external server.
The connection will be established as soon as the first character is received through the serial port.
This should create a permanent link with your server.
The problem is that when you make this change, no other apps will be able to communicate with the attachment, since it can only handle one connection and it will be connected to your server.
So, we will need some sort of API to make remote calls that would in turn be routed to the controller through the established socket.
Does it make sense?
The commands would be:
Code: Select all
set i p 8
set c i 0
Code: Select all
set i p 1
set c i 3
The connection will be established as soon as the first character is received through the serial port.
Roberto.
Re: Understanding the Wifi module
So, I went ahead today and played around with the idea.
I used yaler.net service and was able to make a connection and maintain it open.
Then I used my browser to go to http://gsiot-feme-rgaq.try.yaler.net/, which is the web address that I setup for my RA.
I got nothing at first.
The libraries needed to be changed a bit to make it work, but at last, I was able to get it to answer back.
This proves that the idea works
I was able to browse to a website and connect to my RA with no port forwarding and no firewall issues
I used yaler.net service and was able to make a connection and maintain it open.
Then I used my browser to go to http://gsiot-feme-rgaq.try.yaler.net/, which is the web address that I setup for my RA.
I got nothing at first.
The libraries needed to be changed a bit to make it work, but at last, I was able to get it to answer back.
This proves that the idea works
I was able to browse to a website and connect to my RA with no port forwarding and no firewall issues
Roberto.
-
- Posts: 137
- Joined: Sat Feb 16, 2013 7:44 am
Re: Understanding the Wifi module
This is huge... Especially for commercial applications, where firewalls are more prevalent.