Köszönöm a válaszát!

Két módszerrel próbálkoztam, az egyik ez:
Itt csak próbaképpen írtam be, hogy ha private2.html-t írok a címsorba, akkor behozza-e a képet, de csak üres oldalt kapok. Ha megnézem az üres oldal forrását, akkor is szintén üres oldalt kapok.
Kód: Egész kijelölése
/* Web_Authentication.ino - Webduino Authentication example */
/* This example assumes that you're familiar with the basics
* of the Ethernet library (particularly with setting MAC and
* IP addresses) and with the basics of Webduino. If you
* haven't had a look at the HelloWorld example you should
* probably check it out first */
/* you can change the authentication realm by defining
* WEBDUINO_AUTH_REALM before including WebServer.h */
#define WEBDUINO_AUTH_REALM "Weduino Authentication Example"
#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"
#include "SD.h"
/* CHANGE THIS TO YOUR OWN UNIQUE VALUE. The MAC number should be
* different from any other devices on your network or you'll have
* problems receiving packets. */
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
/* This creates an instance of the webserver. By specifying a prefix
* of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 80);
void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
server.httpSuccess();
if (type != WebServer::HEAD)
{
P(helloMsg) = "<h1>Hello, World!</h1><a href=\"private.html\">Private page</a>";
server.printP(helloMsg);
}
}
void privateCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
/* if the user has requested this page using the following credentials
* username = user
* password = user
* display a page saying "Hello User"
*
* the credentials have to be concatenated with a colon like
* username:password
* and encoded using Base64 - this should be done outside of your Arduino
* to be easy on your resources
*
* in other words: "dXNlcjp1c2Vy" is the Base64 representation of "user:user"
*
* if you need to change the username/password dynamically please search
* the web for a Base64 library */
if (server.checkCredentials("dXNlcjp1c2Vy"))
{
server.httpSuccess();
if (type != WebServer::HEAD)
{
P(helloMsg) = "<h1>Hello User</h1>";
server.printP(helloMsg);
}
}
/* if the user has requested this page using the following credentials
* username = admin
* password = admin
* display a page saying "Hello Admin"
*
* in other words: "YWRtaW46YWRtaW4=" is the Base64 representation of "admin:admin" */
else if (server.checkCredentials("YWRtaW46YWRtaW4="))
{
server.httpSuccess();
if (type != WebServer::HEAD)
{
P(helloMsg) = "<h1>Hello Admin</h1>";
server.printP(helloMsg);
}
}
else
{
/* send a 401 error back causing the web browser to prompt the user for credentials */
server.httpUnauthorized();
}
}
void sdHTML(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
server.httpSuccess();
File datei;
datei = SD.open("index.htm", FILE_READ);
if(datei)
{
int16_t c;
while((c = datei.read()) >= 0) {
server.print((char)c);
}
datei.close();
}
else
{
Serial.println("Datei wurde nicht gefunden");
}
}
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip);
webserver.setDefaultCommand(&defaultCmd);
webserver.addCommand("index.html", &defaultCmd);
webserver.addCommand("private.html", &privateCmd);
webserver.addCommand("private2.html", &sdHTML);
webserver.begin();
}
void loop()
{
char buff[64];
int len = 64;
/* process incoming connections one at a time forever */
webserver.processConnection(buff, &len);
}
A másik egy kicsivel bonyolultabb számomra, mert vegyített:
Itt bejelentkezés után kiírja, hogy sikeres, majd továbbít a STARTWEB részre, aminek a kép bekérése lenne az SD kártyáról a feladata(külön működik).
Itt viszont nem a képet hozza be a böngésző, hanem az sd kártyán lévő index.htm fájl szöveges tartalmát, mintha szerkesztésre nyitnám meg.
Kód: Egész kijelölése
#include <SPI.h>
#include <Ethernet.h>
#include <WebServer.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#define REQ_BUF_SZ 20
#define BUFSIZ 100
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
char rootFileName[] = "index.htm";
EthernetServer server(80);
byte USER_AUTHENDICATED=0;
/************ SDCARD STUFF ************/
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
int t=15;
// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))
void error_P(const char* str) {
PgmPrint("error: ");
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
while(1);
}
/////////////////////////////////////////////////////////////////////////////////////
#define PREFIX ""
WebServer webserver(PREFIX, 80);
/////////////////////////////////////////////////////////////////////////////////////
void privateCmd(WebServer &serverA, WebServer::ConnectionType type, char *, bool)
{
if (serverA.checkCredentials("YWRtaW46YWRtaW4="))
{
serverA.httpSuccess();
USER_AUTHENDICATED=1;
delay(20);
P(helloMsg) = "<html><head><meta http-equiv='refresh' content=3;></head><body bgcolor='#000000' style='font-family:Verdana;color:#ffffff;font-size:12px;'><form>Login Succesfull!</form></body></html>";
serverA.printP(helloMsg);
delay(20);
STARTWEB();
}
else
{serverA.httpUnauthorized();
USER_AUTHENDICATED=0;
}
}
void loop() {
char buff[64];
int len = 64;
// listen for incoming clients0
webserver.processConnection(buff, &len);
if (USER_AUTHENDICATED==1)
{
STARTWEB();
}
}
void defaultCmd(WebServer &serverA, WebServer::ConnectionType type, char *, bool)
{
if (serverA.checkCredentials("YWRtaW46YWRtaW4="))
{
serverA.httpSuccess();
USER_AUTHENDICATED=1;
delay(20);
P(helloMsg) = "<html><head><meta http-equiv='refresh' content=4;></head><body bgcolor='#000000' style='font-family:Verdana;color:#ffffff;font-size:12px;'><form>Login Succesfull!</form></body></html>";
serverA.printP(helloMsg);
delay(20);
STARTWEB();
}
else
{serverA.httpUnauthorized();
USER_AUTHENDICATED=0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
PgmPrint("Free RAM: ");
Serial.println(FreeRam());
// initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
// breadboards. use SPI_FULL_SPEED for better performance.
pinMode(10, OUTPUT); // set the SS pin as an output (necessary!)
digitalWrite(10, HIGH); // but turn off the W5100 chip!
if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
// initialize a FAT volume
if (!volume.init(&card)) error("vol.init failed!");
PgmPrint("Volume is FAT");
Serial.println(volume.fatType(),DEC);
Serial.println();
if (!root.openRoot(&volume)) error("openRoot failed");
// list file in root with date and size
PgmPrintln("Files found in root:");
root.ls(LS_DATE | LS_SIZE);
Serial.println();
// Recursive list of all directories
PgmPrintln("Files found in all dirs:");
root.ls(LS_R);
Serial.println();
PgmPrintln("Done");
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
/////////////////////////////////////////////////////////////////////////////
webserver.setDefaultCommand(&privateCmd);
// webserver.addCommand("private.html", &defaultCmd);
webserver.begin();
/////////////////////////////////////////////////////////////////////////////
}
void STARTWEB()
{
char clientline[BUFSIZ];
char *filename;
int index = 0;
int image = 0;
//Start Webserver with classic arduino way.......
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
index = 0;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c != '\n' && c != '\r') {
clientline[index] = c;
index++;
// are we too big for the buffer? start tossing out data
if (index >= BUFSIZ)
index = BUFSIZ -1;
// continue to read more data!
continue;
}
clientline[index] = 0;
filename = 0;
// Print it out for debugging
Serial.print("ELSO ELLENORZO PONT:");
Serial.println(clientline);
delay(100);
if (strstr(clientline, "GET / ") != 0) {
filename = rootFileName;
Serial.print("MASODIK ELLENORZO PONT:");
Serial.println(filename);
}
if (strstr(clientline, "GET /") != 0) {
if (!filename) filename = clientline + 5; // look after the "GET /" (5 chars)
// a little trick, look for the " HTTP/1.1" string and
// turn the first character of the substring into a 0 to clear it out.
(strstr(clientline, " HTTP"))[0] = 0;
Serial.print("HARMADIK ELLENORZO PONT:");
Serial.println(filename);
////////////////////////////////////////////////////////////////////////
if (file.open(&root, filename, O_READ)) {Serial.println("NEGYEDIK ELLENORZO PONT"); }
client.println("HTTP/1.1 200 OK");
if (strstr(filename, ".htm") != 0)
client.println("Content-Type: text/html");
else
client.println("Content-Type: text");
int16_t c;
while ((c = file.read()) >= 0) {
// uncomment the serial to debug (slow!)
//Serial.print((char)c);
client.print((char)c);
Serial.println("OTODIK ELLENORZO PONT");
}
file.close();
}
else {
// everything else is a 404
client.println("HTTP/1.1 404 Not Found");
client.println("Content-Type: text/html");
client.println();
client.println("<h2>File Not Found!</h2>");
Serial.println("Nincs meg a fájl");
}
break;
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
Megpróbáltam ugyan ezeket a módszereket 2,3k-s képpel de ugyan ezek a jelenségek. Akkor ön szerint nem is érdemes 20k-s kép behívásával sd kártyáról ezzel a hitelesítéssel?

Esetleg másfajta beléptetést tudna ajánlani? Ugyanis ha távolról is elérhető lenne a program, nem akarom, hogy más is hozzáférjen. Előre is köszönöm a válaszát.