mirror of https://github.com/arendst/Tasmota.git
add sml write once cmd
This commit is contained in:
parent
8b7f18dcf4
commit
ecd8e2ed29
|
@ -3817,8 +3817,27 @@ extern char *SML_GetSVal(uint32_t index);
|
|||
lp++;
|
||||
len = 0;
|
||||
goto strexit;
|
||||
|
||||
} else if (fvar2 == 3) {
|
||||
uint8_t vtype;
|
||||
struct T_INDEX ind;
|
||||
lp = isvar(lp, &vtype, &ind, 0, 0, 0);
|
||||
if (vtype != VAR_NV) {
|
||||
// found variable as result
|
||||
if (vtype == NUM_RES || (vtype & STYPE) == 0) {
|
||||
// numeric result
|
||||
fvar = -1;
|
||||
} else {
|
||||
// string result
|
||||
uint8_t sindex = glob_script_mem.type[ind.index].index;
|
||||
char *cp = glob_script_mem.glob_snp + (sindex * glob_script_mem.max_ssize);
|
||||
fvar = SML_Set_WStr(fvar1, cp);
|
||||
}
|
||||
} else {
|
||||
fvar = -99;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
#ifdef ED300L
|
||||
fvar = SML_Status(fvar1);
|
||||
#else
|
||||
|
|
|
@ -89,6 +89,7 @@ struct METER_DESC {
|
|||
char *txmem;
|
||||
uint8_t index;
|
||||
uint8_t max_index;
|
||||
char *script_str;
|
||||
uint8_t sopt;
|
||||
};
|
||||
|
||||
|
@ -3038,6 +3039,15 @@ char *SML_GetSVal(uint32_t index) {
|
|||
if (index < 1 || index > MAX_METERS) { index = 1;}
|
||||
return &meter_id[index - 1][0];
|
||||
}
|
||||
|
||||
int32_t SML_Set_WStr(uint32_t meter, char *hstr) {
|
||||
if (meter < 1 || meter > meters_used) return -1;
|
||||
meter--;
|
||||
if (!meter_ss[meter]) return -2;
|
||||
script_meter_desc[meter].script_str = hstr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // USE_SML_SCRIPT_CMD
|
||||
|
||||
|
||||
|
@ -3150,6 +3160,11 @@ void SML_Check_Send(void) {
|
|||
//AddLog(LOG_LEVEL_INFO, PSTR("100 ms>> %d - %s - %d"),sml_desc_cnt,script_meter_desc[cnt].txmem,script_meter_desc[cnt].tsecs);
|
||||
if ((sml_100ms_cnt >= script_meter_desc[cnt].tsecs)) {
|
||||
sml_100ms_cnt = 0;
|
||||
// check for scriptsync extra output
|
||||
if (script_meter_desc[cnt].script_str) {
|
||||
cp = script_meter_desc[cnt].script_str;
|
||||
script_meter_desc[cnt].script_str = 0;
|
||||
} else {
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("100 ms>> 2"),cp);
|
||||
if (script_meter_desc[cnt].max_index>1) {
|
||||
script_meter_desc[cnt].index++;
|
||||
|
@ -3164,6 +3179,7 @@ void SML_Check_Send(void) {
|
|||
//SML_Send_Seq(cnt,cp);
|
||||
sml_desc_cnt++;
|
||||
}
|
||||
}
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),cp);
|
||||
SML_Send_Seq(cnt,cp);
|
||||
if (sml_desc_cnt >= meters_used) {
|
||||
|
|
Loading…
Reference in New Issue