Refactor AddLog usage

This commit is contained in:
Theo Arends 2021-01-23 17:10:06 +01:00
parent efaed8046d
commit ac054ea666
94 changed files with 737 additions and 745 deletions

View File

@ -395,7 +395,6 @@ void RtcSecond(void)
Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: " D_UTC_TIME " %s, " D_DST_TIME " %s, " D_STD_TIME " %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
@ -410,7 +409,6 @@ void RtcSecond(void)
Rtc.millis = millis();
if ((Rtc.utc_time > (2 * 60 * 60)) && (last_sync < Rtc.utc_time - (2 * 60 * 60))) { // Every two hours a warning
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Not synced"));
last_sync = Rtc.utc_time;
}

View File

@ -174,7 +174,7 @@ uint32_t WcSetup(int32_t fsiz) {
if (Wc.up) {
esp_camera_deinit();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Deinit"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Deinit"));
//return Wc.up;
}
Wc.up = 0;
@ -207,7 +207,7 @@ uint32_t WcSetup(int32_t fsiz) {
config.pin_pwdn = (PinUsed(GPIO_WEBCAM_PWDN)) ? Pin(GPIO_WEBCAM_PWDN) : -1; // PWDN_GPIO_NUM;
config.pin_reset = (PinUsed(GPIO_WEBCAM_RESET)) ? Pin(GPIO_WEBCAM_RESET) : -1; // RESET_GPIO_NUM;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: User template"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: User template"));
} else {
// defaults to AI THINKER
config.pin_d0 = Y2_GPIO_NUM;
@ -226,7 +226,7 @@ uint32_t WcSetup(int32_t fsiz) {
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Default template"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Default template"));
}
//ESP.getPsramSize()
@ -241,15 +241,15 @@ uint32_t WcSetup(int32_t fsiz) {
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 10;
config.fb_count = 2;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM found"));
} else {
config.frame_size = FRAMESIZE_VGA;
config.jpeg_quality = 12;
config.fb_count = 1;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM not found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM not found"));
}
// AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: heap check 1: %d"),ESP_getFreeHeap());
// AddLog(LOG_LEVEL_INFO, PSTR("CAM: heap check 1: %d"),ESP_getFreeHeap());
// stupid workaround camera diver eats up static ram should prefer PSRAM
// so we steal static ram to force driver to alloc PSRAM
@ -260,11 +260,11 @@ uint32_t WcSetup(int32_t fsiz) {
if (x) { free(x); }
if (err != ESP_OK) {
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Init failed with error 0x%x"), err);
AddLog(LOG_LEVEL_INFO, PSTR("CAM: Init failed with error 0x%x"), err);
return 0;
}
// AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: heap check 2: %d"),ESP_getFreeHeap());
// AddLog(LOG_LEVEL_INFO, PSTR("CAM: heap check 2: %d"),ESP_getFreeHeap());
sensor_t * wc_s = esp_camera_sensor_get();
@ -279,7 +279,7 @@ uint32_t WcSetup(int32_t fsiz) {
camera_fb_t *wc_fb = esp_camera_fb_get();
if (!wc_fb) {
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Init failed to get the frame on time"));
AddLog(LOG_LEVEL_INFO, PSTR("CAM: Init failed to get the frame on time"));
return 0;
}
Wc.width = wc_fb->width;
@ -290,7 +290,7 @@ uint32_t WcSetup(int32_t fsiz) {
fd_init();
#endif
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Initialized"));
AddLog(LOG_LEVEL_INFO, PSTR("CAM: Initialized"));
Wc.up = 1;
if (psram) { Wc.up = 2; }
@ -513,7 +513,7 @@ uint32_t WcDetectFace(void) {
image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
if (!image_matrix) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: dl_matrix3du_alloc failed"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: dl_matrix3du_alloc failed"));
esp_camera_fb_return(fb);
return ESP_FAIL;
}
@ -527,7 +527,7 @@ uint32_t WcDetectFace(void) {
esp_camera_fb_return(fb);
if (!s){
dl_matrix3du_free(image_matrix);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: to rgb888 failed"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: to rgb888 failed"));
return ESP_FAIL;
}
@ -594,7 +594,7 @@ uint32_t WcGetFrame(int32_t bnum) {
wc_fb = esp_camera_fb_get();
if (!wc_fb) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Can't get frame"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Can't get frame"));
return 0;
}
if (!bnum) {
@ -625,7 +625,7 @@ pcopy:
memcpy(Wc.picstore[bnum].buff, _jpg_buf, _jpg_buf_len);
Wc.picstore[bnum].len = _jpg_buf_len;
} else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Can't allocate picstore"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Can't allocate picstore"));
Wc.picstore[bnum].len = 0;
}
if (wc_fb) { esp_camera_fb_return(wc_fb); }
@ -669,20 +669,20 @@ void HandleImage(void) {
} else {
bnum--;
if (!Wc.picstore[bnum].len) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: No image #: %d"), bnum);
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: No image #: %d"), bnum);
return;
}
client.write((char *)Wc.picstore[bnum].buff, Wc.picstore[bnum].len);
}
client.stop();
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Sending image #: %d"), bnum+1);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Sending image #: %d"), bnum+1);
}
void HandleImageBasic(void) {
if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP "Capture image"));
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP "Capture image"));
if (Settings.webcam_config.stream) {
if (!Wc.CamServer) {
@ -693,7 +693,7 @@ void HandleImageBasic(void) {
camera_fb_t *wc_fb;
wc_fb = esp_camera_fb_get(); // Acquire frame
if (!wc_fb) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Frame buffer could not be acquired"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Frame buffer could not be acquired"));
return;
}
@ -720,16 +720,16 @@ void HandleImageBasic(void) {
esp_camera_fb_return(wc_fb); // Free frame buffer
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Image sent"));
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Image sent"));
}
void HandleWebcamMjpeg(void) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Handle camserver"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Handle camserver"));
// if (!Wc.stream_active) {
// always restart stream
Wc.stream_active = 1;
Wc.client = Wc.CamServer->client();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Create client"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Create client"));
// }
}
@ -743,13 +743,13 @@ void HandleWebcamMjpegTask(void) {
bool jpeg_converted = false;
if (!Wc.client.connected()) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Client fail"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Client fail"));
Wc.stream_active = 0;
}
if (1 == Wc.stream_active) {
Wc.client.flush();
Wc.client.setTimeout(3);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
Wc.client.print("HTTP/1.1 200 OK\r\n"
"Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY "\r\n"
"\r\n");
@ -758,7 +758,7 @@ void HandleWebcamMjpegTask(void) {
if (2 == Wc.stream_active) {
wc_fb = esp_camera_fb_get();
if (!wc_fb) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Frame fail"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Frame fail"));
Wc.stream_active = 0;
}
}
@ -766,7 +766,7 @@ void HandleWebcamMjpegTask(void) {
if (wc_fb->format != PIXFORMAT_JPEG) {
jpeg_converted = frame2jpg(wc_fb, 80, &_jpg_buf, &_jpg_buf_len);
if (!jpeg_converted){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: JPEG compression failed"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: JPEG compression failed"));
_jpg_buf_len = wc_fb->len;
_jpg_buf = wc_fb->buf;
}
@ -783,7 +783,7 @@ void HandleWebcamMjpegTask(void) {
if (tlen!=_jpg_buf_len) {
esp_camera_fb_return(wc_fb);
Wc.stream_active=0;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Send fail"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Send fail"));
}*/
Wc.client.print("\r\n--" BOUNDARY "\r\n");
@ -800,10 +800,10 @@ void HandleWebcamMjpegTask(void) {
if (jpeg_converted) { free(_jpg_buf); }
esp_camera_fb_return(wc_fb);
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: send frame"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: send frame"));
}
if (0 == Wc.stream_active) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
Wc.client.flush();
Wc.client.stop();
}
@ -813,7 +813,7 @@ void HandleWebcamRoot(void) {
//CamServer->redirect("http://" + String(ip) + ":81/cam.mjpeg");
Wc.CamServer->sendHeader("Location", WiFi.localIP().toString() + ":81/cam.mjpeg");
Wc.CamServer->send(302, "", "");
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Root called"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Root called"));
}
/*********************************************************************************************/
@ -830,7 +830,7 @@ uint32_t WcSetStreamserver(uint32_t flag) {
Wc.CamServer->on("/cam.mjpeg", HandleWebcamMjpeg);
Wc.CamServer->on("/cam.jpg", HandleWebcamMjpeg);
Wc.CamServer->on("/stream", HandleWebcamMjpeg);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream init"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream init"));
Wc.CamServer->begin();
}
} else {
@ -838,7 +838,7 @@ uint32_t WcSetStreamserver(uint32_t flag) {
Wc.CamServer->stop();
delete Wc.CamServer;
Wc.CamServer = NULL;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
}
}
return 0;
@ -868,7 +868,7 @@ void WcLoop(void) {
Wc.rtspp = new WiFiServer(8554);
Wc.rtspp->begin();
Wc.rtsp_start = 1;
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP init"));
AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP init"));
Wc.rtsp_lastframe_time = millis();
}
@ -881,7 +881,7 @@ void WcLoop(void) {
if ((now-Wc.rtsp_lastframe_time) > RTSP_FRAME_TIME) {
Wc.rtsp_session->broadcastCurrentFrame(now);
Wc.rtsp_lastframe_time = now;
// AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP session frame"));
// AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP session frame"));
}
if (Wc.rtsp_session->m_stopped) {
@ -889,7 +889,7 @@ void WcLoop(void) {
delete Wc.rtsp_streamer;
Wc.rtsp_session = NULL;
Wc.rtsp_streamer = NULL;
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP stopped"));
AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP stopped"));
}
}
else {
@ -897,7 +897,7 @@ void WcLoop(void) {
if (Wc.rtsp_client) {
Wc.rtsp_streamer = new OV2640Streamer(&Wc.rtsp_client, Wc.cam); // our streamer for UDP/TCP based RTP transport
Wc.rtsp_session = new CRtspSession(&Wc.rtsp_client, Wc.rtsp_streamer); // our threads RTSP session and state
AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP stream created"));
AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP stream created"));
}
}
}

View File

@ -85,15 +85,15 @@ char eth_hostname[sizeof(TasmotaGlobal.hostname)];
void EthernetEvent(WiFiEvent_t event) {
switch (event) {
case SYSTEM_EVENT_ETH_START:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION));
AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION));
ETH.setHostname(eth_hostname);
break;
case SYSTEM_EVENT_ETH_CONNECTED:
AddLog_P(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED " at %dMbps%s"),
AddLog(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED " at %dMbps%s"),
ETH.linkSpeed(), (ETH.fullDuplex()) ? " Full Duplex" : "");
break;
case SYSTEM_EVENT_ETH_GOT_IP:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"),
AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"),
ETH.macAddress().c_str(), ETH.localIP().toString().c_str(), eth_hostname);
Settings.ipv4_address[1] = (uint32_t)ETH.gatewayIP();
Settings.ipv4_address[2] = (uint32_t)ETH.subnetMask();
@ -101,11 +101,11 @@ void EthernetEvent(WiFiEvent_t event) {
TasmotaGlobal.global_state.eth_down = 0;
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
AddLog_P(LOG_LEVEL_INFO, PSTR("ETH: Disconnected"));
AddLog(LOG_LEVEL_INFO, PSTR("ETH: Disconnected"));
TasmotaGlobal.global_state.eth_down = 1;
break;
case SYSTEM_EVENT_ETH_STOP:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Stopped"));
AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Stopped"));
TasmotaGlobal.global_state.eth_down = 1;
break;
default:
@ -116,7 +116,7 @@ void EthernetEvent(WiFiEvent_t event) {
void EthernetInit(void) {
if (!Settings.flag4.network_ethernet) { return; }
if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: No ETH MDC and/or ETH MDIO GPIO defined"));
AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: No ETH MDC and/or ETH MDIO GPIO defined"));
return;
}
@ -130,7 +130,7 @@ void EthernetInit(void) {
int eth_mdc = Pin(GPIO_ETH_PHY_MDC);
int eth_mdio = Pin(GPIO_ETH_PHY_MDIO);
if (!ETH.begin(Settings.eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings.eth_type, (eth_clock_mode_t)Settings.eth_clk_mode)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error"));
AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error"));
};
}

View File

@ -378,11 +378,11 @@ uint8_t data;
if (ttgo_globs.bma->isDoubleClick()) {
ttgo_globs.bma_double_click = true;
//AddLog_P(LOG_LEVEL_INFO, PSTR("double click"));
//AddLog(LOG_LEVEL_INFO, PSTR("double click"));
}
if (ttgo_globs.bma->isAnyNoMotion()) {
ttgo_globs.bma_click = true;
//AddLog_P(LOG_LEVEL_INFO, PSTR("click"));
//AddLog(LOG_LEVEL_INFO, PSTR("click"));
}
//! setp counter
@ -408,7 +408,7 @@ uint8_t data;
}
if (ttgo_globs.ttgo_power->isPEKShortPressIRQ()) {
ttgo_globs.bma_button = true;
//AddLog_P(LOG_LEVEL_INFO, PSTR("button press"));
//AddLog(LOG_LEVEL_INFO, PSTR("button press"));
}
ttgo_globs.ttgo_power->clearIRQ();
break;

View File

@ -96,7 +96,7 @@ void CORE2_Init(void) {
BreakTime(Rtc.utc_time, tmpTime);
Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
AddLog_P(LOG_LEVEL_INFO, PSTR("Set time from BM8563 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
AddLog(LOG_LEVEL_INFO, PSTR("Set time from BM8563 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
TasmotaGlobal.rules_flag.time_init = 1;
@ -276,8 +276,8 @@ void GetRtc(void) {
RtcTime.day_of_month = RTCdate.Date;
RtcTime.year = RTCdate.Year;
AddLog_P(LOG_LEVEL_INFO, PSTR("RTC: %02d:%02d:%02d"), RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
AddLog_P(LOG_LEVEL_INFO, PSTR("RTC: %02d.%02d.%04d"), RTCdate.Date, RTCdate.Month, RTCdate.Year);
AddLog(LOG_LEVEL_INFO, PSTR("RTC: %02d:%02d:%02d"), RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
AddLog(LOG_LEVEL_INFO, PSTR("RTC: %02d.%02d.%04d"), RTCdate.Date, RTCdate.Month, RTCdate.Year);
}
@ -321,7 +321,7 @@ void CORE2_EverySecond(void) {
if (Rtc.utc_time > START_VALID_TIME && core2_globs.tset==false && abs(Rtc.utc_time - Get_utc()) > 3) {
Set_utc(Rtc.utc_time);
AddLog_P(LOG_LEVEL_INFO, PSTR("Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
AddLog(LOG_LEVEL_INFO, PSTR("Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
core2_globs.tset = true;
}

View File

@ -174,11 +174,11 @@ void CpuLoadLoop(void)
#if defined(F_CPU) && (F_CPU == 160000000L)
int CPU_load = 100 - ( (CPU_loops*(1 + 30*TasmotaGlobal.sleep)) / (CPU_load_check *800) );
CPU_loops = CPU_loops / CPU_load_check;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
#else
int CPU_load = 100 - ( (CPU_loops*(1 + 30*TasmotaGlobal.sleep)) / (CPU_load_check *400) );
CPU_loops = CPU_loops / CPU_load_check;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
#endif
CPU_last_millis = CPU_last_loop_time;
CPU_loops = 0;
@ -202,7 +202,7 @@ void DebugFreeMem(void)
{
register uint32_t *sp asm("a1");
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data);
}
#endif // ESP8266
@ -212,7 +212,7 @@ void DebugFreeMem(void)
{
register uint8_t *sp asm("a1");
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), sp - pxTaskGetStackStart(NULL), XdrvMailbox.data);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), sp - pxTaskGetStackStart(NULL), XdrvMailbox.data);
}
#endif // ESP8266 - ESP32
@ -246,7 +246,7 @@ void DebugRtcDump(char* parms)
uint16_t srow = strtol(parms, &p, 16) / CFG_COLS;
uint16_t mrow = strtol(p, &p, 10);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
if (0 == mrow) { // Default only 8 lines
mrow = 8;
@ -298,7 +298,7 @@ void DebugDump(uint32_t start, uint32_t size) {
uint32_t srow = 0;
uint32_t mrow = maxrow;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
if (0 == mrow) { // Default only 8 lines
mrow = 8;
@ -349,7 +349,7 @@ void DebugCfgDump(char* parms)
uint16_t srow = strtol(parms, &p, 16) / CFG_COLS;
uint16_t mrow = strtol(p, &p, 10);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
if (0 == mrow) { // Default only 8 lines
mrow = 8;
@ -428,7 +428,7 @@ void DebugCfgPoke(char* parms)
uint32_t ndata32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + (buffer[address +1] << 8) + buffer[address];
AddLog_P(LOG_LEVEL_INFO, PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32);
AddLog(LOG_LEVEL_INFO, PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32);
}
void SetFlashMode(uint8_t mode)
@ -594,7 +594,7 @@ void CmndFlashDump(void)
for (uint32_t pos = start; pos < end; pos += bytes_per_cols) {
uint32_t* values = (uint32_t*)(pos);
AddLog_P(LOG_LEVEL_INFO, PSTR("%06X: %08X %08X %08X %08X %08X %08X %08X %08X"), pos - flash_start,
AddLog(LOG_LEVEL_INFO, PSTR("%06X: %08X %08X %08X %08X %08X %08X %08X %08X"), pos - flash_start,
DebugSwap32(values[0]), DebugSwap32(values[1]), DebugSwap32(values[2]), DebugSwap32(values[3]),
DebugSwap32(values[4]), DebugSwap32(values[5]), DebugSwap32(values[6]), DebugSwap32(values[7]));
}
@ -626,7 +626,7 @@ void CmndI2cWrite(void)
Wire.write(buffer[i]);
}
int result = Wire.endTransmission();
AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: Result %d"), result);
AddLog(LOG_LEVEL_INFO, PSTR("I2C: Result %d"), result);
}
}
ResponseCmndDone();

View File

@ -147,7 +147,7 @@ bool LcdPrintLog(void)
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
lcd->setCursor(0, last_row);
lcd->print(disp_screen_buffer[last_row]);

View File

@ -124,7 +124,7 @@ void Ssd1306PrintLog(void)
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
renderer->println(disp_screen_buffer[last_row]);
renderer->Updateframe();

View File

@ -95,7 +95,7 @@ void MatrixScrollLeft(char* txt, int loop)
// Horiz. position of text -- starts off right edge
mtx_x = 8 * mtx_matrices;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt);
disp_refresh = Settings.display_refresh;
case 2:
@ -265,7 +265,7 @@ void MatrixPrintLog(uint8_t direction)
i++;
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer);
mtx_done = 1;
}

View File

@ -118,7 +118,7 @@ void Ili9341InitDriver(void) {
Ili9341InitMode();
tft_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9341"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9341"));
}
}
@ -195,7 +195,7 @@ void Ili9341PrintLog(void) {
DisplayFillScreen(last_row);
tft->print(disp_screen_buffer[last_row]);
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
}
}
}

View File

@ -92,7 +92,7 @@ void EpdInitDriver29(void) {
#endif
epd_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 2.9"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 2.9"));
}
}
@ -134,7 +134,7 @@ void EpdPrintLog29(void)
renderer->DrawStringAt(0, epd_scroll, disp_screen_buffer[last_row], COLORED, 0);
// EpdDisplayFrame();
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
}
}
}

View File

@ -96,7 +96,7 @@ void EpdInitDriver42() {
#endif
epd42_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2"));
}
}

View File

@ -119,7 +119,7 @@ void SH1106PrintLog(void)
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
renderer->println(disp_screen_buffer[last_row]);
renderer->Updateframe();

View File

@ -95,7 +95,7 @@ void ILI9488_InitDriver(void) {
#endif
ili9488_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9488"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9488"));
}
}

View File

@ -84,7 +84,7 @@ void SSD1351_InitDriver() {
color_type = COLOR_COLOR;
ssd1351_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1351"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: SSD1351"));
}
}
@ -110,7 +110,7 @@ void SSD1351PrintLog(void) {
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
renderer->println(disp_screen_buffer[last_row]);
renderer->Updateframe();

View File

@ -82,7 +82,7 @@ void RA8876_InitDriver(void) {
#endif
ra8876_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: RA8876"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: RA8876"));
}
}

View File

@ -136,7 +136,7 @@ void ST7789_InitDriver(void) {
#endif // ESP32
st7789_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ST7789"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: ST7789"));
}
}
@ -190,7 +190,7 @@ bool Xdsp12(uint8_t function)
{
bool result = false;
//AddLog_P(LOG_LEVEL_INFO, PSTR("touch %d - %d"), FT5206_found, function);
//AddLog(LOG_LEVEL_INFO, PSTR("touch %d - %d"), FT5206_found, function);
if (FUNC_DISPLAY_INIT_DRIVER == function) {
ST7789_InitDriver();

View File

@ -205,7 +205,7 @@ void ILI9341_2_PrintLog(bool withDateTime) {
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
renderer->println(disp_screen_buffer[last_row]);
renderer->Updateframe();

View File

@ -93,7 +93,7 @@ void SSD1331_InitDriver() {
color_type = COLOR_COLOR;
ssd1331_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1331"));
AddLog(LOG_LEVEL_INFO, PSTR("DSP: SSD1331"));
}
}
@ -128,7 +128,7 @@ void SSD1331PrintLog(bool withDateTime) {
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
renderer->println(disp_screen_buffer[last_row]);
renderer->Updateframe();

View File

@ -138,7 +138,7 @@ void My92x1ModuleSelected(void)
LightMy92x1Init();
TasmotaGlobal.light_driver = XLGT_02;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: MY29x1 Found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: MY29x1 Found"));
}
}

View File

@ -123,7 +123,7 @@ bool Sm16716SetChannels(void)
// handle any PWM pins, skipping the first 3 values for sm16716
for (uint32_t i = 3; i < Light.subtype; i++) {
if (PinUsed(GPIO_PWM1, i-3)) {
//AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol);
//AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol);
analogWrite(Pin(GPIO_PWM1, i-3), bitRead(TasmotaGlobal.pwm_inverted, i-3) ? Settings.pwm_range - cur_col_10bits[i] : cur_col_10bits[i]);
}
}
@ -177,7 +177,7 @@ void Sm16716ModuleSelected(void)
LightPwmOffset(LST_RGB); // Handle any PWM pins, skipping the first 3 color values for sm16716
TasmotaGlobal.light_type += LST_RGB; // Add RGB to be controlled by sm16716
TasmotaGlobal.light_driver = XLGT_03;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: SM16716 Found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: SM16716 Found"));
}
}

View File

@ -210,7 +210,7 @@ void Sm2135ModuleSelected(void)
TasmotaGlobal.light_type = LT_RGBWC;
TasmotaGlobal.light_driver = XLGT_04;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: SM2135 %s Found"), (SM2135_WCBGR == (Sm2135.model &1)) ? PSTR("BGR") : PSTR("GRB"));
AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: SM2135 %s Found"), (SM2135_WCBGR == (Sm2135.model &1)) ? PSTR("BGR") : PSTR("GRB"));
}
}

View File

@ -70,7 +70,7 @@ void SnfL1SendDelayed(void) {
void SnfL1Send(void)
{
#ifdef SONOFF_L1_DEBUG1
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer);
AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer);
#endif
Serial.print(Snfl1.buffer);
Serial.write(0x1B);
@ -87,7 +87,7 @@ void SnfL1SerialSendOk(void)
void SnfL1Send(const char *buffer)
{
#ifdef SONOFF_L1_DEBUG1
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), buffer);
AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), buffer);
#endif
Serial.print(buffer);
Serial.write(0x1B);
@ -119,7 +119,7 @@ bool SnfL1SerialInput(void)
// AT+UPDATE="sequence":"34906","switch":"on","light_type":1,"colorR":0,"colorG":16,"colorB":0,"bright":6,"mode":1
// AT+UPDATE="switch":"on","light_type":1,"colorR":255,"colorG":0,"colorB":0,"bright":6,"mode":1,"speed":100,"sensitive":10
#ifdef SONOFF_L1_DEBUG1
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer);
AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer);
#endif
if (!strncmp(TasmotaGlobal.serial_in_buffer +3, "RESULT", 6)) {
#ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT
@ -147,7 +147,7 @@ bool SnfL1SerialInput(void)
if (!strncmp(token2, "\"sequence\"", 10)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd sequence %s"), token3);
// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd sequence %s"), token3);
token = nullptr;
}
@ -155,7 +155,7 @@ bool SnfL1SerialInput(void)
else if (!strncmp(token2, "\"switch\"", 8)) {
switch_state = !strncmp(token3, "\"on\"", 4) ? true : false;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd switch %d (%d)"), switch_state, Light.power);
// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd switch %d (%d)"), switch_state, Light.power);
is_power_change = (switch_state != Light.power);
}
@ -178,7 +178,7 @@ bool SnfL1SerialInput(void)
bool all_color_channels_updated = color_updated[0] && color_updated[1] && color_updated[2];
if (all_color_channels_updated) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd color R%d G%d B%d (R%d G%d B%d)"),
// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd color R%d G%d B%d (R%d G%d B%d)"),
// Snfl1.color[0], Snfl1.color[1], Snfl1.color[2],
// Settings.light_color[0], Settings.light_color[1], Settings.light_color[2]);
@ -190,7 +190,7 @@ bool SnfL1SerialInput(void)
else if (!strncmp(token2, "\"bright\"", 8)) {
uint8_t dimmer = atoi(token3);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd dimmer %d (%d)"), dimmer, Settings.light_dimmer);
// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd dimmer %d (%d)"), dimmer, Settings.light_dimmer);
is_brightness_change = (Light.power && (dimmer > 0) && (dimmer != Settings.light_dimmer));
snprintf_P(cmnd_dimmer, sizeof(cmnd_dimmer), PSTR(D_CMND_DIMMER " %d"), dimmer);
@ -311,7 +311,7 @@ bool SnfL1ModuleSelected(void)
TasmotaGlobal.light_type = LT_RGB;
TasmotaGlobal.light_driver = XLGT_05;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found"));
return true;
}
}

View File

@ -74,7 +74,7 @@ void ElectriqMoodLModuleSelected(void)
SetSerial(9600, TS_SERIAL_8N1);
TasmotaGlobal.light_type = LT_RGBW;
TasmotaGlobal.light_driver = XLGT_06;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: ElectriQ Mood Lamp Found"));
AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: ElectriQ Mood Lamp Found"));
}
}

View File

@ -164,7 +164,7 @@ void HlwEvery200ms(void)
}
}
uint32_t median = Hlw.debug[(Hlw.cf1_pulse_counter +1) / 2];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"),
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"),
Hlw.cf_power_pulse_length , Hlw.select_ui_flag, Hlw.cf1_pulse_counter, stemp, Hlw.cf1_summed_pulse_length, cf1_pulse_length, median);
#endif

View File

@ -68,7 +68,7 @@ void CseReceived(void) {
uint8_t header = Cse.rx_buffer[0];
if ((header & 0xFC) == 0xFC) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: Abnormal hardware"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: Abnormal hardware"));
return;
}
@ -165,7 +165,7 @@ void CseSerialInput(void) {
Cse.byte_counter--;
} while ((Cse.byte_counter > 2) && (0x5A != Cse.rx_buffer[1]));
if (0x5A != Cse.rx_buffer[1]) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: " D_CHECKSUM_FAILURE));
AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: " D_CHECKSUM_FAILURE));
Cse.received = false;
Cse.byte_counter = 0;
}
@ -208,7 +208,7 @@ void CseEverySecond(void) {
Energy.kWhtoday_delta += delta;
}
else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: Overload"));
AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: Overload"));
Cse.cf_pulses_last_time = CSE_PULSES_NOT_INITIALIZED;
}
EnergyUpdateToday();

View File

@ -138,15 +138,15 @@ bool PzemRecieve(uint8_t resp, float *data)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, len);
if (len != sizeof(PZEMCommand)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem comms timeout"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem comms timeout"));
return false;
}
if (buffer[6] != PzemCrc(buffer)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem crc error"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem crc error"));
return false;
}
if (buffer[0] != resp) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem bad response"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem bad response"));
return false;
}
@ -208,7 +208,7 @@ void PzemEvery250ms(void)
Pzem.read_state = 1;
}
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PZM: Retry %d"), 5 - Pzem.send_retry);
// AddLog(LOG_LEVEL_DEBUG, PSTR("PZM: Retry %d"), 5 - Pzem.send_retry);
}
}
@ -220,7 +220,7 @@ void PzemEvery250ms(void)
Pzem.phase--;
}
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PZM: Probing address %d, Max phases %d"), Pzem.phase +1, Energy.phase_count);
// AddLog(LOG_LEVEL_DEBUG, PSTR("PZM: Probing address %d, Max phases %d"), Pzem.phase +1, Energy.phase_count);
}
if (Pzem.address) {

View File

@ -484,15 +484,15 @@ void McpSerialInput(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)mcp_buffer, mcp_byte_counter);
if (MCP_BUFFER_SIZE == mcp_byte_counter) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: Overflow"));
// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: Overflow"));
}
else if (1 == mcp_byte_counter) {
if (MCP_ERROR_CRC == mcp_buffer[0]) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: Send " D_CHECKSUM_FAILURE));
// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: Send " D_CHECKSUM_FAILURE));
mcp_timeout = 0;
}
else if (MCP_ERROR_NAK == mcp_buffer[0]) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: NAck"));
// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: NAck"));
mcp_timeout = 0;
}
}
@ -500,7 +500,7 @@ void McpSerialInput(void)
if (mcp_byte_counter == mcp_buffer[1]) {
if (McpChecksum((uint8_t *)mcp_buffer) != mcp_buffer[mcp_byte_counter -1]) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: " D_CHECKSUM_FAILURE));
AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: " D_CHECKSUM_FAILURE));
} else {
if (5 == mcp_buffer[1]) { McpAddressReceive(); }
if (25 == mcp_buffer[1]) { McpParseData(); }

View File

@ -63,7 +63,7 @@ void PzemAcEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, PzemAcModbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PAC: PzemAc %d error %d"), PZEM_AC_DEVICE_ADDRESS + PzemAc.phase, error);
AddLog(LOG_LEVEL_DEBUG, PSTR("PAC: PzemAc %d error %d"), PZEM_AC_DEVICE_ADDRESS + PzemAc.phase, error);
} else {
Energy.data_valid[PzemAc.phase] = 0;
if (10 == registers) {

View File

@ -62,7 +62,7 @@ void PzemDcEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, PzemDcModbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PDC: PzemDc %d error %d"), PZEM_DC_DEVICE_ADDRESS + PzemDc.channel, error);
AddLog(LOG_LEVEL_DEBUG, PSTR("PDC: PzemDc %d error %d"), PZEM_DC_DEVICE_ADDRESS + PzemDc.channel, error);
} else {
Energy.data_valid[PzemDc.channel] = 0;
if (8 == registers) {

View File

@ -131,7 +131,7 @@ void Ade7953GetData(void)
reg[i >> 2][i &3] = value;
}
}
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ADE: %d, %d, [%d, %d, %d, %d], [%d, %d, %d, %d]"),
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ADE: %d, %d, [%d, %d, %d, %d], [%d, %d, %d, %d]"),
Ade7953.voltage_rms, Ade7953.period,
reg[0][0], reg[0][1], reg[0][2], reg[0][3],
reg[1][0], reg[1][1], reg[1][2], reg[1][3]);
@ -154,7 +154,7 @@ void Ade7953GetData(void)
uint32_t current_rms_sum = Ade7953.current_rms[0] + Ade7953.current_rms[1];
uint32_t active_power_sum = Ade7953.active_power[0] + Ade7953.active_power[1];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"),
AddLog(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"),
Ade7953.voltage_rms, Ade7953.period,
Ade7953.current_rms[0], Ade7953.current_rms[1], current_rms_sum,
Ade7953.active_power[0], Ade7953.active_power[1], active_power_sum);

View File

@ -83,7 +83,7 @@ void SDM120Every250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm120Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: SDM120 error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM120 error %d"), error);
} else {
Energy.data_valid[0] = 0;

View File

@ -50,7 +50,7 @@ void Dds2382EverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Dds2382Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "DDS2382 response error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "DDS2382 response error %d"), error);
} else {
Energy.data_valid[0] = 0;

View File

@ -86,7 +86,7 @@ void SDM630Every250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm630Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: SDM630 error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM630 error %d"), error);
} else {
Energy.data_valid[0] = 0;
Energy.data_valid[1] = 0;

View File

@ -67,7 +67,7 @@ void DDSU666Every250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Ddsu666Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: Ddsu666 error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: Ddsu666 error %d"), error);
} else {
Energy.data_valid[0] = 0;

View File

@ -257,7 +257,7 @@ void solaxX1250MSecond(void) // Every 250 milliseconds
DEBUG_SENSOR_LOG(PSTR("SX1: Data response CRC error"));
}
else
{
{
solaxX1_send_retry = 20;
Energy.data_valid[0] = 0;
@ -380,7 +380,7 @@ void solaxX1250MSecond(void) // Every 250 milliseconds
void solaxX1SnsInit(void)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SX1: Solax X1 Inverter Init"));
AddLog(LOG_LEVEL_DEBUG, PSTR("SX1: Solax X1 Inverter Init"));
DEBUG_SENSOR_LOG(PSTR("SX1: RX pin: %d, TX pin: %d"), Pin(GPIO_SOLAXX1_RX), Pin(GPIO_SOLAXX1_TX));
protocolStatus.status = 0b00100000; // hasAddress

View File

@ -123,7 +123,7 @@ void FifLEEvery250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, FifLEModbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("FiF-LE: LE01MR Modbus error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("FiF-LE: LE01MR Modbus error %d"), error);
} else {
Energy.data_valid[0] = 0;

View File

@ -86,7 +86,7 @@ void Bl0940Received(void) {
if ((Bl0940.rx_buffer[0] != BL0940_PACKET_HEADER) || // Bad header
(Bl0940.tps1 && ((tps1 < (Bl0940.tps1 -10)) || (tps1 > (Bl0940.tps1 +10)))) // Invalid temperature change
) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Invalid data"));
AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Invalid data"));
return;
}
@ -101,7 +101,7 @@ void Bl0940Received(void) {
int32_t cf_cnt = Bl0940.rx_buffer[24] << 24 | Bl0940.rx_buffer[23] << 16 | Bl0940.rx_buffer[22] << 8; // CF_CNT signed
Bl0940.cf_pulses = abs(cf_cnt) >> 8;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: U %d, I %d, P %d, C %d, T %d"),
AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: U %d, I %d, P %d, C %d, T %d"),
Bl0940.voltage, Bl0940.current, Bl0940.power, Bl0940.cf_pulses, Bl0940.tps1);
if (Energy.power_on) { // Powered on
@ -149,7 +149,7 @@ void Bl0940SerialInput(void) {
Bl0940.byte_counter--;
} while ((Bl0940.byte_counter > 1) && (BL0940_PACKET_HEADER != Bl0940.rx_buffer[0]));
if (BL0940_PACKET_HEADER != Bl0940.rx_buffer[0]) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: " D_CHECKSUM_FAILURE));
AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: " D_CHECKSUM_FAILURE));
Bl0940.received = false;
Bl0940.byte_counter = 0;
}
@ -191,7 +191,7 @@ void Bl0940EverySecond(void) {
Bl0940.cf_pulses_last_time = Bl0940.cf_pulses;
Energy.kWhtoday_delta += delta;
} else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Overload"));
AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Overload"));
Bl0940.cf_pulses_last_time = BL0940_PULSES_NOT_INITIALIZED;
}
EnergyUpdateToday();
@ -200,7 +200,7 @@ void Bl0940EverySecond(void) {
}
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Poll"));
// AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Poll"));
Bl0940Serial->flush();
Bl0940Serial->write(BL0940_READ_COMMAND);

View File

@ -158,7 +158,7 @@ void ADPSCallback(uint8_t phase)
// Publish adding ADCO serial number into the topic
MqttPublishPrefixTopic_P(RESULT_OR_TELE, serialNumber, false);
AddLog_P(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase);
AddLog(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase);
}
/* ======================================================================
@ -187,7 +187,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
if (flags & TINFO_FLAGS_ADDED) { c = '#'; }
if (flags & TINFO_FLAGS_UPDATED) { c = '*'; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value);
if (ilabel<LABEL_END) {
@ -202,19 +202,19 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
break;
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif changed, now '%s' (%d)"), me->value, tarif);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif changed, now '%s' (%d)"), me->value, tarif);
}
// Current tariff (standard is in clear text in value)
else if (ilabel == LABEL_LTARF)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif name changed, now '%s'"), me->value);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif name changed, now '%s'"), me->value);
}
// Current tariff (standard index is is in clear text in value)
else if (ilabel == LABEL_NTARF)
{
tarif = atoi(me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif index changed, now '%d'"), tarif);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif index changed, now '%d'"), tarif);
}
@ -223,21 +223,21 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
{
Energy.voltage_available = true;
Energy.voltage[0] = (float) atoi(me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s, now %d"), me->value, (int) Energy.voltage[0]);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s, now %d"), me->value, (int) Energy.voltage[0]);
}
// Current I
else if (ilabel == LABEL_IINST || ilabel == LABEL_IRMS1)
{
Energy.current[0] = (float) atoi(me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s, now %d"), me->value, (int) Energy.current[0]);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s, now %d"), me->value, (int) Energy.current[0]);
}
// Power P
else if (ilabel == LABEL_PAPP || ilabel == LABEL_SINSTS)
{
Energy.active_power[0] = (float) atoi(me->value);;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]);
}
// Wh indexes (legacy)
@ -251,7 +251,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
// Base, un seul index
if (ilabel == LABEL_BASE) {
total = atoi(me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%u"), total);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%u"), total);
// Heures creuses/pleines calculer total
} else {
// Heures creuses get heures pleines
@ -269,7 +269,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
}
}
total = hc + hp;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u HP:%u Total:%u"), hc, hp, total);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u HP:%u Total:%u"), hc, hp, total);
}
if (!Settings.flag4.teleinfo_rawdata) {
@ -284,17 +284,17 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
if (!Settings.flag4.teleinfo_rawdata) {
EnergyUpdateTotal(total/1000.0f, true);
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%uWh"), total);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%uWh"), total);
}
// Wh indexes (standard)
else if ( ilabel == LABEL_EASF01)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u"), atoi(me->value));
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u"), atoi(me->value));
}
else if ( ilabel == LABEL_EASF02)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HP:%u"), atoi(me->value));
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HP:%u"), atoi(me->value));
}
// Contract subscribed (legacy)
@ -308,26 +308,26 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
break;
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s' (%d)"), me->value, contrat);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s' (%d)"), me->value, contrat);
}
// Contract subscribed (standard is in clear text in value)
else if (ilabel == LABEL_NGTF)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s'"), me->value);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s'"), me->value);
}
// Contract subscribed (Power)
else if (ilabel == LABEL_ISOUSC || ilabel == LABEL_PREF)
{
isousc = atoi( me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc);
}
// Serial Number of device
else if (ilabel == LABEL_ADCO || ilabel == LABEL_ADSC)
{
strcpy(serialNumber, me->value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber);
}
}
@ -447,20 +447,20 @@ void TInfoInit(void)
tinfo_mode = TINFO_MODE_HISTORIQUE;
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: inferface speed %d bps"),baudrate);
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: inferface speed %d bps"),baudrate);
if (PinUsed(GPIO_TELEINFO_RX)) {
uint8_t rx_pin = Pin(GPIO_TELEINFO_RX);
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d"), rx_pin);
AddLog(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d"), rx_pin);
// Enable Teleinfo pin used, control it
if (PinUsed(GPIO_TELEINFO_ENABLE)) {
uint8_t en_pin = Pin(GPIO_TELEINFO_ENABLE);
pinMode(en_pin, OUTPUT);
digitalWrite(en_pin, HIGH);
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
} else {
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: always enabled"));
AddLog(LOG_LEVEL_INFO, PSTR("TIC: always enabled"));
}
#ifdef ESP8266
@ -488,13 +488,13 @@ void TInfoInit(void)
//SetSerialConfig(TS_SERIAL_7E1);
//TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial"));
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial"));
} else {
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
}
#endif // ESP8266
#ifdef ESP32
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial"));
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial"));
#endif // ESP32
// Init teleinfo
tinfo.init(tinfo_mode);
@ -504,7 +504,7 @@ void TInfoInit(void)
tinfo.attachNewFrame(NewFrameCallback);
tinfo_found = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Ready"));
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Ready"));
}
}
}

View File

@ -76,7 +76,7 @@ void IEM3000Every250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Iem3000Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: Iem3000 error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: Iem3000 error %d"), error);
} else {
Energy.data_valid[0] = 0;

View File

@ -82,7 +82,7 @@ void WE517Every250ms(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, We517Modbus->ReceiveCount());
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 error %d"), error);
} else {
Energy.data_valid[0] = 0;
Energy.data_valid[1] = 0;
@ -188,7 +188,7 @@ void We517SnsInit(void)
uint8_t result = We517Modbus->Begin(WE517_SPEED);
if (result) {
if (2 == result) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED);
AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED);
Serial.begin(WE517_SPEED, SERIAL_8E1);
ClaimSerial();
}

View File

@ -105,10 +105,10 @@
#define ANALOG_PH_CALSOLUTION_LOW_PH 4.0
#define ANALOG_PH_CALSOLUTION_LOW_ANALOG_VALUE 282
// Default values for calibration solution with higher PH
#define ANALOG_PH_CALSOLUTION_HIGH_PH 9.18
#define ANALOG_PH_CALSOLUTION_HIGH_PH 9.18
#define ANALOG_PH_CALSOLUTION_HIGH_ANALOG_VALUE 435
// Multiplier used to store pH with 2 decimal places in a non decimal datatype
// Multiplier used to store pH with 2 decimal places in a non decimal datatype
#define ANALOG_PH_DECIMAL_MULTIPLIER 100.0
struct {
@ -343,14 +343,14 @@ float AdcGetPh(uint32_t idx) {
float m = (y2 - y1) / (x2 - x1);
float ph = m * (adc - x1) + y1;
char phLow_chr[6];
char phHigh_chr[6];
dtostrfd(y1, 2, phLow_chr);
dtostrfd(y2, 2, phHigh_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), adc, phLow_chr, x1, phHigh_chr,x2);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), adc, phLow_chr, x1, phHigh_chr,x2);
return ph;
}
@ -560,7 +560,7 @@ void AdcShow(bool json) {
char ph_chr[6];
dtostrfd(ph, 2, ph_chr);
if (json) {
AdcShowContinuation(&jsonflg);
ResponseAppend_P(PSTR("\"pH%d\":%s"), idx + offset, ph_chr);
@ -618,13 +618,13 @@ void CmndAdcParam(void) {
char *phHigh_chr = subStr(sub_string, XdrvMailbox.data, ",", 4);
float phLow = CharToFloat(phLow_chr);
float phHigh = CharToFloat(phHigh_chr);
Adc[idx].param1 = phLow * ANALOG_PH_DECIMAL_MULTIPLIER;
Adc[idx].param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
Adc[idx].param3 = phHigh * ANALOG_PH_DECIMAL_MULTIPLIER;
Adc[idx].param4 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), phLow_chr, Adc[idx].param2, phHigh_chr, Adc[idx].param4);
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), phLow_chr, Adc[idx].param2, phHigh_chr, Adc[idx].param4);
}
if (ADC_CT_POWER == XdrvMailbox.payload) {

View File

@ -62,7 +62,7 @@ void SonoffScSend(const char *data)
{
Serial.write(data);
Serial.write('\x1B');
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
}
void SonoffScInit(void)
@ -78,7 +78,7 @@ void SonoffScSerialInput(char *rcvstat)
char *str;
uint16_t value[5] = { 0 };
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) {
int8_t i = -1;

View File

@ -344,7 +344,7 @@ void Ds18x20Init(void)
}
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
}
void Ds18x20Convert(void)
@ -429,7 +429,7 @@ bool Ds18x20Read(uint8_t sensor)
}
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR));
return false;
}

View File

@ -58,7 +58,7 @@ void Ds18x20Init(void) {
ds = new OneWire(Pin(GPIO_DSB));
Ds18x20Search();
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
}
void Ds18x20Search(void) {
@ -144,7 +144,7 @@ bool Ds18x20Read(uint8_t sensor, float &t)
}
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR));
return false;
}

View File

@ -52,7 +52,7 @@ bool DhtWaitState(uint32_t sensor, uint32_t level)
unsigned long timeout = micros() + 100;
while (digitalRead(Dht[sensor].pin) != level) {
if (TimeReachedUsec(timeout)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_TIMEOUT_WAITING_FOR " %s " D_PULSE),
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_TIMEOUT_WAITING_FOR " %s " D_PULSE),
(level) ? D_START_SIGNAL_HIGH : D_START_SIGNAL_LOW);
return false;
}
@ -149,7 +149,7 @@ bool DhtRead(uint32_t sensor)
uint8_t checksum = (dht_data[0] + dht_data[1] + dht_data[2] + dht_data[3]) & 0xFF;
if (dht_data[4] != checksum) {
char hex_char[15];
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %s =? %02X"),
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %s =? %02X"),
ToHex_P(dht_data, 5, hex_char, sizeof(hex_char), ' '), checksum);
return false;
}
@ -171,7 +171,7 @@ bool DhtRead(uint32_t sensor)
break;
}
if (isnan(temperature) || isnan(humidity)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "Invalid NAN reading"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "Invalid NAN reading"));
return false;
}
@ -220,7 +220,7 @@ void DhtInit(void)
snprintf_P(Dht[i].stype, sizeof(Dht[i].stype), PSTR("%s%c%02d"), Dht[i].stype, IndexSeparator(), Dht[i].pin);
}
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "(v5) " D_SENSORS_FOUND " %d"), dht_sensors);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "(v5) " D_SENSORS_FOUND " %d"), dht_sensors);
} else {
dht_active = false;
}

View File

@ -86,7 +86,7 @@ bool ShtSendCommand(const uint8_t cmd)
}
if (ackerror) {
// sht_type = 0;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_DID_NOT_ACK_COMMAND));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_DID_NOT_ACK_COMMAND));
}
return (!ackerror);
}
@ -100,7 +100,7 @@ bool ShtAwaitResult(void)
}
delay(20);
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_BUSY));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_BUSY));
// sht_type = 0;
return false;
}
@ -163,7 +163,7 @@ void ShtDetect(void)
sht_scl_pin = Pin(GPIO_I2C_SCL);
if (ShtRead()) {
sht_type = 1;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C D_SHT1X_FOUND));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C D_SHT1X_FOUND));
} else {
Wire.begin(sht_sda_pin, sht_scl_pin);
sht_type = 0;

View File

@ -155,11 +155,11 @@ void Veml6070UvTableInit(void)
uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
} else {
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET);
}
#else
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT);
#endif
}
}
@ -187,7 +187,7 @@ void Veml6070ModeCmd(bool mode_cmd)
uint8_t status = Wire.endTransmission();
// action on status
if (!status) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 mode_cmd"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 mode_cmd"));
}
}
@ -231,7 +231,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level)
// out of range and much to high - it must be outerspace or sensor damaged
snprintf_P(str_uvrisk_text, sizeof(str_uvrisk_text), D_UV_INDEX_7);
return ( risk = 99 );
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk);
}
}

View File

@ -245,14 +245,14 @@ void Ads1115Show(bool json)
int16_t values[4];
for (uint32_t t = 0; t < sizeof(Ads1115.addresses); t++) {
//AddLog_P(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115.addresses[t]);
//AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115.addresses[t]);
if (Ads1115.found[t]) {
uint8_t old_address = Ads1115.address;
Ads1115.address = Ads1115.addresses[t];
for (uint32_t i = 0; i < 4; i++) {
values[i] = Ads1115GetConversion(i);
//AddLog_P(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115.address, i, values[i] );
//AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115.address, i, values[i] );
}
Ads1115.address = old_address;

View File

@ -74,7 +74,7 @@ const char kMhzModels[] PROGMEM = "|B";
const char ABC_ENABLED[] = "ABC is Enabled";
const char ABC_DISABLED[] = "ABC is Disabled";
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000, MHZ_CMND_RANGE_10000 };
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 };
const uint8_t kMhzCommands[][4] PROGMEM = {
// 2 3 6 7
{0x86,0x00,0x00,0x00}, // mhz_cmnd_read_ppm
@ -85,8 +85,7 @@ const uint8_t kMhzCommands[][4] PROGMEM = {
{0x99,0x00,0x03,0xE8}, // mhz_cmnd_set_range_1000
{0x99,0x00,0x07,0xD0}, // mhz_cmnd_set_range_2000
{0x99,0x00,0x0B,0xB8}, // mhz_cmnd_set_range_3000
{0x99,0x00,0x13,0x88}, // mhz_cmnd_set_range_5000
{0x99,0x00,0x27,0x10}}; // mhz_cmnd_set_range_10000
{0x99,0x00,0x13,0x88}}; // mhz_cmnd_set_range_5000
uint8_t mhz_type = 1;
uint16_t mhz_last_ppm = 0;
@ -136,7 +135,7 @@ bool MhzCheckAndApplyFilter(uint16_t ppm, uint8_t s)
if (1 == s) {
return false; // S==1 => "A" version sensor bootup, do not use values.
}
if (mhz_last_ppm < 400 || mhz_last_ppm > 10000) {
if (mhz_last_ppm < 400 || mhz_last_ppm > 5000) {
// Prevent unrealistic values during start-up with filtering enabled.
// Just assume the entered value is correct.
mhz_last_ppm = ppm;
@ -201,17 +200,17 @@ void MhzEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, mhz_response, counter);
if (counter < 9) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 comms timeout"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 comms timeout"));
return;
}
uint8_t crc = MhzCalculateChecksum(mhz_response);
if (mhz_response[8] != crc) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 crc error"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 crc error"));
return;
}
if (0xFF != mhz_response[0] || 0x86 != mhz_response[1]) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 bad response"));
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 bad response"));
return;
}
@ -270,7 +269,6 @@ void MhzEverySecond(void)
#define D_JSON_RANGE_2000 "2000 ppm range"
#define D_JSON_RANGE_3000 "3000 ppm range"
#define D_JSON_RANGE_5000 "5000 ppm range"
#define D_JSON_RANGE_10000 "10000 ppm range"
bool MhzCommandSensor(void)
{
@ -311,10 +309,6 @@ bool MhzCommandSensor(void)
MhzSendCmd(MHZ_CMND_RANGE_5000);
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_5000);
break;
case 10000:
MhzSendCmd(MHZ_CMND_RANGE_10000);
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_10000);
break;
default:
if (!Settings.SensorBits1.mhz19b_abc_disable) {
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED);

View File

@ -70,16 +70,16 @@ void Senseair250ms(void) // Every 250 mSec
if (data_ready) {
uint8_t error = SenseairModbus->Receive16BitRegister(&value);
if (error) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
} else {
switch(senseair_read_state) {
case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92
senseair_type = 2;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value);
break;
case 1: // 0x00 (0) READ_ERRORLOG - fe 04 02 00 00 ad 24
if (value) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value);
}
break;
case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59
@ -97,11 +97,11 @@ void Senseair250ms(void) // Every 250 mSec
case 5: // 0x1C (28) READ_RELAY_STATE - S8: fe 04 02 01 54 ad 4b - firmware version
{
bool relay_state = value >> 8 & 1;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state);
break;
}
case 6: // 0x0A (10) READ_TEMP_ADJUSTMENT - S8: fe 84 02 f2 f1 - Illegal Data Address
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
break;
}
}

View File

@ -145,7 +145,7 @@ bool PmsReadData(void)
#else
if (sum != buffer_u16[14]) {
#endif // PMS_MODEL_PMS3003
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PMS: " D_CHECKSUM_FAILURE));
AddLog(LOG_LEVEL_DEBUG, PSTR("PMS: " D_CHECKSUM_FAILURE));
return false;
}

View File

@ -82,7 +82,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
}
// char hex_char[60];
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDS: Send %s"), ToHex_P((unsigned char*)novasds_cmnd, 19, hex_char, sizeof(hex_char), ' '));
// AddLog(LOG_LEVEL_DEBUG, PSTR("SDS: Send %s"), ToHex_P((unsigned char*)novasds_cmnd, 19, hex_char, sizeof(hex_char), ' '));
// send cmnd
NovaSdsSerial->write(novasds_cmnd, sizeof(novasds_cmnd));
@ -115,7 +115,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
// checksum & tail check
if ((0xAB != recbuf[9] ) || (recbuf[8] != ((recbuf[2] + recbuf[3] + recbuf[4] + recbuf[5] + recbuf[6] + recbuf[7]) & 0xFF))) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDS: " D_CHECKSUM_FAILURE));
AddLog(LOG_LEVEL_DEBUG, PSTR("SDS: " D_CHECKSUM_FAILURE));
return false;
}

View File

@ -47,7 +47,7 @@ void sgp30_Init(void)
if (sgp.begin()) {
sgp30_type = true;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
// AddLog(LOG_LEVEL_DEBUG, PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
I2cSetActiveFound(SGP30_ADDRESS, "SGP30");
}
}
@ -97,7 +97,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
uint16_t eCO2_base;
if (!sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) return; // Failed to get baseline readings
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base);
// AddLog(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base);
}
}

View File

@ -71,7 +71,7 @@ uint8_t Sr04TModeDetect(void)
}
}
AddLog_P(LOG_LEVEL_INFO,PSTR("SR04: Mode %d"), sr04_type);
AddLog(LOG_LEVEL_INFO,PSTR("SR04: Mode %d"), sr04_type);
return sr04_type;
}
@ -123,7 +123,7 @@ uint16_t Sr04TMode2Distance(void)
//check crc sum
if (crc != sonar_serial->read()) {
AddLog_P(LOG_LEVEL_ERROR,PSTR("SR04: Reading CRC error."));
AddLog(LOG_LEVEL_ERROR,PSTR("SR04: Reading CRC error."));
return NO_ECHO;
}
//DEBUG_SENSOR_LOG(PSTR("SR04: Distance: %d"), distance);

View File

@ -1437,7 +1437,7 @@ int16_t readGesture(void) {
if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES) { // We will escape after a few loops
disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop
APDS9960_overload = true; // we report this as "long"-gesture
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Sensor overload"));
AddLog(LOG_LEVEL_DEBUG, PSTR("Sensor overload"));
}
gesture_loop_counter += 1;
@ -1453,7 +1453,7 @@ int16_t readGesture(void) {
fifo_level = I2cRead8(APDS9960_I2C_ADDR, APDS9960_GFLVL);
#ifdef USE_DEBUG_DRIVER
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Level : %d"), fifo_level);
AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Level : %d"), fifo_level);
#endif // USE_DEBUG_DRIVER
/* If there's stuff in the FIFO, read it into our data block */
@ -1471,7 +1471,7 @@ int16_t readGesture(void) {
for ( i = 0; i < bytes_read; i++ ) {
ptr += sprintf(ptr, "%02X", fifo_data[i]);
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Dump : %s"), output);
AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Dump : %s"), output);
#endif // USE_DEBUG_DRIVER
/* If at least 1 set of data, sort the data into U/D/L/R */
@ -1745,27 +1745,27 @@ void handleGesture(void) {
if (isGestureAvailable()) {
switch (readGesture()) {
case DIR_UP:
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_UP);
AddLog(LOG_LEVEL_DEBUG, GESTURE_UP);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_UP);
break;
case DIR_DOWN:
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_DOWN);
AddLog(LOG_LEVEL_DEBUG, GESTURE_DOWN);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_DOWN);
break;
case DIR_LEFT:
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_LEFT);
AddLog(LOG_LEVEL_DEBUG, GESTURE_LEFT);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_LEFT);
break;
case DIR_RIGHT:
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_RIGHT);
AddLog(LOG_LEVEL_DEBUG, GESTURE_RIGHT);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_RIGHT);
break;
default:
if (APDS9960_overload) {
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_LONG);
AddLog(LOG_LEVEL_DEBUG, GESTURE_LONG);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_LONG);
} else {
AddLog_P(LOG_LEVEL_DEBUG, GESTURE_NONE);
AddLog(LOG_LEVEL_DEBUG, GESTURE_NONE);
snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_NONE);
}
break;
@ -1812,7 +1812,7 @@ void APDS9960_detect(void) {
#ifdef USE_DEBUG_DRIVER
// Debug new chip
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: %s Chip %X"), APDS9960_TAG, APDS9960_type);
AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: %s Chip %X"), APDS9960_TAG, APDS9960_type);
#endif // USE_DEBUG_DRIVER
if (APDS9960_type == APDS9960_CHIPID_1 || APDS9960_type == APDS9960_CHIPID_2 || APDS9960_type == APDS9960_CHIPID_3) {

View File

@ -514,7 +514,7 @@ bool MCP230xx_Command(void)
if (Settings.mcp230xx_config[pin].int_count_en) {
Settings.mcp230xx_config[pin].int_count_en=0;
MCP230xx_CheckForIntCounter();
AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin);
}
Response_P(MCP230XX_INTCFG_RESPONSE,"DEF",pin,Settings.mcp230xx_config[pin].int_report_defer); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
return serviced;
@ -552,14 +552,14 @@ bool MCP230xx_Command(void)
Settings.mcp230xx_config[pin].int_count_en=intcnt;
if (Settings.mcp230xx_config[pin].int_report_defer) {
Settings.mcp230xx_config[pin].int_report_defer=0;
AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin);
}
if (Settings.mcp230xx_config[pin].int_report_mode < 3) {
Settings.mcp230xx_config[pin].int_report_mode=3;
AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin);
}
if ((Settings.mcp230xx_config[pin].int_count_en) && (!Settings.mcp230xx_int_timer)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin);
AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin);
}
MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts
Response_P(MCP230XX_INTCFG_RESPONSE,"CNT",pin,Settings.mcp230xx_config[pin].int_count_en); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
@ -803,7 +803,7 @@ void MCP230xx_SwitchRelay() {
uint8_t pin = mcp230xx_outpinmapping[i - (TasmotaGlobal.devices_present - mcp230xx_oldoutpincount)];
uint8_t pincmd = Settings.mcp230xx_config[pin].pinmode - 5;
uint8_t relay_state = bitRead(XdrvMailbox.index, i);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: relay %d pin_no %d state %d"), i,pin, relay_state);
AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: relay %d pin_no %d state %d"), i,pin, relay_state);
switch (relay_state) {
case 1:
MCP230xx_SetOutPin(pin,abs(pincmd-1));

View File

@ -293,7 +293,7 @@ void Mpr121Init(struct mpr121 *pS, bool initial)
// Check if sensor is running
pS->running[i] = (0x00 != I2cRead8(pS->i2c_addr[i], MPR121_ECR_REG));
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT");
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT");
} else {
@ -305,7 +305,7 @@ void Mpr121Init(struct mpr121 *pS, bool initial)
// Display no sensor found message
if (!(pS->connected[0] || pS->connected[1] || pS->connected[2]
|| pS->connected[3])) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found"));
}
} // void Mpr121Init(struct mpr121 *s)
@ -334,7 +334,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
// Read data
if (!I2cValidRead16LE(&pS->current[i], pS->i2c_addr[i], MPR121_ELEX_REG)) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]);
AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]);
Mpr121Init(pS, false);
return;
}
@ -343,7 +343,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
// Clear OVCF bit
I2cWrite8(pS->i2c_addr[i], MPR121_ELEX_REG, 0x00);
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
Mpr121Init(pS, false);
return;
}

View File

@ -142,7 +142,7 @@ void DS3231EverySecond(void)
RtcTime.year = tmpTime.year + 1970;
Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
AddLog_P(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
AddLog(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
TasmotaGlobal.rules_flag.time_init = 1;
@ -151,7 +151,7 @@ void DS3231EverySecond(void)
}
}
else if (!ds3231WriteStatus && Rtc.utc_time > START_VALID_TIME && abs(Rtc.utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second
AddLog_P(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
AddLog(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
SetDS3231Time (Rtc.utc_time); //update the DS3231 time
ds3231WriteStatus = true;

View File

@ -490,7 +490,7 @@ void HandleHxAction(void)
{
if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711));
if (Webserver->hasArg("save")) {
HxSaveSettings();
@ -549,7 +549,7 @@ void HxLogUpdates(void)
char weigth_item_chr[33];
dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr);
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr);
}
#endif // USE_HX711_GUI

View File

@ -247,31 +247,31 @@ void MGC3130_handleGesture(){
}
switch(MGC_data.out.gestureInfo.gestureCode){
case MGC3130_GESTURE_GARBAGE:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("NONE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("NONE"));
break;
case MGC3130_FLICK_WEST_EAST:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge);
//AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_WE"), edge);
break;
case MGC3130_FLICK_EAST_WEST:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge);
//AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_EW"), edge);
break;
case MGC3130_FLICK_SOUTH_NORTH:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge);
//AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_SN"), edge);
break;
case MGC3130_FLICK_NORTH_SOUTH:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge);
//AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_NS"), edge);
break;
case MGC3130_CIRCLE_CLOCKWISE:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("CW"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("CW"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CW"));
break;
case MGC3130_CIRCLE_CCLOCKWISE:
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("CCW"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("CCW"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CCW"));
break;
}
@ -280,101 +280,101 @@ void MGC3130_handleGesture(){
bool MGC3130_handleTouch(){
bool success = false; // if we find a touch of higher order, we are done
if (MGC_data.out.touchInfo.doubleTapCentre && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_C"));
MGC3130_touchTimeout = 5;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.doubleTapEast && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_E"));
MGC3130_touchTimeout = 5;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.doubleTapNorth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_N"));
MGC3130_touchTimeout = 5;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.doubleTapWest && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_W"));
MGC3130_touchTimeout = 5;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.doubleTapSouth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_S"));
MGC3130_touchTimeout = 5;
success = true;
MGC3130_touchCounter = 1;
}
if (MGC_data.out.touchInfo.tapCentre && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_C"));
MGC3130_touchTimeout = 2;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.tapEast && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_EAST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_E"));
MGC3130_touchTimeout = 2;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.tapNorth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_N"));
MGC3130_touchTimeout = 2;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.tapWest && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_WEST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_W"));
MGC3130_touchTimeout = 2;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.tapSouth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_S"));
MGC3130_touchTimeout = 2;
success = true;
MGC3130_touchCounter = 1;
}
else if (MGC_data.out.touchInfo.touchCentre && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_C"));
success = true;
MGC3130_touchCounter++; // This will reset to 0 after touching for approx. 1h and 50 minutes ;)
}
else if (MGC_data.out.touchInfo.touchEast && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_E"));
success = true;
MGC3130_touchCounter++;
}
else if (MGC_data.out.touchInfo.touchNorth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_N"));
success = true;
MGC3130_touchCounter++;
}
else if (MGC_data.out.touchInfo.touchWest && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_W"));
success = true;
MGC3130_touchCounter++;
}
else if (MGC_data.out.touchInfo.touchSouth && !success){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH"));
//AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_S"));
success = true;
MGC3130_touchCounter++;
@ -396,7 +396,7 @@ void MGC3130_handleAirWheel(){
}
void MGC3130_handleSystemStatus(){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MGC3130: system_status: response to ID:%02x, error code: %04x"),MGC_data.status.id, MGC_data.status.error);
AddLog(LOG_LEVEL_DEBUG,PSTR("MGC3130: system_status: response to ID:%02x, error code: %04x"),MGC_data.status.id, MGC_data.status.error);
}
bool MGC3130_receiveMessage(){
@ -414,7 +414,7 @@ bool MGC3130_receiveMessage(){
loaderVersion[1] = MGC_data.fw.loaderVersion[0];
loaderVersion[0] = MGC_data.fw.loaderVersion[1];
loaderPlatform = MGC_data.fw.loaderPlatform;
AddLog_P(LOG_LEVEL_INFO,PSTR("MGC3130: GestIC:%s"),MGC_data.fw.fwVersion);
AddLog(LOG_LEVEL_INFO,PSTR("MGC3130: GestIC:%s"),MGC_data.fw.fwVersion);
break;
}
MGC_data.out.id = 0;
@ -443,7 +443,7 @@ bool MGC3130_readData()
uint8_t _mismatch = MGC_data.out.counter - _lastCounter;
if(_mismatch != 1){
if(i>4 && MGC_data.out.id != MGC3130_FW_VERSION){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MGC3130: missed a packet, mismatch: %u"), _mismatch - 1);
AddLog(LOG_LEVEL_DEBUG,PSTR("MGC3130: missed a packet, mismatch: %u"), _mismatch - 1);
AddLogBuffer(LOG_LEVEL_DEBUG,MGC_data.buffer,i);
}
}

View File

@ -619,7 +619,7 @@ void RfSnsInit(void)
void RfSnsAnalyzeRawSignal(void)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number);
AddLog(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number);
#ifdef USE_THEO_V2
RfSnsAnalyzeTheov2();

View File

@ -166,14 +166,14 @@ void AzEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, az_response, counter);
if (!az_received) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 comms timeout"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 comms timeout"));
return;
}
i = 0;
while((az_response[i] != 'T') && (i < counter)) {i++;} // find the start of response
if(az_response[i] != 'T') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find start of response"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find start of response"));
return;
}
i++; // advance to start of temperature value
@ -183,7 +183,7 @@ void AzEverySecond(void)
response_substr[j++] = az_response[i++];
}
if((az_response[i] != 'C') && (az_response[i] != 'F')){
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of temperature"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of temperature"));
return;
}
response_substr[j] = 0; // add null terminator
@ -195,12 +195,12 @@ void AzEverySecond(void)
}
i++; // advance to first delimiter
if(az_response[i] != ':') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error first delimiter"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error first delimiter"));
return;
}
i++; // advance to start of CO2
if(az_response[i] != 'C') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of CO2"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of CO2"));
return;
}
i++; // advance to start of CO2 value
@ -210,7 +210,7 @@ void AzEverySecond(void)
response_substr[j++] = az_response[i++];
}
if(az_response[i] != 'p') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of CO2"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of CO2"));
return;
}
response_substr[j] = 0; // add null terminator
@ -220,12 +220,12 @@ void AzEverySecond(void)
#endif // USE_LIGHT
i += 3; // advance to second delimiter
if(az_response[i] != ':') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error second delimiter"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error second delimiter"));
return;
}
i++; // advance to start of humidity
if(az_response[i] != 'H') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of humidity"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of humidity"));
return;
}
i++; // advance to start of humidity value
@ -235,7 +235,7 @@ void AzEverySecond(void)
response_substr[j++] = az_response[i++];
}
if(az_response[i] != '%') {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of humidity"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of humidity"));
return;
}
response_substr[j] = 0; // add null terminator
@ -256,7 +256,7 @@ void AzEverySecond(void)
}
} while(((millis() - start) < AZ_READ_TIMEOUT));
az_clock_update = AZ_CLOCK_UPDATE_INTERVAL;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 clock updated"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 clock updated"));
} else {
az_clock_update--;
}

View File

@ -80,7 +80,7 @@ void PN532_Init(void) {
ToHex_P((unsigned char*)empty_uid, sizeof(empty_uid), Pn532.uids, sizeof(Pn532.uids));
PN532_setPassiveActivationRetries(0xFF);
PN532_SAMConfig();
AddLog_P(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF);
AddLog(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF);
Pn532.present = true;
}
}
@ -429,7 +429,7 @@ void PN532_ScanForTag(void) {
}
if (mifareclassic_WriteDataBlock(1, card_data)) {
erase_success = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success"));
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
}
}
@ -438,7 +438,7 @@ void PN532_ScanForTag(void) {
memcpy(&card_data,&Pn532.newdata,sizeof(card_data));
if (mifareclassic_WriteDataBlock(1, card_data)) {
set_success = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
}
#else
@ -453,11 +453,11 @@ void PN532_ScanForTag(void) {
card_data[Pn532.newdata_len] = '\0'; // Enforce null termination
if (mifareclassic_WriteDataBlock(1, card_data)) {
set_success = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
}
} else {
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric"));
}
#endif // USE_PN532_DATA_RAW
}
@ -468,12 +468,12 @@ void PN532_ScanForTag(void) {
switch (Pn532.function) {
case 0x01:
if (!erase_success) {
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode"));
}
break;
case 0x02:
if (!set_success) {
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode"));
}
default:
break;
@ -509,7 +509,7 @@ bool PN532_Command(void) {
UpperCase(XdrvMailbox.data,XdrvMailbox.data);
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) {
Pn532.function = 1; // Block 1 of next card/tag will be reset to 0x00...
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased"));
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased"));
ResponseTime_P(PSTR(",\"PN532\":{\"COMMAND\":\"E\"}}"));
return serviced;
}
@ -525,7 +525,7 @@ bool PN532_Command(void) {
memcpy(&Pn532.newdata,&sub_string_tmp,Pn532.newdata_len);
Pn532.newdata[Pn532.newdata_len] = 0x00; // Null terminate the string
Pn532.function = 2;
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), Pn532.newdata);
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), Pn532.newdata);
ResponseTime_P(PSTR(",\"PN532\":{\"COMMAND\":\"S\"}}"));
return serviced;
}

View File

@ -75,7 +75,7 @@ void Max4409Detect(void)
if ((I2cValidRead8(&buffer1, max44009_address, REG_LOWER_THRESHOLD)) &&
(I2cValidRead8(&buffer2, max44009_address, REG_THRESHOLD_TIMER))) {
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("MAX44009 %x: %x, %x"), max44009_address, (int)buffer1, (int)buffer2);
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MAX44009 %x: %x, %x"), max44009_address, (int)buffer1, (int)buffer2);
if ((0x00 == buffer1) &&
(0xFF == buffer2)) {

View File

@ -93,7 +93,7 @@ void Scd30Detect(void)
I2cSetActiveFound(SCD30_ADDRESS, "SCD30");
scd30Found = true;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SCD: FW v%d.%d"), major, minor);
AddLog(LOG_LEVEL_DEBUG, PSTR("SCD: FW v%d.%d"), major, minor);
}
// gets data from the sensor every 3 seconds or so to give the sensor time to gather new data

View File

@ -142,7 +142,7 @@ void hreEvery50ms(void)
sync_run = 0;
sync_counter = 0;
hre_state = hre_syncing;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing"));
break;
case hre_syncing:
@ -165,19 +165,19 @@ void hreEvery50ms(void)
if (sync_counter > 1000)
{
hre_state = hre_sleep;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE D_ERROR));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE D_ERROR));
}
break;
// Start reading the data block
case hre_read:
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "sync_run:%d, sync_counter:%d"), sync_run, sync_counter);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "sync_run:%d, sync_counter:%d"), sync_run, sync_counter);
read_counter = 0;
parity_errors = 0;
curr_start = TasmotaGlobal.uptime;
memset(buff, 0, sizeof(buff));
hre_state = hre_reading;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_reading"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_reading"));
// So this is intended to fall through to the hre_reading section.
// it seems that if there is much of a delay between getting the sync
// bits and starting the read, the HRE won't output the message we
@ -190,7 +190,7 @@ void hreEvery50ms(void)
if (read_counter == 46)
{
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"),
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"),
parity_errors, hre_read_errors, buff);
if (parity_errors == 0)
{
@ -218,7 +218,7 @@ void hreEvery50ms(void)
case hre_sleep:
hre_usage_time = curr_start;
hre_state = hre_sleeping;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping"));
case hre_sleeping:
// If there isn't some delay between readings, rate calculations

View File

@ -143,7 +143,7 @@ void SPS30_Detect(void)
uint8_t dcode[32];
sps30_get_data(SPS_CMD_GET_SERIAL,dcode,sizeof(dcode));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("sps30 found with serial: %s"),dcode);
AddLog(LOG_LEVEL_DEBUG, PSTR("sps30 found with serial: %s"),dcode);
sps30_cmd(SPS_CMD_START_MEASUREMENT);
sps30_running = 1;
sps30_ready = 1;

View File

@ -216,13 +216,13 @@ bool ChirpSet(uint8_t addr) {
chirp_timeout_count = 10;
chirp_next_job = 0;
if(chirp_sensor[chirp_current].version == 255){ // this should be Chirp! and it seems to need a power cycle (or RESET to GND)
AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: wrote new address %u, please power off device"), addr);
AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: wrote new address %u, please power off device"), addr);
chirp_sensor[chirp_current].version == 0; // make it "invisible"
}
return true;
}
}
AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: address %u incorrect and not used"), addr);
AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: address %u incorrect and not used"), addr);
return false;
}
@ -241,13 +241,13 @@ bool ChirpScan()
I2cSetActiveFound(address, "CHIRP");
if (chirp_found_sensors<CHIRP_MAX_SENSOR_COUNT) {
chirp_sensor[chirp_found_sensors].address = address; // push next sensor, as long as there is space in the array
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CHIRP: fw %x"), chirp_sensor[chirp_found_sensors].version);
AddLog(LOG_LEVEL_DEBUG, PSTR("CHIRP: fw %x"), chirp_sensor[chirp_found_sensors].version);
}
chirp_found_sensors++;
}
}
// chirp_timeout_count = 11; // wait a second to read the real fw-version in the next step
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Found %u CHIRP sensor(s)."), chirp_found_sensors);
AddLog(LOG_LEVEL_DEBUG, PSTR("Found %u CHIRP sensor(s)."), chirp_found_sensors);
return (chirp_found_sensors > 0);
}
@ -387,7 +387,7 @@ void ChirpEvery100MSecond(void)
DEBUG_SENSOR_LOG(PSTR("CHIRP: timeout 1/10 sec: %u, tele: %u"), chirp_timeout_count, Settings.tele_period);
}
else{
AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: TELEPERIOD must be > 16 seconds !"));
AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: TELEPERIOD must be > 16 seconds !"));
// we could overwrite it to i.e. 20 seconds here
}
chirp_next_job = 1; // back to step 1

View File

@ -317,7 +317,7 @@ void PAJ7620Detect(void)
uint8_t PAJ7620_ver = I2cRead8(PAJ7620_ADDR,2);
if (0x7620 == PAJ7620_id) { // this device ID makes sense ;)
I2cSetActiveFound(PAJ7620_ADDR, PAJ7620_name);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PAJ: ID: 0x%x and VER: %u"), PAJ7620_id, PAJ7620_ver);
AddLog(LOG_LEVEL_DEBUG, PSTR("PAJ: ID: 0x%x and VER: %u"), PAJ7620_id, PAJ7620_ver);
PAJ7620_next_job = 1; // now init
}
else {

View File

@ -192,7 +192,7 @@ class ESP32BLEScanCallback : public BLEAdvertisedDeviceCallbacks
uint8_t PWR = oBeacon.getSignalPower();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"),
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"),
"BLE",
advertisedDevice->getAddress().toString().c_str(),
Major, Minor,
@ -240,7 +240,7 @@ void ESP32StartScanTask(){
0, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),"BLE");
}
void ESP32scanEndedCB(NimBLEScanResults results);
@ -258,25 +258,25 @@ void ESP32ScanTask(void *pvParameters){
for (;;) {
vTaskDelay(10000/ portTICK_PERIOD_MS);
ESP32BLEScan->clearResults();
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Clear scanning results"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Clear scanning results"),"BLE");
}
}
void ESP32scanEndedCB(NimBLEScanResults results) {
ESP32BLE.mode.runningScan = 0;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Stop scanning"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Stop scanning"),"BLE");
}
void ESP32StopScanTask() {
ESP32BLEScan->stop();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Pausing scanner task"),"BLE");
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Pausing scanner task"),"BLE");
}
void ESP32ResumeScanTask() {
ESP32BLE.mode.runningScan = 1;
ESP32BLEScan->start(0, ESP32scanEndedCB, false);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Resumed scanner task"),"BLE");
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Resumed scanner task"),"BLE");
}
void ESP32Init() {
@ -285,11 +285,11 @@ void ESP32Init() {
TasmotaGlobal.wifi_stay_asleep = true;
if (WiFi.getSleep() == false) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE");
WiFi.setSleep(true); // Sleep
}
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE");
if (!ESP32BLE.mode.init) {
NimBLEDevice::init("");
@ -344,12 +344,12 @@ void esp32_every_second(void) {
if (TasmotaGlobal.ota_state_flag) {
if (ESP32BLE.mode.runningScan) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Upgrade procedure started"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Upgrade procedure started"),"BLE");
ESP32StopScanTask();
}
} else {
if (!ESP32BLE.mode.runningScan) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Resuming scan"),"BLE");
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Resuming scan"),"BLE");
ESP32ResumeScanTask();
}
}
@ -409,7 +409,7 @@ void hm17_sendcmd(uint8_t cmd) {
hm17_sbclr();
hm17_cmd=cmd;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd);
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd);
#endif
switch (cmd) {
case HM17_TEST:
@ -522,7 +522,7 @@ void hm17_decode(void) {
case HM17_TEST:
if (!strncmp(hm17_sbuffer,"OK",2)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("AT OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("AT OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -532,7 +532,7 @@ void hm17_decode(void) {
case HM17_ROLE:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("ROLE OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("ROLE OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -541,7 +541,7 @@ void hm17_decode(void) {
case HM17_IMME:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IMME OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IMME OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -550,7 +550,7 @@ void hm17_decode(void) {
case HM17_IBEA:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IBEA OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IBEA OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -559,7 +559,7 @@ void hm17_decode(void) {
case HM17_SCAN:
if (!strncmp(hm17_sbuffer,"OK+Set:5",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("SCAN OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("SCAN OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -568,7 +568,7 @@ void hm17_decode(void) {
case HM17_RESET:
if (!strncmp(hm17_sbuffer,"OK+RESET",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RESET OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RESET OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -577,7 +577,7 @@ void hm17_decode(void) {
case HM17_RENEW:
if (!strncmp(hm17_sbuffer,"OK+RENEW",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RENEW OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RENEW OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -587,7 +587,7 @@ void hm17_decode(void) {
if (!strncmp(hm17_sbuffer,"OK+CONNA",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNA OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNA OK"));
#endif
hm17_connecting=2;
break;
@ -595,21 +595,21 @@ void hm17_decode(void) {
if (!strncmp(hm17_sbuffer,"OK+CONNE",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNE ERROR"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNE ERROR"));
#endif
break;
}
if (!strncmp(hm17_sbuffer,"OK+CONNF",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNF ERROR"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNF ERROR"));
#endif
break;
}
if (hm17_connecting==2 && !strncmp(hm17_sbuffer,"OK+CONN",7)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONN OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONN OK"));
#endif
hm17_connecting=3;
hm17_sendcmd(HM17_TEST);
@ -624,7 +624,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=1;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCS OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCS OK"));
#endif
break;
}
@ -632,7 +632,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=1;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISIS OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISIS OK"));
#endif
break;
}
@ -640,7 +640,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCE OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCE OK"));
#endif
hm17_scanning=0;
break;
@ -650,8 +650,8 @@ void hm17_decode(void) {
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("NAME OK"));
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR("NAME OK"));
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
hm17_sbclr();
@ -668,8 +668,8 @@ void hm17_decode(void) {
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("DIS0 OK"));
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR("DIS0 OK"));
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
hm17_sbclr();
@ -683,9 +683,9 @@ hm17_v110:
if (hm17_sindex==78) {
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("DISC: OK"));
AddLog(LOG_LEVEL_INFO, PSTR("DISC: OK"));
//OK+DISC:4C 000C0E:003 A9144081A8 3B16849611 862EC1005: 0B1CE7485D :4DB4E940F C0E:-078
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
memcpy(ib.FACID,&hm17_sbuffer[8],8);
@ -704,7 +704,7 @@ hm17_v110:
}
} else {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]);
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]);
#endif
}
break;
@ -746,7 +746,7 @@ uint32_t difftime=millis()-hm17_lastms;
if (hm17_cmd==99) {
if (hm17_sindex>=HM17_BSIZ-2 || (hm17_sindex && (difftime>100))) {
AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer);
AddLog(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer);
hm17_sbclr();
}
}

View File

@ -46,7 +46,7 @@
char ib_mac[14];
struct {
union {
struct {
@ -167,8 +167,8 @@ int advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
if (manufacturerDataLen){
const uint8_t *manufacturerData = (const uint8_t *)data.data();
DumpHex(manufacturerData, 2, ib.FACID);
if (manufacturerDataLen == 25 &&
manufacturerData[0] == 0x4C &&
if (manufacturerDataLen == 25 &&
manufacturerData[0] == 0x4C &&
manufacturerData[1] == 0x00)
{
BLEBeacon oBeacon = BLEBeacon();
@ -191,7 +191,7 @@ int advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
// if we added it
if (ibeacon_add(&ib) == 1){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"),
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"),
"iBeacon",
advertisedDevice->getAddress().toString().c_str(),
Major, Minor,
@ -277,11 +277,11 @@ void esp32_every_second(void) {
// if device not present at all.
if (!ageS){
//AddLog_P(LOG_LEVEL_INFO, PSTR("iBeacon no device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]);
//AddLog(LOG_LEVEL_INFO, PSTR("iBeacon no device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]);
ibeacons[cnt].FLAGS=0;
ibeacon_mqtt(ibeacons[cnt].MAC,"0000",ibeacons[cnt].UID,ibeacons[cnt].MAJOR,ibeacons[cnt].MINOR,ibeacons[cnt].NAME);
} else {
//AddLog_P(LOG_LEVEL_INFO, PSTR("iBeacon device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]);
//AddLog(LOG_LEVEL_INFO, PSTR("iBeacon device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]);
}
//ibeacons[cnt].TIME++;
ibeacons[cnt].REPTIME++; // counter used to send mqtt for a dev regularly
@ -332,7 +332,7 @@ void hm17_sendcmd(uint8_t cmd) {
hm17_sbclr();
hm17_cmd=cmd;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd);
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd);
#endif
switch (cmd) {
case HM17_TEST:
@ -383,7 +383,7 @@ uint32_t ibeacon_add(struct IBEACON *ib) {
return 0;
}
// don't bother protecting this.
// don't bother protecting this.
//TasAutoMutex localmutex(&beaconmutex, "iBeacAdd");
// keyfob starts with ffff, ibeacon has valid facid
@ -448,7 +448,7 @@ void hm17_decode(void) {
case HM17_TEST:
if (!strncmp(hm17_sbuffer,"OK",2)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("AT OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("AT OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -458,7 +458,7 @@ void hm17_decode(void) {
case HM17_ROLE:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("ROLE OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("ROLE OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -467,7 +467,7 @@ void hm17_decode(void) {
case HM17_IMME:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IMME OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IMME OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -476,7 +476,7 @@ void hm17_decode(void) {
case HM17_IBEA:
if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IBEA OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IBEA OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -485,7 +485,7 @@ void hm17_decode(void) {
case HM17_SCAN:
if (!strncmp(hm17_sbuffer,"OK+Set:5",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("SCAN OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("SCAN OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -494,7 +494,7 @@ void hm17_decode(void) {
case HM17_RESET:
if (!strncmp(hm17_sbuffer,"OK+RESET",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RESET OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RESET OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -503,7 +503,7 @@ void hm17_decode(void) {
case HM17_RENEW:
if (!strncmp(hm17_sbuffer,"OK+RENEW",8)) {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RENEW OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RENEW OK"));
#endif
hm17_sbclr();
hm17_result=HM17_SUCESS;
@ -513,7 +513,7 @@ void hm17_decode(void) {
if (!strncmp(hm17_sbuffer,"OK+CONNA",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNA OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNA OK"));
#endif
hm17_connecting=2;
break;
@ -521,21 +521,21 @@ void hm17_decode(void) {
if (!strncmp(hm17_sbuffer,"OK+CONNE",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNE ERROR"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNE ERROR"));
#endif
break;
}
if (!strncmp(hm17_sbuffer,"OK+CONNF",8)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNF ERROR"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNF ERROR"));
#endif
break;
}
if (hm17_connecting==2 && !strncmp(hm17_sbuffer,"OK+CONN",7)) {
hm17_sbclr();
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONN OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONN OK"));
#endif
hm17_connecting=3;
hm17_sendcmd(HM17_TEST);
@ -550,7 +550,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=1;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCS OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCS OK"));
#endif
break;
}
@ -558,7 +558,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=1;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISIS OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISIS OK"));
#endif
break;
}
@ -566,7 +566,7 @@ void hm17_decode(void) {
hm17_sbclr();
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCE OK"));
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCE OK"));
#endif
hm17_scanning=0;
break;
@ -576,8 +576,8 @@ void hm17_decode(void) {
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("NAME OK"));
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR("NAME OK"));
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
hm17_sbclr();
@ -594,8 +594,8 @@ void hm17_decode(void) {
hm17_result=HM17_SUCESS;
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("DIS0 OK"));
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR("DIS0 OK"));
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
hm17_sbclr();
@ -609,9 +609,9 @@ hm17_v110:
if (hm17_sindex==78) {
#ifdef IBEACON_DEBUG
if (hm17_debug) {
AddLog_P(LOG_LEVEL_INFO, PSTR("DISC: OK"));
AddLog(LOG_LEVEL_INFO, PSTR("DISC: OK"));
//OK+DISC:4C 000C0E:003 A9144081A8 3B16849611 862EC1005: 0B1CE7485D :4DB4E940F C0E:-078
AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
}
#endif
memcpy(ib.FACID,&hm17_sbuffer[8],8);
@ -630,7 +630,7 @@ hm17_v110:
}
} else {
#ifdef IBEACON_DEBUG
if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]);
if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]);
#endif
}
break;
@ -672,7 +672,7 @@ void IBEACON_loop() {
if (hm17_cmd==99) {
if (hm17_sindex>=HM17_BSIZ-2 || (hm17_sindex && (difftime>100))) {
AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer);
AddLog(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer);
hm17_sbclr();
}
}
@ -731,7 +731,7 @@ void IBEACON_Show(void) {
}
// add a break line after us, if we showed anything.
if (total) WSContentSend_PD(HTTP_IBEACON_HL);
}
#endif // USE_WEBSERVER

View File

@ -1258,7 +1258,7 @@ void sml_shift_in(uint32_t meters,uint32_t shard) {
SML_Decode(meters);
} else {
// crc error
//AddLog_P(LOG_LEVEL_INFO, PSTR("ebus crc error"));
//AddLog(LOG_LEVEL_INFO, PSTR("ebus crc error"));
}
}
meter_spos[meters]=0;
@ -2014,7 +2014,7 @@ void SML_Init(void) {
index--;
srcpin=strtol(lp,&lp,10);
if (Gpio_used(srcpin)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("gpio rx double define!"));
AddLog(LOG_LEVEL_INFO, PSTR("gpio rx double define!"));
dddef_exit:
if (script_meter) free(script_meter);
script_meter=0;
@ -2051,7 +2051,7 @@ dddef_exit:
lp++;
script_meter_desc[index].trxpin=strtol(lp,&lp,10);
if (Gpio_used(script_meter_desc[index].trxpin)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("gpio tx double define!"));
AddLog(LOG_LEVEL_INFO, PSTR("gpio tx double define!"));
goto dddef_exit;
}
if (*lp!=',') goto next_line;

View File

@ -125,7 +125,7 @@ static void _debug_fval(const char *str, float fval, uint8_t prec = 4 )
{
char fstr[32];
dtostrfd(fval, prec, fstr);
AddLog_P( LOG_LEVEL_DEBUG, PSTR("%s: %s"), str, fstr );
AddLog( LOG_LEVEL_DEBUG, PSTR("%s: %s"), str, fstr );
}
@ -168,7 +168,7 @@ bool Ina226TestPresence(uint8_t device)
// Read config
uint16_t config = I2cRead16( Ina226Info[device].address, INA226_REG_CONFIG );
//AddLog_P( LOG_LEVEL_NONE, PSTR("Config register %04x" ), config);
//AddLog( LOG_LEVEL_NONE, PSTR("Config register %04x" ), config);
if (config != Ina226Info[device].config)
return false;
@ -203,11 +203,11 @@ void Ina226Init()
Ina226Info_t *p = Ina226Info;
//AddLog_P( LOG_LEVEL_NONE, "Ina226Init");
// AddLog_P( LOG_LEVEL_NONE, "Size of Settings: %d bytes", sizeof(Settings));
//AddLog( LOG_LEVEL_NONE, "Ina226Init");
// AddLog( LOG_LEVEL_NONE, "Size of Settings: %d bytes", sizeof(Settings));
// if (!TasmotaGlobal.i2c_enabled)
// AddLog_P(LOG_LEVEL_DEBUG, "INA226: Initialization failed: No I2C support");
// AddLog(LOG_LEVEL_DEBUG, "INA226: Initialization failed: No I2C support");
// Clear Ina226 info data
@ -216,7 +216,7 @@ void Ina226Init()
*p = {0};
}
//AddLog_P( LOG_LEVEL_NONE, PSTR("Sizeof Ina226Cfg: %d" ), sizeof(Ina226Cfg));
//AddLog( LOG_LEVEL_NONE, PSTR("Sizeof Ina226Cfg: %d" ), sizeof(Ina226Cfg));
// Detect devices
@ -227,25 +227,25 @@ void Ina226Init()
// Skip device probing if the full scale current is zero
//AddLog_P( LOG_LEVEL_NONE, "fs_i[%d]: %d", i, Settings.ina226_i_fs[i]);
//AddLog( LOG_LEVEL_NONE, "fs_i[%d]: %d", i, Settings.ina226_i_fs[i]);
if (!Settings.ina226_i_fs[i])
continue;
//AddLog_P( LOG_LEVEL_NONE, PSTR("INA226 trying address %02x" ), addr );
//AddLog( LOG_LEVEL_NONE, PSTR("INA226 trying address %02x" ), addr );
// Try Resetting the device
if (!I2cWrite16( addr, INA226_REG_CONFIG, INA226_CONFIG_RESET)){
AddLog_P( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr);
AddLog( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr);
continue; // No device
}
// Read config
uint16_t config = I2cRead16( addr, INA226_REG_CONFIG );
//AddLog_P( LOG_LEVEL_NONE, PSTR("INA226 Config register %04x" ), config);
//AddLog( LOG_LEVEL_NONE, PSTR("INA226 Config register %04x" ), config);
if (INA226_RES_CONFIG != config)
continue;
@ -264,19 +264,19 @@ void Ina226Init()
// Configuration
p->config = config;
// Full scale current in tenths of an amp
//AddLog_P( LOG_LEVEL_NONE, "Full Scale I in tenths of an amp: %u", Settings.ina226_i_fs[i]);
//AddLog( LOG_LEVEL_NONE, "Full Scale I in tenths of an amp: %u", Settings.ina226_i_fs[i]);
p->i_lsb = (((float) Settings.ina226_i_fs[i])/10.0f)/32768.0f;
//_debug_fval("i_lsb: %s", p->i_lsb, 7);
// Get shunt resistor value in micro ohms
uint32_t r_shunt_uohms = _expand_r_shunt(Settings.ina226_r_shunt[i]);
//AddLog_P( LOG_LEVEL_NONE, "Shunt R in micro-ohms: %u", r_shunt_uohms);
//AddLog( LOG_LEVEL_NONE, "Shunt R in micro-ohms: %u", r_shunt_uohms);
p->calibrationValue = ((uint16_t) (0.00512/(p->i_lsb * r_shunt_uohms/1000000.0f)));
// Device present
p->present = true;
//AddLog_P( LOG_LEVEL_NONE, "INA226 Device %d calibration value: %04X", i, p->calibrationValue);
//AddLog( LOG_LEVEL_NONE, "INA226 Device %d calibration value: %04X", i, p->calibrationValue);
Ina226SetCalibration(i);
@ -336,11 +336,11 @@ float Ina226ReadPower_w(uint8_t device)
void Ina226Read(uint8_t device)
{
//AddLog_P( LOG_LEVEL_NONE, "Ina226Read");
//AddLog( LOG_LEVEL_NONE, "Ina226Read");
voltages[device] = Ina226ReadBus_v(device);
currents[device] = Ina226ReadShunt_i(device);
powers[device] = Ina226ReadPower_w(device);
//AddLog_P( LOG_LEVEL_NONE, "INA226 Device %d", device );
//AddLog( LOG_LEVEL_NONE, "INA226 Device %d", device );
//_debug_fval("Voltage", voltages[device]);
//_debug_fval("Current", currents[device]);
//_debug_fval("Power", powers[device]);
@ -352,7 +352,7 @@ void Ina226Read(uint8_t device)
void Ina226EverySecond()
{
//AddLog_P( LOG_LEVEL_NONE, "Ina226EverySecond");
//AddLog( LOG_LEVEL_NONE, "Ina226EverySecond");
for (uint8_t device = 0; device < INA226_MAX_ADDRESSES; device++){
// If there are Ina226s, and the device was present, and the device still is present, read its registers
if (Ina226sFound && Ina226Info[device].present && Ina226TestPresence(device)){
@ -363,7 +363,7 @@ void Ina226EverySecond()
// If device was present, note that it dropped off here
//if(Ina226Info[device].present){
//reinit_count[device]++;
//AddLog_P( LOG_LEVEL_DEBUG, "INA226 Device %d dropped off, count: %d", device, reinit_count[device]);
//AddLog( LOG_LEVEL_DEBUG, "INA226 Device %d dropped off, count: %d", device, reinit_count[device]);
//}
// Device no longer present
Ina226Info[device].present = false;
@ -384,8 +384,8 @@ bool Ina226CommandSensor()
uint8_t i, param_count, device, p1 = XdrvMailbox.payload;
uint32_t r_shunt_uohms;
uint16_t compact_r_shunt_uohms;
//AddLog_P( LOG_LEVEL_NONE, "Command received: %d", XdrvMailbox.payload);
//AddLog_P( LOG_LEVEL_NONE, "Command data received: %s", XdrvMailbox.data);
//AddLog( LOG_LEVEL_NONE, "Command received: %d", XdrvMailbox.payload);
//AddLog( LOG_LEVEL_NONE, "Command data received: %s", XdrvMailbox.data);
// Make a copy of the data and add another terminator
@ -401,7 +401,7 @@ bool Ina226CommandSensor()
if (param_str[i] == ' ' || param_str[i] == ',' || param_str[i] == 0){
param_str[i] = 0;
params[param_count] = cp;
//AddLog_P( LOG_LEVEL_NONE, "INA226 Command parameter: %d, value: %s", param_count, params[param_count]);
//AddLog( LOG_LEVEL_NONE, "INA226 Command parameter: %d, value: %s", param_count, params[param_count]);
param_count++;
cp = param_str + i + 1;
}
@ -437,7 +437,7 @@ bool Ina226CommandSensor()
r_shunt_uohms = (uint32_t) ((CharToFloat(params[1])) * 1000000.0f);
//AddLog_P( LOG_LEVEL_NONE, "r_shunt_uohms: %d", r_shunt_uohms);
//AddLog( LOG_LEVEL_NONE, "r_shunt_uohms: %d", r_shunt_uohms);
if (r_shunt_uohms > 32767){
uint32_t r_shunt_mohms = r_shunt_uohms/1000UL;
Settings.ina226_r_shunt[device] = (uint16_t) (r_shunt_mohms | 0x8000);
@ -445,13 +445,13 @@ bool Ina226CommandSensor()
else
Settings.ina226_r_shunt[device] = (uint16_t) r_shunt_uohms;
//AddLog_P( LOG_LEVEL_NONE, "r_shunt_compacted: %04X", Settings.ina226_r_shunt[device]);
//AddLog( LOG_LEVEL_NONE, "r_shunt_compacted: %04X", Settings.ina226_r_shunt[device]);
show_config = true;
break;
case 2: // Set full scale current in tenths of amps from user input in Amps
Settings.ina226_i_fs[device] = (uint16_t) ((CharToFloat(params[1])) * 10.0f);
//AddLog_P( LOG_LEVEL_NONE, "i_fs: %d", Settings.ina226_i_fs[device]);
//AddLog( LOG_LEVEL_NONE, "i_fs: %d", Settings.ina226_i_fs[device]);
show_config = true;
break;

View File

@ -69,7 +69,7 @@ void DS1624_Restart(uint8_t config, uint32_t idx) {
config &= ~(DS1621_CFG_DONE|DS1621_CFG_1SHOT);
I2cWrite8(addr, DS1624_CONF_REGISTER, config); // 1shot off
delay(10); // by spec after writing
AddLog_P(LOG_LEVEL_ERROR, "%s addr %x is reset, reconfig: %x", ds1624_sns[idx].name, addr, config);
AddLog(LOG_LEVEL_ERROR, "%s addr %x is reset, reconfig: %x", ds1624_sns[idx].name, addr, config);
}
I2cValidRead(addr, DS1624_START_REGISTER, 1);
}
@ -94,7 +94,7 @@ void DS1624_HotPlugUp(uint32_t idx)
ds1624_sns[idx].errcnt = 0;
ds1624_sns[idx].misscnt = 0;
DS1624_Restart(config,idx);
AddLog_P(LOG_LEVEL_INFO, "Hot Plug %s addr %x config: %x", ds1624_sns[idx].name, addr, config);
AddLog(LOG_LEVEL_INFO, "Hot Plug %s addr %x config: %x", ds1624_sns[idx].name, addr, config);
}
}
@ -104,7 +104,7 @@ void DS1624_HotPlugDown(int idx)
if (!I2cActive(addr)) { return; }
I2cResetActive(addr);
ds1624_sns[idx].valid = false;
AddLog_P(LOG_LEVEL_INFO, "Hot UnPlug %s", ds1624_sns[idx].name);
AddLog(LOG_LEVEL_INFO, "Hot UnPlug %s", ds1624_sns[idx].name);
}
bool DS1624GetTemp(float *value, int idx)
@ -114,13 +114,13 @@ bool DS1624GetTemp(float *value, int idx)
uint8_t config;
if (!I2cValidRead8(&config, addr, DS1624_CONF_REGISTER)) {
ds1624_sns[idx].misscnt++;
AddLog_P(LOG_LEVEL_INFO, "%s device missing (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].misscnt);
AddLog(LOG_LEVEL_INFO, "%s device missing (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].misscnt);
return false;
}
ds1624_sns[idx].misscnt=0;
if (config & (DS1621_CFG_1SHOT|DS1621_CFG_DONE)) {
ds1624_sns[idx].errcnt++;
AddLog_P(LOG_LEVEL_INFO, "%s config error, restart... (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].errcnt);
AddLog(LOG_LEVEL_INFO, "%s config error, restart... (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].errcnt);
DS1624_Restart(config, idx);
return false;
}

View File

@ -573,17 +573,17 @@ void UBXSelectMode(uint16_t mode)
break;
case 4:
Flog->startRecording(true);
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending"));
AddLog(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending"));
break;
case 5:
Flog->startRecording(false);
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log"));
AddLog(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log"));
break;
case 6:
if(Flog->recording == true){
Flog->stopRecording();
}
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: stop recording"));
AddLog(LOG_LEVEL_INFO, PSTR("UBX: stop recording"));
break;
#endif //USE_FLOG
case 7:
@ -689,7 +689,7 @@ void UBXHandleTIME()
gpsTime.second = UBX.Message.navTime.sec;
UBX.rec_buffer.values.time = MakeTime(gpsTime);
if (UBX.mode.forceUTCupdate || Rtc.user_time_entry == false){
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: UTC-Time is valid, set system time"));
AddLog(LOG_LEVEL_INFO, PSTR("UBX: UTC-Time is valid, set system time"));
Rtc.utc_time = UBX.rec_buffer.values.time;
}
Rtc.user_time_entry = true;
@ -702,7 +702,7 @@ void UBXHandleOther(void)
if (UBX.state.non_empty_loops>6) { // we expect only 4-5 non-empty loops in a row, could change with other sensor speed (Hz)
if(UBX.mode.runningVPort) return;
UBXinitCFG(); // this should only happen with lots of NMEA-messages, but it is only a guess!!
AddLog_P(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init"));
AddLog(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init"));
UBXSerial->flush();
UBX.state.non_empty_loops = 0;
}

View File

@ -419,7 +419,7 @@ void MINRFinit(void) {
MINRF.option.minimalSummary = 0;
MINRF.option.directBridgeMode = 0;
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Started"));
AddLog(LOG_LEVEL_INFO, PSTR("NRF: Started"));
}
}
@ -452,7 +452,7 @@ bool MINRFinitBLE(uint8_t _mode)
MINRFchangePacketModeTo(_mode);
return true;
}
// AddLog_P(LOG_LEVEL_INFO,PSTR("MINRF chip NOT !!!! connected"));
// AddLog(LOG_LEVEL_INFO,PSTR("MINRF chip NOT !!!! connected"));
return false;
}
@ -495,7 +495,7 @@ bool MINRFreceivePacket(void)
MINRFswapbuf((uint8_t*)&MINRF.buffer, sizeof(MINRF.buffer) );
// MINRF_LOG_BUFFER();
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: _lsfrlist: %x, chan: %u, mode: %u"),_lsfrlist[MINRF.currentChan],MINRF.currentChan, MINRF.packetMode);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: _lsfrlist: %x, chan: %u, mode: %u"),_lsfrlist[MINRF.currentChan],MINRF.currentChan, MINRF.packetMode);
switch (MINRF.packetMode) {
case 0: case NLIGHT: case MJYD2S:
MINRFwhiten((uint8_t *)&MINRF.buffer, sizeof(MINRF.buffer), MINRF.channel[MINRF.currentChan] | 0x40); // "BEACON" mode, "NLIGHT" mode, "MJYD2S" mode
@ -603,7 +603,7 @@ void MINRFhandleScan(void){
MINRFscanResult.erase(std::remove_if(MINRFscanResult.begin(),
MINRFscanResult.end(),
[&i](scan_entry_t e) {
if(e.showedUp>2) AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: Beacon %02u: %02X%02X%02X%02X%02X%02X Cid: %04X Svc: %04X UUID: %04X"),i,e.MAC[0],e.MAC[1],e.MAC[2],e.MAC[3],e.MAC[4],e.MAC[5],e.cid,e.svc,e.uuid);
if(e.showedUp>2) AddLog(LOG_LEVEL_INFO,PSTR("NRF: Beacon %02u: %02X%02X%02X%02X%02X%02X Cid: %04X Svc: %04X UUID: %04X"),i,e.MAC[0],e.MAC[1],e.MAC[2],e.MAC[3],e.MAC[4],e.MAC[5],e.cid,e.svc,e.uuid);
i++;
return ((e.showedUp < 3));
}),
@ -616,7 +616,7 @@ void MINRFhandleScan(void){
for(uint32_t i=0; i<MINRFscanResult.size(); i++){
if(memcmp(MINRF.buffer.bleAdv.MAC,MINRFscanResult[i].MAC,sizeof(MINRF.buffer.bleAdv.MAC))==0){
MINRFscanResult[i].showedUp++;
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: ADVk: %02x %02x %02x %02x %02x %02x"),MINRF.buffer.bleAdv.MAC[0],MINRF.buffer.bleAdv.MAC[1],MINRF.buffer.bleAdv.MAC[2],MINRF.buffer.bleAdv.MAC[3],MINRF.buffer.bleAdv.MAC[4],MINRF.buffer.bleAdv.MAC[5]);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: ADVk: %02x %02x %02x %02x %02x %02x"),MINRF.buffer.bleAdv.MAC[0],MINRF.buffer.bleAdv.MAC[1],MINRF.buffer.bleAdv.MAC[2],MINRF.buffer.bleAdv.MAC[3],MINRF.buffer.bleAdv.MAC[4],MINRF.buffer.bleAdv.MAC[5]);
return;
}
}
@ -640,7 +640,7 @@ void MINRFhandleScan(void){
*/
void MINRFstartBeacon(uint16_t entry){
memcpy(MINRF.beacon.MAC,MINRFscanResult[entry].MAC,sizeof(MINRF.beacon.MAC));
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: Beacon activated: %02x:%02x:%02x:%02x:%02x:%02x"),MINRF.beacon.MAC[0],MINRF.beacon.MAC[1],MINRF.beacon.MAC[2],MINRF.beacon.MAC[3],MINRF.beacon.MAC[4],MINRF.beacon.MAC[5]);
AddLog(LOG_LEVEL_INFO,PSTR("NRF: Beacon activated: %02x:%02x:%02x:%02x:%02x:%02x"),MINRF.beacon.MAC[0],MINRF.beacon.MAC[1],MINRF.beacon.MAC[2],MINRF.beacon.MAC[3],MINRF.beacon.MAC[4],MINRF.beacon.MAC[5]);
MINRF.beacon.time = 0;
MINRF.beacon.active = true;
}
@ -665,55 +665,55 @@ bool MINRFhandleBeacon(scan_entry_t * entry, uint32_t offset){
if(memcmp((uint8_t*)&_buf[2],MINRF.beacon.MAC,2)==0){ // always at least 2 undestroyed bytes left
if(_buf[8]!=2 && _buf[9]!=1){
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: unsupported ADV %02x %02x"), _buf[8],_buf[9]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: unsupported ADV %02x %02x"), _buf[8],_buf[9]);
return success;
}
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Beacon:____________"));
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Beacon:____________"));
for (uint32_t i = 8; i<32+offset;i++){
uint32_t size = _buf[i];
if (size>30) break;
uint32_t ADtype = _buf[i+1];
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Size: %u AD: %x i:%u"), size, ADtype,i);
// AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Size: %u AD: %x i:%u"), size, ADtype,i);
if (size+i>32+offset) size=32-i+offset-2;
if (size>30) break;
char _stemp[(size*2)];
uint32_t backupSize;
switch(ADtype){
case 0x01:
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Flags: %02x"), _buf[i+2]);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Flags: %02x"), _buf[i+2]);
break;
case 0x02: case 0x03:
entry->uuid = _buf[i+3]*256 + _buf[i+2];
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: UUID: %04x"), entry->uuid);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: UUID: %04x"), entry->uuid);
success = true;
break;
case 0x08: case 0x09:
backupSize = _buf[i+size+1];
_buf[i+size+1] = 0;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Name: %s"), (char*)&_buf[i+2]);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Name: %s"), (char*)&_buf[i+2]);
success = true;
_buf[i+size+1] = backupSize;
break;
case 0x0a:
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: TxPow: %02u"), _buf[i+2]);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: TxPow: %02u"), _buf[i+2]);
break;
case 0xff:
entry->cid = _buf[i+3]*256 + _buf[i+2];
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Cid: %04x"), entry->cid);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Cid: %04x"), entry->cid);
ToHex_P((unsigned char*)&_buf+i+4,size-3,_stemp,(size*2));
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
success = true;
break;
case 0x16:
entry->svc = _buf[i+3]*256 + _buf[i+2];
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Svc: %04x"), entry->svc);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Svc: %04x"), entry->svc);
ToHex_P((unsigned char*)&_buf+i+4,size-3,_stemp,(size*2));
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
success = true;
break;
default:
ToHex_P((unsigned char*)&_buf+i+2,size-1,_stemp,(size*2));
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp);
}
i+=size;
}
@ -732,7 +732,7 @@ void MINRFbeaconCounter(void) {
/*
char stemp[20];
snprintf_P(stemp, sizeof(stemp),PSTR("{%s:{\"Beacon\": %u}}"),D_CMND_NRF, MINRF.beacon.time);
AddLog_P(LOG_LEVEL_DEBUG, stemp);
AddLog(LOG_LEVEL_DEBUG, stemp);
RulesProcessEvent(stemp);
*/
Response_P(PSTR("{%s:{\"Beacon\":%u}}"), D_CMND_NRF, MINRF.beacon.time);
@ -761,9 +761,9 @@ void MINRFcomputeBeaconPDU(uint8_t (&_MAC)[6], uint32_t (&PDU)[3], uint32_t offs
#ifdef USE_MI_DECRYPTION
int MINRFdecryptPacket(char *_buf){
encPacket_t *packet = (encPacket_t*)_buf;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("to decrypt: %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[0],(uint8_t)_buf[1],(uint8_t)_buf[2],(uint8_t)_buf[3],(uint8_t)_buf[4],(uint8_t)_buf[5],(uint8_t)_buf[6],(uint8_t)_buf[7]);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[8],(uint8_t)_buf[9],(uint8_t)_buf[10],(uint8_t)_buf[11],(uint8_t)_buf[12],(uint8_t)_buf[13],(uint8_t)_buf[14],(uint8_t)_buf[15]);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x "),(uint8_t)_buf[16],(uint8_t)_buf[17],(uint8_t)_buf[18],(uint8_t)_buf[19],(uint8_t)_buf[20]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("to decrypt: %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[0],(uint8_t)_buf[1],(uint8_t)_buf[2],(uint8_t)_buf[3],(uint8_t)_buf[4],(uint8_t)_buf[5],(uint8_t)_buf[6],(uint8_t)_buf[7]);
// AddLog(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[8],(uint8_t)_buf[9],(uint8_t)_buf[10],(uint8_t)_buf[11],(uint8_t)_buf[12],(uint8_t)_buf[13],(uint8_t)_buf[14],(uint8_t)_buf[15]);
// AddLog(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x "),(uint8_t)_buf[16],(uint8_t)_buf[17],(uint8_t)_buf[18],(uint8_t)_buf[19],(uint8_t)_buf[20]);
int ret = 0;
unsigned char output[16] = {0};
@ -781,13 +781,13 @@ int MINRFdecryptPacket(char *_buf){
uint8_t _bindkey[16] = {0x0};
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(packet->MAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("have key"));
// AddLog(LOG_LEVEL_DEBUG,PSTR("have key"));
memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey));
break;
}
// else{
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]);
// }
}
@ -804,7 +804,7 @@ int MINRFdecryptPacket(char *_buf){
br_ccm_run(&ctx, 0, output, sizeof(packet->payload.cipher));
ret = br_ccm_check_tag(&ctx, packet->payload.tag);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, output[0],output[1],output[2],output[3],output[4]);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, output[0],output[1],output[2],output[3],output[4]);
memcpy((uint8_t*)(packet->payload.cipher)+1,output,sizeof(packet->payload.cipher));
return ret;
}
@ -823,22 +823,22 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){
memcpy((uint8_t*)&nonce+6,(uint8_t*)&packet->PID,2);
nonce[8] = packet->frameCnt;
memcpy((uint8_t*)&nonce+9,(uint8_t*)&packet->padding[0] + packet->payloadSize + 5, 3);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("nonce: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"), nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("nonce: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"), nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11]);
uint8_t _bindkey[16];
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(MIBLElights[_light-1].MAC,MIBLEbindKeys[i].MAC,sizeof(MIBLElights[_light-1].MAC))==0){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("have key"));
AddLog(LOG_LEVEL_DEBUG,PSTR("have key"));
memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey));
break;
}
// else{
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]);
// }
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("size %u"),packet->payloadSize);
// AddLog(LOG_LEVEL_DEBUG,PSTR("size %u"),packet->payloadSize);
uint32_t _size;
int32_t _offset;
uint32_t _tagSize;
@ -862,9 +862,9 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){
return 0;
break;
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("size %u , offset %u"),_size,_offset);
// AddLog(LOG_LEVEL_DEBUG,PSTR("size %u , offset %u"),_size,_offset);
memcpy(_output,(uint8_t*)&packet->padding[0] + packet->payloadSize - _offset, _size);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Output : %02x %02x %02x %02x %02x %02x %02x"), _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Output : %02x %02x %02x %02x %02x %02x %02x"), _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]);
br_aes_small_ctrcbc_keys keyCtx;
br_aes_small_ctrcbc_init(&keyCtx, _bindkey, sizeof(_bindkey));
@ -875,7 +875,7 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){
br_ccm_aad_inject(&ctx, authData, sizeof(authData));
br_ccm_flip(&ctx);
br_ccm_run(&ctx, 0, _output, _size);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Err:%i, Decrypted : %02x %02x %02x %02x %02x %02x %02x"), ret, _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Err:%i, Decrypted : %02x %02x %02x %02x %02x %02x %02x"), ret, _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]);
br_ccm_get_tag(&ctx, tag);
ret = memcmp(tag,(uint8_t*)&packet->padding[0] + packet->payloadSize + 8, _tagSize);
@ -1124,7 +1124,7 @@ uint32_t MINRFgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type){
break;
}
MIBLEsensors.push_back(_newSensor);
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLEsensors.size()-1);
AddLog(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLEsensors.size()-1);
return (MIBLEsensors.size()-1);
};
@ -1203,7 +1203,7 @@ void MINRFhandleMiBeaconPacket(void){
switch(MINRF.buffer.miBeacon.type){
case 0x1:
if(MINRF.buffer.miBeacon.counter==_sensorVec->lastCnt) break;
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: YEE-RC button: %u Long: %u"), MINRF.buffer.miBeacon.Btn.num, MINRF.buffer.miBeacon.Btn.longPress);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: YEE-RC button: %u Long: %u"), MINRF.buffer.miBeacon.Btn.num, MINRF.buffer.miBeacon.Btn.longPress);
_sensorVec->lastCnt=MINRF.buffer.miBeacon.counter;
_sensorVec->Btn=MINRF.buffer.miBeacon.Btn.num + (MINRF.buffer.miBeacon.Btn.longPress/2)*6;
_sensorVec->eventType.Btn = 1;
@ -1323,10 +1323,10 @@ void MINRFhandleNlightPacket(void){ // no MiBeacon
uint32_t offset = 6;
uint8_t _buf[32+offset];
MINRFrecalcBuffer((uint8_t*)&_buf,offset);
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6],_buf[7],_buf[8],_buf[9],_buf[10],_buf[11],_buf[12],_buf[13],_buf[14],_buf[15],_buf[16],_buf[17],_buf[18]);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6],_buf[7],_buf[8],_buf[9],_buf[10],_buf[11],_buf[12],_buf[13],_buf[14],_buf[15],_buf[16],_buf[17],_buf[18]);
uint32_t _frame_PID = _buf[15]<<24 | _buf[16]<<16 | _buf[17]<<8 | _buf[18];
if(_frame_PID!=0x4030dd03) return; // invalid packet
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID);
uint32_t _idx = MINRF.activeLight-1;
if((millis() - MIBLElights[_idx].lastTime)<1500) return;
if(_buf[19]!=MIBLElights[_idx].lastCnt){
@ -1334,7 +1334,7 @@ void MINRFhandleNlightPacket(void){ // no MiBeacon
MIBLElights[_idx].events++;
MIBLElights[_idx].shallSendMQTT = 1;
MIBLElights[_idx].lastTime = millis();
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: NLIGHT %u: events: %u, Cnt:%u"), _idx,MIBLElights[_idx].events, MIBLElights[_idx].lastCnt);
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: NLIGHT %u: events: %u, Cnt:%u"), _idx,MIBLElights[_idx].events, MIBLElights[_idx].lastCnt);
}
}
@ -1344,20 +1344,20 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon
MINRFrecalcBuffer((uint8_t*)&_buf,offset);
mjysd02_Packet_t *_packet = (mjysd02_Packet_t*)&_buf;
if(_packet->PID!=0x07f6) return; // invalid packet
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S: %02u %04x %04x %04x %02x"),_packet->payloadSize,_packet->UUID,_packet->frameCtrl,_packet->PID,_packet->frameCnt);
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: PAYLOAD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_packet->data[0],_packet->data[1],_packet->data[2],_packet->data[3],_packet->data[4],_packet->data[5],_packet->data[6],_packet->data[7],_packet->data[8],_packet->data[9],_packet->data[10],_packet->data[11],_packet->data[12],_packet->data[13],_packet->data[14],_packet->data[15],_packet->data[16],_packet->data[17]);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S: %02u %04x %04x %04x %02x"),_packet->payloadSize,_packet->UUID,_packet->frameCtrl,_packet->PID,_packet->frameCnt);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: PAYLOAD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_packet->data[0],_packet->data[1],_packet->data[2],_packet->data[3],_packet->data[4],_packet->data[5],_packet->data[6],_packet->data[7],_packet->data[8],_packet->data[9],_packet->data[10],_packet->data[11],_packet->data[12],_packet->data[13],_packet->data[14],_packet->data[15],_packet->data[16],_packet->data[17]);
uint32_t _idx = MINRF.activeLight-1;
switch(_packet->frameCtrl){
case 0x5910:
if(_packet->frameCnt!=MIBLElights[_idx].lastCnt){
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S after motion:%x"),_packet->frameCnt);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S after motion:%x"),_packet->frameCnt);
MIBLElights[_idx].lastCnt = _packet->frameCnt;
if(millis()-MIBLElights[_idx].lastTime>120000){
MIBLElights[_idx].eventType = 1;
MIBLElights[_idx].events++;
MIBLElights[_idx].shallSendMQTT = 1;
MIBLElights[_idx].lastTime = millis();
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S secondary PIR"));
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S secondary PIR"));
}
}
break;
@ -1373,7 +1373,7 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon
if(millis()-MIBLElights[_idx].lastTime>1000){
MIBLElights[_idx].eventType = 1; //PIR
MIBLElights[_idx].shallSendMQTT = 1;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S primary PIR"));
AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S primary PIR"));
MIBLElights[_idx].events++;
}
MIBLElights[_idx].lastTime = millis();
@ -1394,23 +1394,23 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon
MIBLElights[_idx].NMT = output[6]<<24 | output[5]<<16 | output[4]<<8 | output[3];
MIBLElights[_idx].eventType = 3; // NMT 0, 120, 300, 600, 1800, ... seconds
MIBLElights[_idx].shallSendMQTT = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S NMT: %u"), MIBLElights[_idx].NMT );
// AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S NMT: %u"), MIBLElights[_idx].NMT );
break;
}
}
}
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID);
}
void MINRFhandleLightPacket(void){
switch(MIBLElights[MINRF.activeLight-1].type){
case NLIGHT:
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT!!"));
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT!!"));
MINRFhandleNlightPacket();
break;
case MJYD2S:
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S !!"));
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S !!"));
MINRFhandleMJYD2SPacket();
break;
}
@ -1420,7 +1420,7 @@ void MINRFhandleLightPacket(void){
void MINRFaddLight(uint8_t _MAC[], uint8_t _type){ // no MiBeacon
for(uint32_t i=0; i<MIBLElights.size(); i++){
if(memcmp(_MAC,MIBLElights[i].MAC,sizeof(MIBLElights[i].MAC))==0){
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: Known MAC!!"));
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: Known MAC!!"));
return;
}
}
@ -1434,14 +1434,14 @@ void MINRFaddLight(uint8_t _MAC[], uint8_t _type){ // no MiBeacon
_light.bat=0;
_light.lux=0;
MIBLElights.push_back(_light);
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLElights.size()-1);
AddLog(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLElights.size()-1);
}
void MINRFhandleATCPacket(void){
ATCPacket_t *_packet = (ATCPacket_t*)&MINRF.buffer;
uint32_t _slot = MINRFgetSensorSlot(_packet->MAC, 0x0a1c); // This must be a hard-coded fake ID
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("known %s at slot %u"), kMINRFDeviceType[MIBLEsensors[_slot].type-1],_slot);
// AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: ATC: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),MINRF.buffer.raw[0],MINRF.buffer.raw[1],MINRF.buffer.raw[2],MINRF.buffer.raw[3],MINRF.buffer.raw[4],MINRF.buffer.raw[5],MINRF.buffer.raw[6],MINRF.buffer.raw[7],MINRF.buffer.raw[8],MINRF.buffer.raw[9],MINRF.buffer.raw[10],MINRF.buffer.raw[11]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("known %s at slot %u"), kMINRFDeviceType[MIBLEsensors[_slot].type-1],_slot);
// AddLog(LOG_LEVEL_INFO,PSTR("NRF: ATC: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),MINRF.buffer.raw[0],MINRF.buffer.raw[1],MINRF.buffer.raw[2],MINRF.buffer.raw[3],MINRF.buffer.raw[4],MINRF.buffer.raw[5],MINRF.buffer.raw[6],MINRF.buffer.raw[7],MINRF.buffer.raw[8],MINRF.buffer.raw[9],MINRF.buffer.raw[10],MINRF.buffer.raw[11]);
if(_slot==0xff) return;
MIBLEsensors[_slot].temp = (float)(__builtin_bswap16(_packet->temp))/10.0f;
@ -1472,7 +1472,7 @@ void MINRF_EVERY_50_MSECOND() { // Every 50mseconds
MINRF.mode.shallTriggerTele = 0;
}
// DEBUG_SENSOR_LOG(PSTR("NRF: nothing received"));
// if (MINRF.packetMode==ATC) AddLog_P(LOG_LEVEL_INFO,PSTR("no ATC.."));
// if (MINRF.packetMode==ATC) AddLog(LOG_LEVEL_INFO,PSTR("no ATC.."));
}
else {

View File

@ -385,14 +385,14 @@ enum MI32_BEACON_CMND {
class MI32SensorCallback : public NimBLEClientCallbacks {
void onConnect(NimBLEClient* pclient) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("connected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]);
AddLog(LOG_LEVEL_DEBUG,PSTR("connected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]);
MI32.mode.willConnect = 0;
MI32.mode.connected = 1;
}
void onDisconnect(NimBLEClient* pclient) {
MI32.mode.connected = 0;
MI32.mode.willReadBatt = 0;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("disconnected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]);
AddLog(LOG_LEVEL_DEBUG,PSTR("disconnected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]);
}
bool onConnParamsUpdateRequest(NimBLEClient* MI32Client, const ble_gap_upd_params* params) {
if(params->itvl_min < 24) { /** 1.25ms units */
@ -410,13 +410,13 @@ class MI32SensorCallback : public NimBLEClientCallbacks {
class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
// AddLog(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
int RSSI = advertisedDevice->getRSSI();
uint8_t addr[6];
memcpy(addr,advertisedDevice->getAddress().getNative(),6);
MI32_ReverseMAC(addr);
if (advertisedDevice->getServiceDataCount() == 0) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
// AddLog(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
if(MI32.state.beaconScanCounter==0 && !MI32.mode.activeBeacon){
MI32Scan->erase(advertisedDevice->getAddress());
return;
@ -428,7 +428,7 @@ class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
}
uint16_t UUID = advertisedDevice->getServiceDataUUID(0).getNative()->u16.value;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),UUID);
// AddLog(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),UUID);
size_t ServiceDataLength = advertisedDevice->getServiceData(0).length();
if(UUID==0xfe95) {
@ -447,7 +447,7 @@ class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
if(MI32.state.beaconScanCounter!=0 || MI32.mode.activeBeacon){
MI32HandleGenericBeacon(advertisedDevice->getPayload(), advertisedDevice->getPayloadLength(), RSSI, addr);
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %x: %s Buffer: %u"), UUID, advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
// AddLog(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %x: %s Buffer: %u"), UUID, advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
MI32Scan->erase(advertisedDevice->getAddress());
}
};
@ -463,12 +463,12 @@ static NimBLEClient* MI32Client;
\*********************************************************************************************/
void MI32scanEndedCB(NimBLEScanResults results){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Scan ended"));
AddLog(LOG_LEVEL_DEBUG,PSTR("Scan ended"));
MI32.mode.runningScan = 0;
}
void MI32notifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Notified length: %u"),length);
AddLog(LOG_LEVEL_DEBUG,PSTR("Notified length: %u"),length);
switch(MIBLEsensors[MI32.state.sensor].type){
case LYWSD03MMC: case LYWSD02: case MHOC401:
MI32readHT_LY((char*)pData);
@ -546,12 +546,12 @@ void MI32AddKey(char* payload){
bool unknownKey = true;
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(keyMAC.MAC,MIBLEbindKeys[i].MAC,sizeof(keyMAC.MAC))==0){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("known key"));
AddLog(LOG_LEVEL_DEBUG,PSTR("known key"));
unknownKey=false;
}
}
if(unknownKey){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("New key"));
AddLog(LOG_LEVEL_DEBUG,PSTR("New key"));
MIBLEbindKeys.push_back(keyMAC);
}
}
@ -573,7 +573,7 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){
uint32_t tag;
const unsigned char authData[1] = {0x11};
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Decrypt Size of Buffer: %u, payload length: %u"), _bufSize, data_len);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Decrypt Size of Buffer: %u, payload length: %u"), _bufSize, data_len);
// AddLogBuffer(LOG_LEVEL_DEBUG,(uint8_t*)_buf, _bufSize);
// nonce: device MAC, device type, frame cnt, ext. cnt
@ -583,24 +583,24 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){
memcpy((uint8_t*)&nonce+6,(uint8_t*)&packet->PID,2);
nonce[8] = packet->frameCnt;
memcpy((uint8_t*)&nonce+9,(uint8_t*)&_buf[_bufSize-9],3);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("nonceCnt1 and 2: %02x %02x %02x"),nonce[9],nonce[10],nonce[11]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("nonceCnt1 and 2: %02x %02x %02x"),nonce[9],nonce[10],nonce[11]);
memcpy((uint8_t*)&tag,(uint8_t*)&_buf[_bufSize-6],4);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("tag: %02x %02x %02x %02x"),tag[0],tag[1],tag[2],tag[3]);
// AddLog(LOG_LEVEL_DEBUG,PSTR("tag: %02x %02x %02x %02x"),tag[0],tag[1],tag[2],tag[3]);
MI32_ReverseMAC(packet->MAC);
uint8_t _bindkey[16] = {0x0};
bool foundNoKey = true;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(packet->MAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){
memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey));
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
foundNoKey = false;
break;
}
}
if(foundNoKey){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!"));
return -2;
}
@ -620,7 +620,7 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){
ret = br_ccm_check_tag(&ctx, &tag);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]);
return ret-1;
}
#endif // USE_MI_DECRYPTION
@ -675,9 +675,9 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, uint8_t counter)
for(uint32_t i=0; i<MIBLEsensors.size(); i++){
if(memcmp(_MAC,MIBLEsensors[i].MAC,sizeof(_MAC))==0){
DEBUG_SENSOR_LOG(PSTR("%s: known sensor at slot: %u"),D_CMND_MI32, i);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
if(MIBLEsensors[i].lastCnt==counter) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Old packet"));
// AddLog(LOG_LEVEL_DEBUG,PSTR("Old packet"));
return 0xff; // packet received before, stop here
}
return i;
@ -732,7 +732,7 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, uint8_t counter)
break;
}
MIBLEsensors.push_back(_newSensor);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
MI32.mode.shallShowStatusInfo = 1;
return MIBLEsensors.size()-1;
};
@ -780,7 +780,7 @@ void MI32PreInit(void) {
MI32.option.showRSSI = 1;
MI32.option.ignoreBogusBattery = 1; // from advertisements
MI32.option.holdBackFirstAutodiscovery = 1;
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: pre-init"));
AddLog(LOG_LEVEL_INFO,PSTR("M32: pre-init"));
}
void MI32Init(void) {
@ -790,13 +790,13 @@ void MI32Init(void) {
TasmotaGlobal.wifi_stay_asleep = true;
if (WiFi.getSleep() == false) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Put WiFi modem in sleep mode"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Put WiFi modem in sleep mode"));
WiFi.setSleep(true); // Sleep
}
if (!MI32.mode.init) {
NimBLEDevice::init("");
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Init BLE device"));
AddLog(LOG_LEVEL_INFO,PSTR("M32: Init BLE device"));
MI32.mode.canScan = 1;
MI32.mode.init = 1;
MI32.period = Settings.tele_period;
@ -851,16 +851,16 @@ bool MI32ConnectActiveSensor(){ // only use inside a task !!
NimBLEAddress _address = NimBLEAddress(MIBLEsensors[MI32.state.sensor].MAC);
if(NimBLEDevice::getClientListSize()) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: found any clients in the list"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: found any clients in the list"),D_CMND_MI32);
MI32Client = NimBLEDevice::getClientByPeerAddress(_address);
if(MI32Client){
// Should be impossible
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: got connected client"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: got connected client"),D_CMND_MI32);
}
else {
// Should be the norm after the first iteration
MI32Client = NimBLEDevice::getDisconnectedClient();
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: got disconnected client"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: got disconnected client"),D_CMND_MI32);
}
}
@ -870,18 +870,18 @@ bool MI32ConnectActiveSensor(){ // only use inside a task !!
return false;
}
if(!MI32Client) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: will create client"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: will create client"),D_CMND_MI32);
MI32Client = NimBLEDevice::createClient();
MI32Client->setClientCallbacks(&MI32SensorCB , false);
MI32Client->setConnectionParams(12,12,0,48);
MI32Client->setConnectTimeout(30);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: did create new client"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: did create new client"),D_CMND_MI32);
}
vTaskDelay(300/ portTICK_PERIOD_MS);
if (!MI32Client->connect(_address,false)) {
MI32.mode.willConnect = 0;
// NimBLEDevice::deleteClient(MI32Client);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: did not connect client"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: did not connect client"),D_CMND_MI32);
return false;
}
return true;
@ -899,7 +899,7 @@ void MI32StartScanTask(){
0, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),D_CMND_MI32);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),D_CMND_MI32);
}
void MI32ScanTask(void *pvParameters){
@ -940,8 +940,8 @@ void MI32StartSensorTask(){
15, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start sensor connections"),D_CMND_MI32);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start sensor connections"),D_CMND_MI32);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
}
void MI32SensorTask(void *pvParameters){
@ -1014,8 +1014,8 @@ void MI32StartTimeTask(){
15, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start time set"),D_CMND_MI32);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start time set"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
}
void MI32TimeTask(void *pvParameters){
@ -1079,8 +1079,8 @@ void MI32StartUnitTask(){
15, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start unit set"),D_CMND_MI32);
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start unit set"),D_CMND_MI32);
// AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor);
}
void MI32UnitTask(void *pvParameters){
@ -1270,13 +1270,13 @@ void MI32parseMiBeacon(char * _buf, uint32_t _slot, uint16_t _bufSize){
else return; // 0x3058 holds no data, TODO: check for unpaired devices, that need connections
break;
case MJYD2S:
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MJYD2S: %x"),_beacon.frame);
AddLog(LOG_LEVEL_DEBUG,PSTR("MJYD2S: %x"),_beacon.frame);
if (_beacon.frame == 0x5948){ // Now let's build/recreate a special MiBeacon
memmove((uint8_t*)&_beacon.MAC+6,(uint8_t*)&_beacon.MAC, _bufSize); // shift payload by the size of the MAC = 6 bytes
memcpy((uint8_t*)&_beacon.MAC,MIBLEsensors[_slot].MAC,6); // now insert the real MAC from our internal vector
_bufSize+=6; // the packet has grown
MI32_ReverseMAC(_beacon.MAC); // payload MAC is always reversed
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MJYD2S: special packet"));
AddLog(LOG_LEVEL_DEBUG,PSTR("MJYD2S: special packet"));
}
if (_beacon.frame != 0x5910){
decryptRet = MI32_decryptPacket((char*)&_beacon.productID,_bufSize,MJYD2S); //start with PID
@ -1284,7 +1284,7 @@ void MI32parseMiBeacon(char * _buf, uint32_t _slot, uint16_t _bufSize){
break;
}
if(decryptRet!=0){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption failed with error: %d"),decryptRet);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption failed with error: %d"),decryptRet);
return;
}
#endif //USE_MI_DECRYPTION
@ -1293,13 +1293,13 @@ if(decryptRet!=0){
DEBUG_SENSOR_LOG(PSTR("CGD1 no support for MiBeacon, type %u"),MIBLEsensors[_slot].type);
return;
}
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u with payload type: %02x"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot,_beacon.type);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u with payload type: %02x"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot,_beacon.type);
switch(_beacon.type){
case 0x01:
MIBLEsensors[_slot].Btn=_beacon.Btn.num + (_beacon.Btn.longPress/2)*6;
MIBLEsensors[_slot].eventType.Btn = 1;
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 1: U16: %u Button"), MIBLEsensors[_slot].Btn );
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 1: U16: %u Button"), MIBLEsensors[_slot].Btn );
break;
case 0x04:
_tempFloat=(float)(_beacon.temp)/10.0f;
@ -1308,7 +1308,7 @@ if(decryptRet!=0){
MIBLEsensors[_slot].eventType.temp = 1;
DEBUG_SENSOR_LOG(PSTR("Mode 4: temp updated"));
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 4: U16: %u Temp"), _beacon.temp );
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 4: U16: %u Temp"), _beacon.temp );
break;
case 0x06:
_tempFloat=(float)(_beacon.hum)/10.0f;
@ -1317,7 +1317,7 @@ if(decryptRet!=0){
MIBLEsensors[_slot].eventType.hum = 1;
DEBUG_SENSOR_LOG(PSTR("Mode 6: hum updated"));
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 6: U16: %u Hum"), _beacon.hum);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 6: U16: %u Hum"), _beacon.hum);
break;
case 0x07:
MIBLEsensors[_slot].lux=_beacon.lux & 0x00ffffff;
@ -1325,19 +1325,19 @@ if(decryptRet!=0){
MIBLEsensors[_slot].eventType.noMotion = 1;
}
MIBLEsensors[_slot].eventType.lux = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
break;
case 0x08:
MIBLEsensors[_slot].moisture=_beacon.moist;
MIBLEsensors[_slot].eventType.moist = 1;
DEBUG_SENSOR_LOG(PSTR("Mode 8: moisture updated"));
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 8: U8: %u Moisture"), _beacon.moist);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 8: U8: %u Moisture"), _beacon.moist);
break;
case 0x09:
MIBLEsensors[_slot].fertility=_beacon.fert;
MIBLEsensors[_slot].eventType.fert = 1;
DEBUG_SENSOR_LOG(PSTR("Mode 9: fertility updated"));
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 9: U16: %u Fertility"), _beacon.fert);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 9: U16: %u Fertility"), _beacon.fert);
break;
case 0x0a:
if(MI32.option.ignoreBogusBattery){
@ -1350,7 +1350,7 @@ if(decryptRet!=0){
MIBLEsensors[_slot].eventType.bat = 1;
DEBUG_SENSOR_LOG(PSTR("Mode a: bat updated"));
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode a: U8: %u %%"), _beacon.bat);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode a: U8: %u %%"), _beacon.bat);
break;
case 0x0d:
_tempFloat=(float)(_beacon.HT.temp)/10.0f;
@ -1364,7 +1364,7 @@ if(decryptRet!=0){
DEBUG_SENSOR_LOG(PSTR("Mode d: hum updated"));
}
MIBLEsensors[_slot].eventType.tempHum = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
break;
#ifdef USE_MI_DECRYPTION
case 0x0f:
@ -1376,13 +1376,13 @@ if(decryptRet!=0){
MIBLEsensors[_slot].eventType.lux = 1;
MIBLEsensors[_slot].NMT = 0;
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux );
// AddLog(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux );
break;
case 0x17:
MIBLEsensors[_slot].NMT = _beacon.NMT;
MIBLEsensors[_slot].eventType.NMT = 1;
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 17: NMT: %u seconds"), _beacon.NMT);
// AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 17: NMT: %u seconds"), _beacon.NMT);
break;
#endif //USE_MI_DECRYPTION
default:
@ -1392,7 +1392,7 @@ if(decryptRet!=0){
MIBLEsensors[_slot].NMT = 0;
MIBLEsensors[_slot].lastTime = millis();
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux );
// AddLog(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux );
}
else{
AddLogBuffer(LOG_LEVEL_DEBUG,(uint8_t*)_buf,_bufSize);
@ -1407,7 +1407,7 @@ if(decryptRet!=0){
void MI32ParseATCPacket(char * _buf, uint32_t length, uint8_t addr[6], int RSSI){
ATCPacket_t *_packet = (ATCPacket_t*)_buf;
uint32_t _slot = MIBLEgetSensorSlot(_packet->MAC, 0x0a1c, _packet->frameCnt); // This must be a hard-coded fake ID
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
if(_slot==0xff) return;
MIBLEsensors[_slot].RSSI=RSSI;
@ -1427,7 +1427,7 @@ void MI32parseCGD1Packet(char * _buf, uint32_t length, uint8_t addr[6], int RSSI
uint8_t _addr[6];
memcpy(_addr,addr,6);
uint32_t _slot = MIBLEgetSensorSlot(_addr, 0x0576, 0); // This must be hard-coded, no object-id in Cleargrass-packet, we have no packet counter too
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
if(_slot==0xff) return;
MIBLEsensors[_slot].RSSI=RSSI;
cg_packet_t _packet;
@ -1469,7 +1469,7 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) {
return;
}
uint16_t _type= buf[3]*256 + buf[2];
// AddLog_P(LOG_LEVEL_INFO, PSTR("%02x %02x %02x %02x"),(uint8_t)buf[0], (uint8_t)buf[1],(uint8_t)buf[2],(uint8_t)buf[3]);
// AddLog(LOG_LEVEL_INFO, PSTR("%02x %02x %02x %02x"),(uint8_t)buf[0], (uint8_t)buf[1],(uint8_t)buf[2],(uint8_t)buf[3]);
uint8_t _addr[6];
memcpy(_addr,addr,6);
uint16_t _slot = MIBLEgetSensorSlot(_addr, _type, buf[4]);
@ -1489,36 +1489,36 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) {
* @param UUID
*/
void MI32ParseGenericBeacon(uint8_t* payload, size_t payloadLength, uint16_t* CID, uint16_t*SVC, uint16_t* UUID){
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Beacon:____________"));
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Beacon:____________"));
for (uint32_t i = 0; i<payloadLength;){
uint32_t ADtype = payload[i+1];
uint32_t offset = payload[i];
switch(ADtype){
case 0x01:
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Flags: %02x"), payload[i+2]);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("Flags: %02x"), payload[i+2]);
break;
case 0x02: case 0x03:
*UUID = payload[i+3]*256 + payload[i+2];
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("UUID: %04x"), *UUID);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("UUID: %04x"), *UUID);
break;
case 0x08: case 0x09:
{
uint8_t _saveChar = payload[i+offset+1];
payload[i+offset+1] = 0;
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Name: %s"), (char*)&payload[i+2]);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("Name: %s"), (char*)&payload[i+2]);
payload[i+offset+1] = _saveChar;
}
break;
case 0x0a:
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("TxPow: %02u"), payload[i+2]);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("TxPow: %02u"), payload[i+2]);
break;
case 0xff:
*CID = payload[i+3]*256 + payload[i+2];
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("CID: %04x"), *CID);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("CID: %04x"), *CID);
break;
case 0x16:
*SVC = payload[i+3]*256 + payload[i+2];
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("SVC: %04x"), *SVC);
AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("SVC: %04x"), *SVC);
break;
}
i+=offset+1;
@ -1547,13 +1547,13 @@ void MI32HandleGenericBeacon(uint8_t* payload, size_t payloadLength, int RSSI, u
}
// else handle scan
if(MIBLEscanResult.size()>19) {
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full"));
AddLog(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full"));
MI32.state.beaconScanCounter = 1;
return;
}
for(auto _scanResult : MIBLEscanResult){
if(memcmp(addr,_scanResult.MAC,6)==0){
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: known device"));
// AddLog(LOG_LEVEL_INFO,PSTR("M32: known device"));
return;
}
}
@ -1583,12 +1583,12 @@ void MI32addBeacon(uint8_t index, char* data){
_new.time = 0;
if(memcmp(_empty,_new.MAC,6) == 0){
_new.active = false;
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index);
AddLog(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index);
}
else{
_new.active = true;
MI32.mode.activeBeacon = 1;
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC);
AddLog(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC);
}
}
@ -1643,7 +1643,7 @@ void MI32readHT_LY(char *_buf){
DEBUG_SENSOR_LOG(PSTR("%s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
if(_buf[0] != 0 && _buf[1] != 0){
memcpy(&LYWSD0x_HT,(void *)_buf,sizeof(LYWSD0x_HT));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
uint32_t _slot = MI32.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
@ -1672,7 +1672,7 @@ void MI32readHT_LY(char *_buf){
bool MI32readBat(char *_buf){
DEBUG_SENSOR_LOG(PSTR("%s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
if(_buf[0] != 0){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_MI32,_buf[0]);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_MI32,_buf[0]);
uint32_t _slot = MI32.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
if(_buf[0]<101){
@ -1680,7 +1680,7 @@ bool MI32readBat(char *_buf){
if(MIBLEsensors[_slot].type==FLORA){
memcpy(MIBLEsensors[_slot].firmware, _buf+2, 5);
MIBLEsensors[_slot].firmware[5] = '\0';
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Firmware: %s"),D_CMND_MI32,MIBLEsensors[_slot].firmware);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Firmware: %s"),D_CMND_MI32,MIBLEsensors[_slot].firmware);
}
MIBLEsensors[_slot].eventType.bat = 1;
MIBLEsensors[_slot].shallSendMQTT = 1;
@ -1795,8 +1795,8 @@ void MI32EverySecond(bool restart){
if(MI32.mode.connected == 0) {
if (MI32.mode.shallReadBatt) {
//TODO: decide automatically, which sensor can not work without connections
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: active sensor now: %u of %u"),D_CMND_MI32, MI32.state.sensor, MIBLEsensors.size()-1);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("will connect to %s"),kMI32DeviceType[MIBLEsensors[MI32.state.sensor].type-1] );
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: active sensor now: %u of %u"),D_CMND_MI32, MI32.state.sensor, MIBLEsensors.size()-1);
AddLog(LOG_LEVEL_DEBUG, PSTR("will connect to %s"),kMI32DeviceType[MIBLEsensors[MI32.state.sensor].type-1] );
MI32StartTask(MI32_TASK_BATT);
}
@ -1843,7 +1843,7 @@ void CmndMi32Time(void) {
if (XdrvMailbox.data_len > 0) {
if (MIBLEsensors.size() > XdrvMailbox.payload) {
if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time"));
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time"));
MI32.state.sensor = XdrvMailbox.payload;
MI32.mode.canScan = 0;
MI32.mode.canConnect = 0;
@ -1873,7 +1873,7 @@ void CmndMi32Unit(void) {
if (XdrvMailbox.data_len > 0) {
if (MIBLEsensors.size() > XdrvMailbox.payload) {
if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit"));
MI32.state.sensor = XdrvMailbox.payload;
MI32.mode.canScan = 0;
MI32.mode.canConnect = 0;
@ -1923,7 +1923,7 @@ void CmndMi32Block(void){
switch (XdrvMailbox.index) {
case 0:
MIBLEBlockList.clear();
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
// AddLog(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
ResponseCmndIdxChar(PSTR("Block list cleared"));
break;
case 1:
@ -1953,7 +1953,7 @@ void CmndMi32Block(void){
ResponseCmndIdxChar(XdrvMailbox.data);
MI32removeMIBLEsensor(_MACasBytes.buf);
}
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
// AddLog(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
break;
}
}

View File

@ -490,7 +490,7 @@ int toggleUnit(BLE_ESP32::generic_sensor_t *op){
bool MI32Operation(int slot, int optype, const char *svc, const char *charactistic, const char *notifychar = nullptr, const uint8_t *data = nullptr, int datalen = 0, uint8_t *addr = nullptr ) {
if (!svc || !svc[0]){
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Op inv svc"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: Op inv svc"));
return 0;
}
@ -499,17 +499,17 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
// ALWAYS use this function to create a new one.
int res = BLE_ESP32::newOperation(&op);
if (!res){
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Can't get a newOperation"));
AddLog(LOG_LEVEL_ERROR,PSTR("M32: Can't get a newOperation"));
return 0;
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Got a newOperation"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Got a newOperation"));
}
if (slot >= 0){
op->addr = NimBLEAddress(MIBLEsensors[slot].MAC);
} else {
if (!addr){
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: No addr"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: No addr"));
BLE_ESP32::freeOperation(&op);
return 0;
}
@ -521,7 +521,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
if (!op->serviceUUID.bitSize()){
BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad service string %s"), svc);
AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad service string %s"), svc);
return 0;
}
@ -531,7 +531,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
op->characteristicUUID = NimBLEUUID(charactistic);
if (!op->characteristicUUID.bitSize()){
BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad characteristic string %s"), charactistic);
AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad characteristic string %s"), charactistic);
return 0;
}
}
@ -539,7 +539,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
op->notificationCharacteristicUUID = NimBLEUUID(notifychar);
if (!op->notificationCharacteristicUUID.bitSize()){
BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad notifycharacteristic string %s"), notifychar);
AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad notifycharacteristic string %s"), notifychar);
return 0;
}
}
@ -564,13 +564,13 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
uint32_t context = (optype << 24) | (MIBLEsensors[slot].type << 16) | slot;
op->context = (void *)context;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str());
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str());
res = BLE_ESP32::extQueueOperation(&op);
if (!res){
// if it fails to add to the queue, do please delete it
BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Failed to queue new operation - deleted"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: Failed to queue new operation - deleted"));
}
return res;
@ -611,9 +611,9 @@ int genericBatReadFn(int slot){
break;
}
if (res > 0){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type);
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res);
}
return res;
}
@ -653,7 +653,7 @@ int genericSensorReadFn(int slot, int force){
// called once per second
int readOneSensor(){
if (MI32.sensorreader.active){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor - already active reading %d"), MI32.sensorreader.slot-1);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor - already active reading %d"), MI32.sensorreader.slot-1);
return 0;
}
@ -663,12 +663,12 @@ int readOneSensor(){
do {
// MI32.sensorreader.slot is reset to zero to trigger a read sequence
if (MI32.sensorreader.slot >= MIBLEsensors.size()){
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size());
//AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size());
return 0;
}
res = genericSensorReadFn(MI32.sensorreader.slot, 0);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res);
// if this sensor in this slot does not need to be read via notify, just move on top the next one
if (res < 0){
@ -680,7 +680,7 @@ int readOneSensor(){
if (res == 0){
// can't read at the moment (no operations available?)
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res);
return 0;
}
@ -689,7 +689,7 @@ int readOneSensor(){
// and make it wait until the read/notify is complete
// this is cleared in the response callback.
MI32.sensorreader.active = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res);
// started one
return 1;
@ -714,7 +714,7 @@ int readOneBat(){
if (res < 0){
MI32.batteryreader.slot++;
if (MI32.batteryreader.slot >= MIBLEsensors.size()){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop complete at %d"), MI32.batteryreader.slot);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt loop complete at %d"), MI32.batteryreader.slot);
}
return 0;
}
@ -730,7 +730,7 @@ int readOneBat(){
// this is cleared in the response callback.
MI32.batteryreader.active = 1;
if (MI32.batteryreader.slot >= MIBLEsensors.size()){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop will complete at %d"), MI32.batteryreader.slot);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt loop will complete at %d"), MI32.batteryreader.slot);
}
// started one
return 1;
@ -816,7 +816,7 @@ int genericTimeWriteFn(int slot){
int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
uint32_t context = (uint32_t) op->context;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI op complete context %x"), context);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI op complete context %x"), context);
int opType = context >> 24;
int devType = (context >> 16) & 0xff;
@ -832,12 +832,12 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
bool fail = false;
if (op->addr != addr){
// slot changed during operation?
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Slot mac changed during an operation"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: Slot mac changed during an operation"));
fail = true;
}
if (op->state <= GEN_STATE_FAILED){
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Operation failed %d for %s"), op->state, slotMAC);
AddLog(LOG_LEVEL_ERROR, PSTR("M32: Operation failed %d for %s"), op->state, slotMAC);
fail = true;
}
@ -857,7 +857,7 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
switch(opType){
case OP_TIME_WRITE:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Time write for %s complete"), slotMAC);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Time write for %s complete"), slotMAC);
return 0; // nothing to do
case OP_BATT_READ:{
uint8_t *data = nullptr;
@ -876,33 +876,33 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
// allow another...
MI32.batteryreader.active = 0;
AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt read slot %d done state %x"), slot, op->state);
AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt read slot %d done state %x"), slot, op->state);
} return 0;
case OP_UNIT_WRITE: // nothing more to do?
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit write for %s complete"), slotMAC);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit write for %s complete"), slotMAC);
return 0;
case OP_UNIT_READ: {
uint8_t currUnit = op->dataRead[0];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit read for %s complete %d"), slotMAC, currUnit);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit read for %s complete %d"), slotMAC, currUnit);
} return 0;
case OP_UNIT_TOGGLE: {
uint8_t currUnit = op->dataToWrite[0];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen);
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen);
} return 0;
case OP_READ_HT_LY: {
// allow another...
MI32.sensorreader.active = 0;
MI32notifyHT_LY(slot, (char*)op->dataNotify, op->notifylen);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HT_LY notify for %s complete"), slotMAC);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: HT_LY notify for %s complete"), slotMAC);
} return 0;
default:
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: OpType %d not recognised?"), opType);
AddLog(LOG_LEVEL_ERROR, PSTR("M32: OpType %d not recognised?"), opType);
return 0;
}
@ -914,7 +914,7 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
// we will try not to use this...
BLEAdvertisedDevice *advertisedDevice = pStruct->advertisedDevice;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
// AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
int RSSI = pStruct->RSSI;
const uint8_t *addr = pStruct->addr;
if(MI32isInBlockList(addr) == true) return 0;
@ -937,13 +937,13 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
char temp[60];
BLE_ESP32::dump(temp, 13, addr, 6);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s svc[0] UUID (%x)"), temp, UUID);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s svc[0] UUID (%x)"), temp, UUID);
std::string ServiceDataStr = advertisedDevice->getServiceData(0);
uint32_t ServiceDataLength = ServiceDataStr.length();
const uint8_t *ServiceData = (const uint8_t *)ServiceDataStr.data();
BLE_ESP32::dump(temp, 60, ServiceData, ServiceDataLength);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s"), temp);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s"), temp);
if (UUID){
@ -1041,14 +1041,14 @@ int MI32AddKey(char* payload, char* key = nullptr){
bool unknownKey = true;
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(keyMAC.MAC,MIBLEbindKeys[i].MAC,sizeof(keyMAC.MAC))==0){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Known key"));
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Known key"));
memcpy(MIBLEbindKeys[i].key, keyMAC.key, 16);
unknownKey=false;
return 1;
}
}
if(unknownKey){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: New key"));
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: New key"));
MIBLEbindKeys.push_back(keyMAC);
return 1;
}
@ -1066,17 +1066,17 @@ int MIDecryptPayload(const uint8_t *macin, const uint8_t *nonce, uint32_t tag, u
uint8_t _bindkey[32] = {0x0};
const unsigned char authData[16] = {0x11};
bool foundNoKey = true;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
if(memcmp(mac, MIBLEbindKeys[i].MAC, 6)==0){
memcpy(_bindkey, MIBLEbindKeys[i].key, 16);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
foundNoKey = false;
break;
}
}
if(foundNoKey){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No Key found"));
return -2; // indicates needs key
}
@ -1098,7 +1098,7 @@ int MIDecryptPayload(const uint8_t *macin, const uint8_t *nonce, uint32_t tag, u
// returns 1 if matched, else 0
int ret = br_ccm_check_tag(&ctx, &tag);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]);
return ret-1; // -> -1=fail, 0=success
}
@ -1168,7 +1168,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
parsed->devicetype = *((uint16_t *)(data + byteindex));
byteindex += 2;
parsed->framecnt = data[byteindex];
//if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI frame %d"), parsed->framecnt);
//if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI frame %d"), parsed->framecnt);
byteindex++;
@ -1217,17 +1217,17 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
break;
case 0: // suceeded
parsed->needkey = KEY_REQUIRED_AND_FOUND;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload decrypted"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload decrypted"));
break;
case -1: // key failed to work
parsed->needkey = KEY_REQUIRED_AND_INVALID;
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload decrypt failed"));
AddLog(LOG_LEVEL_ERROR,PSTR("M32: Payload decrypt failed"));
parsed->payloadpresent = 0;
return 0;
break;
case -2: // key not present
parsed->needkey = KEY_REQUIRED_BUT_NOT_FOUND;
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload encrypted but no key"));
AddLog(LOG_LEVEL_ERROR,PSTR("M32: Payload encrypted but no key"));
parsed->payloadpresent = 0;
return 0;
break;
@ -1262,7 +1262,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
}
if ((len - byteindex) == 0){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No payload"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No payload"));
parsed->payload.size = 0;
parsed->payloadpresent = 0;
return 0;
@ -1271,14 +1271,14 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
// we have payload which did not need decrypt.
if (decres == 1){
parsed->needkey = KEY_NOT_REQUIRED;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload unencrypted"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload unencrypted"));
}
// already decrypted if required
parsed->payloadpresent = 1;
memcpy(&parsed->payload, (data + byteindex), (len - byteindex));
if (parsed->payload.size != (len - byteindex) - 3){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload length mismatch"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload length mismatch"));
}
return 1;
@ -1319,7 +1319,7 @@ void MI32nullifyEndOfMQTT_DATA(){
*/
uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter){
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: will test ID-type: %x"),D_CMND_MI32, _type);
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: will test ID-type: %x"),D_CMND_MI32, _type);
bool _success = false;
for (uint32_t i=0; i < MI_MI32_TYPES; i++){ // i < sizeof(kMI32DeviceID) gives compiler warning
if(_type == kMI32DeviceID[i]){
@ -1328,40 +1328,40 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter)
break;
}
else {
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]);
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]);
}
}
if(!_success) {
_type = 1; // unknown
}
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: vector size %u"),D_CMND_MI32, MIBLEsensors.size());
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: vector size %u"),D_CMND_MI32, MIBLEsensors.size());
for(uint32_t i=0; i<MIBLEsensors.size(); i++){
if(memcmp(mac, MIBLEsensors[i].MAC, 6)==0){
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
if(MIBLEsensors[i].lastCnt==counter) {
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Old packet"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size());
// AddLog(LOG_LEVEL_DEBUG,PSTR("Old packet"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size());
//return 0xff; // packet received before, stop here
}
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Frame %d, last %d"), counter, MIBLEsensors[i].lastCnt);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Frame %d, last %d"), counter, MIBLEsensors[i].lastCnt);
MIBLEsensors[i].lastCnt = counter;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size());
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size());
if (MIBLEsensors[i].type != _type){
// this happens on incorrectly configured pvvx ATC firmware
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: %s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i,
AddLog(LOG_LEVEL_ERROR,PSTR("M32: %s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i,
kMI32DeviceID[MIBLEsensors[i].type-1], kMI32DeviceType[MIBLEsensors[i].type-1], kMI32DeviceID[_type-1], kMI32DeviceType[_type-1]);
MIBLEsensors[i].type = _type;
}
return i;
}
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]);
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]);
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]);
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]);
}
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size());
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: found new sensor"),D_CMND_MI32);
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size());
//AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: found new sensor"),D_CMND_MI32);
mi_sensor_t _newSensor;
memset(&_newSensor, 0 , sizeof(_newSensor));
memcpy(_newSensor.MAC, mac, 6);
@ -1411,7 +1411,7 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter)
break;
}
MIBLEsensors.push_back(_newSensor);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
MI32.mode.shallShowStatusInfo = 1;
return MIBLEsensors.size()-1;
};
@ -1444,7 +1444,7 @@ void MI32StatusInfo() {
int MI32scanCompleteCallback(NimBLEScanResults results){
// we actually don't need to do anything here....
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Scan complete"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Scan complete"));
return 0;
}
@ -1473,7 +1473,7 @@ void MI32Init(void) {
// note: for operations, we will set individual callbacks in the operations we request
//void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn);
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: init: request callbacks"));
AddLog(LOG_LEVEL_INFO,PSTR("M32: init: request callbacks"));
MI32.period = Settings.tele_period;
MI32.mode.init = 1;
return;
@ -1496,19 +1496,19 @@ int MIParseBatt(int slot, uint8_t *data, int len){
MIBLEsensors[slot].bat = value;
if(MIBLEsensors[slot].type==MI_FLORA){
if (len < 7){
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: FLORA: not enough bytes read for firmware?"));
AddLog(LOG_LEVEL_ERROR,PSTR("M32: FLORA: not enough bytes read for firmware?"));
} else {
memcpy(MIBLEsensors[slot].firmware, data+2, 5);
MIBLEsensors[slot].firmware[5] = '\0';
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware);
}
}
MIBLEsensors[slot].eventType.bat = 1;
MIBLEsensors[slot].shallSendMQTT = 1;
MI32.mode.shallTriggerTele = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Batt read for %s complete %d"), slotMAC, value);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Batt read for %s complete %d"), slotMAC, value);
} else {
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value);
AddLog(LOG_LEVEL_ERROR,PSTR("M32: Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value);
}
return 0;
@ -1540,7 +1540,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
if(_slot==0xff) return;
if ((_slot >= 0) && (_slot < MIBLEsensors.size())){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
MIBLEsensors[_slot].RSSI=RSSI;
MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED;
@ -1557,7 +1557,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
}
return;
} else {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: PVVX packet mac mismatch - ignored?"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: PVVX packet mac mismatch - ignored?"));
return;
}
}
@ -1571,9 +1571,9 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
if (memcmp(addrrev, _packet->MAC, 6)){
MI32_ReverseMAC(_packet->MAC);
if (!memcmp(addrrev, _packet->MAC, 6)){
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with reversed MAC addr?"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with reversed MAC addr?"));
} else {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with MAC addr mismatch - is this mesh?"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with MAC addr mismatch - is this mesh?"));
memcpy(addrrev, _packet->MAC, 6);
}
addr = addrrev;
@ -1584,7 +1584,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
if(_slot==0xff) return;
if ((_slot >= 0) && (_slot < MIBLEsensors.size())){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
MIBLEsensors[_slot].RSSI=RSSI;
MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED;
@ -1616,7 +1616,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
char tmp[20];
BLE_ESP32::dump(tmp, 20, (uint8_t*)&(parsed->payload), parsed->payload.size+3);
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MI%d payload %s"), _slot, tmp);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MI%d payload %s"), _slot, tmp);
switch(parsed->payload.type){
case 0x01: // button press
@ -1636,22 +1636,22 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
if(_tempFloat<60){
MIBLEsensors[_slot].temp=_tempFloat;
MIBLEsensors[_slot].eventType.temp = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp updated"));
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp ignored > 60 (%f)"), _tempFloat);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp ignored > 60 (%f)"), _tempFloat);
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 4: U16: %u Temp"), _beacon.temp );
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 4: U16: %u Temp"), _beacon.temp );
} break;
case 0x06: {
float _tempFloat=(float)(pld->hum)/10.0f;
if(_tempFloat<101){
MIBLEsensors[_slot].hum=_tempFloat;
MIBLEsensors[_slot].eventType.hum = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum updated"));
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum ignored > 101 (%f)"), _tempFloat);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum ignored > 101 (%f)"), _tempFloat);
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 6: U16: %u Hum"), _beacon.hum);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 6: U16: %u Hum"), _beacon.hum);
} break;
case 0x07:
MIBLEsensors[_slot].lux=pld->lux & 0x00ffffff;
@ -1659,19 +1659,19 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
MIBLEsensors[_slot].eventType.noMotion = 1;
}
MIBLEsensors[_slot].eventType.lux = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
break;
case 0x08:
MIBLEsensors[_slot].moisture=pld->moist;
MIBLEsensors[_slot].eventType.moist = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 8: moisture updated"));
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 8: U8: %u Moisture"), _beacon.moist);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 8: moisture updated"));
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 8: U8: %u Moisture"), _beacon.moist);
break;
case 0x09: // 'conductivity'
MIBLEsensors[_slot].fertility=pld->fert;
MIBLEsensors[_slot].eventType.fert = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 9: fertility updated"));
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 9: U16: %u Fertility"), _beacon.fert);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 9: fertility updated"));
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 9: U16: %u Fertility"), _beacon.fert);
break;
case 0x0a:
if(MI32.option.ignoreBogusBattery){
@ -1683,31 +1683,31 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
if(pld->bat<101){
MIBLEsensors[_slot].bat = pld->bat;
MIBLEsensors[_slot].eventType.bat = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat updated"));
} else {
MIBLEsensors[_slot].bat = 100;
MIBLEsensors[_slot].eventType.bat = 1;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat > 100 (%d)"), pld->bat);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat > 100 (%d)"), pld->bat);
}
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode a: U8: %u %%"), _beacon.bat);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode a: U8: %u %%"), _beacon.bat);
break;
case 0x0d:{
float _tempFloat=(float)(pld->HT.temp)/10.0f;
if(_tempFloat < 60){
MIBLEsensors[_slot].temp = _tempFloat;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp updated"));
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp ignored > 60 (%f)"), _tempFloat);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp ignored > 60 (%f)"), _tempFloat);
}
_tempFloat=(float)(pld->HT.hum)/10.0f;
if(_tempFloat < 100){
MIBLEsensors[_slot].hum = _tempFloat;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum updated"));
} else {
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum ignored > 100 (%f)"), _tempFloat);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum ignored > 100 (%f)"), _tempFloat);
}
MIBLEsensors[_slot].eventType.tempHum = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
} break;
case 0x0f:
if (parsed->payload.ten != 0) break;
@ -1718,7 +1718,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
MIBLEsensors[_slot].eventType.lux = 1;
MIBLEsensors[_slot].NMT = 0;
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: PIR: primary"),MIBLEsensors[_slot].lux );
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: PIR: primary"),MIBLEsensors[_slot].lux );
break;
case 0x10:{ // 'formaldehide'
const uint16_t f = uint16_t(parsed->payload.data[0]) | (uint16_t(parsed->payload.data[1]) << 8);
@ -1742,11 +1742,11 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
MIBLEsensors[_slot].NMT = pld->NMT;
MIBLEsensors[_slot].eventType.NMT = 1;
MI32.mode.shallTriggerTele = 1;
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 17: NMT: %u seconds"), _beacon.NMT);
// AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 17: NMT: %u seconds"), _beacon.NMT);
} break;
default: {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Unknown MI pld"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Unknown MI pld"));
res = 0;
} break;
}
@ -1771,7 +1771,7 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr
MI32_ReverseMAC(addrrev);
if (memcmp(addrrev, parsed.macdata.mac, 6)){
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI packet with MAC addr mismatch - is this mesh?"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI packet with MAC addr mismatch - is this mesh?"));
memcpy(addrrev, parsed.macdata.mac, 6);
MI32_ReverseMAC(addrrev);
addr = addrrev;
@ -1785,7 +1785,7 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr
}
MIBLEsensors[_slot].RSSI=RSSI;
if (!res){ // - if the payload is not valid
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MIParsePacket returned %d"), res);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MIParsePacket returned %d"), res);
return;
} else {
}
@ -1814,14 +1814,14 @@ void MI32removeMIBLEsensor(uint8_t* MAC){
\***********************************************************************/
void MI32notifyHT_LY(int slot, char *_buf, int len){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
// the value 0b00 is 28.16 C?
if(_buf[0] != 0 || _buf[1] != 0){
memcpy(&LYWSD0x_HT,(void *)_buf,sizeof(LYWSD0x_HT));
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: %s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: %s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
uint32_t _slot = slot;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MIBLE: Sensor slot: %u"), _slot);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MIBLE: Sensor slot: %u"), _slot);
static float _tempFloat;
_tempFloat=(float)(LYWSD0x_HT.temp)/100.0f;
if(_tempFloat<60){
@ -1831,7 +1831,7 @@ void MI32notifyHT_LY(int slot, char *_buf, int len){
_tempFloat=(float)LYWSD0x_HT.hum;
if(_tempFloat<100){
MIBLEsensors[_slot].hum = _tempFloat;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: LYWSD0x: hum updated"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: LYWSD0x: hum updated"));
}
MIBLEsensors[_slot].eventType.tempHum = 1;
if (MIBLEsensors[_slot].type == MI_LYWSD03MMC || MIBLEsensors[_slot].type == MI_MHOC401){
@ -1875,7 +1875,7 @@ void MI32Every50mSecond(){
void MI32EverySecond(bool restart){
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec"));
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec"));
MI32TimeoutSensors();
MI32ShowSomeSensors();
@ -1893,7 +1893,7 @@ void MI32EverySecond(bool restart){
if (MI32.secondsCounter >= MI32.period){
// only if we finished the last read
if (MI32.sensorreader.slot >= MIBLEsensors.size()){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off readOneSensor"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Kick off readOneSensor"));
// kick off notification sensor reading every period.
MI32.sensorreader.slot = 0;
MI32.secondsCounter = 0;
@ -1903,11 +1903,11 @@ void MI32EverySecond(bool restart){
if (MI32.secondsCounter2 >= MI32.period){
if (MI32.mqttCurrentSlot >= MIBLEsensors.size()){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off tele sending"));
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Kick off tele sending"));
MI32.mqttCurrentSlot = 0;
MI32.secondsCounter2 = 0;
} else {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot);
MI32.mqttCurrentSlot = 0;
MI32.secondsCounter2 = 0;
}
@ -1968,15 +1968,15 @@ void CmndMi32Time(void) {
if (MIBLEsensors.size() > slot) {
int res = genericTimeWriteFn(slot);
if (res > 0){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will set Time"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: will set Time"));
ResponseCmndNumber(slot);
return;
}
if (res < 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time on sensor type"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time on sensor type"));
}
if (res == 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time right now"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time right now"));
}
}
}
@ -2009,15 +2009,15 @@ void CmndMi32Unit(void) {
// TOGGLE unit?
int res = genericUnitWriteFn(slot, -1);
if (res > 0){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will toggle Unit"));
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: will toggle Unit"));
ResponseCmndNumber(slot);
return;
}
if (res < 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit on sensor type"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit on sensor type"));
}
if (res == 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit right now"));
AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit right now"));
}
}
}
@ -2091,7 +2091,7 @@ void CmndMi32Block(void){
MIBLEBlockList.push_back(_MACasBytes);
MI32removeMIBLEsensor(_MACasBytes.buf);
}
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: size of ilist: %u"), MIBLEBlockList.size());
// AddLog(LOG_LEVEL_INFO,PSTR("M32: size of ilist: %u"), MIBLEBlockList.size());
} break;
}
MI32BlockListResp();
@ -2136,7 +2136,7 @@ void MI32KeyListResp(){
void CmndMi32Keys(void){
#ifdef BLE_ESP32_ALIASES
int op = XdrvMailbox.index;
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Key %d %s"), op, XdrvMailbox.data);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Key %d %s"), op, XdrvMailbox.data);
int res = -1;
switch(op){
@ -2175,7 +2175,7 @@ void CmndMi32Keys(void){
return;
}
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Add key mac %s = key %s"), mac, key);
AddLog(LOG_LEVEL_ERROR,PSTR("M32: Add key mac %s = key %s"), mac, key);
char tmp[20];
// convert mac back to string
ToHex_P(addr,6,tmp,20,0);
@ -2186,7 +2186,7 @@ void CmndMi32Keys(void){
} while (p);
if (added){
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Added %d Keys"), added);
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Added %d Keys"), added);
MI32KeyListResp();
} else {
MI32KeyListResp();
@ -2194,7 +2194,7 @@ void CmndMi32Keys(void){
return;
} break;
case 2:{ // clear
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Keys clearing %d"), MIBLEbindKeys.size());
if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Keys clearing %d"), MIBLEbindKeys.size());
for (int i = MIBLEbindKeys.size()-1; i >= 0; i--){
MIBLEbindKeys.pop_back();
}
@ -2246,9 +2246,9 @@ const char HTTP_MI_KEY_STYLE[] PROGMEM = "";
#define D_MI32_KEY "MI32 Set Key"
void HandleMI32Key(){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HandleMI32Key hit"));
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: HandleMI32Key hit"));
if (!HttpCheckPriviledgedAccess()) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: !HttpCheckPriviledgedAccess()"));
AddLog(LOG_LEVEL_DEBUG, PSTR("M32: !HttpCheckPriviledgedAccess()"));
return;
}
WSContentStart_P(PSTR(D_MI32_KEY));
@ -2292,7 +2292,7 @@ void MI32TimeoutSensors(){
//if (MIBLEsensors[i].MAC[2] || MIBLEsensors[i].MAC[3] || MIBLEsensors[i].MAC[4] || MIBLEsensors[i].MAC[5]){
if (!BLE_ESP32::devicePresent(MIBLEsensors[i].MAC)){
uint8_t *mac = MIBLEsensors[i].MAC;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
TasAutoMutex localmutex(&slotmutex, "Mi32Timeout");
MIBLEsensors.erase(MIBLEsensors.begin() + i);
}
@ -2497,7 +2497,7 @@ void MI32ShowSomeSensors(){
}
ResponseAppend_P(PSTR("}"));
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
#ifdef USE_RULES
RulesTeleperiod(); // Allow rule based HA messages
@ -2547,7 +2547,7 @@ void MI32ShowTriggeredSensors(){
if (cnt){ // if we got one, then publish
ResponseAppend_P(PSTR("}"));
MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data);
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data);
#ifdef USE_RULES
RulesTeleperiod(); // Allow rule based HA messages

View File

@ -624,7 +624,7 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, int _rssi){
break;
}
MIBLEsensors.push_back(_newSensor);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_HM10, kHM10DeviceType[_type-1],MIBLEsensors.size()-1);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_HM10, kHM10DeviceType[_type-1],MIBLEsensors.size()-1);
return MIBLEsensors.size()-1;
};
@ -638,7 +638,7 @@ void HM10SerialInit(void) {
HM10.serialSpeed = HM10_BAUDRATE;
HM10Serial = new TasmotaSerial(Pin(GPIO_HM10_RX), Pin(GPIO_HM10_TX), 1, 0, HM10_MAX_RX_BUF);
if (HM10Serial->begin(HM10.serialSpeed)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s start serial communication fixed to 115200 baud"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s start serial communication fixed to 115200 baud"),D_CMND_HM10);
if (HM10Serial->hardwareSerial()) {
ClaimSerial();
DEBUG_SENSOR_LOG(PSTR("%s: claim HW"),D_CMND_HM10);
@ -681,7 +681,7 @@ void HM10parseMiBeacon(char * _buf, uint32_t _slot){
HM10_ReverseMAC(_beacon.MAC);
// if(memcmp(_beacon.MAC,MIBLEsensors[_slot].MAC,sizeof(_beacon.MAC))!=0){
// if (MIBLEsensors[_slot].showedUp>3) return; // probably false alarm from a damaged packet
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: remove garbage sensor"),D_CMND_HM10);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%s: remove garbage sensor"),D_CMND_HM10);
// DEBUG_SENSOR_LOG(PSTR("%s i: %x %x %x %x %x %x"),D_CMND_HM10, MIBLEsensors[_slot].MAC[5], MIBLEsensors[_slot].MAC[4],MIBLEsensors[_slot].MAC[3],MIBLEsensors[_slot].MAC[2],MIBLEsensors[_slot].MAC[1],MIBLEsensors[_slot].MAC[0]);
// DEBUG_SENSOR_LOG(PSTR("%s n: %x %x %x %x %x %x"),D_CMND_HM10, _beacon.MAC[5], _beacon.MAC[4], _beacon.MAC[3],_beacon.MAC[2],_beacon.MAC[1],_beacon.MAC[0]);
// MIBLEsensors.erase(MIBLEsensors.begin()+_slot);
@ -697,7 +697,7 @@ void HM10parseMiBeacon(char * _buf, uint32_t _slot){
DEBUG_SENSOR_LOG(PSTR("LYWSD03 and CGD1 no support for MiBeacon, type %u"),MIBLEsensors[_slot].type);
return;
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: %s mibeacon type: %x"),D_CMND_HM10, kHM10DeviceType[MIBLEsensors[_slot].type-1], _beacon.type);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: %s mibeacon type: %x"),D_CMND_HM10, kHM10DeviceType[MIBLEsensors[_slot].type-1], _beacon.type);
DEBUG_SENSOR_LOG(PSTR("%s at slot %u"), kHM10DeviceType[MIBLEsensors[_slot].type-1],_slot);
switch(_beacon.type){
@ -848,7 +848,7 @@ void HM10readHT_LY(char *_buf){
if(_buf[0]==0x4f && _buf[1]==0x4b) return; // "OK"
if(_buf[0] != 0 && _buf[1] != 0){
LYWSD0x_HT_t *packet = (LYWSD0x_HT_t*)_buf;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u"),D_CMND_HM10,packet->temp,packet->hum);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u"),D_CMND_HM10,packet->temp,packet->hum);
uint32_t _slot = HM10.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
@ -881,7 +881,7 @@ void HM10readHT_CGD1(char *_buf){
if(_buf[0] == 0){
if(_buf[1]==0 && _buf[2]==0 && _buf[3]==0 && _buf[4]==0) return;
CGD1_HT_t *_packet = (CGD1_HT_t*)_buf;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H * 100: %u"),D_CMND_HM10,_packet->temp,_packet->hum);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H * 100: %u"),D_CMND_HM10,_packet->temp,_packet->hum);
uint32_t _slot = HM10.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
@ -911,7 +911,7 @@ void HM10readHT_MJ_HT_V1(char *_buf){
// 0123456789012
uint32_t _temp = (atoi(_buf+2) * 10) + atoi(_buf+5);
uint32_t _hum = (atoi(_buf+9) * 10) + atoi(_buf+12);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, H * 10: %u"),D_CMND_HM10,_temp,_hum);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, H * 10: %u"),D_CMND_HM10,_temp,_hum);
uint32_t _slot = HM10.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
@ -937,7 +937,7 @@ void HM10readTLMF(char *_buf){
AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)_buf,16);
Flora_TLMF_t *_packet = (Flora_TLMF_t*)_buf;
if(_packet->ID==0xFB003C02){ // this is a magic word ... hopefully independent of FW version
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, L: %u, M: %u, F: %u"),D_CMND_HM10,_packet->temp,_packet->lux,_packet->moist,_packet->fert);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, L: %u, M: %u, F: %u"),D_CMND_HM10,_packet->temp,_packet->lux,_packet->moist,_packet->fert);
uint32_t _slot = HM10.state.sensor;
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
MIBLEsensors[_slot].showedUp=255; // this sensor is real
@ -968,7 +968,7 @@ bool HM10readBat(char *_buf){
// if (MIBLEsensors[_slot].type == LYWSD03MMC || MIBLEsensors[_slot].type == MHOC401) return true;
// }
if(_buf[0] != 0){
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_HM10,_buf[0]);
AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_HM10,_buf[0]);
DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot);
if(_buf[0]<101){
MIBLEsensors[_slot].bat=_buf[0];
@ -1008,13 +1008,13 @@ void HM10HandleGenericBeacon(void){
}
// else handle scan
if(MIBLEscanResult.size()>19) {
AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: Scan buffer full"));
AddLog(LOG_LEVEL_INFO,PSTR("HM10: Scan buffer full"));
HM10.state.beaconScanCounter = 1;
return;
}
for(auto _scanResult : MIBLEscanResult){
if(memcmp(HM10.rxAdvertisement.MAC,_scanResult.MAC,6)==0){
// AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: known device"));
// AddLog(LOG_LEVEL_INFO,PSTR("HM10: known device"));
return;
}
}
@ -1036,12 +1036,12 @@ void HM10addBeacon(uint8_t index, char* data){
_new.time = 0;
if(memcmp(_empty,_new.MAC,6) == 0){
_new.active = false;
AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: beacon%u deactivated"), index);
AddLog(LOG_LEVEL_INFO,PSTR("HM10: beacon%u deactivated"), index);
}
else{
_new.active = true;
HM10.mode.activeBeacon = 1;
AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: beacon added with MAC: %s"), _MAC);
AddLog(LOG_LEVEL_INFO,PSTR("HM10: beacon added with MAC: %s"), _MAC);
}
}
@ -1105,7 +1105,7 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds
*_rx= HM10Serial->read();
if(i==18){
if(memcmp(HM10.rxBuffer+4,"ISA:",4)==0){ //last 4 bytes of "OK+DISA:" should be safe enough
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s packet size: %u"),D_CMND_HM10,HM10.rxBuffer[16]);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%s packet size: %u"),D_CMND_HM10,HM10.rxBuffer[16]);
_targetsize = HM10.rxBuffer[16] + 19; // this is the size byte according to HM-10 docs
if(_targetsize>64) _targetsize=64;
memcpy(HM10.rxAdvertisement.MAC,HM10.rxBuffer+8,6);
@ -1180,7 +1180,7 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds
HM10HandleGenericBeacon();
}
uint16_t _type = (uint8_t)HM10.rxAdvertisement.svcData[5]*256 + (uint8_t)HM10.rxAdvertisement.svcData[4];
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%04x %02x %04x %04x %04x"),HM10.rxAdvertisement.UUID,HM10.rxAdvertisement.TX,HM10.rxAdvertisement.CID,HM10.rxAdvertisement.SVC, _type);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%04x %02x %04x %04x %04x"),HM10.rxAdvertisement.UUID,HM10.rxAdvertisement.TX,HM10.rxAdvertisement.CID,HM10.rxAdvertisement.SVC, _type);
if(HM10.rxAdvertisement.SVC==0x181a) _type = 0xa1c;
else if(HM10.rxAdvertisement.SVC==0xfdcd) _type = 0x0576;
uint16_t _slot = MIBLEgetSensorSlot(HM10.rxAdvertisement.MAC, _type, HM10.rxAdvertisement.RSSI);
@ -1199,9 +1199,9 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds
break;
case none:
if(success) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: response: %s"),D_CMND_HM10, (char *)HM10.rxBuffer);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: response: %s"),D_CMND_HM10, (char *)HM10.rxBuffer);
// for(uint32_t j = 0; j<i+1; j+=8){
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)ret[j],(uint8_t)ret[j+1],(uint8_t)ret[j+2],(uint8_t)ret[j+3],(uint8_t)ret[j+4],(uint8_t)ret[j+5],(uint8_t)ret[j+6],(uint8_t)ret[j+7]);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)ret[j],(uint8_t)ret[j+1],(uint8_t)ret[j+2],(uint8_t)ret[j+3],(uint8_t)ret[j+4],(uint8_t)ret[j+5],(uint8_t)ret[j+6],(uint8_t)ret[j+7]);
// }
HM10ParseResponse(HM10.rxBuffer,i);
}
@ -1225,21 +1225,21 @@ void HM10_TaskEvery100ms(){
while (runningTaskLoop) { // always iterate through the whole task list
switch(HM10_TASK_LIST[i][0]) { // handle the kind of task
case TASK_HM10_ROLE1:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: set role to 1"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: set role to 1"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
HM10Serial->write("AT+ROLE1");
break;
case TASK_HM10_IMME1:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: set imme to 1"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: set imme to 1"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
HM10Serial->write("AT+IMME1");
break;
case TASK_HM10_DISC:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: start discovery"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: start discovery"),D_CMND_HM10);
HM10.current_task_delay = 90; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1247,14 +1247,14 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+DISA?");
break;
case TASK_HM10_VERSION:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read version"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read version"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
HM10Serial->write("AT+VERR?");
break;
case TASK_HM10_NAME:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read name"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read name"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1263,7 +1263,7 @@ void HM10_TaskEvery100ms(){
case TASK_HM10_CONN:
char _con[20];
sprintf_P(_con,"AT+CON%02x%02x%02x%02x%02x%02x",MIBLEsensors[HM10.state.sensor].MAC[0],MIBLEsensors[HM10.state.sensor].MAC[1],MIBLEsensors[HM10.state.sensor].MAC[2],MIBLEsensors[HM10.state.sensor].MAC[3],MIBLEsensors[HM10.state.sensor].MAC[4],MIBLEsensors[HM10.state.sensor].MAC[5]);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: %s connect %s"),D_CMND_HM10,kHM10DeviceType[MIBLEsensors[HM10.state.sensor].type-1],_con);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: %s connect %s"),D_CMND_HM10,kHM10DeviceType[MIBLEsensors[HM10.state.sensor].type-1],_con);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1272,21 +1272,21 @@ void HM10_TaskEvery100ms(){
HM10.mode.connected = true;
break;
case TASK_HM10_DISCONN:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: disconnect"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: disconnect"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
HM10Serial->write("AT");
break;
case TASK_HM10_RESET:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Reset Device"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Reset Device"),D_CMND_HM10);
HM10Serial->write("AT+RESET");
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
break;
case TASK_HM10_SUB_L3:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10);
HM10.current_task_delay = 25; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
HM10.mode.awaiting = tempHumLY;
@ -1294,7 +1294,7 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+NOTIFY_ON0037");
break;
case TASK_HM10_UN_L3:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1302,7 +1302,7 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+NOTIFYOFF0037");
break;
case TASK_HM10_SUB_L2:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10);
HM10.current_task_delay = 85; // set task delay
HM10.mode.awaiting = tempHumLY;
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
@ -1311,7 +1311,7 @@ void HM10_TaskEvery100ms(){
else HM10Serial->write("AT+NOTIFY_ON004B"); //MHO-C303
break;
case TASK_HM10_UN_L2:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1320,7 +1320,7 @@ void HM10_TaskEvery100ms(){
else HM10Serial->write("AT+NOTIFY_OFF004B"); //MHO-C303
break;
case TASK_HM10_TIME_L2:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: set time"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: set time"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1328,10 +1328,10 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+SEND_DATAWR002F");
HM10Serial->write(HM10.timebuf,4);
HM10Serial->write(Rtc.time_timezone / 60);
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s Time-string: %x%x%x%x%x"),D_CMND_HM10, HM10.timebuf[0],HM10.timebuf[1],HM10.timebuf[2],HM10.timebuf[3],(Rtc.time_timezone /60));
AddLog(LOG_LEVEL_DEBUG,PSTR("%s Time-string: %x%x%x%x%x"),D_CMND_HM10, HM10.timebuf[0],HM10.timebuf[1],HM10.timebuf[2],HM10.timebuf[3],(Rtc.time_timezone /60));
break;
// case TASK_HM10_READ_BT_L3:
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 003A"),D_CMND_HM10);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 003A"),D_CMND_HM10);
// HM10.current_task_delay = 2; // set task delay
// HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
// runningTaskLoop = false;
@ -1339,7 +1339,7 @@ void HM10_TaskEvery100ms(){
// HM10.mode.awaiting = bat;
// break;
case TASK_HM10_READ_BT_L2:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0043"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0043"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1348,7 +1348,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = bat;
break;
case TASK_HM10_READ_BF_FL:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0038"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0038"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1356,7 +1356,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = bat;
break;
case TASK_HM10_CALL_TLMF_FL:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: write to handle 0033"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: write to handle 0033"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_READ_TLMF_FL,i);
runningTaskLoop = false;
@ -1366,7 +1366,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = none;
break;
case TASK_HM10_READ_TLMF_FL:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0035"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0035"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1374,7 +1374,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = TLMF;
break;
case TASK_HM10_READ_B_CGD1:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0011"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0011"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1382,7 +1382,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = bat;
break;
case TASK_HM10_SUB_HT_CGD1:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe 4b"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe 4b"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1390,7 +1390,7 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+NOTIFY_ON004b");
break;
case TASK_HM10_UN_HT_CGD1:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe 4b"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe 4b"),D_CMND_HM10);
HM10.current_task_delay = 5; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1398,14 +1398,14 @@ void HM10_TaskEvery100ms(){
HM10Serial->write("AT+NOTIFYOFF004b");
break;
case TASK_HM10_SCAN9:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: scan time to 9"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: scan time to 9"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
HM10Serial->write("AT+SCAN9");
break;
case TASK_HM10_READ_B_MJ:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0x18"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0x18"),D_CMND_HM10);
HM10.current_task_delay = 2; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1413,7 +1413,7 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = bat;
break;
case TASK_HM10_SUB_HT_MJ:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe to 0x0f"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe to 0x0f"),D_CMND_HM10);
HM10.current_task_delay = 10; // set task delay
HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i);
runningTaskLoop = false;
@ -1421,22 +1421,22 @@ void HM10_TaskEvery100ms(){
HM10.mode.awaiting = tempHumMJ;
break;
case TASK_HM10_FEEDBACK:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: get response"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: get response"),D_CMND_HM10);
HM10SerialHandleFeedback();
HM10.current_task_delay = HM10_TASK_LIST[i+1][1];; // set task delay
HM10_TASK_LIST[i][0] = TASK_HM10_DONE; // no feedback for reset
runningTaskLoop = false;
break;
case TASK_HM10_STATUS_EVENT:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: show status"),D_CMND_HM10);
AddLog(LOG_LEVEL_DEBUG, PSTR("%s: show status"),D_CMND_HM10);
HM10StatusInfo();
HM10.current_task_delay = HM10_TASK_LIST[i+1][1];; // set task delay
HM10_TASK_LIST[i][0] = TASK_HM10_DONE; // no feedback for reset
runningTaskLoop = false;
break;
case TASK_HM10_DONE: // this entry was already handled
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFound done HM10_TASK"),D_CMND_HM10);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("%snext slot:%u, i: %u"),D_CMND_HM10, HM10_TASK_LIST[i+1][0],i);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%sFound done HM10_TASK"),D_CMND_HM10);
// AddLog(LOG_LEVEL_DEBUG, PSTR("%snext slot:%u, i: %u"),D_CMND_HM10, HM10_TASK_LIST[i+1][0],i);
if(HM10_TASK_LIST[i+1][0] == TASK_HM10_NOTASK) { // check the next entry and if there is none
DEBUG_SENSOR_LOG(PSTR("%sno Tasks left"),D_CMND_HM10);
DEBUG_SENSOR_LOG(PSTR("%sHM10_TASK_DONE current slot %u"),D_CMND_HM10, i);
@ -1462,7 +1462,7 @@ void HM10StatusInfo() {
/*
char stemp[20];
snprintf_P(stemp, sizeof(stemp),PSTR("{%s:{\"found\": %u}}"),D_CMND_HM10, MIBLEsensors.size());
AddLog_P(LOG_LEVEL_INFO, stemp);
AddLog(LOG_LEVEL_INFO, stemp);
RulesProcessEvent(stemp);
*/
Response_P(PSTR("{\"%s\":{\"found\":%u}}"), D_CMND_HM10, MIBLEsensors.size());
@ -1688,7 +1688,7 @@ void CmndHM10Block(void){
switch (XdrvMailbox.index) {
case 0:
MIBLEBlockList.clear();
// AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size());
// AddLog(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size());
ResponseCmndIdxChar(PSTR("block list cleared"));
break;
case 1:
@ -1718,7 +1718,7 @@ void CmndHM10Block(void){
ResponseCmndIdxChar(XdrvMailbox.data);
HM10removeMIBLEsensor(_MACasBytes.buf);
}
// AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size());
// AddLog(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size());
break;
}
}

View File

@ -176,7 +176,7 @@ bool HdcTriggerRead(void) {
hdc_next_read = millis() + HDC1080_CONV_TIME;
if(status) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcTriggerRead: failed to open the transaction for HDC_REG_TEMP. Status = %d"), status);
AddLog(LOG_LEVEL_DEBUG, PSTR("HdcTriggerRead: failed to open the transaction for HDC_REG_TEMP. Status = %d"), status);
return false;
}
@ -205,7 +205,7 @@ bool HdcRead(void) {
status = HdcTransactionClose(HDC1080_ADDR, sensor_data, 4);
if(status) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcRead: failed to read HDC_REG_TEMP. Status = %d"), status);
AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: failed to read HDC_REG_TEMP. Status = %d"), status);
return false;
}
@ -213,7 +213,7 @@ bool HdcRead(void) {
temp_data = (uint16_t) ((sensor_data[0] << 8) | sensor_data[1]);
rh_data = (uint16_t) ((sensor_data[2] << 8) | sensor_data[3]);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature raw data: 0x%04x; humidity raw data: 0x%04x"), temp_data, rh_data);
AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature raw data: 0x%04x; humidity raw data: 0x%04x"), temp_data, rh_data);
// read the temperature from the first 16 bits of the result
@ -237,7 +237,7 @@ bool HdcRead(void) {
void HdcDetect(void) {
if (I2cActive(HDC1080_ADDR)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR);
// AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR);
return;
}
@ -245,7 +245,7 @@ void HdcDetect(void) {
hdc_manufacturer_id = HdcReadManufacturerId();
hdc_device_id = HdcReadDeviceId();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcDetect: detected device with manufacturerId = 0x%04X and deviceId = 0x%04X"), hdc_manufacturer_id, hdc_device_id);
AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: detected device with manufacturerId = 0x%04X and deviceId = 0x%04X"), hdc_manufacturer_id, hdc_device_id);
if (hdc_device_id == HDC1080_DEV_ID) {
HdcInit();
@ -284,7 +284,7 @@ void HdcShow(bool json) {
bool Xsns65(uint8_t function)
{
if (!I2cEnabled(XI2C_45)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device."));
// AddLog(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device."));
return false;
}

View File

@ -69,7 +69,7 @@ void IAQ_Read(void) {
for( uint32_t i=0; i<9; i++ ) {
buf[i]= Wire.read();
}
// AddLog_P(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]);
// AddLog(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]);
iAQ.pred = (buf[0]<<8) + buf[1];
iAQ.status = buf[2];
iAQ.resistance = ((uint32_t)buf[3]<<24) + ((uint32_t)buf[4]<<16) + ((uint32_t)buf[5]<<8) + (uint32_t)buf[6];
@ -95,7 +95,7 @@ void IAQ_Show(uint8_t json)
if (json) {
if (iAQ.status!=IAQ_STATUS_OK){
AddLog_P(LOG_LEVEL_INFO, PSTR("iAQ: " D_ERROR " %x" ),iAQ.status);
AddLog(LOG_LEVEL_INFO, PSTR("iAQ: " D_ERROR " %x" ),iAQ.status);
return;
}
else {

View File

@ -218,7 +218,7 @@ bool AS3935AutoTuneCaps(uint8_t irqpin) {
// functions
bool AS3935CalRCOResult(void) {
if(AS3935ReadRegister(CAL_SRCO_NOK) || AS3935ReadRegister(CAL_TRCO_NOK)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: AS3935 Fatal Failure of TRCO or SRCO calibration"));
AddLog(LOG_LEVEL_INFO, PSTR("I2C: AS3935 Fatal Failure of TRCO or SRCO calibration"));
return false;
}
return true;
@ -514,7 +514,7 @@ void AS3935Detect(void) {
if (!AS3935Setup()) return;
as3935_sensor.active = true;
} else {
AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: AS3935 GPIO Pin not defined!"));
AddLog(LOG_LEVEL_INFO, PSTR("I2C: AS3935 GPIO Pin not defined!"));
}
}
}

View File

@ -79,7 +79,7 @@ void ICACHE_RAM_ATTR WindMeterUpdateSpeed(void)
if (time_diff > Settings.windmeter_pulse_debounce * 1000) {
WindMeter.counter_time = time;
WindMeter.counter++;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMET: Counter %d"), WindMeter.counter);
// AddLog(LOG_LEVEL_DEBUG, PSTR("WMET: Counter %d"), WindMeter.counter);
}
}
@ -119,7 +119,7 @@ void WindMeterEverySecond(void)
{
//uint32_t time = micros();
//uint32_t delta_time = time - WindMeter.speed_time;
//AddLog_P(LOG_LEVEL_INFO, PSTR("delta_time: %d"), delta_time);
//AddLog(LOG_LEVEL_INFO, PSTR("delta_time: %d"), delta_time);
// speed = ( (pulses / pulses_per_rotation) * (2 * pi * radius) ) / delta_time
WindMeter.speed = ((WindMeter.counter / Settings.windmeter_pulses_x_rot) * (windmeter_2pi * ((float)Settings.windmeter_radius / 1000))) * ((float)Settings.windmeter_speed_factor / 1000);
@ -131,7 +131,7 @@ void WindMeterEverySecond(void)
//dtostrfd(WindMeter.speed, 2, speed_string);
//char uspeed_string[FLOATSZ];
//dtostrfd(ConvertSpeed(WindMeter.speed), 2, uspeed_string);
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMET: Speed %s [m/s] - %s [unit]"), speed_string, uspeed_string);
//AddLog(LOG_LEVEL_DEBUG, PSTR("WMET: Speed %s [m/s] - %s [unit]"), speed_string, uspeed_string);
#ifndef USE_WINDMETER_NOSTATISTICS
if (WindMeter.speed < WindMeter.speed_min) {

View File

@ -165,7 +165,7 @@ void ICACHE_RAM_ATTR sns_opentherm_handleInterrupt()
void sns_opentherm_processResponseCallback(unsigned long response, int st)
{
OpenThermResponseStatus status = (OpenThermResponseStatus)st;
AddLog_P(LOG_LEVEL_DEBUG_MORE,
AddLog(LOG_LEVEL_DEBUG_MORE,
PSTR("[OTH]: Processing response. Status=%s, Response=0x%lX"),
sns_ot_master->statusToString(status), response);
@ -311,7 +311,7 @@ void sns_ot_start_handshake()
return;
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("[OTH]: perform handshake"));
AddLog(LOG_LEVEL_DEBUG, PSTR("[OTH]: perform handshake"));
sns_ot_master->sendRequestAync(
OpenTherm::buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::SConfigSMemberIDcode, 0));
@ -325,14 +325,14 @@ void sns_ot_process_handshake(unsigned long response, int st)
if (status != OpenThermResponseStatus::SUCCESS || !sns_ot_master->isValidResponse(response))
{
AddLog_P(LOG_LEVEL_ERROR,
AddLog(LOG_LEVEL_ERROR,
PSTR("[OTH]: getSlaveConfiguration failed. Status=%s"),
sns_ot_master->statusToString(status));
sns_ot_connection_status = OpenThermConnectionStatus::OTC_DISCONNECTED;
return;
}
AddLog_P(LOG_LEVEL_DEBUG, PSTR("[OTH]: getLastResponseStatus SUCCESS. Slave Cfg: %lX"), response);
AddLog(LOG_LEVEL_DEBUG, PSTR("[OTH]: getLastResponseStatus SUCCESS. Slave Cfg: %lX"), response);
sns_ot_boiler_status.m_slave_flags = (response & 0xFF00) >> 8;

View File

@ -168,7 +168,7 @@ unsigned long sns_opentherm_set_slave_flags(struct OpenThermCommandT *self, stru
}
if (self->m_results[1].m_bool != centralHeatingIsOn) {
AddLog_P(LOG_LEVEL_INFO,
AddLog(LOG_LEVEL_INFO,
PSTR("[OTH]: Central Heating transitioning from %s to %s"),
self->m_results[1].m_bool ? "on" : "off",
status->m_enableCentralHeating ? "on" : "off");
@ -219,7 +219,7 @@ unsigned long sns_opentherm_set_boiler_temperature(struct OpenThermCommandT *sel
{
return -1;
}
AddLog_P(LOG_LEVEL_INFO,
AddLog(LOG_LEVEL_INFO,
PSTR("[OTH]: Setting Boiler Temp. Old: %d, New: %d"),
(int)self->m_results[0].m_float,
(int)status->m_boilerSetpoint);
@ -258,7 +258,7 @@ unsigned long sns_opentherm_set_boiler_dhw_temperature(struct OpenThermCommandT
{
return -1;
}
AddLog_P(LOG_LEVEL_INFO,
AddLog(LOG_LEVEL_INFO,
PSTR("[OTH]: Setting Hot Water Temp. Old: %d, New: %d"),
(int)self->m_results[0].m_float,
(int)status->m_hotWaterSetpoint);
@ -400,7 +400,7 @@ void sns_opentherm_check_retry_request()
if (!canRetry && !cmd->m_flags.supported)
{
cmd->m_flags.notSupported = true;
AddLog_P(LOG_LEVEL_ERROR,
AddLog(LOG_LEVEL_ERROR,
PSTR("[OTH]: command %s is not supported by the boiler. Last status: %s"),
cmd->m_command_name,
sns_ot_master->statusToString(sns_ot_master->getLastResponseStatus()));

View File

@ -63,7 +63,7 @@ String FormatMetricName(const char *metric) { // cleanup spaces and uppercases
void HandleMetrics(void) {
if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Prometheus"));
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Prometheus"));
WSContentBegin(200, CT_PLAIN);

View File

@ -103,7 +103,7 @@ void As608Init(void) {
if (As608Finger->verifyPassword()) {
As608Finger->getTemplateCount();
AddLog_P(LOG_LEVEL_INFO, PSTR("AS6: Detected with %d fingerprint(s) stored"), As608Finger->templateCount);
AddLog(LOG_LEVEL_INFO, PSTR("AS6: Detected with %d fingerprint(s) stored"), As608Finger->templateCount);
As608.selected = true;
}
}
@ -147,7 +147,7 @@ void As608Loop(void) {
// p = As608Finger->fingerFastSearch(); // Match found - fails on R503
p = As608Finger->fingerSearch(); // Match found
if (p != FINGERPRINT_OK) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("AS6: No matching finger"));
// AddLog(LOG_LEVEL_DEBUG, PSTR("AS6: No matching finger"));
return;
}

View File

@ -113,7 +113,7 @@ void RC522Init(void) {
}
uint8_t empty_uid[4] = { 0 };
ToHex_P((unsigned char*)empty_uid, sizeof(empty_uid), Rc522.uids, sizeof(Rc522.uids));
AddLog_P(LOG_LEVEL_INFO, PSTR("MFR: RC522 Rfid Reader detected %s"), ver);
AddLog(LOG_LEVEL_INFO, PSTR("MFR: RC522 Rfid Reader detected %s"), ver);
Rc522.present = true;
// }
// Mfrc522->PCD_Init(); // Re-init as SelfTest blows init

View File

@ -159,7 +159,7 @@ void seeSoilDetect(void) { // detect sensors
buf = (uint8_t) Wire.read();
if (buf != SEESAW_HW_ID_CODE) { // check hardware id
#ifdef DEBUG_SEESAW_SOIL
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: HWID mismatch ADDR=%X, ID=%X"), addr, buf);
AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: HWID mismatch ADDR=%X, ID=%X"), addr, buf);
#endif // DEBUG_SEESAW_SOIL
continue;
}
@ -173,7 +173,7 @@ void seeSoilDetect(void) { // detect sensors
SeeSoil.count++;
SeeSoil.present = true;
#ifdef DEBUG_SEESAW_SOIL
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: FOUND sensor %u at %02X"), i, addr);
AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: FOUND sensor %u at %02X"), i, addr);
#endif // DEBUG_SEESAW_SOIL
}
}
@ -201,7 +201,7 @@ void seeSoilCommand(uint32_t command) { // issue commands to sensors
break;
default:
#ifdef DEBUG_SEESAW_SOIL
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: ILL CMD:%02X"), command);
AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: ILL CMD:%02X"), command);
#endif // DEBUG_SEESAW_SOIL
return;
}
@ -212,7 +212,7 @@ void seeSoilCommand(uint32_t command) { // issue commands to sensors
Wire.write((uint8_t) regLow);
uint32_t err = Wire.endTransmission();
#ifdef DEBUG_SEESAW_SOIL
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: SNS=%u ADDR=%02X CMD=%02X ERR=%u"), i, addr, command, err);
AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: SNS=%u ADDR=%02X CMD=%02X ERR=%u"), i, addr, command, err);
#endif // DEBUG_SEESAW_SOIL
}
}
@ -242,7 +242,7 @@ void seeSoilRead(uint32_t command) { // read values from sensors
#endif // SEESAW_SOIL_RAW
}
#ifdef DEBUG_SEESAW_SOIL
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: READ #%u ADDR=%02X NUM=%u RET=%X"), i, SeeSoilSNS[i].address, num, ret);
AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: READ #%u ADDR=%02X NUM=%u RET=%X"), i, SeeSoilSNS[i].address, num, ret);
#endif // DEBUG_SEESAW_SOIL
}
}

View File

@ -1,5 +1,5 @@
/*
xsns_82_wiegand.ino - Support for Wiegand Interface 125kHz NFC Tag Reader for Tasmota
xsns_82_wiegand.ino - Support for Wiegand Interface 125kHz Rfid Tag Reader for Tasmota
Copyright (C) 2021 Sigurd Leuther and Theo Arends
@ -181,7 +181,7 @@ void Wiegand::Init() {
isInit = false;
if (PinUsed(GPIO_WIEGAND_D0) && PinUsed(GPIO_WIEGAND_D1)) { // Only start, if the Wiegang pins are selected
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Init()"));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Init()"));
#endif // DEV_WIEGAND_TEST_MODE>0
pinMode(Pin(GPIO_WIEGAND_D0), INPUT_PULLUP);
pinMode(Pin(GPIO_WIEGAND_D1), INPUT_PULLUP);
@ -189,14 +189,14 @@ void Wiegand::Init() {
attachInterrupt(Pin(GPIO_WIEGAND_D1), handleD1Interrupt, FALLING);
isInit = true; // Helps to run only if correctly setup
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Testmode, D0:%u, D1:%u"), Pin(GPIO_WIEGAND_D0), Pin(GPIO_WIEGAND_D1)); // For tests without reader attaiched
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Testmode, D0:%u, D1:%u"), Pin(GPIO_WIEGAND_D0), Pin(GPIO_WIEGAND_D1)); // For tests without reader attaiched
#else
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Wiegand Rfid Reader detected"));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Wiegand Rfid Reader detected"));
#endif // DEV_WIEGAND_TEST_MODE>0
}
#if (DEV_WIEGAND_TEST_MODE)>0
else {
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: no GPIOs."));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: no GPIOs."));
}
#endif // DEV_WIEGAND_TEST_MODE>0
}
@ -232,13 +232,13 @@ uint64_t Wiegand::CheckAndConvertRfid(uint64_t rfidIn, uint16_t bitcount) {
calcParity = CalculateParities(rfidIn, bitCount); // Check result on http://www.ccdesignworks.com/wiegand_calc.htm with raw tag as input
if (calcParity != (evenParityBit | oddParityBit)) { // Parity bit is wrong
rfidIn=0;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WIE: %llu parity error"), rfidIn);
AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: %llu parity error"), rfidIn);
}
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: even (left) parity: %u "), (evenParityBit>>7));
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: even (calc) parity: %u "), (calcParity & 0x80)>>7);
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: odd (right) parity: %u "), oddParityBit);
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: odd (calc) parity: %u "), (calcParity & 0x01));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: even (left) parity: %u "), (evenParityBit>>7));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: even (calc) parity: %u "), (calcParity & 0x80)>>7);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: odd (right) parity: %u "), oddParityBit);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: odd (calc) parity: %u "), (calcParity & 0x01));
#endif // DEV_WIEGAND_TEST_MODE>0
return rfidIn;
}
@ -295,7 +295,7 @@ bool Wiegand::WiegandConversion () {
}
if (diffTicks > WIEGAND_BIT_TIMEOUT) { // Last bit found is WIEGAND_BIT_TIMEOUT ms ago
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Raw tag %llu, Bit count %u"), rfidBuffer, bitCount);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Raw tag %llu, Bit count %u"), rfidBuffer, bitCount);
#endif // DEV_WIEGAND_TEST_MODE>0
if ((24 == bitCount) || (26 == bitCount) || (32 == bitCount) || (34 == bitCount)) {
// 24, 26, 32, 34-bit Wiegand codes
@ -334,14 +334,14 @@ bool Wiegand::WiegandConversion () {
bRet = false; // Watching time not finished
}
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Tag out %llu, tag size %u "), rfid, tagSize);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag out %llu, tag size %u "), rfid, tagSize);
#endif // DEV_WIEGAND_TEST_MODE>0
return bRet;
}
void Wiegand::ScanForTag() {
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag()."));
AddLog(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag()."));
#if (DEV_WIEGAND_TEST_MODE==1)
switch (millis() %4) {
case 0:
@ -360,18 +360,18 @@ void Wiegand::ScanForTag() {
rfidBuffer = GetRandomRfid(34);
break;
}
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Raw generated %lX"), rfidBuffer); // For tests without reader attaiched
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Raw generated %lX"), rfidBuffer); // For tests without reader attaiched
#endif // DEV_WIEGAND_TEST_MODE==1
#endif // DEV_WIEGAND_TEST_MODE>0
if (bitCount > 0) {
uint64_t oldTag = rfid;
bool validKey = WiegandConversion();
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Previous tag %llu"), oldTag);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Previous tag %llu"), oldTag);
#endif // DEV_WIEGAND_TEST_MODE>0
if (validKey) { // Only in case of valid key do action. Issue#10585
if (oldTag == rfid) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WIE: Old tag"));
AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: Old tag"));
}
ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":%0llu,\"" D_JSON_SIZE "\":%u}}"), rfid, tagSize);
MqttPublishTeleSensor();
@ -383,7 +383,7 @@ void Wiegand::ScanForTag() {
void Wiegand::Show(void) {
WSContentSend_PD(PSTR("{s}Wiegand UID{m}%llu {e}"), rfid);
#if (DEV_WIEGAND_TEST_MODE)>0
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount);
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount);
#endif // DEV_WIEGAND_TEST_MODE>0
}
#endif // USE_WEBSERVER

View File

@ -592,14 +592,14 @@ void NeoPool250ms(void) // Every 250 mSec
}
#ifdef DEBUG_TASMOTA_SENSOR
else {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus receive error %d"), error);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus receive error %d"), error);
}
#endif // DEBUG_TASMOTA_SENSOR
free(buffer);
}
#ifdef DEBUG_TASMOTA_SENSOR
else {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus block 0x%04X - 0x%04X skipped"), NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].addr+NeoPoolReg[neopool_read_state].cnt);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus block 0x%04X - 0x%04X skipped"), NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].addr+NeoPoolReg[neopool_read_state].cnt);
}
#endif // DEBUG_TASMOTA_SENSOR
@ -620,7 +620,7 @@ void NeoPool250ms(void) // Every 250 mSec
(NeoPoolGetData(MBF_NOTIFICATION) & (1 << (NeoPoolReg[neopool_read_state].addr >> 8)-1))) {
#endif // NEOPOOL_OPTIMIZE_READINGS
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus send(%d, %d, 0x%04X, %d)"), NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus send(%d, %d, 0x%04X, %d)"), NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt);
#endif // DEBUG_TASMOTA_SENSOR
NeoPoolModbus->Send(NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt);
#ifdef NEOPOOL_OPTIMIZE_READINGS
@ -629,7 +629,7 @@ void NeoPool250ms(void) // Every 250 mSec
// search next addr block having notification
while( (NeoPoolReg[neopool_read_state].addr & 0x0F00) != 0x100 || (NeoPoolGetData(MBF_NOTIFICATION) & (1 << (NeoPoolReg[neopool_read_state].addr >> 8)-1)) ) {
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: notify 0x%04X - addr block 0x%04X ignored"), NeoPoolGetData(MBF_NOTIFICATION), NeoPoolReg[neopool_read_state].addr);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: notify 0x%04X - addr block 0x%04X ignored"), NeoPoolGetData(MBF_NOTIFICATION), NeoPoolReg[neopool_read_state].addr);
#endif // DEBUG_TASMOTA_SENSOR
++neopool_read_state %= ARRAY_SIZE(NeoPoolReg);
// neopool_read_state++;
@ -686,13 +686,13 @@ bool NeoPoolInitData(void)
if (nullptr != NeoPoolReg[i].data) {
memset(NeoPoolReg[i].data, 0, sizeof(uint16_t)*NeoPoolReg[i].cnt);
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: Init - addr 0x%04x cnt %d data %p"), NeoPoolReg[i].addr, NeoPoolReg[i].cnt, NeoPoolReg[i].data);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: Init - addr 0x%04x cnt %d data %p"), NeoPoolReg[i].addr, NeoPoolReg[i].cnt, NeoPoolReg[i].data);
#endif // DEBUG_TASMOTA_SENSOR
res = true;
}
#ifdef DEBUG_TASMOTA_SENSOR
else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: Init - out of memory"));
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: Init - out of memory"));
}
#endif // DEBUG_TASMOTA_SENSOR
}
@ -717,7 +717,7 @@ uint8_t NeoPoolReadRegister(uint16_t addr, uint16_t *data, uint16_t cnt)
uint8_t error = NeoPoolModbus->ReceiveBuffer(buffer, cnt);
if (error) {
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data error %d"), addr, error);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data error %d"), addr, error);
#endif // DEBUG_TASMOTA_SENSOR
neopool_poll = true;
return NEOPOOL_ERROR_RW_DATA;
@ -731,12 +731,12 @@ uint8_t NeoPoolReadRegister(uint16_t addr, uint16_t *data, uint16_t cnt)
return 0;
}
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read out of memory"), addr);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read out of memory"), addr);
#endif // DEBUG_TASMOTA_SENSOR
return NEOPOOL_ERROR_OUT_OF_MEM;
}
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data timeout"), addr);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data timeout"), addr);
#endif // DEBUG_TASMOTA_SENSOR
neopool_poll = true;
return NEOPOOL_ERROR_TIMEOUT;
@ -754,7 +754,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt)
frame = (uint8_t*)malloc(numbytes);
if (nullptr == frame) {
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write out of memory"), addr);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write out of memory"), addr);
#endif // DEBUG_TASMOTA_SENSOR
return NEOPOOL_ERROR_OUT_OF_MEM;
}
@ -787,7 +787,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt)
uint8_t error = NeoPoolModbus->ReceiveBuffer(buffer, 1);
if (0!=error && 9!=error) { // ReceiveBuffer can't handle 0x10 code result
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response error %d"), addr, error);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response error %d"), addr, error);
#endif // DEBUG_TASMOTA_SENSOR
neopool_poll = true;
return NEOPOOL_ERROR_RW_DATA;
@ -803,7 +803,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt)
return NEOPOOL_OK;
}
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response timeout"), addr);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response timeout"), addr);
#endif // DEBUG_TASMOTA_SENSOR
neopool_poll = true;
return NEOPOOL_ERROR_TIMEOUT;
@ -986,7 +986,7 @@ void NeoPoolShow(bool json)
// Hydrolysis
#ifdef DEBUG_TASMOTA_SENSOR
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: MBF_PAR_MODEL 0x%04X MBF_HIDRO_STATUS 0x%04X"), NeoPoolGetData(MBF_PAR_MODEL), NeoPoolGetData(MBF_HIDRO_STATUS));
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: MBF_PAR_MODEL 0x%04X MBF_HIDRO_STATUS 0x%04X"), NeoPoolGetData(MBF_PAR_MODEL), NeoPoolGetData(MBF_HIDRO_STATUS));
#endif // DEBUG_TASMOTA_SENSOR
if ((NeoPoolGetData(MBF_PAR_MODEL) & MBMSK_MODEL_HIDRO) && (NeoPoolGetData(MBF_HIDRO_STATUS) & MBMSK_HIDRO_STATUS_MODULE_ACTIVE)) {
dtostrfd((float)NeoPoolGetData(MBF_HIDRO_CURRENT), 1, parameter);
@ -1240,7 +1240,7 @@ bool NeoPoolCmnd(void)
t_low = (uint16_t)(new_time & 0xFFFF);
t_high = (uint16_t)((new_time>>16) & 0xFFFF);
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: set time to %ld (%04X%04X)"), new_time, t_low, t_high);
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: set time to %ld (%04X%04X)"), new_time, t_low, t_high);
#endif // DEBUG_TASMOTA_SENSOR
serviced = (NEOPOOL_OK == NeoPoolWriteRegister(MBF_PAR_TIME_HIGH, &t_high, 1));
if (serviced) {
@ -1254,7 +1254,7 @@ bool NeoPoolCmnd(void)
else if (0 == params_cnt) {
serviced = (NEOPOOL_OK == NeoPoolReadRegister(MBF_PAR_TIME_LOW, &t_low, 1) && NEOPOOL_OK == NeoPoolReadRegister(MBF_PAR_TIME_HIGH, &t_high, 1));
#ifdef DEBUG_TASMOTA_SENSOR
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: time read 0x%04X%04X %ld"), t_high, t_low, (uint32_t)t_low + ((uint32_t)t_high << 16));
AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: time read 0x%04X%04X %ld"), t_high, t_low, (uint32_t)t_low + ((uint32_t)t_high << 16));
#endif // DEBUG_TASMOTA_SENSOR
}
else {

View File

@ -59,10 +59,10 @@ uint16_t Tof10120Read() {
distance = distance <<8;
distance |= Wire.read();
} else { // Incorrect value read
AddLog_P(LOG_LEVEL_DEBUG, "TOF: No value read");
AddLog(LOG_LEVEL_DEBUG, "TOF: No value read");
return TOF10120_INCORRECT_DISTANCE;
}
AddLog_P(LOG_LEVEL_DEBUG_MORE, "TOF: Distance %u", distance);
AddLog(LOG_LEVEL_DEBUG_MORE, "TOF: Distance %u", distance);
return distance;
}

View File

@ -1032,7 +1032,7 @@ bool XsnsCall(uint8_t Function) {
uint32_t profile_millis = millis() - profile_start_millis;
if (profile_millis) {
if (FUNC_EVERY_SECOND == Function) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), TasmotaGlobal.uptime, Function, x, profile_millis);
AddLog(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), TasmotaGlobal.uptime, Function, x, profile_millis);
}
}
#endif // PROFILE_XSNS_SENSOR_EVERY_SECOND
@ -1052,7 +1052,7 @@ bool XsnsCall(uint8_t Function) {
uint32_t profile_millis = millis() - profile_start_millis;
if (profile_millis) {
if (FUNC_EVERY_SECOND == Function) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), TasmotaGlobal.uptime, Function, profile_millis);
AddLog(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), TasmotaGlobal.uptime, Function, profile_millis);
}
}
#endif // PROFILE_XSNS_EVERY_SECOND