Cannot fathom why just one LED won't work with a particular library but will with another library

Not addressing your actual problem, but one hint I usually and hope at one point people will pick up on:

Instead of having tons of individual variables like here

// PUB-SUB constants
constexpr char * DEVICE_NAME = "ALERT";
constexpr char * WINDOWSHUT_MSSG = "Office window shut.";
constexpr char * WINDOWOPEN_MSSG = "Office window open.";
constexpr char * BWINDOWSHUT_MSSG = "Bathroom window shut.";
constexpr char * BWINDOWOPEN_MSSG = "Bathroom window open.";
constexpr char * BDSHUT_MSSG = "Bathroom door shut.";
constexpr char * BDOPEN_MSSG = "Bathroom door open.";
constexpr char * SDCLOSED_MSSG = "Sliding door closed.";
constexpr char * SDOPEN_MSSG = "Sliding door open.";
constexpr char * KEEPBOLT_MSSG = "Stores door locked.";
constexpr char * KEEPOPEN_MSSG = "Stores door unlocked.";
constexpr char * MDKEEPBOLT_MSSG = "Main door locked.";
constexpr char * MDKEEPOPEN_MSSG = "Main door unlocked.";
constexpr char * RSATUS_MSSG = "Requesting Status";
constexpr char * SHOPL_MSSG = "SHOPLIFTER";
constexpr char * RESCUE_MSSG = "RESCUE";
constexpr char * RAIN_MSSG = "RAIN";

and a rats nest of check logic like this

        if (strcmp(data, SHOPL_MSSG) == 0) {
                myDFPlayer.playMp3Folder(1);
        } else if (strcmp(data, RESCUE_MSSG) == 0) {
                myDFPlayer.playMp3Folder(4);
        } else if (strcmp(data, RAIN_MSSG) == 0) {
                myDFPlayer.playMp3Folder(20);
        } else if (strcmp(data, MDKEEPOPEN_MSSG) == 0) {
                maindoorlocked = 1;
        } else if (strcmp(data, MDKEEPBOLT_MSSG) == 0) {
                maindoorlocked = 0;
        } else if (strcmp(data, SDOPEN_MSSG) == 0) {
                slidingstate = 1;
        } else if (strcmp(data, SDCLOSED_MSSG) == 0) {
                slidingstate = 0;
        } else if (strcmp(data, KEEPOPEN_MSSG) == 0) {
                Storeskeepstate = 1;
        } else if (strcmp(data, KEEPBOLT_MSSG) == 0) {
                Storeskeepstate = 0;
        } else if (strcmp(data, BWINDOWOPEN_MSSG) == 0) {
                bathroomwindowlocked = 1;
        } else if (strcmp(data, BWINDOWSHUT_MSSG) == 0) {
                bathroomwindowlocked = 0;
        } else if (strcmp(data, WINDOWOPEN_MSSG) == 0) {
                officewindowlocked = 1;
        } else if (strcmp(data, WINDOWSHUT_MSSG) == 0) {
                officewindowlocked = 0;
        }

I’d rather go with an array of strings (const char[][64]) and optionally some enum and have the check performed in a for() loop.

1 Like