works, needs more work
This commit is contained in:
parent
f94639c1a0
commit
4d23c1039b
6 changed files with 75 additions and 66 deletions
|
@ -1,39 +0,0 @@
|
|||
#ifndef THESERVER_H
|
||||
#define THESERVER_H
|
||||
|
||||
#include "WebServer.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
static WebServer server(8080);
|
||||
|
||||
void custom_message_response(const char *message, int response_code)
|
||||
{
|
||||
cJSON *json_response = cJSON_CreateObject();
|
||||
cJSON_AddBoolToObject(json_response, "ok", true);
|
||||
cJSON_AddStringToObject(json_response, "message", message);
|
||||
server.send(response_code, "application/json", cJSON_Print(json_response));
|
||||
cJSON_Delete(json_response);
|
||||
}
|
||||
|
||||
static void getFirewallRules()
|
||||
{
|
||||
custom_message_response("firewall rules..", 200);
|
||||
}
|
||||
|
||||
static void setup_routing()
|
||||
{
|
||||
server.on("/api/v1/firewall", HTTP_GET, getFirewallRules);
|
||||
}
|
||||
|
||||
void setup_server()
|
||||
{
|
||||
setup_routing();
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void handle_server_clients()
|
||||
{
|
||||
server.handleClient();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef THEWIFI_H
|
||||
#define THEWIFI_H
|
||||
|
||||
#include "esp32-hal-log.h"
|
||||
#include "WiFi.h"
|
||||
#include "theSecrets.h"
|
||||
|
||||
const char *esp_ip_address;
|
||||
|
||||
void setup_wifi()
|
||||
{
|
||||
log_i("Attempting to connect to WPA SSID: %s", ssid);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, psk);
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(1000);
|
||||
}
|
||||
esp_ip_address = WiFi.localIP().toString().c_str();
|
||||
log_i("Connected, IP Address: %s", esp_ip_address);
|
||||
}
|
||||
|
||||
#endif
|
Reference in a new issue