Browse Source

fix web

pull/1197/head
lumapu 1 year ago
parent
commit
097dd3c39c
  1. 7
      src/hm/hmPayload.h
  2. 21
      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() { void loop() {
if (NULL != mHighPrioIv) { if (NULL != mHighPrioIv) {
ivSend(mHighPrioIv, true); ivSend(mHighPrioIv, true); // for e.g. devcontrol commands
mHighPrioIv = NULL; mHighPrioIv = NULL;
} }
} }
@ -144,7 +144,7 @@ class HmPayload {
if (mSerialDebug) { if (mSerialDebug) {
DPRINT_IVID(DBG_INFO, iv->id); DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("Devcontrol request 0x")); DBGPRINT(F("Devcontrol request 0x"));
DBGPRINT(String(iv->devControlCmd, HEX)); DHEX(iv->devControlCmd);
DBGPRINT(F(" power limit ")); DBGPRINT(F(" power limit "));
DBGPRINTLN(String(iv->powerLimit[0])); DBGPRINTLN(String(iv->powerLimit[0]));
} }
@ -301,7 +301,8 @@ class HmPayload {
mPayload[iv->id].retransmits++; mPayload[iv->id].retransmits++;
mPayload[iv->id].txCmd = iv->getQueuedCmd(); mPayload[iv->id].txCmd = iv->getQueuedCmd();
if (mSerialDebug) { 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); DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("prepareDevInformCmd 0x")); DBGPRINT(F("prepareDevInformCmd 0x"));
DBGHEXLN(mPayload[iv->id].txCmd); DBGHEXLN(mPayload[iv->id].txCmd);

21
src/hm/miPayload.h

@ -1,6 +1,6 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// 2023 Ahoy, https://ahoydtu.de // 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__ #ifndef __MI_PAYLOAD_H__
@ -49,7 +49,7 @@ class MiPayload {
} }
mSerialDebug = false; mSerialDebug = false;
mHighPrioIv = NULL; mHighPrioIv = NULL;
mCbMiPayload = NULL; mCbPayload = NULL;
} }
void enableSerialDebug(bool enable) { void enableSerialDebug(bool enable) {
@ -57,7 +57,7 @@ class MiPayload {
} }
void addPayloadListener(miPayloadListenerType cb) { void addPayloadListener(miPayloadListenerType cb) {
mCbMiPayload = cb; mCbPayload = cb;
} }
void addAlarmListener(alarmListenerType cb) { void addAlarmListener(alarmListenerType cb) {
@ -434,8 +434,8 @@ class MiPayload {
private: private:
void notify(uint8_t val, Inverter<> *iv) { void notify(uint8_t val, Inverter<> *iv) {
if(NULL != mCbMiPayload) if(NULL != mCbPayload)
(mCbMiPayload)(val, iv); (mCbPayload)(val, iv);
} }
void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t stschan = CH1) { void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t stschan = CH1) {
@ -506,14 +506,11 @@ class MiPayload {
} }
/*if(AlarmData == mPayload[iv->id].txCmd) { /*if(AlarmData == mPayload[iv->id].txCmd) {
uint8_t i = 0; uint8_t i = 0;
uint16_t code;
uint32_t start, end;
while(1) { while(1) {
code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); if(0 == iv->parseAlarmLog(i++, payload, payloadLen))
if(0 == code)
break; break;
if (NULL != mCbAlarm) if (NULL != mCbAlarm)
(mCbAlarm)(code, start, end); (mCbAlarm)(iv);
yield(); yield();
} }
}*/ }*/
@ -789,10 +786,10 @@ const byteAssign_t InfoAssignment[] = {
uint32_t *mTimestamp; uint32_t *mTimestamp;
miPayload_t mPayload[MAX_NUM_INVERTERS]; miPayload_t mPayload[MAX_NUM_INVERTERS];
bool mSerialDebug; bool mSerialDebug;
Inverter<> *mHighPrioIv; Inverter<> *mHighPrioIv;
alarmListenerType mCbAlarm; alarmListenerType mCbAlarm;
payloadListenerType mCbMiPayload; payloadListenerType mCbPayload;
}; };
#endif /*__MI_PAYLOAD_H__*/ #endif /*__MI_PAYLOAD_H__*/

3
src/web/RestApi.h

@ -107,7 +107,7 @@ class RestApi {
getIvAlarms(root, request->url().substring(20).toInt()); getIvAlarms(root, request->url().substring(20).toInt());
else if(path.substring(0, 17) == "inverter/version/") else if(path.substring(0, 17) == "inverter/version/")
getIvVersion(root, request->url().substring(22).toInt()); 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()); getIvStatistis(root, request->url().substring(24).toInt());
else else
getNotFound(root, F("http://") + request->host() + F("/api/")); getNotFound(root, F("http://") + request->host() + F("/api/"));
@ -317,6 +317,7 @@ class RestApi {
obj[F("error")] = F("inverter not found!"); obj[F("error")] = F("inverter not found!");
return; return;
} }
obj[F("name")] = String(iv->config->name);
obj[F("rx_success")] = iv->radioStatistics.rxSuccess; obj[F("rx_success")] = iv->radioStatistics.rxSuccess;
obj[F("rx_fail")] = iv->radioStatistics.rxFail; obj[F("rx_fail")] = iv->radioStatistics.rxFail;
obj[F("rx_fail_answer")] = iv->radioStatistics.rxFailNoAnser; 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: "; var ageInfo = "Last received data requested at: ";
if(ts > 0) { if(obj.ts_last_success > 0) {
var date = new Date(ts * 1000); var date = new Date(obj.ts_last_success * 1000);
ageInfo += toIsoDateStr(date); ageInfo += toIsoDateStr(date);
} }
else else
ageInfo += "nothing received"; ageInfo += "nothing received";
if(rssi > -127) { if(obj.rssi > -127) {
if(gen < 2) if(obj.generation < 2)
ageInfo += " (RSSI: " + ((rssi == -64) ? ">=" : "<") + " -64dBm)"; ageInfo += " (RSSI: " + ((obj.rssi == -64) ? ">=" : "<") + " -64dBm)";
else else
ageInfo += " (RSSI: " + rssi + "dBm)"; ageInfo += " (RSSI: " + obj.rssi + "dBm)";
} }
return ml("div", {class: "mb-5"}, [ return ml("div", {class: "mb-5"}, [
@ -220,7 +220,7 @@
ml("div", {}, [ ml("div", {}, [
ivHead(obj), ivHead(obj),
ml("div", {class: "row mb-2"}, chn), 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) 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) { function parse(obj) {

Loading…
Cancel
Save