mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-19 18:01:30 +10:00
* Add ulfius webserver support to macos native target * fix: update PiWebServer docs for macOS and add explicit cstring include Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/3ce82582-23e0-4afe-b22f-b24f81721488 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: add --cflags to openssl@3 pkg-config and fix apt package name Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/1a6c59aa-4393-4134-8cee-61eeee0e9127 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#pragma once
|
|
// Portduino webserver is built whenever the ulfius headers are reachable,
|
|
// not only on Linux. macOS users can `brew install ulfius` to enable it;
|
|
// without ulfius the entire body is skipped and main.cpp's matching
|
|
// __has_include guard avoids referencing the type.
|
|
#ifdef ARCH_PORTDUINO
|
|
#if __has_include(<ulfius.h>)
|
|
#include "PhoneAPI.h"
|
|
#include "ulfius-cfg.h"
|
|
#include "ulfius.h"
|
|
#include <Arduino.h>
|
|
#include <functional>
|
|
|
|
#define STATIC_FILE_CHUNK 256
|
|
|
|
void initWebServer();
|
|
void createSSLCert();
|
|
int callback_static_file(const struct _u_request *request, struct _u_response *response, void *user_data);
|
|
const char *get_filename_ext(const char *path);
|
|
|
|
struct _file_config {
|
|
char *files_path;
|
|
char *url_prefix;
|
|
struct _u_map mime_types;
|
|
struct _u_map map_header;
|
|
char *redirect_on_404;
|
|
char *rootPath;
|
|
};
|
|
|
|
class HttpAPI : public PhoneAPI
|
|
{
|
|
|
|
public:
|
|
HttpAPI() { api_type = TYPE_HTTP; }
|
|
|
|
/// Check the current underlying physical link to see if the client is currently connected
|
|
virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this
|
|
|
|
private:
|
|
// Nothing here yet
|
|
|
|
protected:
|
|
};
|
|
|
|
class PiWebServerThread
|
|
{
|
|
private:
|
|
char *key_pem = NULL;
|
|
char *cert_pem = NULL;
|
|
// struct _u_map mime_types;
|
|
std::string webrootpath;
|
|
HttpAPI webAPI;
|
|
|
|
public:
|
|
PiWebServerThread();
|
|
~PiWebServerThread();
|
|
int CreateSSLCertificate();
|
|
int CheckSSLandLoad();
|
|
uint32_t requestRestart = 0;
|
|
struct _u_instance instanceWeb;
|
|
};
|
|
|
|
extern PiWebServerThread *piwebServerThread;
|
|
|
|
#endif
|
|
#endif |