I try to use a usb storage to send a page HTML.
im not understanding how open the file and send it with wifiwebserver.
// #ifndef defines_h
// #define defines_h
#define DEBUG_WIFI_WEBSERVER_PORT Serial
#define _WIFI_LOGLEVEL_ 4
#define _WIFININA_LOGLEVEL_ 3
#if (defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_GIGA))
#if defined(BOARD_NAME)
#undef BOARD_NAME
#endif
#if defined(CORE_CM7)
#warning Using Portenta H7 M7 core
#define BOARD_NAME "PORTENTA_H7_M7"
#else
#warning Using Portenta H7 M4 core
#define BOARD_NAME "PORTENTA_H7_M4"
#endif
#define USE_WIFI_PORTENTA_H7 true
#define USE_WIFI_NINA false
#define USE_WIFI_CUSTOM false
#endif
#if USE_WIFI_PORTENTA_H7
#warning Using Portenta H7 WiFi
#define SHIELD_TYPE "Portenta_H7 WiFi"
#endif
#ifndef BOARD_NAME
#if defined(ARDUINO_BOARD)
#define BOARD_NAME ARDUINO_BOARD
#elif defined(BOARD_TYPE)
#define BOARD_NAME BOARD_TYPE
#else
#define BOARD_NAME "Unknown Board"
#endif
#endif
#include "WiFiWebServer.h"
#include "arduino_secrets.h"
// #include "defines.h"
#include "Arduino_USBHostMbed5.h"
#include "DigitalOut.h"
#include "FATFileSystem.h"
USBHostMSD msd;
mbed::FATFileSystem usb("usb");
mbed::fs_file_t file;
char *ssid = SECRET_SSID;
char *pass = SECRET_PASS;
int status = WL_IDLE_STATUS; // the Wifi radio's status
IPAddress ip(192, 168, 1, 39);
WiFiWebServer server(80);
void handleCSS() {
FILE *file = fopen("/usb/index.html", "r");
server.streamFile(file, "text/html");
fflush(stdout);
server.send(200);
}
void handleNotFound() {
server.send(404, "text/plain", "404: Not found");
}
void WIFIsetup() {
while (!msd.connect()) {
delay(1000);
}
while (!Serial && millis() < 5000)
;
WiFi.config(ip);
status = WiFi.begin(ssid, pass);
while (status != WL_CONNECTED) {
delay(500);
status = WiFi.status();
}
server.on("/", HTTP_GET, handleCSS);
server.onNotFound(handleNotFound);
server.begin();
Serial.print(WiFi.localIP());
}
void WIFIloop() {
server.handleClient();
}
Any clue?
maybe im not using correct library?