hallo liebes forum ![]()
ich habe ein problem meine im flash speicher abgelegten string arrays im browser auszugeben.
zur überprüfung ob ich überhaupt in den "if (c == '\n') {..." fall komme, gebe ich die string arrays einmal mit Serial.println und einmal mit client.println aus
das komische ist, dass er es seriell sendet, aber wenn ich in den browser gehe und meine IP eintippe nichts angezeigt bekomme
ich hoffe irgendjemand kann mir helfen
danke im voraus HasiFlo ![]()
//mein code
#include <SPI.h> // insert by Katsu
#include <Ethernet.h>
#include <avr/pgmspace.h>
byte mac[] = { 0x54, 0x55, 0x58, 0x10, 0x00, 0x24 }; // entspricht einer MAC von 84.85.88.16.0.36
byte ip[] = { 10, 0, 0, 15 }; // IP-Adresse
Server server(80);
prog_char string_00[] PROGMEM = "HTTP/1.1 200 OK";
prog_char string_01[] PROGMEM = "Content-Type: text/html";
prog_char string_02[] PROGMEM = "";
prog_char string_03[] PROGMEM = "Arduino Webserver HasiFlo";
prog_char string_04[] PROGMEM = "";
prog_char string_05[] PROGMEM = "";
prog_char string_06[] PROGMEM = "
"; prog_char string_07[] PROGMEM = "
Arduino Webserver 2.0 by HasiFlo
";
prog_char string_08[] PROGMEM = ""; prog_char string_10[] PROGMEM = " ";
PROGMEM const char *web_str[]=
{ string_00,
string_01,
string_02,
string_03,
string_04,
string_05,
string_06,
string_07,
string_08,
string_09,
string_10
};
char buffer [80];
int Pin3 = 3;
int Pin4 = 4;
int Pin5 = 5;
int Pin6 = 6;
String readString = String(100); // string for fetching data from address
boolean Pin3ON = false; // Status flag
boolean Pin4ON = false;
void setup(){
Ethernet.begin(mac, ip);
server.begin();
pinMode(Pin3, OUTPUT);
pinMode(Pin4, OUTPUT);
Serial.begin(9600); }
void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
// readString.append(c); removed by Katsu
readString = readString + c; // insert by Katsu
// very simple but it works...
}
Serial.print(c); //output chars to serial port
if (c == '\n') { //if HTTP request has ended
for (int i = 0; i < 10; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(web_str*))); // Necessary casts and dereferencing, just copy.*
- client.println( buffer );*
- delay( 500 );*
- } *
for (int i = 0; i < 10; i++) - {*
strcpy_P(buffer, (char*)pgm_read_word(&(web_str*))); // Necessary casts and dereferencing, just copy.
_ Serial.println( buffer );_
_ delay( 500 );_
_ } _
_//clearing string for next read*_
readString="";
//stopping client
client.stop();
}}}}}