parent
532ed3e46f
commit
85ac1c9806
|
|
@ -330,7 +330,7 @@ const char page_system_html[] PROGMEM = R"rawliteral(
|
|||
<tr><td class="ps1">Available software update</td><td class="ps2"><span id="sw_new_ver"></span> <span class="underlined-text" onclick="checkUpdate()">Check update from cloud</span></td></tr>
|
||||
<tr><td style="height: 1px;"></td><td style="height: 1px;"></td></tr>
|
||||
<tr><td class="ps3">System configuration</td><td></td></tr>
|
||||
<tr><td class="pc1">mDNS record</td><td ><input type="text" name="mdns" id=mdnsid ><span class=pc1>.local</span> <button class="btn_save" onclick="changeValue(document.getElementById('mdnsid').value, 'set_mdns?mdns=', 'system')">Save</button></td></tr>
|
||||
<tr><td class="pc1">Cam name & mDNS record</td><td ><input type="text" name="mdns" id=mdnsid ><span class=pc1>.local</span> <button class="btn_save" onclick="changeValue(document.getElementById('mdnsid').value, 'set_mdns?mdns=', 'system')">Save</button></td></tr>
|
||||
<tr>
|
||||
<td class="pc1">Log level</td><td><label for="loglevel"></label>
|
||||
<select class="select" id="loglevelid" name="loglevel" onchange="changeValue(this.value, 'set_int?log_level=', 'system')">
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "connect.h"
|
||||
|
||||
PrusaConnect Connect(&SystemConfig, &SystemLog, &SystemCamera);
|
||||
PrusaConnect Connect(&SystemConfig, &SystemLog, &SystemCamera, &SystemWifiMngt);
|
||||
|
||||
/**
|
||||
* @brief Constructor for PrusaConnect class
|
||||
|
|
@ -20,10 +20,11 @@ PrusaConnect Connect(&SystemConfig, &SystemLog, &SystemCamera);
|
|||
* @param Logs* - pointer to Logs class
|
||||
* @param Camera* - pointer to Camera class
|
||||
*/
|
||||
PrusaConnect::PrusaConnect(Configuration *i_conf, Logs *i_log, Camera *i_camera) {
|
||||
PrusaConnect::PrusaConnect(Configuration *i_conf, Logs *i_log, Camera *i_camera, WiFiMngt *i_wifi) {
|
||||
config = i_conf;
|
||||
log = i_log;
|
||||
camera = i_camera;
|
||||
wifi = i_wifi;
|
||||
BackendAvailability = WaitForFirstConnection;
|
||||
SendDeviceInformationToBackend = true;
|
||||
}
|
||||
|
|
@ -36,8 +37,6 @@ PrusaConnect::PrusaConnect(Configuration *i_conf, Logs *i_log, Camera *i_camera)
|
|||
*/
|
||||
void PrusaConnect::Init() {
|
||||
log->AddEvent(LogLevel_Info, F("Init PrusaConnect lib"));
|
||||
//camera->CapturePhoto();
|
||||
//camera->CaptureReturnFrameBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,7 +120,7 @@ bool PrusaConnect::SendDataToBackend(String *i_data, int i_data_length, String i
|
|||
size_t sendet_data = 0;
|
||||
/* sending photo */
|
||||
if (SendPhoto == i_data_type) {
|
||||
log->AddEvent(LogLevel_Verbose, F("Send data photo"));
|
||||
log->AddEvent(LogLevel_Verbose, F("Sendig photo"));
|
||||
|
||||
/* sending photo */
|
||||
uint8_t *fbBuf = camera->GetPhotoFb()->buf;
|
||||
|
|
@ -136,18 +135,17 @@ bool PrusaConnect::SendDataToBackend(String *i_data, int i_data_length, String i
|
|||
sendet_data += client.write(fbBuf, remainder);
|
||||
}
|
||||
}
|
||||
|
||||
client.println("\r\n");
|
||||
client.flush();
|
||||
log->AddEvent(LogLevel_Verbose, String(i_data_length) + "/" + String(sendet_data));
|
||||
|
||||
/* sending device information */
|
||||
} else if (SendInfo == i_data_type) {
|
||||
log->AddEvent(LogLevel_Verbose, F("Send data info"));
|
||||
log->AddEvent(LogLevel_Verbose, F("Sending info"));
|
||||
sendet_data = client.print(*i_data);
|
||||
client.flush();
|
||||
}
|
||||
|
||||
log->AddEvent(LogLevel_Info, "Send done: " + String(sendet_data) + " bytes");
|
||||
log->AddEvent(LogLevel_Info, "Send done: " + String(i_data_length) + "/" + String(sendet_data) + " bytes");
|
||||
esp_task_wdt_reset();
|
||||
|
||||
/* read response from server */
|
||||
|
|
@ -203,7 +201,6 @@ void PrusaConnect::SendPhotoToBackend() {
|
|||
log->AddEvent(LogLevel_Info, F("Start sending photo to prusaconnect"));
|
||||
String Photo = "";
|
||||
SendDataToBackend(&Photo, camera->GetPhotoFb()->len, "image/jpg", "Photo", HOST_URL_CAM_PATH, SendPhoto);
|
||||
SystemLog.AddEvent(LogLevel_Info, "Free RAM: " + String(ESP.getFreeHeap()) + " bytes");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -221,7 +218,7 @@ void PrusaConnect::SendInfoToBackend() {
|
|||
String json_string = "";
|
||||
|
||||
JsonObject config = json_data["config"].to<JsonObject>();
|
||||
config["name"] = "ESP32-CAM";
|
||||
config["name"] = wifi->GetMdns();
|
||||
|
||||
JsonObject resolution = config["resolution"].to<JsonObject>();
|
||||
resolution["width"] = SystemCamera.GetFrameSizeWidth();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include "Certificate.h"
|
||||
#include "server.h"
|
||||
|
||||
class WiFiMngt;
|
||||
|
||||
/**
|
||||
* @brief BackendAvailabilitStatus enum
|
||||
* status of backend availability
|
||||
|
|
@ -61,11 +63,12 @@ private:
|
|||
Configuration *config; ///< pointer to configuration object
|
||||
Logs *log; ///< pointer to logs object
|
||||
Camera *camera; ///< pointer to camera object
|
||||
WiFiMngt *wifi; ///< pointer to wifi object
|
||||
|
||||
bool SendDataToBackend(String *, int, String, String, String, SendDataToBackendType);
|
||||
|
||||
public:
|
||||
PrusaConnect(Configuration*, Logs*, Camera*);
|
||||
PrusaConnect(Configuration*, Logs*, Camera*, WiFiMngt*);
|
||||
~PrusaConnect(){};
|
||||
|
||||
void Init();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ void WiFiMngt_WiFiEventApStaDisconnected(WiFiEvent_t , WiFiEventInfo_t);
|
|||
void WiFiMngt_WiFiEventApStaIpAssigned(WiFiEvent_t , WiFiEventInfo_t);
|
||||
void WiFiMngt_WiFiEventApStaProbeReqRecved(WiFiEvent_t , WiFiEventInfo_t);
|
||||
|
||||
/**
|
||||
* @brief NetworkIpMethod_enum
|
||||
* method for obtaining IP address
|
||||
*/
|
||||
enum NetworkIpMethod_enum {
|
||||
NetworkIpMethodDhcp = 0, ///< DHCP IP
|
||||
NetworkIpMethodStatic = 1, ///< STATIC IP
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<tr><td class="ps1">Available software update</td><td class="ps2"><span id="sw_new_ver"></span> <span class="underlined-text" onclick="checkUpdate()">Check update from cloud</span></td></tr>
|
||||
<tr><td style="height: 1px;"></td><td style="height: 1px;"></td></tr>
|
||||
<tr><td class="ps3">System configuration</td><td></td></tr>
|
||||
<tr><td class="pc1">mDNS record</td><td ><input type="text" name="mdns" id=mdnsid ><span class=pc1>.local</span> <button class="btn_save" onclick="changeValue(document.getElementById('mdnsid').value, 'set_mdns?mdns=', 'system')">Save</button></td></tr>
|
||||
<tr><td class="pc1">Cam name & mDNS record</td><td ><input type="text" name="mdns" id=mdnsid ><span class=pc1>.local</span> <button class="btn_save" onclick="changeValue(document.getElementById('mdnsid').value, 'set_mdns?mdns=', 'system')">Save</button></td></tr>
|
||||
<tr>
|
||||
<td class="pc1">Log level</td><td><label for="loglevel"></label>
|
||||
<select class="select" id="loglevelid" name="loglevel" onchange="changeValue(this.value, 'set_int?log_level=', 'system')">
|
||||
|
|
|
|||
Loading…
Reference in New Issue