Go Down

Topic: Feeling interest for a WiFi shield (Read 32519 times) previous topic - next topic

metRo_

My really congratulations for your project ;)

How you take the button action on the ipod example? i mean, how the arduino know that you click the button?

MOS6502

Maybe I'm just being an idiot, but is webpage1[] supposed to be displayed in the example code? Every time I pull up the hello world example, all I get is the single line.

Again, I'm probably missing something stupid, I just want to be sure I have everything working correctly.

AsyncLabs

No, you're not an idiot.  ;D

One of the limitations of the stack right now is that the webpage cannot exceed ~450 bytes.  This is due to the RAM limitation on the 168.  We were trying to create a way to send multiple packets, which would allow you to serve a larger page (limited by the remaining flash space).  The second webpage was our test to get the multiple packets working.  However, we weren't able to get it going, and we wanted to get some code out to the general public, so we shelved the multiple packets for now.
If you look farther below, you'll see a #if 0 section which is the commented out code to support multiple packets that we were working on.  

Sorry about the confusion.

BenQuark

@MCxPRT

You can put it below #include "config.h" in WiShield.h.

AsyncLabs

Quote

How you take the button action on the ipod example? i mean, how the arduino know that you click the button?


We'll hopefully have an example sketch to show how to do this by the end of the weekend.  But, the 50,000 ft view is this (what we did in the demo videos), and I apologize if my terminology is not precisely correct (but I'm a hardware guy anyway, so I'm forgiven  ;D):
1.  When the client (ipod) makes a request, you'll get a string of data back (GET / ......).  The slash is for the root index.html page.  The arduino will return back the response for the webserver (webpage[] var).  
2.  We constructed a webpage that had form button inputs sending the data back with the GET HTML mechanism.  Basically when a button was hit (say the blue led), we'd send a get response to set the var led to '1', i.e., the ipod would go to the following URL:
http://192.168.1.2/?led=1
3.  On the arduino side, we'd get this request, but we now would parse the GET / ...... to get the led=1 out of the data.  With a switch statement, we could actually check what the led variable was set to (1,2,3) for the red, green, and blue LED on the BlinkM.  This would tell the Arduino which button was pressed, and we'd then issues the correct commands in the sketch to control the other pieces of hardware.

For our other demo with the remote control, we parsed the same way, but this time had the Arduino control the PWM signals to the IR LED to send the correct IR codes to the TV and DVD player.a

There are other ways to do this as well.  You could POST form data, which doesn't show the variable-value pair in the URL string (it's stored in the header of the incoming packet).  You could also do something simpler, which is just have page links that open different pages.  You would just have to parse the incoming data for this special page that you are going to do something on based on the link click.

Anyway, I know this is a very high level view, but we'll have a sketch soon that shows this in detail.

Thomas Jespersen

Quote
How you take the button action on the ipod example? i mean, how the arduino know that you click the button?

Take a look at this code, to see how it is done with the Ethernet Shield (it's mostly the same) - http://elec.tkjweb.dk/blog/arduino-projects/ethernet-dmx-controller/
Need any help with your electronics projects?
TKJ Electronics, a consultancy company located in Denmark (Europe), has the required ex

metRo_

#111
May 09, 2009, 03:19 pm Last Edit: May 09, 2009, 03:31 pm by metRo_ Reason: 1
Thanks
Why you don't use an i2c eeprom to save the webpage[] http://www.arduino.cc/playground/Code/I2CEEPROM24LC512 ?  It's very easy to use that memory

TeamMCS

Async, how easy is it just to open up an arbitrary port for binary access?

Pauly

Anyone good at concatinating(sp?) long strings?
I want to add the variable  te (temperature) to the webpage example, but can't seem to get it.

const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<center><p><h1>Hello World!<br> Temp is" & te &"</h1></p></center>"};

Thanks.

MOS6502

I may be wrong, but I was under the impression that the arduino environment was unable to handle concatenations like this?

YPort

#115
May 10, 2009, 01:13 am Last Edit: May 10, 2009, 01:15 am by YPort Reason: 1
Below is how to convert a floating temp reading to a string
Code: [Select]

char temp_val[4];
float temp_c;
int temp_c1;
int temp_c2;

temp_c1 = temp_c;
temp_c2 = (temp_c -(int)temp_c)*10;
n = sprintf(temp_val, "%2d.%1d", temp_c1, temp_c2);


If you read the webserver code, you will see the constant "webpage" is quoted by function "memcpy_P". if you do this:

Code: [Select]

const prog_char webpage[] PROGMEM = "Temp is 00.0"

memcpy_P(data, webpage, webpage_len);  
memcpy_P(data[9], temp_val, 4);  //new added line to insert(replace) temp



data[9] means starting replace from string position 9, and width is 4; notice the "webpage" define is for demo only (won't work).

Hope this helps.

mem

#116
May 10, 2009, 05:00 am Last Edit: May 10, 2009, 05:02 am by mem Reason: 1
Quote
n = sprintf(temp_val, "%2d.%1d", temp_c1, temp_c2);

produces a 5 character string ( 4 printable characters plus the terminating null), use:
char temp_val[5];


Pauly

Good idea YPort. So in order to send a variable to the webpage I have to convert it to a string first?
But then you state the  line below won't work.
memcpy_P(data[9], temp_val, 4);  //new added line to insert(replace) temp

Anyone know how to get a variable to show up on the actual webpage of the webpage example?

estranged

Any chance of the wifi class subclassing Print?  Then we could use the print() and println() methods and not have to worry so much about string processing.  The standard Ethernet library does this.

YPort

#119
May 10, 2009, 06:25 am Last Edit: May 10, 2009, 06:34 am by YPort Reason: 1
Pauly, add the following lines in the right place inside the webserver
example; don't change anything else, see what you will get in your
browser when you access it

Code: [Select]

char temp[5] = "78.9";

//add this extra line after each memcpy_P function calls
memcpy_P(data[80], temp, 4);



Go Up