Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LOOK AT LINE 70.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <string>
#include "FS.h"
using namespace std;
//std::string
char payload[] = "<img src='im.png' height='2000' width='1500'/>";
/* Set these to your desired credentials. */
//1AManInTh3Middl3
const char *ssid = "DONT JOIN!!";
const char *password = "";
IPAddress myIP;
WiFiServer httpserver(80);
void setup() {
delay(4000);
Serial.begin(9600);
Serial.println();
// put your setup code here, to run once:
Serial.println("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
myIP = WiFi.softAPIP();
Serial.println("AP IP address: ");
Serial.println(myIP);
httpserver.begin();
}
void loop() {
// put your main code here, to run repeatedly:
WiFiClient client = httpserver.available();
if(!client){return;}
if(client.available()){
String req = client.readStringUntil('\0');
Serial.println(req);
File f;
if(SPIFFS.begin()){
f = SPIFFS.open("/a.png", "r");
Serial.println("Resource loaded...");
}else{
Serial.print("Fatal fail!");
while(1);
}
const int buffsize = 1760;
char response[buffsize];
//RANDOM STRING THAT NEEDS TO BE SEEN IN WIRESHARK
client.print("1111111ASDIHAOSDHAIOSHDOIAHSDOIHAOISHDX1111111ASDIHAOSDHAIOSHDOIAHSDOIHAOISHDX1111111ASDIHAOSDHAIOSHDOIAHSDOIHAOISHDX\r\n\r\n");
//client.println("HTTP/1.1 200 OK");
//client.println("Connection: keep-alive");
//client.println("Content-Type: image/png");
//client.print("Content-Length: ");
//client.println(f.size());
//client.println();
/*int count = 0;
while(f.available()){
response[count] = f.read();
count++;
if(count>buffsize-1){
client.write((const uint8_t *)response,buffsize);
count = 0;
}
}
if(count>0){
client.write((const uint8_t *)response,buffsize);
}
//"HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Type: image/png\r\nContent-Length: %d",f.size()
//strcpy(response,"HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Type: image/png\r\nContent-Length: ");
//itoa(f.size(),response+strlen(response),10);
//Serial.println("--------Debug response ------- ");
//Serial.println(response);
//Serial.println("------------------------------ ");
//res = string("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Type: image/png\r\nContent-Length:") + itoa(f.size());
//const char *buff = res.c_str();
//Serial.println(client.println(response));
//Serial.println();
*/
f.close();
client.flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment