BLYNK_WRITE() has no validation?

hello blynk developers!

i have a situation here:

in my projects i usually #define a unique name for every virtual pin, for better readability in the code. like these:

#define GRAVITY     V13  // read phone gyro and send to arduino
#define SHUP        V14  // shift 1 gear up
#define SHDW        V15  // shift 1 gear down
#define CALIBRATE   V16  // calibrate motor and gyro
#define AUTOMODE    V17  // select auto / manual shifting mode

…and use like that:

BLYNK_WRITE(TRPRESET) {
  if (param.asInt() == 1) tripMM = 0, rpmAvg = 0, rpmMax = 0, spdAvg = 0, spdMax = 0, activeTime = 0;
}

BLYNK_WRITE(CALIBRATE) {
  if (param.asInt() == 1 && spd == 0 && rpm == 0) {  // calibration allowed only while standstill
    inclCalibr = rawIncl * inclMulti;
    calibrateGears();
  }
}

etc.

however, i have observed that if i mistype the variable name in BLYNK_WRITE(), it compiles anyway, so actually it doesn’t cares if there is a valid variable / define is used or not.

in other built in functions (like: pinMode, digitalWrite(), etc) it gives error on compile time, if undeclared variables are used:

exit status 1
'X' was not declared in this scope

i think there should be at least some basic validation for these situations (for example, to check if it is a number between 0-255, or so).

as the arduino ide does not have typo highlighting, sometimes can cause a headache to find these kind of bugs…

thank you!

EDIT: just checked, and Blynk.virtualWrite(); doesn’t accepts undeclared variables. it should be the same with BLYNK_WRITE()

1 Like

What do you mean by mistype?

try to use a non existing #define in BLYNK_WRITE(), it will compile.
i mean, if i have
#define myPin V10

and i accidently use:
BLYNK_WRITE(myPinn)

it will compile, without throwing any error. but i think it should stop and give error instead, like other functions.
for example Blynk.virtualWrite(); doesn’t accepts non existing defines. it should be the same with BLYNK_WRITE()

maybe i can not explain very well…
does this makes any sense to you, @Dmitriy?