Salut à tous.
J'ai quelques soucis avec un code que j'ai trouvé sur le web.
Il sert à faire fontionner NetIO sous Android :
https://play.google.com/store/apps/details?id=com.luvago.netio
Site web : http://netio.davideickhoff.de/
Afin d'un faire facilement une télécommande.
Mais j'ai des erreurs dans le code fournis.
Qui comme on peut le voir dans le code, est prévus pour la version 0022.
Et qui comporte une librairie externe à télécharger.
/*
IDE Version 0022
Arduino Uno
Arduino Ethernet Shield with Wiznet W5100 Ethernet chip
*/
// include library
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h> // library from http://gkaindl.com/software/arduino-ethernet/dhcp
// end include library
#define DEBUG 1
//global variable
byte mac[] = {
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA }; // mac address of Ethernet shield
//----- iPhone Remote -------
#define BUFSIZ 64
Server iPhoneServer(2560); // server port number of Ethernet shield
//---------------------------
// setup
void setup(){
Serial.begin(115200); //for debug
if (DEBUG) Serial.println("Attempting to obtain a DHCP lease...");
EthernetDHCP.begin(mac);
if (DEBUG) {
const byte* ipAddr = EthernetDHCP.ipAddress();
const byte* gatewayAddr = EthernetDHCP.gatewayIpAddress();
const byte* dnsAddr = EthernetDHCP.dnsIpAddress();
Serial.println("A DHCP lease has been obtained.");
Serial.print("My IP address is ");
Serial.println(ip_to_str(ipAddr));
Serial.print("Gateway IP address is ");
Serial.println(ip_to_str(gatewayAddr));
Serial.print("DNS IP address is ");
Serial.println(ip_to_str(dnsAddr));
}
iPhoneServer.begin(); // start the server
}
// end setup
// main loop
void loop()
{
EthernetDHCP.maintain(); // Call this once per loop().
iPhoneInterface();
}
// end main loop
void iPhoneInterface() {
int index = 0;
char Remote[BUFSIZ];
Client client = iPhoneServer.available();
if (client) {
if (client.connected()) {
while (client.available()) {
char c = client.read();
//Serial.print(c); // print to the screen
if (c != '\n' && c != '\r') { // no linefeed or CR so keep reading
Remote[index] = c;
index++;
if (index >= BUFSIZ)
index = BUFSIZ -1;
continue;
}
Remote[index] = 0;
}
Serial.println(Remote); // print string sent from iPhone
if (strstr(Remote, "Local")) { // initialsend
client.println("OK");
}
if (strstr(Remote, "X10")) { // is it an X10 command
client.println("OK");
}
if (strstr(Remote, "FireLights")) { // set the slider to 0
client.println("0");
}
if (strstr(Remote, "Fire lights")) { // is it a slider value
client.println("OK");
}
if (strstr(Remote, "DoorLights")) { // set the slider to 0
client.println("0");
}
if (strstr(Remote, "Door lights")) { // is it a slider value
client.println("OK");
}
} //----- End of if client.connected
} //------- End of if client
} //--------- End of iPhoneInterface()
//---------- Just a utility function to nicely format an IP address. ------------
const char* ip_to_str(const uint8_t* ipAddr)
{
static char buf[16];
sprintf(buf, "%d.%d.%d.%d\0", ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3]);
return buf;
}
Merci d'avance pour aide.