Browse Source

fix web

pull/1197/head
lumapu 1 year ago
parent
commit
097dd3c39c
  1. 7
      src/hm/hmPayload.h
  2. 23
      src/hm/miPayload.h
  3. 3
      src/web/RestApi.h
  4. 18
      src/web/html/visualization.html

7
src/hm/hmPayload.h

@ -72,7 +72,7 @@ class HmPayload {
void loop() {
if (NULL != mHighPrioIv) {
ivSend(mHighPrioIv, true);
ivSend(mHighPrioIv, true); // for e.g. devcontrol commands
mHighPrioIv = NULL;
}
}
@ -144,7 +144,7 @@ class HmPayload {
if (mSerialDebug) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("Devcontrol request 0x"));
DBGPRINT(String(iv->devControlCmd, HEX));
DHEX(iv->devControlCmd);
DBGPRINT(F(" power limit "));
DBGPRINTLN(String(iv->powerLimit[0]));
}
@ -301,7 +301,8 @@ class HmPayload {
mPayload[iv->id].retransmits++;
mPayload[iv->id].txCmd = iv->getQueuedCmd();
if (mSerialDebug) {
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
DPRINT_IVID(DBG_WARN, iv->id);
DBGPRINTLN(F("CRC Error: Request Complete Retransmit"));
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("prepareDevInformCmd 0x"));
DBGHEXLN(mPayload[iv->id].txCmd);

23
src/hm/miPayload.h

@ -1,6 +1,6 @@
//-----------------------------------------------------------------------------
// 2023 Ahoy, https://ahoydtu.de
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------
#ifndef __MI_PAYLOAD_H__
@ -49,7 +49,7 @@ class MiPayload {
}
mSerialDebug = false;
mHighPrioIv = NULL;
mCbMiPayload = NULL;
mCbPayload = NULL;
}
void enableSerialDebug(bool enable) {
@ -57,7 +57,7 @@ class MiPayload {
}
void addPayloadListener(miPayloadListenerType cb) {
mCbMiPayload = cb;
mCbPayload = cb;
}
void addAlarmListener(alarmListenerType cb) {
@ -108,7 +108,7 @@ class MiPayload {
mPayload[iv->id].requested = true;
yield();
if (mSerialDebug){
if (mSerialDebug) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("Requesting Inv SN "));
DBGPRINTLN(String(iv->config->serial.u64, HEX));
@ -434,8 +434,8 @@ class MiPayload {
private:
void notify(uint8_t val, Inverter<> *iv) {
if(NULL != mCbMiPayload)
(mCbMiPayload)(val, iv);
if(NULL != mCbPayload)
(mCbPayload)(val, iv);
}
void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t stschan = CH1) {
@ -506,14 +506,11 @@ class MiPayload {
}
/*if(AlarmData == mPayload[iv->id].txCmd) {
uint8_t i = 0;
uint16_t code;
uint32_t start, end;
while(1) {
code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end);
if(0 == code)
if(0 == iv->parseAlarmLog(i++, payload, payloadLen))
break;
if (NULL != mCbAlarm)
(mCbAlarm)(code, start, end);
(mCbAlarm)(iv);
yield();
}
}*/
@ -789,10 +786,10 @@ const byteAssign_t InfoAssignment[] = {
uint32_t *mTimestamp;
miPayload_t mPayload[MAX_NUM_INVERTERS];
bool mSerialDebug;
Inverter<> *mHighPrioIv;
alarmListenerType mCbAlarm;
payloadListenerType mCbMiPayload;
payloadListenerType mCbPayload;
};
#endif /*__MI_PAYLOAD_H__*/

3
src/web/RestApi.h

@ -107,7 +107,7 @@ class RestApi {
getIvAlarms(root, request->url().substring(20).toInt());
else if(path.substring(0, 17) == "inverter/version/")
getIvVersion(root, request->url().substring(22).toInt());
else if(path.substring(0, 17) == "inverter/radiostat/")
else if(path.substring(0, 19) == "inverter/radiostat/")
getIvStatistis(root, request->url().substring(24).toInt());
else
getNotFound(root, F("http://") + request->host() + F("/api/"));
@ -317,6 +317,7 @@ class RestApi {
obj[F("error")] = F("inverter not found!");
return;
}
obj[F("name")] = String(iv->config->name);
obj[F("rx_success")] = iv->radioStatistics.rxSuccess;
obj[F("rx_fail")] = iv->radioStatistics.rxFail;
obj[F("rx_fail_answer")] = iv->radioStatistics.rxFailNoAnser;

18
src/web/html/visualization.html

@ -177,20 +177,20 @@
]);
}
function tsInfo(ts, gen, rssi) {
function tsInfo(obj) {
var ageInfo = "Last received data requested at: ";
if(ts > 0) {
var date = new Date(ts * 1000);
if(obj.ts_last_success > 0) {
var date = new Date(obj.ts_last_success * 1000);
ageInfo += toIsoDateStr(date);
}
else
ageInfo += "nothing received";
if(rssi > -127) {
if(gen < 2)
ageInfo += " (RSSI: " + ((rssi == -64) ? ">=" : "<") + " -64dBm)";
if(obj.rssi > -127) {
if(obj.generation < 2)
ageInfo += " (RSSI: " + ((obj.rssi == -64) ? ">=" : "<") + " -64dBm)";
else
ageInfo += " (RSSI: " + rssi + "dBm)";
ageInfo += " (RSSI: " + obj.rssi + "dBm)";
}
return ml("div", {class: "mb-5"}, [
@ -220,7 +220,7 @@
ml("div", {}, [
ivHead(obj),
ml("div", {class: "row mb-2"}, chn),
tsInfo(obj.ts_last_success, obj.generation, obj.rssi)
tsInfo(obj)
])
);
@ -302,7 +302,7 @@
tr("TX retransmits", obj.retransmits)
])
]);
modal("Info for inverter " + obj.name, ml("div", {}, html));
modal("Radio statistics for inverter " + obj.name, ml("div", {}, html));
}
function parse(obj) {

Loading…
Cancel
Save