Hi guys, I got a problem with my ethernet-shield.
I'm using it on an arduino duemilanove und it has worked before.
When im turning it off an on a lot of times sometimes i can connect and see the page and its just driving me crazy.
Im guessing it has something to do with the code, i think the hardware is ok.
I would be VERY glad if someone could take a look at it.
It has a lot of stuffe unrelatet to the ethernet, but i'll post it complete as i dont know which parts are relavant.
Thanks you allready =)
#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"
#include <RCSwitch.h>
#include <VirtualWire.h>
int RF_TX_PIN = 2;
RCSwitch mySwitch = RCSwitch();
int red = 0; //integer for red darkness
int blue = 0; //integer for blue darkness
int green = 0; //integer for green darkness
int i=0;
char befehl[40];
int bar1redmix=0;
int bar1greenmix=0;
int bar1bluemix=0;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 0, 16};
byte gateway[] = { 192, 168, 0, 1 };
#define PREFIX ""
WebServer webserver(PREFIX, 80);
void indexCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
server.httpSuccess();
if (type != WebServer::HEAD)
{
P(helloMsg) =
"<!DOCTYPE html><html><head><title>Homeserver</title>"
"<meta charset=\"utf-8\"><meta name=\"apple-mobile-web-app-capable\" content=\"yes\" /><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"><meta name=\"viewport\" content=\"width=device-width, user-scalable=no\">"
"<link rel=\"stylesheet\" href=\"http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css\" />"
"<script src=\"http://code.jquery.com/jquery-1.6.4.min.js\"></script>"
"<script src=\"http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js\"></script>"
"</head>"
"<body>"
"<center>"
"<h1>Index!</h1>"
"<form action='/tv.html' method='POST'>"
"<p><button value='0'>Tv</button></p>"
"</form>"
"<form action='/bar.html' method='POST'>"
"<p><button value='0'>Bar</button></p>"
"</form>"
"<form action='/lights.html' method='POST'>"
"<p><button value='0'>Lights</button></p>"
"</form>"
"</center></body></html>";
server.printP(helloMsg);
}
}
void barCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
if (type == WebServer::POST)
{
bool repeat;
char name[16], value[16];
do
{
repeat = server.readPOSTparam(name, 16, value, 16);
if (strcmp(name, "+") == 0)
{
const char *msg = "bar1up/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "-") == 0)
{
const char *msg = "bar1down/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "on") == 0)
{
const char *msg = "bar1on/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "off") == 0)
{
const char *msg = "bar1off/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "flash") == 0)
{
const char *msg = "bar1flash/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "strobe") == 0)
{
const char *msg = "bar1strobe/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "fade") == 0)
{
const char *msg = "bar1fade/";
vw_send((uint8_t *)msg, strlen(msg));
}
else if (strcmp(name, "mix") == 0)
{
const char *msg = "bar1mix/";
vw_send((uint8_t *)msg, strlen(msg));
}
}
while (repeat);
server.httpSeeOther(PREFIX);
return;
}
server.httpSuccess();
if (type != WebServer::HEAD)
{
P(helloMsg) =
"<!DOCTYPE html><html><head>"
"<title>Bar Remote</title>"
"</head>"
"<body>"
"<center>"
"<h1>Bar</h1>"
"<form action='/index.html' method='POST'>"
"<p><button value='0'>Index</button></p>"
"</form>"
"<table border='0'>"
"<tr>"
"<td><form action='/bar.html' method='POST'><p><button name='+' value='0'>+</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='-' value='0'>-</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='on' value='0'>On</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='off' value='0'>Off</button></form></p></td>"
"</tr>"
"
"
"<tr>"
"<td><form action='/bar.html' method='POST'><p><button name='flash' value='0'>Flash</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='strobe' value='0'>Strobe</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='fade' value='0'>Fade</button></form></p></td>"
"<td><form action='/bar.html' method='POST'><p><button name='mix' value='0'>Mix</button></form></p></td>"
"</tr>"
"</table></center>"
"</body></html>";
server.printP(helloMsg);
}
}
void tvCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
if (type == WebServer::POST)
{
bool repeat;
char name[16], value[16];
do
{
repeat = server.readPOSTparam(name, 16, value, 16);
if (strcmp(name, "on/off") == 0)
{
Serial.print("irbatvonoff/");
}
else if (strcmp(name, "tv/av") == 0)
{
Serial.print("irbatvav/");
}
else if (strcmp(name, "txt") == 0)
{
Serial.print("irbatvtxt/");
}
else if (strcmp(name, "mute") == 0)
{
Serial.print("irbatvmute/");
}
else if (strcmp(name, "vol+") == 0)
{
Serial.print("irbatvvolup/");
}
else if (strcmp(name, "vol-") == 0)
{
Serial.print("irbatvvoldown/");
}
else if (strcmp(name, "prog+") == 0)
{
Serial.print("irbatvproup/");
}
else if (strcmp(name, "prog-") == 0)
{
Serial.print("irbatvprodown/");
}
}
while (repeat);
server.httpSeeOther(PREFIX);
return;
}