Skip to content

Commit

Permalink
Fix GB Camera Link Server
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanFuentealba committed Aug 24, 2024
1 parent e5e5f74 commit 51c3e36
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 68 deletions.
10 changes: 5 additions & 5 deletions esp32_marauder/GameboyCameraServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ void onImageRequest(AsyncWebServerRequest *request) {
request->send(response);
}
void gb_camera_setup() {
_index_html = link_camera_index_html_gz;
_index_html_len = link_camera_index_html_gz_len;
WiFi.mode(WIFI_AP);
strncpy(index_html, reinterpret_cast<const char*>(link_camera_index_html), sizeof(link_camera_index_html));
gbStartAP("[MALVEKE] Flipper GB Cam", "12345678");

_server.on("/image", HTTP_GET, onImageRequest);
Expand Down Expand Up @@ -236,8 +234,10 @@ void gb_camera_setup() {
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});

_server.addHandler(new GameboyCaptiveRequestHandler()).setFilter(ON_AP_FILTER);
_server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", reinterpret_cast<const char*>(link_camera_index_html));
});
_server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER);
_server.begin();
}

Expand Down
5 changes: 4 additions & 1 deletion esp32_marauder/GameboyServer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "GameboyServer.h"

void gbStartAP(char* ssid, char* password) {
const IPAddress _IP(172, 0, 0, 1);
// WiFi.softAP(ssid, password);
// _IP = WiFi.softAPIP();
WiFi.softAPConfig(_IP, _IP, IPAddress(255, 255, 255, 0));
WiFi.softAP(ssid, password);
_IP = WiFi.softAPIP();
_json["type"] = "connected";
_json["ip"] = _IP;
_json["ssid"] = ssid;
Expand Down
16 changes: 0 additions & 16 deletions esp32_marauder/GameboyServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sstream>
#include <vector>
#include <string>
// #include "SPIFFS.h"

#define MAX_HTML_SIZE 20000

Expand All @@ -26,19 +25,4 @@ const uint8_t* _index_html;

void gbStartAP(char* ssid, char* password);

class GameboyCaptiveRequestHandler : public AsyncWebHandler {
public:
GameboyCaptiveRequestHandler() {}
virtual ~GameboyCaptiveRequestHandler() {}

bool canHandle(AsyncWebServerRequest *request) { return true; }

void handleRequest(AsyncWebServerRequest *request) {
// request->send(SPIFFS, "/index.html");
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", _index_html, _index_html_len);
// AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", (const char*) _index_html);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}
};
#endif
2 changes: 1 addition & 1 deletion esp32_marauder/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define PCB_2_5 1
#define PCB_2_5_1 2

#define MALVEKE_VERSION PCB_2_5
#define MALVEKE_VERSION PCB_2_5_1

#define POLISH_POTATO

Expand Down
81 changes: 37 additions & 44 deletions esp32_marauder/esp32_marauder.ino
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/* FLASH SETTINGS
Board: LOLIN D32
Flash Frequency: 80MHz
Partition Scheme: Minimal SPIFFS
https://www.online-utility.org/image/convert/to/XBM
*/

#include "configs.h"

#include <WiFi.h>
Expand Down Expand Up @@ -217,54 +210,54 @@ void loop()

//if ((!do_draw) && (wifi_scan_obj.currentScanMode != ESP_UPDATE))
//{
if(!gameboy_cartridge.isRestoringRAM()){
cli_obj.main(currentTime);
if (!gameboy_cartridge.isRestoringRAM()) {
cli_obj.main(currentTime);
}

gameboy_cartridge.main();
gameboy_advance_cartridge.main();
gameboy_live_camera.main();
gameboy_test_pin.main();
if(!gameboy_live_camera.isRunning() && !gameboy_cartridge.isWrittingRAM() && !gameboy_cartridge.isWrittingROM() && !gameboy_cartridge.isRestoringRAM()) {
if (!gameboy_live_camera.isRunning() && !gameboy_cartridge.isWrittingRAM() && !gameboy_cartridge.isWrittingROM() && !gameboy_cartridge.isRestoringRAM()) {

wifi_scan_obj.main(currentTime);
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
wifi_scan_obj.main(currentTime);
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);

#ifdef HAS_GPS
#ifdef HAS_GPS
gps_obj.main();
#endif
#endif

// Save buffer to SD and/or serial
buffer_obj.save();
settings_obj.main(currentTime);
if (((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) && (wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL)) ||
(mini)) {
//cli_obj.main(currentTime);
}
//if (wifi_scan_obj.currentScanMode == OTA_UPDATE)
// web_obj.main();
#ifdef HAS_SCREEN
// Save buffer to SD and/or serial
buffer_obj.save();
settings_obj.main(currentTime);
if (((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) && (wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL)) ||
(mini)) {
//cli_obj.main(currentTime);
}
//if (wifi_scan_obj.currentScanMode == OTA_UPDATE)
// web_obj.main();
#ifdef HAS_SCREEN
delay(1);
#else
#else
delay(50);
#endif
//}
/*else if (wifi_scan_obj.currentScanMode == ESP_UPDATE) {
#ifdef HAS_SCREEN
display_obj.main(wifi_scan_obj.currentScanMode);
menu_function_obj.main(currentTime);
#endif
#ifdef MARAUDER_FLIPPER
flipper_led.main();
#elif defined(XIAO_ESP32_S3)
xiao_led.main();
#else
led_obj.main(currentTime);
#endif
//cli_obj.main(currentTime);
delay(1);
}*/
#endif
//}
/*else if (wifi_scan_obj.currentScanMode == ESP_UPDATE) {
#ifdef HAS_SCREEN
display_obj.main(wifi_scan_obj.currentScanMode);
menu_function_obj.main(currentTime);
#endif
#ifdef MARAUDER_FLIPPER
flipper_led.main();
#elif defined(XIAO_ESP32_S3)
xiao_led.main();
#else
led_obj.main(currentTime);
#endif
//cli_obj.main(currentTime);
delay(1);
}*/
}
}
43 changes: 42 additions & 1 deletion esp32_marauder/gameboy_server_link_camera_assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,48 @@ static const uint8_t link_camera_index_css_gz[] PROGMEM = {
};
// array size is 374
#define link_camera_index_html_gz_len 374

// array size is 619
static const uint8_t link_camera_index_html[] PROGMEM = {
0x3c, 0x21, 0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65, 0x20, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a,
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x22, 0x65, 0x6e, 0x22, 0x3e,
0x0a, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6d,
0x65, 0x74, 0x61, 0x20, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x22, 0x55, 0x54, 0x46,
0x2d, 0x38, 0x22, 0x20, 0x2f, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b,
0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x69, 0x63, 0x6f, 0x6e, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x22, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x73, 0x76, 0x67, 0x2b, 0x78, 0x6d, 0x6c, 0x22,
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x2e,
0x69, 0x63, 0x6f, 0x2e, 0x67, 0x7a, 0x22, 0x20, 0x2f, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c,
0x6d, 0x65, 0x74, 0x61, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x76, 0x69, 0x65, 0x77, 0x70,
0x6f, 0x72, 0x74, 0x22, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3d, 0x22, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68,
0x2c, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x2d, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x3d,
0x31, 0x2e, 0x30, 0x22, 0x20, 0x2f, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74,
0x6c, 0x65, 0x3e, 0x5b, 0x4d, 0x41, 0x4c, 0x56, 0x45, 0x4b, 0x45, 0x5d, 0x20, 0x47, 0x61, 0x6d,
0x65, 0x20, 0x42, 0x6f, 0x79, 0x20, 0x43, 0x61, 0x6d, 0x65, 0x72, 0x61, 0x20, 0x2d, 0x20, 0x43,
0x61, 0x62, 0x6c, 0x65, 0x20, 0x4c, 0x69, 0x6e, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65,
0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3e, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x20, 0x62, 0x6f, 0x64, 0x79,
0x2c, 0x20, 0x23, 0x61, 0x70, 0x70, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x65,
0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c,
0x65, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x74,
0x79, 0x70, 0x65, 0x3d, 0x22, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x20, 0x63, 0x72, 0x6f,
0x73, 0x73, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x69,
0x6e, 0x64, 0x65, 0x78, 0x2e, 0x6a, 0x73, 0x22, 0x3e, 0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70,
0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c,
0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x63, 0x72,
0x6f, 0x73, 0x73, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22,
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x0a, 0x20, 0x20, 0x3c,
0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x61, 0x70, 0x70,
0x22, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x66, 0x6c, 0x65, 0x78, 0x20, 0x66, 0x6c,
0x65, 0x78, 0x2d, 0x31, 0x20, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x2d, 0x63, 0x65, 0x6e, 0x74, 0x65,
0x72, 0x20, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x2d, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72,
0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a
};
static const uint8_t link_camera_index_html_gz[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x65, 0x52, 0xcb, 0x4e, 0xc3, 0x30,
0x10, 0xbc, 0xf7, 0x2b, 0x16, 0x23, 0x4e, 0x34, 0x4d, 0x7b, 0x43, 0x90, 0x54, 0x02, 0x54, 0x38,
Expand Down

0 comments on commit 51c3e36

Please sign in to comment.