Pages: 1 ... 6 7 [8] 9 10 ... 33   Go Down
Author Topic: Feeling interest for a WiFi shield  (Read 21169 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My really congratulations for your project smiley-wink

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

Rochester, MI
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduinooooooo!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

San Jose, CA USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

San Jose, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@MCxPRT

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

San Jose, CA USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Denmark (Europe)
Offline Offline
Full Member
***
Karma: 0
Posts: 198
Electronics Designer & Consultant
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Need any help with your electronics projects?
TKJ Electronics, a consultancy company located in Denmark (Europe), has the required ex

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: May 09, 2009, 08:31:40 am by metRo_ » Logged

The Big Smoke
Offline Offline
Sr. Member
****
Karma: 0
Posts: 260
Hacking and Slashing
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rochester, MI
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduinooooooo!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is how to convert a floating temp reading to a string
Code:
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:
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.
« Last Edit: May 09, 2009, 06:15:16 pm by YPort » Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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];

« Last Edit: May 09, 2009, 10:02:18 pm by mem » Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

U of A, Tucson, AZ
Offline Offline
Full Member
***
Karma: 0
Posts: 164
Hello World
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
char temp[5] = "78.9";

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

« Last Edit: May 09, 2009, 11:34:31 pm by YPort » Logged

Pages: 1 ... 6 7 [8] 9 10 ... 33   Go Up
Jump to: