From 72ee040948084a678329bee1acb95bc5d41938a6 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 2 May 2020 16:44:44 +0200 Subject: [PATCH] webcam test whitout script scripter local ip text var --- tasmota/xdrv_10_scripter.ino | 4 ++++ tasmota/xdrv_39_webcam.ino | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 8f01bae2f..040442084 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1562,6 +1562,10 @@ chknext: } break; case 'l': + if (!strncmp(vname,"lip",3)) { + if (sp) strlcpy(sp,(const char*)WiFi.localIP().toString().c_str(),glob_script_mem.max_ssize); + goto strexit; + } if (!strncmp(vname,"loglvl",6)) { fvar=glob_script_mem.script_loglevel; tind->index=SCRIPT_LOGLEVEL; diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino index 1a2f3b260..a223ddfa6 100644 --- a/tasmota/xdrv_39_webcam.ino +++ b/tasmota/xdrv_39_webcam.ino @@ -561,6 +561,13 @@ uint8_t *out_buf=0; } } +void wc_show_stream(void) { +#ifndef USE_SCRIPT + if (CamServer) WSContentSend_P("

webcam stream",WiFi.localIP().toString().c_str()); +#endif +} + + uint32_t wc_set_streamserver(uint32_t flag) { if (global_state.wifi_down) return 0; @@ -583,7 +590,6 @@ uint32_t wc_set_streamserver(uint32_t flag) { delete CamServer; CamServer=NULL; AddLog_P(WC_LOGLEVEL, "cam stream exit"); - } } return 0; @@ -630,6 +636,26 @@ red led = gpio 33 /*********************************************************************************************\ * Interface \*********************************************************************************************/ +#define D_CMND_WC "webcam" + +const char kWCCommands[] PROGMEM = "|" // no prefix + D_CMND_WC + ; + +void (* const WCCommand[])(void) PROGMEM = { + &CmndWC, + }; + +void CmndWC(void) { + uint8_t flag=0; + if (XdrvMailbox.data_len > 0) { + wc_set_streamserver(XdrvMailbox.payload); + wc_setup(flag); + } + if (CamServer) flag=1; + Response_P(PSTR("{\"" D_CMND_WC "\":{\"streaming\":%d}"),flag); +} + bool Xdrv39(uint8_t function) { bool result = false; @@ -641,6 +667,12 @@ bool Xdrv39(uint8_t function) { case FUNC_WEB_ADD_HANDLER: wc_pic_setup(); break; + case FUNC_WEB_ADD_MAIN_BUTTON: + wc_show_stream(); + break; + case FUNC_COMMAND: + result = DecodeCommand(kWCCommands, WCCommand); + break; } return result; }