Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- If you think my spacing is wonky, it isn't, it's Pastebin's fault.
- Read the RAW paste data instead. otherwise, continue on */
- #include <SPI.h>
- #include <Ethernet.h>
- #include <SD.h>
- byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
- IPAddress ip(192,168,1,120);
- EthernetServer server(80);
- char current = '';
- char FileName[7];
- int x;
- void setup()
- {
- Serial.begin(9600);
- Ethernet.begin(mac, ip);
- server.begin(); //Boot!
- SD.begin(); //Start reading from that SD Car there
- }
- void loop() {
- EthernetClient client = server.available();
- if(client) {
- Serial.println("Request Recieved!");
- while (client.connected()) {
- if (client.available()) {
- char Packet[] = client.read();
- delay(100); //Wait a bit for it to get that request! It's big!
- Serial.print(Packet[0,29]);
- if(Packet[0] == 'G' && Packet[1] == 'E' && Packet[2] == 'T') {
- for(x=5; current != ' '; x++)
- {
- FileName[x-5] = Packet[x];
- current = Packet[x+1];
- }
- }
- Serial.print("File name is: ");
- Serial.println(FileName);
- doc = SD.open(FileName);
- if(doc) {
- client.println("HTTP/1.1 200 OK");
- client.println("Content-Type: text/html");
- client.println("Connection: close");
- client.print(doc);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment