-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fd787a
commit 74c9aa0
Showing
9 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <Arduino.h> | ||
|
||
void http_api_ping_setup(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void http_not_found_setup(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <Arduino.h> | ||
#include <ArduinoJson.h> | ||
|
||
#include "config.h" | ||
|
||
#include "log.h" | ||
#include "global.h" | ||
#include "display/display.h" | ||
#include "network/http_api.h" | ||
#include "network/http_api_util.h" | ||
|
||
extern HTTPWEBSERVER server; | ||
|
||
|
||
String http_normal_ping_json() { | ||
|
||
unsigned long ms = millis(); | ||
String timeString = getTimeString(ms); | ||
|
||
DynamicJsonDocument doc(2000); | ||
doc["product"] = product; | ||
doc["uptime"] = timeString; | ||
doc["uptimeMills"] = ms; | ||
doc["majorVer"] = ver; | ||
doc["minorVer"] = minorVer; | ||
doc["settingId"] = SETTING_ID; | ||
|
||
String json; | ||
serializeJson(doc, json); | ||
|
||
httplog(json); | ||
return json; | ||
} | ||
|
||
|
||
void http_handle_ping() { | ||
String message = http_normal_ping_json(); | ||
server.send(200, MimeType::JSON, message); | ||
} | ||
|
||
void http_api_ping_setup() { | ||
server.on ( "/ping", HTTP_GET, http_handle_ping); | ||
apilog("API Ping initialized."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <Arduino.h> | ||
#include <ArduinoJson.h> | ||
|
||
#include "config.h" | ||
|
||
#include "log.h" | ||
#include "global.h" | ||
#include "display/display.h" | ||
#include "network/http_api.h" | ||
#include "network/http_api_base_json.h" | ||
|
||
extern HTTPWEBSERVER server; | ||
|
||
void http_handle_not_found() { | ||
String message = "404 File Not Found\n\n"; | ||
server.send(404, MimeType::HTML, message); | ||
} | ||
|
||
void http_not_found_setup() { | ||
server.onNotFound ( http_handle_not_found ); | ||
} |