parametrage wifi shield

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 :cry:

cordialement

Le masque de sous-réseau indique que seul la dernière partie est variable. Il faut que ton adresse IP soit aussi en 192.168.20.x pour que les deux se voient, non ?

Essaie de modifier l'adresse IP en choisissant une voisine de ton adresse IP : 192.168.0.x par exemple.

oui , mais en mode adhoc logiquement ça ne devrait pas posé de problème !!

logiquement si mon module est en adhoc il crée son reseau wifi et a n'importe quel requête il renvoi sa page ...

je me trompe peut-être , voir surement ! :-?

as-tu au moins essayé ma proposition ?

oui , ça ma mis sur la voie ...:slight_smile: pour paramétré mon portable en adhoc.
merci bien

par contre il doit ne pas être encore correctement paramétré , j'ai la page hello world qui s'affiche , mais dé que je clic sur led 1 j'ai un message comme quoi la connexion a expiré :-?

pour le mode infrastructure , si j'ai bien compris , le wishield se connecte a ma freebox (mode routeur )
et normalement en paramétrant correctement mon portable j'ai accès a la page web du wishild par la freebox...mais ya peut etre besoin de redirigé les ports...voir surement... :-?

oui, redirection paramétrable dans l'interface du site adsl.free.fr (avec reboot éventuellement) mais c'est seulement si tu veux utiliser ton IP depuis Internet (82.246.8.232:80 redirigé sur 192.168.0.2:80 par ex.) et pas le mode router (192.168.0.x peut parler avec 192.168.0.y)

donc logiquement je doit avoir acces a l'arduino depuis mon portable en mode infra ?

quand je me met en mode infra , la led passe bien au rouge donc , ça veut dire que la connexion est établi...
mais impossible d'avoir accès au module !!! et apres un scan des ip histoire d'être sur , rien a part mon routeur et mon pc !! >:(

j'ai du mal a comprendre la !!

Le scan d'IP ne peut pas marcher, il n'y a rien sur l'Arduino pour répondre au scan.

La passerelle sur free est 192.168.0.254, tu l'as bien modifiée dans le code ci-dessus ? L'Arduino a beau être simple par défaut, les périphériques complexes du type Bluetooth, Wifi, GPS, voire même XBee nécessite quelques connaissances particulières (ou de fréquenter un club d'entraide qui organise des ateliers hebdomadaires...)

et je le met a quel endroit ?

unsigned char local_ip[] = {192,168,1,2}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,10}; // router or gateway <=============ici ?
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network

même résultat :-/

et sinon vous avez des sites a me conseiller ? de préférence francophone

gateway = passerelle

oui j'ai tilté après avoir posté ! :wink: