Pages: 1 ... 27 28 [29]   Go Down
Author Topic: Domo'Duino, la domotique par Arduino (NEWS: Modules 2.4ghz )  (Read 35590 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 451
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Salut,

Voila le code actuel sur lequel j'essaye de bidouiller pour arriver à le faire fonctionner. En fait l'identification fonctionne mais ensuite plus rien ne fonctionne dans le code. Aucun bouton rien ...

http://chicowebsite.free.fr/secu.pde

J'ai essayer ton dernier code mais il ne fonctionne pas du tout et comme tous à été changer dedans j'ai un peu (beaucoup) de mal à le comprendre ^^
Logged

Mon Blog sur l'environnement Arduino ... Tutos fait par un débutant pour les débutants ^^

http://chicowebsite.free.fr/

Made in Belgium
Offline Offline
God Member
*****
Karma: 1
Posts: 756
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Il me semble qu'à l'époque, ce "figage" était du a un problème de taille mémoire (sram) c'est pour celà que j'avais fais un max de macro avec le code html répétitif en progmem dans la dernière version ?
Tu utilisais un arduino uno ou mega, je sais plus ?
Logged


Aix en Provence
Offline Offline
Sr. Member
****
Karma: 2
Posts: 264
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour,

En cherchant des exemples de mise en oeuvre de serveur web avec arduino, je suis tombé sur un exemple d'authentification par MdP dans les exemples de la librairie Webduino, mais tu l'as probablement déjà vu.

A tout hasard, voici le code de cet exemple :
Code:
/* Web_Authentication.ino - Webduino Authentication example */

/* This example assumes that you're familiar with the basics
 * of the Ethernet library (particularly with setting MAC and
 * IP addresses) and with the basics of Webduino. If you
 * haven't had a look at the HelloWorld example you should
 * probably check it out first */

/* you can change the authentication realm by defining
 * WEBDUINO_AUTH_REALM before including WebServer.h */
#define WEBDUINO_AUTH_REALM "Weduino Authentication Example"

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"

/* CHANGE THIS TO YOUR OWN UNIQUE VALUE.  The MAC number should be
 * different from any other devices on your network or you'll have
 * problems receiving packets. */
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

/* CHANGE THIS TO MATCH YOUR HOST NETWORK.  Most home networks are in
 * the 192.168.0.XXX or 192.168.1.XXX subrange.  Pick an address
 * that's not in use and isn't going to be automatically allocated by
 * DHCP from your router. */
static uint8_t ip[] = { 192, 168, 1, 210 };

/* This creates an instance of the webserver.  By specifying a prefix
 * of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 80);

void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  server.httpSuccess();
  if (type != WebServer::HEAD)
  {
    P(helloMsg) = "<h1>Hello, World!</h1><a href=\"private.html\">Private page</a>";
    server.printP(helloMsg);
  }
}

void privateCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  /* if the user has requested this page using the following credentials
   * username = user
   * password = user
   * display a page saying "Hello User"
   *
   * the credentials have to be concatenated with a colon like
   * username:password
   * and encoded using Base64 - this should be done outside of your Arduino
   * to be easy on your resources
   *
   * in other words: "dXNlcjp1c2Vy" is the Base64 representation of "user:user"
   *
   * if you need to change the username/password dynamically please search
   * the web for a Base64 library */
  if (server.checkCredentials("dXNlcjp1c2Vy"))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Hello User</h1>";
      server.printP(helloMsg);
    }
  }
  /* if the user has requested this page using the following credentials
   * username = admin
   * password = admin
   * display a page saying "Hello Admin"
   *
   * in other words: "YWRtaW46YWRtaW4=" is the Base64 representation of "admin:admin" */
  else if (server.checkCredentials("YWRtaW46YWRtaW4="))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Hello Admin</h1>";
      server.printP(helloMsg);
    }
  }
  else
  {
    /* send a 401 error back causing the web browser to prompt the user for credentials */
    server.httpUnauthorized();
  }
}

void setup()
{
  Ethernet.begin(mac, ip);
  webserver.setDefaultCommand(&defaultCmd);
  webserver.addCommand("index.html", &defaultCmd);
  webserver.addCommand("private.html", &privateCmd);
  webserver.begin();
}

void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

Je ne sais pas si c'est exactement ce que tu cherches !

@+
Logged

Made in Belgium
Offline Offline
God Member
*****
Karma: 1
Posts: 756
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Je ne connais pas lib Webduino et la classe WebServer, mais ça ressemble à ce que l'on a fais non ?
Donc chico, il faudrait peut être regardé ce qu'il y a de nouveau depuis ton retour (Webduino par exemple) et qui pourrait t'être utile  ?
Merci Bribri je crois que tu as trouvé quelque chose de sympa là, enfin je connaissais pas.  smiley-surprise
Logged


Offline Offline
Sr. Member
****
Karma: 0
Posts: 451
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour,

En cherchant des exemples de mise en oeuvre de serveur web avec arduino, je suis tombé sur un exemple d'authentification par MdP dans les exemples de la librairie Webduino, mais tu l'as probablement déjà vu.

A tout hasard, voici le code de cet exemple :
Code:
/* Web_Authentication.ino - Webduino Authentication example */

/* This example assumes that you're familiar with the basics
 * of the Ethernet library (particularly with setting MAC and
 * IP addresses) and with the basics of Webduino. If you
 * haven't had a look at the HelloWorld example you should
 * probably check it out first */

/* you can change the authentication realm by defining
 * WEBDUINO_AUTH_REALM before including WebServer.h */
#define WEBDUINO_AUTH_REALM "Weduino Authentication Example"

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"

/* CHANGE THIS TO YOUR OWN UNIQUE VALUE.  The MAC number should be
 * different from any other devices on your network or you'll have
 * problems receiving packets. */
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

/* CHANGE THIS TO MATCH YOUR HOST NETWORK.  Most home networks are in
 * the 192.168.0.XXX or 192.168.1.XXX subrange.  Pick an address
 * that's not in use and isn't going to be automatically allocated by
 * DHCP from your router. */
static uint8_t ip[] = { 192, 168, 1, 210 };

/* This creates an instance of the webserver.  By specifying a prefix
 * of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 80);

void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  server.httpSuccess();
  if (type != WebServer::HEAD)
  {
    P(helloMsg) = "<h1>Hello, World!</h1><a href=\"private.html\">Private page</a>";
    server.printP(helloMsg);
  }
}

void privateCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  /* if the user has requested this page using the following credentials
   * username = user
   * password = user
   * display a page saying "Hello User"
   *
   * the credentials have to be concatenated with a colon like
   * username:password
   * and encoded using Base64 - this should be done outside of your Arduino
   * to be easy on your resources
   *
   * in other words: "dXNlcjp1c2Vy" is the Base64 representation of "user:user"
   *
   * if you need to change the username/password dynamically please search
   * the web for a Base64 library */
  if (server.checkCredentials("dXNlcjp1c2Vy"))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Hello User</h1>";
      server.printP(helloMsg);
    }
  }
  /* if the user has requested this page using the following credentials
   * username = admin
   * password = admin
   * display a page saying "Hello Admin"
   *
   * in other words: "YWRtaW46YWRtaW4=" is the Base64 representation of "admin:admin" */
  else if (server.checkCredentials("YWRtaW46YWRtaW4="))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Hello Admin</h1>";
      server.printP(helloMsg);
    }
  }
  else
  {
    /* send a 401 error back causing the web browser to prompt the user for credentials */
    server.httpUnauthorized();
  }
}

void setup()
{
  Ethernet.begin(mac, ip);
  webserver.setDefaultCommand(&defaultCmd);
  webserver.addCommand("index.html", &defaultCmd);
  webserver.addCommand("private.html", &privateCmd);
  webserver.begin();
}

void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

Je ne sais pas si c'est exactement ce que tu cherches !

@+

Salut,

Merci a toi mais ce code ne fonctionne pas, il y a une erreur au niveau de

Code:
WebServer webserver(PREFIX, 80);
Logged

Mon Blog sur l'environnement Arduino ... Tutos fait par un débutant pour les débutants ^^

http://chicowebsite.free.fr/

Aix en Provence
Offline Offline
Sr. Member
****
Karma: 2
Posts: 264
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour,
As-tu téléchargé et installé la librairie WebServer.h ?
https://github.com/sirleech/Webduino
Il faudra certainement adapter le sketch, car il a été écrit pour l’IDE 1.0 : Web_Authentication.ino et non Web_Authentication.pde
Je ne suis pas du tout un spécialiste du C, je ne te serai pas d'un grand secours dans le « debuggage » du sketch.
J’ai pas mal galéré pour transformer tout mon sketch pour l’IDE 1.01
@+
Logged

Made in Belgium
Offline Offline
God Member
*****
Karma: 1
Posts: 756
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oups  smiley-sleep, on a complètement zapper le fait que tu utilises un shield à base d'enc28j60 et non w5100 donc il y a de grande chance que la lib webduino ne soit tout simplement pas compatible  smiley-sweat .
%#$£ d'enc28j60  smiley-mr-green.
Logged


Aix en Provence
Offline Offline
Sr. Member
****
Karma: 2
Posts: 264
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

En plus !
Logged

Pages: 1 ... 27 28 [29]   Go Up
Jump to: