Old local changes from desktop pc
This commit is contained in:
parent
bc7e414e53
commit
c600d373aa
|
@ -1,6 +1,8 @@
|
|||
.ipynb_checkpoints
|
||||
__pycache__
|
||||
*.st
|
||||
/espidf
|
||||
/venv
|
||||
/hardware/case/generated
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
venv
|
||||
hardware/case/generated/
|
||||
/example-data
|
|
@ -22,6 +22,8 @@ class Logger
|
|||
public:
|
||||
using NtpTimeT = unsigned long;
|
||||
|
||||
static constexpr int HEADER_SIZE = sizeof(NtpTimeT) + sizeof(millis());
|
||||
|
||||
~Logger();
|
||||
|
||||
template <class... Args>
|
||||
|
@ -53,6 +55,11 @@ public:
|
|||
static void init();
|
||||
static void setNtpTime(NtpTimeT time);
|
||||
|
||||
|
||||
const size_t totalSize() const { return totalSize_; }
|
||||
const size_t currentSize() const { return currentSize_; }
|
||||
const char * data() const { return data_; }
|
||||
|
||||
private:
|
||||
Logger();
|
||||
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
#include "UserDB.h"
|
||||
#include "Logger.h"
|
||||
|
||||
|
||||
// Api
|
||||
#include "WebsocketServer.h"
|
||||
#include "SessionAPI.h"
|
||||
#include "WifiAPI.h"
|
||||
|
||||
|
||||
using Session_T = SimpleMeasurementSession<MeasurementT, CONFIG_SESSION_MAX_SIZE>;
|
||||
SessionManager<Session_T> sessionManager;
|
||||
|
||||
|
@ -380,6 +378,12 @@ void httpSetup(SessionManager<SessionT> *sessionManager, WifiManager *wifiManage
|
|||
prefs.putBool("hostname", CONFIG_HOSTNAME + getIdSuffix());
|
||||
httpd_resp_send(req, "OK", -1);
|
||||
};
|
||||
auto cbLoggingGet = [](httpd_req_t *req)
|
||||
{
|
||||
const auto logger = Logger::getInstance();
|
||||
httpd_resp_set_hdr(req, "Content-Type", "application/octet-stream");
|
||||
httpd_resp_send(req, logger->data(), logger->currentSize());
|
||||
};
|
||||
|
||||
espHttpServer.start();
|
||||
|
||||
|
@ -387,34 +391,29 @@ void httpSetup(SessionManager<SessionT> *sessionManager, WifiManager *wifiManage
|
|||
espHttpServer.on("/api/wifi", HTTP_POST, cbWifiPost);
|
||||
espHttpServer.on("/api/restart", HTTP_GET, cbRestart);
|
||||
|
||||
if (!wifiManager->inProvisioningMode())
|
||||
{
|
||||
espHttpServer.on("/api/session/start", HTTP_GET, cbStartSession);
|
||||
espHttpServer.on("/api/session/start", HTTP_POST, cbStartSession);
|
||||
espHttpServer.on("/api/session/start", HTTP_GET, cbStartSession);
|
||||
espHttpServer.on("/api/session/start", HTTP_POST, cbStartSession);
|
||||
|
||||
espHttpServer.on("/api/session/stop", HTTP_GET, cbStopSession);
|
||||
espHttpServer.on("/api/session/stop", HTTP_POST, cbStopSession);
|
||||
espHttpServer.on("/api/session/stop", HTTP_GET, cbStopSession);
|
||||
espHttpServer.on("/api/session/stop", HTTP_POST, cbStopSession);
|
||||
|
||||
espHttpServer.on("/api/session/data", HTTP_GET, cbGetData);
|
||||
espHttpServer.on("/api/status", HTTP_GET, cbStatus);
|
||||
espHttpServer.on("/api/tare", HTTP_GET, cbTare);
|
||||
espHttpServer.on("/api/firmwareupdate", HTTP_GET, cbFirmwareUpdate);
|
||||
espHttpServer.on("/api/session/data", HTTP_GET, cbGetData);
|
||||
espHttpServer.on("/api/status", HTTP_GET, cbStatus);
|
||||
espHttpServer.on("/api/tare", HTTP_GET, cbTare);
|
||||
espHttpServer.on("/api/firmwareupdate", HTTP_GET, cbFirmwareUpdate);
|
||||
|
||||
espHttpServer.on("/api/settings", HTTP_GET, cbSettingsGet);
|
||||
espHttpServer.on("/api/settings", HTTP_POST, cbSettingsPost);
|
||||
espHttpServer.on("/api/settings", HTTP_DELETE, cbSettingsDelete);
|
||||
espHttpServer.on("/api/settings", HTTP_GET, cbSettingsGet);
|
||||
espHttpServer.on("/api/settings", HTTP_POST, cbSettingsPost);
|
||||
espHttpServer.on("/api/settings", HTTP_DELETE, cbSettingsDelete);
|
||||
|
||||
auto webdav = webdavHandler("/webdav/", "/dat");
|
||||
espHttpServer.on("/webdav/*?", HTTP_GET, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_PROPFIND, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_DELETE, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_OPTIONS, webdav);
|
||||
LOG_INFO("HTTP setup done");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("HTTP setup with limited API in provisioning mode");
|
||||
}
|
||||
espHttpServer.on("/api/log", HTTP_GET, cbLoggingGet);
|
||||
|
||||
auto webdav = webdavHandler("/webdav/", "/dat");
|
||||
espHttpServer.on("/webdav/*?", HTTP_GET, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_PROPFIND, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_DELETE, webdav);
|
||||
espHttpServer.on("/webdav/*?", HTTP_OPTIONS, webdav);
|
||||
LOG_INFO("HTTP setup done");
|
||||
}
|
||||
|
||||
void mdnsSetup(const String &fullHostname)
|
||||
|
@ -443,7 +442,7 @@ void setup()
|
|||
LOG_WARNING("Failed to mount/format SPIFFS file system");
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
|
||||
auto spiffsSetupTimeSecs = (millis() - millisBeforeSpiffsInit) / 1000;
|
||||
|
||||
userStorage.init();
|
||||
|
|
Binary file not shown.
|
@ -3,6 +3,7 @@ import numpy as np
|
|||
from msgpack.fallback import unpackb
|
||||
import requests
|
||||
import array
|
||||
import sys
|
||||
|
||||
|
||||
def ext_hook(code, data):
|
||||
|
@ -50,6 +51,6 @@ def analyze(data, max_size=8*1024):
|
|||
print("Time range {}, dense {} [minutes]".format(time_range_seconds / 60, dense_time_range_seconds / 60))
|
||||
|
||||
#from_network()
|
||||
res = from_file('real_data/1593335527.st')
|
||||
res = from_file(sys.argv[1])
|
||||
print(res)
|
||||
#analyze(res)
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
Web Socket Protocol Draft
|
||||
==========================
|
||||
|
||||
Requirements:
|
||||
- fast when necessary (not even msgpack overhead)
|
||||
- sending live data updates
|
||||
- easy otherwise, based on msgpack
|
||||
- sending existing measured data
|
||||
-
|
||||
|
||||
|
||||
Message Format
|
||||
--------------
|
||||
|
||||
- 1byte "opcode" (if lower than threshold, probably 8, pure binary msg, otherwise msgpack)
|
||||
- msgpack data, or custom binary data
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
|
||||
class WebsocketConnection
|
||||
{
|
||||
sendMessage(opcode, optionalData); // optional data is packed via msgpck
|
||||
registerMessageReceive(func, singleShot);
|
||||
|
||||
request(opcode, data, onReplyFunc); // with futures, async
|
||||
// register a single shot receive that calls the "onReplyFunc", or promise
|
||||
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
```cpp
|
||||
|
||||
class WebsocketInterface
|
||||
{
|
||||
public:
|
||||
virtual bool onMessageReceived(websockets::WebsocketsClient &client)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
WebsocketServer * server_;
|
||||
}
|
||||
|
||||
class SessionWebsocketInterface
|
||||
{
|
||||
public:
|
||||
|
||||
}
|
||||
|
||||
|
||||
class WebsocketServer
|
||||
{
|
||||
void sendToAll(char * data, size_t size);
|
||||
|
||||
void registerInterface(WebsocketInterface *);
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
can this be done with static polymorphism as well? does std::tuple and std::apply work?! -> test
|
Loading…
Reference in New Issue