Help Needed with Multiple Devices in Blynk

Hi Blynk Community,

I’m new to Blynk and ran into a problem. I’m using multiple Argon Particle boards with the Blynk app.

What I’ve Tried:
I’ve added the Auth tokens of each device in an array, along with their respective device IDs in another array, as shown below. The issue is that when I add a new device, I have to update both arrays, which can be cumbersome when flashing code.

Relevant Code Snippet:

#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
#define BLYNK_TEMPLATE_NAME         "Device"

const char* authTokens[] = {
    "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",  
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    // "TOKEN_3"
};

const char* deviceIDs[] = {
    "aaaaaaaaaaaaaaaaaaaaaaaa",   // device 1
    "bbbbbbbbbbbbbbbbbbbbbbbb",   // device 2
    // "DEVICE_ID_3"
};

int authTokenIndex = -1;
String myID = System.deviceID();

void blynkBegin() {
    for (int i = 0; i < sizeof(deviceIDs) / sizeof(deviceIDs[0]); i++) {
        if (myID == deviceIDs[i]) {
            authTokenIndex = i;
            break;
        }
    }

    if (authTokenIndex >= 0) {
        Blynk.begin(authTokens[authTokenIndex]);
    } else {
        Particle.publish("Error", "Device ID not found");
    }
}

void setup() {
    Serial.begin(115200);
    blynkBegin();
    // setup
}

void loop() {
    Blynk.run();
    // loop
}

Any advice would be greatly appreciated! Thanks!

Could you please explain the end goal?

Why do you need to keep all the tokens on the device?

I’m having 10 devices with different tokens but same template and all devices working simultaneously. The snippet I sent is frugally designed for temporary purpose.

The end goal is to upload same firmware file in all devices. for now if I didn’t keep all tokens in the code I’ll have to generate separate binary file to flash. This logic is irrelevant if the number of device increase in future.

P.S. : I have already implemented token matching logic i.e. the different devices would take their respective tokens.