Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Sep 12, 2024
1 parent 3b2f68b commit a44010b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 17 deletions.
1 change: 1 addition & 0 deletions tasmota/Plugins/module_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct {
#endif
} FLASH_MODULE;


#define EXEC_OFFSET ((FLASH_MODULE*)mt->mod_addr)->execution_offset

#ifdef ESP8266
Expand Down
30 changes: 29 additions & 1 deletion tasmota/Plugins/xsns_53_sml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4776,10 +4776,38 @@ SETREGS
}


uint32_t SML_SetOptions(uint32_t in) {
if (in &0x100) {
sml_options = in;
}
return sml_options;
}

typedef struct {
uint32_t (*SML_SetBaud)(uint32_t,uint32_t);
uint32_t (*sml_status)(uint32_t);
uint32_t (*SML_Write)(int32_t,char*);
uint32_t (*SML_Read)(int32_t,char*,uint32_t);
uint32_t (*sml_getv)(uint32_t);
uint32_t (*SML_Shift_Num)(uint32_t,uint32_t);
double (*SML_GetVal)(uint32_t);
char * (*SML_GetSVal)(uint32_t);
int32_t (*SML_Set_WStr)(uint32_t,char*);
void (*SML_Decode)(uint8_t);
uint32_t (*SML_SetOptions)(uint32_t);
} SML_TABLE;

uint32_t SML_Getvars(uint16_t function) {
switch (function) {
switch (function & 15) {
case 0:
return 1;
case 1:
// must return adjusted jumptable here
return 0:
case 2:
return sml_options;
case 3:
sml_options = function >> 8;
break;
}
return 0;
Expand Down
46 changes: 30 additions & 16 deletions tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ void Script_ticker4_end(void) {
#endif
#endif

#if defined(USE_SML_M) && defined (USE_SML_SCRIPT_CMD)
extern uint8_t sml_options;
#endif
//#if defined(USE_SML_M) && defined (USE_SML_SCRIPT_CMD)
//extern uint8_t sml_options;
//#endif

#if defined(EEP_SCRIPT_SIZE) && !defined(ESP32)

Expand Down Expand Up @@ -541,6 +541,7 @@ double SML_GetVal(uint32_t index);
char *SML_GetSVal(uint32_t index);
int32_t SML_Set_WStr(uint32_t meter, char *hstr);
void SML_Decode(uint8_t index);
uint32_t SML_SetOptions(uint32_t in);

typedef struct {
uint32_t (*SML_SetBaud)(uint32_t,uint32_t);
Expand All @@ -553,10 +554,11 @@ typedef struct {
char * (*SML_GetSVal)(uint32_t);
int32_t (*SML_Set_WStr)(uint32_t,char*);
void (*SML_Decode)(uint8_t);
uint32_t (*SML_SetOptions)(uint32_t);
} SML_TABLE;

#ifdef USE_SML_M
SML_TABLE smltab PROGMEM = {&SML_SetBaud,&sml_status,&SML_Write,&SML_Read,&sml_getv,&SML_Shift_Num,&SML_GetVal,&SML_GetSVal,&SML_Set_WStr};
SML_TABLE smltab PROGMEM = {&SML_SetBaud,&sml_status,&SML_Write,&SML_Read,&sml_getv,&SML_Shift_Num,&SML_GetVal,&SML_GetSVal,&SML_Set_WStr,&SML_Decode,&SML_SetOptions};
#endif

#ifdef USE_SCRIPT_ONEWIRE
Expand Down Expand Up @@ -656,7 +658,7 @@ typedef struct {
uint32_t from_time;
uint32_t to_time;
#endif
#if defined(USE_SML_M) && defined(USE_SML_SCRIPT_CMD) && defined(USE_SCRIPT_SERIAL)
#if (defined(USE_SML_M) || defined(USE_BINPLUGINS)) && defined(USE_SML_SCRIPT_CMD) && defined(USE_SCRIPT_SERIAL)
char *hstr;
#endif

Expand Down Expand Up @@ -5360,7 +5362,7 @@ char *Plugin_Query(uint16_t, uint8_t);
#endif //USE_ANGLE_FUNC


#if (defined(USE_SML_M) || defined(USE_BINPLUGINS))) && defined (USE_SML_SCRIPT_CMD)
#if (defined(USE_SML_M) || defined(USE_BINPLUGINS)) && defined(USE_SML_SCRIPT_CMD)
if (!strncmp_XP(lp, XPSTR("sml["), 4)) {
lp = GetNumericArgument(lp + 4, OPER_EQU, &fvar, gv);
SCRIPT_SKIP_SPACES
Expand Down Expand Up @@ -5433,26 +5435,30 @@ char *Plugin_Query(uint16_t, uint8_t);
char *cp = glob_script_mem.glob_snp + (sindex * glob_script_mem.max_ssize);
fvar = smlp->SML_Set_WStr(fvar1, cp);
}
} else {
fvar = -99;
}
} else {
fvar = -99;
}
} else {
fvar = smlp->sml_status(fvar1);
}
}
goto nfuncexit;
}
if (!strncmp_XP(vname, XPSTR("smlj"), 4)) {
fvar = sml_options;
SML_TABLE *smlp = get_sml_table();
if (smlp) {
fvar = smlp->SML_SetOptions(0); // sml_options;
}
tind->index = SML_JSON_ENABLE;
goto exit_settable;
}
if (!strncmp_XP(lp, XPSTR("smld("), 5)) {
lp = GetNumericArgument(lp + 5, OPER_EQU, &fvar, gv);
if (fvar < 1) fvar = 1;
SML_TABLE *smlp = get_sml_table();
smlp->SML_Decode(fvar - 1);
if (smlp) {
smlp->SML_Decode(fvar - 1);
}
goto nfuncexit;
}
if (!strncmp_XP(lp, XPSTR("smls("), 5)) {
Expand All @@ -5461,13 +5467,17 @@ char *Plugin_Query(uint16_t, uint8_t);
if (meter < 1) meter = 1;
lp = GetNumericArgument(lp, OPER_EQU, &fvar, gv);
SML_TABLE *smlp = get_sml_table();
smlp->SML_Shift_Num(meter - 1, fvar);
if (smlp) {
smlp->SML_Shift_Num(meter - 1, fvar);
}
goto nfuncexit;
}
if (!strncmp_XP(lp, XPSTR("smlv["), 5)) {
lp = GetNumericArgument(lp + 5, OPER_EQU, &fvar, gv);
SML_TABLE *smlp = get_sml_table();
fvar = smlp->sml_getv(fvar);
if (smlp) {
fvar = smlp->sml_getv(fvar);
}
goto nfuncexit;
}
#endif //USE_SML_M
Expand Down Expand Up @@ -8552,9 +8562,13 @@ getnext:
}
glob_script_mem.cmdbuffer_size = *dfvar;
break;
#if defined(USE_SML_M) && defined (USE_SML_SCRIPT_CMD)
#if (defined(USE_SML_M) || defined(USE_BINPLUGINS)) && defined(USE_SML_SCRIPT_CMD)
case SML_JSON_ENABLE:
sml_options = *dfvar;
//sml_options = *dfvar;
SML_TABLE *smlp = get_sml_table();
if (smlp) {
fvar = smlp->SML_SetOptions(0x100 | (uint8_t) *dfvar); // sml_options;
}
break;
#endif
}
Expand Down Expand Up @@ -13836,7 +13850,7 @@ bool Xdrv10(uint32_t function) {
Script_Check_Hue(0);
#endif //USE_SCRIPT_HUE

#if defined(USE_SML_M) && defined(USE_SML_SCRIPT_CMD) && defined(USE_SCRIPT_SERIAL)
#if (defined(USE_SML_M) || defined(USE_BINPLUGINS)) && defined(USE_SML_SCRIPT_CMD) && defined(USE_SCRIPT_SERIAL)
glob_script_mem.hstr = 0;
#endif
}
Expand Down
7 changes: 7 additions & 0 deletions tasmota/tasmota_xsns_sensor/xsns_53_sml.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,13 @@ next_line:

#ifdef USE_SML_SCRIPT_CMD

uint32_t SML_SetOptions(uint32_t in) {
if (in & 0x100) {
sml_options = in;
}
return sml_options;
}

uint32_t SML_SetBaud(uint32_t meter, uint32_t br) {
if (sml_globs.ready == false) return 0;
if (meter < 1 || meter > sml_globs.meters_used) return 0;
Expand Down

0 comments on commit a44010b

Please sign in to comment.