I would like to determine the name of the Arduino sketch running on my Arduino Leonardo. This is so when I provision the Arduino I can change the file name and have the sketch automatically change a number in the script.
Is this possible?
To give an idea of why we're doing this, we have to provision 50 Arduinos and rather than hand-edit a bunch of scripts, I would rather just change the file name.
I have no idea how to do what I am looking to do, but as a show of good faith for onlookers here is the code in which I set the EEPROM on an Arduino:
#include <EEPROM.h>
#include "EEPROMAnything.h"
// begin EDIT ME
char CONFIG_NUMBER[]="##"; // Config Number goes here
// end EDIT ME
char IPADDRESS[]="XX.XX.XX.XXX";
char APN[]="myapn";
const int buflen = 32;
struct config_t {
char model[buflen];
char serial_num[buflen];
char ipaddress[buflen];
char apn[buflen];
}configuration;
int ee_addr=0;
boolean registrationDone = false;
void setup(){
Serial.begin(115200);
Serial.println(F("Starting Up"));
}
void loop()
{
config_t configuration;
strcpy(configuration.model, MODEL);
strcpy(configuration.serial_num, SERIAL_NUM);
strcpy(configuration.ipaddress, IPADDRESS);
strcpy(configuration.apn, APN);
if (!registrationDone){
EEPROM_writeAnything(ee_addr,configuration);
registrationDone = true;
}
EEPROM_readAnything(ee_addr, configuration);
Serial.println(F("Settings"));
Serial.println(String(configuration.model));
Serial.println(String(configuration.serial_num));
Serial.println(String(configuration.ipaddress));
Serial.println(String(configuration.apn));
delay(5000);
}
Thanks in advance for any ideas! Sara