Hi There , i feel i'm still in the newbie stage but know enough to get into trouble. I'm stuck with one section of code in my sketch that i need guidance on please.
I have written a sketch that retrieves a users configuration settings from a webserver and stores them as variables for use in the sketch. It uses IotWebConf.h and TelegramBot.h for this portion of the code. for %99 of the variables it works as intended however i'm struggling with the last one.
Where i'm stuck is i'm trying to add a variable to initilise the BotToken[] array ?
original and working code is :
const char BotToken[] = "This is where my bots API code is put"; // Defines bot token. Enter your Telegram bot token here.
However i want to change it to use a variable as per below :
#define STRING_LEN 128
char stringParamValue3[STRING_LEN];
IotWebConfParameter stringParam3 = IotWebConfParameter("Telegram API Number", "Telegram API",
stringParamValue3, STRING_LEN, "password");
const char BotToken[] = stringParamValue3; // Basically just taken away the "" and added a known variable in its place
Doing so i end up with the below error on compile
initializer fails to determine size of 'BotToken'
So not really understanding whats going on i then try this :
#define STRING_LEN 128
char stringParamValue3[STRING_LEN];
IotWebConfParameter stringParam3 = IotWebConfParameter("Telegram API Number", "Telegram API", stringParamValue3, STRING_LEN, "password");
const char BotToken[128] {stringParamValue3}; // I added char length in the [] and added {} from what i was reading up on initializing a char array
I then end up with the error of :
invalid conversion from 'char*' to 'char' [-fpermissive]
Again not really understanding what is going on i try :
#define STRING_LEN 128
char stringParamValue3[STRING_LEN];
IotWebConfParameter stringParam3 = IotWebConfParameter("Telegram API Number", "Telegram API", stringParamValue3, STRING_LEN, "password");
const char* BotToken[128] {stringParamValue3}; // I added a * to make it const char*
now the errors moved to a different line of code in the sketch of
TelegramBot bot (BotToken, net_ssl); // Adds library functions.
and the error is
no matching function for call to 'TelegramBot::TelegramBot(const char* [128], BearSSL::WiFiClientSecure&)'
As you can see i haven't grasped the concept of what is going on and feel like i'm just playing a game of trial and error.
Is it possible someone can guide me on whats going on here and how i go about correcting it please ?
Cheers