bonjour , je viens d'acheter un arduino +wifi shield pour faire mumuse , mais impossible de lancer l' exemple webserver fourni avec , que ce soit en ad hoc ou en infrastructure !!
voici l'exemple:
/*
- Web Server
- A simple web server example using the WiShield 1.0
*/
#include <WiShield.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,20,20}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,10}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"test"}; // max 32 bytes
unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"12345678"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_ADHOC;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------
void setup()
{
WiFi.init();
}
// This is the webpage that is served up by the webserver
const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n
Hello World!! I am WiShield
<form method="get" action="0">Toggle LED:<input type="submit" name="0" value="LED1">"};void loop()
{
WiFi.run();
}
et la partie que je suppose etre pour la page web...
#include "uip.h"
#include <string.h>
#include "webserver.h"
#include "config.h"
static int handle_connection(struct webserver_state *s);
void webserver_init(void)
{
uip_listen(HTONS(80));
}
void webserver_appcall(void)
{
struct webserver_state *s = &(uip_conn->appstate);
if(uip_connected()) {
PSOCK_INIT(&s->p, s->inputbuf, sizeof(s->inputbuf));
}
handle_connection(s);
}
#define ISO_nl 0x0a
#define ISO_space 0x20
#define ISO_slash 0x2f
const char http_get[5] = {0x47, 0x45, 0x54, 0x20, }; /* "GET " */
unsigned short fill_buf(void* blk)
{
unsigned short webpage_len;
webpage_len = (strlen_P(webpage)>uip_mss())?uip_mss():strlen_P(webpage);
memcpy_P(uip_appdata, webpage, webpage_len);
return webpage_len;
}
static int handle_connection(struct webserver_state *s)
{
PSOCK_BEGIN(&s->p);
// the incoming GET request will have the following format:
// GET / HTTP/1.1 ....
// we have to parse this string to determine the resource being requested
// if the requested resource is not the root webpage ('/') then,
// GET / HTTP/1.1 ....
// we should parse the specific resource and react appropriately
// read incoming data until we read a space character
PSOCK_READTO(&s->p, ISO_space);
// parse the data to determine if it was a GET request
if(strncmp(s->inputbuf, http_get, 4) != 0) {
PSOCK_CLOSE_EXIT(&s->p);
}
// continue reading until the next space character
PSOCK_READTO(&s->p, ISO_space);
// determine the requested resource
// in this case, we check if the request was for the '/' root page
// AKA index.html
if(s->inputbuf[0] != ISO_slash) {
// request for unknown webpage, close and exit
PSOCK_CLOSE_EXIT(&s->p);
}
if(s->inputbuf[1] != ISO_space) {
// request for unavailable resource
// not supported, modify to add support for additional resources
PSOCK_CLOSE_EXIT(&s->p);
}
//PSOCK_SEND_STR(&s->p, "HTTP/1.1 200 OK\r\n");
//PSOCK_SEND_STR(&s->p, "Content-Type: text/html\r\n");
//PSOCK_SEND_STR(&s->p, "\r\n");
//PSOCK_SEND_STR(&s->p, "Hello World, I am WiShield");
//PSOCK_SEND_STR(&s->p, "
Hello World!! I am WiShield
");PSOCK_GENERATOR_SEND(&s->p, fill_buf, 0);
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
que se soit en ad hoc ou infra , ça se connecte ( led rouge du wishield allumé)
et réseau "essai" trouvé.
mais impossible d'avoir la page qui est supposé être envoyé par le module !!!!!
pas de reponse au ping sur 192,168,20,20!!
si quelqu'un a la solution
cordialement