AntiGuide: ArduinoPremiersPasInternet



PagePrincipale :: DerniersChangements :: ParametresUtilisateur :: Vous êtes 216.73.216.28 :: Signaler un abus :: le: 20250825 12:57:03
ide: 80 MO, 260 unzippé: http://arduino.cc/en/Main/Software#toc2, pas d'installation windows
essayer blink

enf ait web client! e autres à corriger

depuis: http://blog.rexave.net/wp-content/uploads/2013/10/ethercard-master.zip

premier essai
lu: http://arduino.cc/en/Tutorial/WebServer
1) voie série ???
2) sans doute modume 5100
3) pas d'erreur!
4) ir ethernet shield à pin 13, douteux, c'est la diode!




client(juste ajouté pin 10 comme CS de la carte ethernet)
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "www.logsm.net";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  Serial.begin(9600);
  Serial.println("\n[webClient]");

  if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0) 
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
    
  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());
  
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/index.html"), "", website, my_callback);
  }
}


signaler l'ambiguité obligation indiquer pin 10 (au lieu de 8)

essayé exemple webclient, Ok, dhcp, etc .. convient pour Dazibao et Sms2Go?
essayé udplistenner, pin 10, OK.

http://playground.arduino.cc/Code/WebServer
démarre mais ne répond pas ?????



webserver:
lu: http://forum.arduino.cc/index.php?topic=90269.0
ajouté dhcp, tout bon
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x00,0x14,0xA5,0x76,0x19,0x3A  };
static byte lowip= 255;  // left part by Dhcp 255 if no!
int id=0;
int n=0;
int ok=1;
byte Ethernet::buffer[500];      //??????
BufferFiller bfill;                     //???????
void setup () {
  pinMode(13, OUTPUT);     

  Serial.begin(9600);
  Serial.println("andiamo");
  Serial.print("Ethernet Controller: ");
  if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0) {
    ok=0;
    Serial.println( "Access Failed.");
  } else Serial.println("Ok.");
  //  ether.staticSetup(myip);
  if (ok==1) {
     Serial.print("Dhcp: ");
     if (!ether.dhcpSetup()) {
       ok=0;
       Serial.println("failed.");
     } else Serial.println("Ok.");
  } 
  
  if (ok==1){
     if (lowip<255) ether.myip[3]=lowip;
     Serial.println("Clock Server");
     ether.printIp("IP:  ", ether.myip);
     ether.printIp("GW:  ", ether.gwip);  
     ether.printIp("DNS: ", ether.dnsip);  
  }
}

static word homePage() {
  id=1-id;
  n=n+1; // compte les appels à homePage
  if (id==1) digitalWrite(13,HIGH);
  if (id==0) digitalWrite(13,LOW);
   long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  bfill = ether.tcpOffset();    
   //???????
  bfill.emit_p(PSTR(                                 //???????
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='1'/>"
    "<title>Po server</title>"
    "<h1>$D$D:$D$D:$D$D</h1> led is $D n= $D"),
      h/10, h%10, m/10, m%10, s/10, s%10, id,n);                //???????
  return bfill.position();                                           //???????
}

void loop () {
   if (ok==1){
  //delay(100);
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  if (pos)  {// check if valid tcp data is received

    ether.httpServerReply(homePage()); // send web page data
  }
   }
}