You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tasmota/tasmota_xsns_sensor/xsns_53_sml.ino
+63-53Lines changed: 63 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -3156,28 +3156,38 @@ void SML_Init(void) {
3156
3156
// add descriptor +1,1,c,0,10,H20
3157
3157
//toLogEOL(">>",lp);
3158
3158
lp++;
3159
-
index = *lp & 7;
3160
-
lp += 2;
3159
+
char *lp1;
3160
+
#ifdef SML_REPLACE_VARS
3161
+
char dstbuf[SML_SRCBSIZE*2];
3162
+
Replace_Cmd_Vars(lp, 1, dstbuf, sizeof(dstbuf));
3163
+
lp += SML_getlinelen(lp);
3164
+
lp1 = dstbuf;
3165
+
#else
3166
+
lp1 = lp;
3167
+
lp += SML_getlinelen(lp);
3168
+
#endif
3169
+
index = *lp1 & 7;
3170
+
lp1 += 2;
3161
3171
if (index < 1 || index > sml_globs.meters_used) {
3162
3172
AddLog(LOG_LEVEL_INFO, PSTR("illegal meter number!"));
3163
3173
goto next_line;
3164
3174
}
3165
3175
index--;
3166
3176
mmp = &meter_desc[index];
3167
-
if (*lp == '[') {
3177
+
if (*lp1 == '[') {
3168
3178
// sign TCP mode
3169
3179
srcpin = TCP_MODE_FLG;
3170
-
lp++;
3180
+
lp1++;
3171
3181
char str[32];
3172
3182
uint8_t cnt;
3173
3183
for (cnt = 0; cnt < sizeof(str) - 1; cnt++) {
3174
-
if (!*lp || *lp == '\n' || *lp == ']') {
3184
+
if (!*lp1 || *lp1 == '\n' || *lp1 == ']') {
3175
3185
break;
3176
3186
}
3177
-
str[cnt] = *lp++;
3187
+
str[cnt] = *lp1++;
3178
3188
}
3179
3189
str[cnt] = 0;
3180
-
lp++;
3190
+
lp1++;
3181
3191
#ifdef USE_SML_TCP
3182
3192
#ifdef USE_SML_TCP_IP_STR
3183
3193
strcpy(mmp->ip_addr, str);
@@ -3186,7 +3196,7 @@ void SML_Init(void) {
3186
3196
#endif
3187
3197
#endif
3188
3198
} else {
3189
-
srcpin = strtol(lp, &lp, 10);
3199
+
srcpin = strtol(lp1, &lp1, 10);
3190
3200
if (Gpio_used(abs(srcpin))) {
3191
3201
AddLog(LOG_LEVEL_INFO, PSTR("SML: Error: Duplicate GPIO %d defined. Not usable for RX in meter number %d"), abs(srcpin), index + 1);
3192
3202
dddef_exit:
@@ -3196,73 +3206,73 @@ dddef_exit:
3196
3206
}
3197
3207
}
3198
3208
mmp->srcpin = srcpin;
3199
-
if (*lp != ',') goto next_line;
3200
-
lp++;
3201
-
mmp->type = *lp;
3202
-
lp++;
3203
-
if (*lp != ',') {
3204
-
switch (*lp) {
3209
+
if (*lp1 != ',') goto next_line;
3210
+
lp1++;
3211
+
mmp->type = *lp1;
3212
+
lp1++;
3213
+
if (*lp1 != ',') {
3214
+
switch (*lp1) {
3205
3215
case'N':
3206
-
lp++;
3207
-
mmp->sopt = 0x10 | (*lp & 3);
3208
-
lp++;
3216
+
lp1++;
3217
+
mmp->sopt = 0x10 | (*lp1 & 3);
3218
+
lp1++;
3209
3219
break;
3210
3220
case'E':
3211
-
lp++;
3212
-
mmp->sopt = 0x20 | (*lp & 3);
3213
-
lp++;
3221
+
lp1++;
3222
+
mmp->sopt = 0x20 | (*lp1 & 3);
3223
+
lp1++;
3214
3224
break;
3215
3225
case'O':
3216
-
lp++;
3217
-
mmp->sopt = 0x30 | (*lp & 3);
3218
-
lp++;
3226
+
lp1++;
3227
+
mmp->sopt = 0x30 | (*lp1 & 3);
3228
+
lp1++;
3219
3229
break;
3220
3230
default:
3221
-
mmp->sopt = *lp&7;
3222
-
lp++;
3231
+
mmp->sopt = *lp1&7;
3232
+
lp1++;
3223
3233
}
3224
3234
} else {
3225
3235
mmp->sopt = 0;
3226
3236
}
3227
-
lp++;
3228
-
mmp->flag = strtol(lp, &lp, 10);
3229
-
if (*lp != ',') goto next_line;
3230
-
lp++;
3231
-
mmp->params = strtol(lp, &lp, 10);
3232
-
if (*lp != ',') goto next_line;
3233
-
lp++;
3237
+
lp1++;
3238
+
mmp->flag = strtol(lp1, &lp1, 10);
3239
+
if (*lp1 != ',') goto next_line;
3240
+
lp1++;
3241
+
mmp->params = strtol(lp1, &lp1, 10);
3242
+
if (*lp1 != ',') goto next_line;
3243
+
lp1++;
3234
3244
mmp->prefix[SML_PREFIX_SIZE - 1] = 0;
3235
3245
for (uint32_t cnt = 0; cnt < SML_PREFIX_SIZE; cnt++) {
3236
-
if (*lp == SCRIPT_EOL || *lp == ',') {
3246
+
if (*lp1 == SCRIPT_EOL || *lp1 == ',') {
3237
3247
mmp->prefix[cnt] = 0;
3238
3248
break;
3239
3249
}
3240
-
mmp->prefix[cnt] = *lp++;
3250
+
mmp->prefix[cnt] = *lp1++;
3241
3251
}
3242
-
if (*lp == ',') {
3243
-
lp++;
3252
+
if (*lp1 == ',') {
3253
+
lp1++;
3244
3254
// get TRX pin
3245
-
mmp->trxpin = strtol(lp, &lp, 10);
3255
+
mmp->trxpin = strtol(lp1, &lp1, 10);
3246
3256
if (mmp->srcpin != TCP_MODE_FLG) {
3247
3257
if (Gpio_used(mmp->trxpin)) {
3248
3258
AddLog(LOG_LEVEL_INFO, PSTR("SML: Error: Duplicate GPIO %d defined. Not usable for TX in meter number %d"), meter_desc[index].trxpin, index + 1);
3249
3259
goto dddef_exit;
3250
3260
}
3251
3261
}
3252
3262
// optional transmit enable pin
3253
-
if (*lp == '(') {
3254
-
lp++;
3255
-
if (*lp == 'i') {
3256
-
lp++;
3263
+
if (*lp1 == '(') {
3264
+
lp1++;
3265
+
if (*lp1 == 'i') {
3266
+
lp1++;
3257
3267
mmp->trx_en.trxenpol = 1;
3258
3268
} else {
3259
3269
mmp->trx_en.trxenpol = 0;
3260
3270
}
3261
-
mmp->trx_en.trxenpin = strtol(lp, &lp, 10);
3262
-
if (*lp != ')') {
3271
+
mmp->trx_en.trxenpin = strtol(lp1, &lp1, 10);
3272
+
if (*lp1 != ')') {
3263
3273
goto dddef_exit;
3264
3274
}
3265
-
lp++;
3275
+
lp1++;
3266
3276
if (Gpio_used(mmp->trx_en.trxenpin)) {
3267
3277
AddLog(LOG_LEVEL_INFO, PSTR("SML: Error: Duplicate GPIO %d defined. Not usable for TX enable in meter number %d"), meter_desc[index].trx_en.trxenpin, index + 1);
0 commit comments