Bonjour à tous,
pour commencer, je sais qu'il y a des infos sur le sujet disponible, même sur ce forum. Malgrès tout, je reste bloqué depuis 1 semaine sur le même soucis.
Premièrement, voici ma config :
- arduino mega
- module ethernet ENC28J60
- un serveur web sur mon pc
- le module ethernet branché sur mon pc également, avec un partage de connexion (mon réseau internet est en wifi).
Donc, ce que je veux tout simplement faire : récupérer une information présente sur une page php de mon serveur web (test.php), à l'aide d'une ID (pour, après, une requête sur base SQL).
La connexion fonctionne, mais aucune infos n'arrive dans le moniteur série.
Voici ce que j'ai dans le moniteur série :
[webClient]
IP: 192.168.137.117
GW: 192.168.137.1
DNS: 192.168.137.1
SRV: 192.168.137.1
>>>
HTTP/1.0 200 OK
Connection: Close
Content-Type: text/html
Date: Wed, 12 Nov 2014 13:01:38 GMT
Server: ZazouMiniWebServer v1.2.8
...
Je précise qu'il est normale que les deux IP (serveur et client) soit les mêmes, car je me sers du partage de connexion sous windaud ! ![]()
Ma page php :
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<?php
if(isset($_POST["id"]) && !empty($_POST["id"]))
echo "Id : " + $_POST["id"];
else
echo "Nothing to show";
?>
</body>
</html>
Et mon code arduino :
#include <EtherCard.h>
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
boolean x = true;
byte Ethernet::buffer[700];
static uint32_t timer;
const char website[] PROGMEM = "192.168.137.1";
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(57600);
Serial.println(F("\n[webClient]"));
if (ether.begin(sizeof Ethernet::buffer, mymac, 53) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("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);
delay(1000);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if ((millis() > timer) && x == true) {
timer = millis() + 5000;
const char *postval = "id=422";
ether.httpPost(PSTR("/test.php"), website, NULL, postval, my_callback);
x = false;
}
}
Merci d'avance pour vos réponses !
Hugo ![]()