diff --git a/src/driver/drv_bl_shared.c b/src/driver/drv_bl_shared.c
index d6b8b6ec4..4c9d3ebe3 100644
--- a/src/driver/drv_bl_shared.c
+++ b/src/driver/drv_bl_shared.c
@@ -68,6 +68,9 @@ float changeSendThresholds[OBK_NUM_MEASUREMENTS] = {
int changeSendAlwaysFrames = 60;
int changeDoNotSendMinFrames = 5;
+float g_apparentPower;
+float g_powerFactor;
+float g_reactivePower;
void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request)
{
@@ -107,27 +110,27 @@ void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request)
"
| Energy Today |
#include "../driver/drv_ntp.h"
#include "../driver/drv_local.h"
+#include "../driver/drv_bl_shared.h"
void JSON_PrintKeyValue_String(void* request, jsonCb_t printer, const char *key, const char *value, bool bComma) {
printer(request, "\"%s\":\"%s\"", key, value);
@@ -223,10 +224,11 @@ static int http_tasmota_json_ENERGY(void* request, jsonCb_t printer) {
if (OBK_IS_NAN(energy_hour)) {
energy_hour = 0;
}
+
printer(request, "{");
printer(request, "\"Power\": %f,", power);
- printer(request, "\"ApparentPower\": 0,");
- printer(request, "\"ReactivePower\": 0,");
+ printer(request, "\"ApparentPower\": $f,", g_apparentPower);
+ printer(request, "\"ReactivePower\": %f,", g_reactivePower);
printer(request, "\"Factor\":%f,", factor);
printer(request, "\"Voltage\":%f,", voltage);
printer(request, "\"Current\":%f,", current);
@@ -298,7 +300,11 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
}
return 0;
}
-
+// Test command: http://192.168.0.159/cm?cmnd=STATUS%208
+// For a device without sensors, it returns (on Tasmota):
+/*
+{"StatusSNS":{"Time":"2023-04-10T10:19:55"}}
+*/
static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bAppendHeader) {
char buff[20];
@@ -439,11 +445,13 @@ static int http_tasmota_json_status_TIM(void* request, jsonCb_t printer) {
printer(request, "}");
return 0;
}
+// Test command: http://192.168.0.159/cm?cmnd=STATUS%202
static int http_tasmota_json_status_FWR(void* request, jsonCb_t printer) {
printer(request, "\"StatusFWR\":{");
JSON_PrintKeyValue_String(request, printer, "Version", DEVICENAME_PREFIX_FULL"_"USER_SW_VER, true);
JSON_PrintKeyValue_String(request, printer, "BuildDateTime", __DATE__" "__TIME__, true);
+ // NOTE: what is this value? It's not a reboot count
JSON_PrintKeyValue_Int(request, printer, "Boot", 7, true);
JSON_PrintKeyValue_String(request, printer, "Core", "0.0", true);
JSON_PrintKeyValue_String(request, printer, "SDK", "obk", true);
@@ -453,6 +461,7 @@ static int http_tasmota_json_status_FWR(void* request, jsonCb_t printer) {
printer(request, "}");
return 0;
}
+// Test command: http://192.168.0.159/cm?cmnd=STATUS%204
static int http_tasmota_json_status_MEM(void* request, jsonCb_t printer) {
printer(request, "\"StatusMEM\":{");
JSON_PrintKeyValue_Int(request, printer, "ProgramSize", 616, true);
@@ -479,7 +488,10 @@ static int http_tasmota_json_status_MEM(void* request, jsonCb_t printer) {
printer(request, "}");
return 0;
}
+// Test command: http://192.168.0.159/cm?cmnd=STATUS%205
static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
+ char tmpMac[16];
+ HAL_GetMACStr(tmpMac);
printer(request, "\"StatusNET\":{");
JSON_PrintKeyValue_String(request, printer, "Hostname", CFG_GetShortDeviceName(), true);
@@ -488,7 +500,7 @@ static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
JSON_PrintKeyValue_String(request, printer, "Subnetmask", "255.255.255.0", true);
JSON_PrintKeyValue_String(request, printer, "DNSServer1", "192.168.0.1", true);
JSON_PrintKeyValue_String(request, printer, "DNSServer2", "0.0.0.0", true);
- JSON_PrintKeyValue_String(request, printer, "Mac", "10:52:1C:D7:9E:2C", true);
+ JSON_PrintKeyValue_String(request, printer, "Mac", tmpMac, true);
JSON_PrintKeyValue_Int(request, printer, "Webserver", 2, true);
JSON_PrintKeyValue_Int(request, printer, "HTTP_API", 1, true);
JSON_PrintKeyValue_Int(request, printer, "WifiConfig", 4, true);
@@ -496,6 +508,7 @@ static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
printer(request, "}");
return 0;
}
+// Test command: http://192.168.0.159/cm?cmnd=STATUS%206
static int http_tasmota_json_status_MQT(void* request, jsonCb_t printer) {
printer(request, "\"StatusMQT\":{");
@@ -631,7 +644,7 @@ static int http_tasmota_json_status_generic(void* request, jsonCb_t printer) {
printer(request, ",");
-
+ // Test command: http://192.168.0.159/cm?cmnd=STATUS%203
printer(request, "\"StatusLOG\":{");
printer(request, "\"SerialLog\":2,");
printer(request, "\"WebLog\":2,");
|