/*
* Letters_or_Digits_2.ino
*
*
* tested on: https://wokwi.com/projects/397289487844238337
*
*
* -----------------------------------------------------------------------------------
* -----------------------------------------------------------------------------------
* indexOf()
* Locates a character or String within another String. By default, searches from
* the beginning of the String, but can also start from a given index, allowing
* for the locating of all instances of the character or String.
*
* Syntax:
* myString.indexOf(val)
* myString.indexOf(val, to)
*
* Parameters:
* myString: a variable of type String.
* val: the value to search for. Allowed data types: char, String.
* from: the index to start the search from.
*
* Returns: the index of val within the String, or -1 if not found.
* -----------------------------------------------------------------------------------
* -----------------------------------------------------------------------------------
*
*
*/
//
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
// @@@@
struct stct_GLBL_t { // @@@@
// @@@@
// the size -in Byte- of the FRAM @@@@
const uint32_t kFRAM_Size32 = 262144UL; // @@@@
// maximum address of the FRAM (FM25V05 --> 512Kb ==> 0-65,535) @@@@
const uint32_t kFRAM_TOP_Addr32 = 262143UL; // kFRAM_Size32-1 @@@@
// FRAM first address of REGISTERED Caller DATA (20xNUM+20xNAME+20xSURNAME+3xcallerID+'\0') @@@@
const uint32_t kFRAM_START_Addr32 = 64UL; // @@@@
// @@@@
// value of the current Session Identifier (value read once in -setup()-) @@@@
uint16_t CurrentSessionID16 = 0; // @@@@
// @@@@
// maximum String length -Reg.Caller data- @@@@
const uint8_t kCallerDataLen8 = 64; // @@@@
// maximum String length -Reg.Caller Number- @@@@
const uint8_t kCallerNMBRlen8 = 20; // (e.g.: "ABCDEF12345678901234") @@@@
// @@@@
// maximum String length -Reg.Caller Name- @@@@
const uint8_t kCallerNAMElen8 = 20; // (e.g.: "Abcdefghijklmnopqrst") @@@@
// maximum String length -Reg.Caller SURNAME- @@@@
const uint8_t kCallerSURNMlen8 = 20; // (e.g.: "Abcdefghijklmnopqrst") @@@@
// maximum String length -Reg.Caller ID- @@@@
const uint8_t kCallerIDlen8 = 3; // "Abc"/"123"/"1A9"/"AA0"/... (three characters) @@@@
// @@@@
// status flag of the FRAM chip: -true- when the FRAM is operative, otherwise set <false> (as default) @@@@
bool bol_FRAM_Enbld = false; // @@@@
// @@@@
// size of the array used to store in FRAM the Unknowk Caller (18xTlphn.Num.+6xDate [YYMMDD]) @@@@
const uint8_t kUnknwnCllrRECORDlen8 = 24; // @@@@
// @@@@
// DUMMY: only for padding @@@@
//uint8_t Dummy8_5 = 55; // -ONLY- for prevent padding @@@@
//uint8_t Dummy8_4 = 44; // -ONLY- for prevent padding @@@@
//uint8_t Dummy8_3 = 33; // -ONLY- for prevent padding @@@@
//uint8_t Dummy8_2 = 22; // -ONLY- for prevent padding @@@@
//uint8_t Dummy8_1 = 11; // -ONLY- for prevent padding @@@@
// @@@@
//uint16_t Dummy16_2 = 1602; // -ONLY- for prevent padding @@@@
//uint16_t Dummy16_1 = 1601; // -ONLY- for prevent padding @@@@
// @@@@
// @@@@
// struct data size: 56+24+4+4+4+4+4=100 [100 is 25 times 4-Byte. NO padding] @@@@
} Gstct_GLBL; // @@@@
// @@@@
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
// ####### ********** ####### PADDED variables Declaration @@@@@@@ PADDED variables Declaration ####### @@@@
//
//
// WARNING: creation of a GLOBAL array of char
// each one of 24+1 Byte (same to: Gstct_GLBL.kUnknwnCllrRECORDlen8)
// [TELEPHONE NUMBER(18Byte)+DATE(6Byte-YYMMDD)+'\0']
// (that is an array with size of 1000Byte in RAM)
// Gchr_aryUnknwnCllrs[40]*[TELEPHONE NUMBER(18Byte)+DATE(6Byte-YYMMDD)+'\0']
char Gchr_aryUnknwnCllrs[40][25];
// Gchr_aryUnknwnCllrs[40]*[TELEPHONE NUMBER(18Byte)+DATE(6Byte-YYMMDD)+'\0']
// WARNING: the GLOBAL array have a size of 1000Byte in RAM
//
void Str_toARRAY(String sTelNum, uint8_t Indx8) {
// copy the String sTelNum to the GLOBAL array of char
strcpy(Gchr_aryUnknwnCllrs[Indx8], sTelNum.c_str());
//
} // Str_toARRAY()
void ary_toSTRING(String &sTelNum, String &sDate, uint8_t Indx8) {
//
String sNum = String(Gchr_aryUnknwnCllrs[Indx8]);
//
sDate = sNum.substring(18); // get the last 6 char. of 24 (YYMMDD)
sTelNum = sNum.substring(0, 18); // get the first 18 char. (Telephone Number)
//
} // ary_toSTRING()
// *************************************************************************************************
void setup() {
//
Serial.begin(115200);
//
String sTelNum, sDate;
sTelNum.reserve(24);
sDate.reserve(6);
//
sTelNum = "012345678901234567240501";
Str_toARRAY(sTelNum, 0);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 0);
Serial.print(F("\nTel NUM -1- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "123456789012345678240502";
Str_toARRAY(sTelNum, 1);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 1);
Serial.print(F("Tel NUM -2- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "234567890123456789240503";
Str_toARRAY(sTelNum, 2);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 2);
Serial.print(F("Tel NUM -3- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "345678901234567890240504";
Str_toARRAY(sTelNum, 3);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 3);
Serial.print(F("Tel NUM -4- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "456789012345678901240505";
Str_toARRAY(sTelNum, 4);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 4);
Serial.print(F("Tel NUM -5- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "567890123456789012240506";
Str_toARRAY(sTelNum, 5);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 5);
Serial.print(F("Tel NUM -6- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "678901234567890123240507";
Str_toARRAY(sTelNum, 6);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 6);
Serial.print(F("Tel NUM -7- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "789012345678901234240508";
Str_toARRAY(sTelNum, 7);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 7);
Serial.print(F("Tel NUM -8- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "890123456789012345240509";
Str_toARRAY(sTelNum, 8);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 8);
Serial.print(F("Tel NUM -9- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
sTelNum = "901234567890123456240510";
Str_toARRAY(sTelNum, 9);
sTelNum = "", sDate = "";
ary_toSTRING(sTelNum, sDate, 9);
Serial.print(F("Tel NUM -10- = ")); Serial.print(sTelNum);
Serial.print(F(" - at: 20")); Serial.println(sDate);
//
/*
Serial OUTPUT:
Tel NUM -1- = 012345678901234567 - at: 20240501
Tel NUM -2- = 123456789012345678 - at: 20240502
Tel NUM -3- = 234567890123456789 - at: 20240503
Tel NUM -4- = 345678901234567890 - at: 20240504
Tel NUM -5- = 456789012345678901 - at: 20240505
Tel NUM -6- = 567890123456789012 - at: 20240506
Tel NUM -7- = 678901234567890123 - at: 20240507
Tel NUM -8- = 789012345678901234 - at: 20240508
Tel NUM -9- = 890123456789012345 - at: 20240509
Tel NUM -10- = 901234567890123456 - at: 20240510
*/
} // setup()
void loop() {
//
delay(50);
//
} // loop()