Defining data structure to build agenda

I’m not familiar with arduino, this is actually my first project. I’m trying to build an agenda of contacts, this contacts are within a txt file stored in a SD Card. So my idea is to read the file where each line represents a mobile number. For example if I want to call someone or send SMS I can use a GPRS shield and use AT Commands. There are quite a lot tutorials about this and it is pretty straight foward. So consider piece of code to send messages :

#include <SoftwareSerial.h>

//Create software serial object to communicate with SIM900
SoftwareSerial mySerial(7, 8); //SIM900 Tx & Rx is connected to Arduino #7 & #8
int iteration = 0;

void setup()
{
  //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  
  //Begin serial communication with Arduino and SIM900
  mySerial.begin(9600);

  Serial.println("Initializing..."); 
  delay(1000);

  mySerial.println("AT"); //Handshaking with SIM900
  updateSerial();

  mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
  updateSerial();  
  mySerial.println("AT+CMGS=\"+ZZxxxxxxxxxxx\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
  updateSerial();
  mySerial.print("Hello, I am Mr.Arduino"); //text content
  updateSerial();
  mySerial.write(26);
}

void loop()
{
}

void updateSerial()
{
  delay(500);
  while (Serial.available()) 
  {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available()) 
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

I was wondering what’s the best way to build an agenda so I could for example send to a group of contacts… I know arduino does not have much memory, I read in few threads that String type is hard to work with and demands higher amounts of memory. So I would like opinions, since I am newbie. Which data structure would perform better for this case?

I tryed to work with char but ended up with erros like conversion from ‘const char*’ to ‘char’ [-fpermissive].

I’ll present another piece of code that represents what I first intend to do, this should merge with the above code when things get clearer

#include <SD.h>
#include <SPI.h>

File file;
// DECLARE DATA STRUCTURE HERE, to be defined with your help.
boolean SDfound;
int index = 0;


void setup() {
  Serial.begin(9600);

  if (SDfound == 0) {
    if (!SD.begin(53)) {
      Serial.print("The SD card cannot be found");
      while(1);
    }
  }
  SDfound = 1;
  file = SD.open("agenda.txt");

  if (!file) {
    Serial.print("The text file cannot be opened");
    while(1);
  }

  while (file.available()) {
    DATASTRUCTURE[index] = printFile.readStringUntil('\n'); // Here i am storing the line content in a certain index within the data structure.
	index++;
  }

  file.close();
}

void loop() {
   //empty
}

In possession of the agenda I could change the setup function of the first code to:

for(iteration=0;iteration<=sizeof(DATASTRUCTURE);i++){
	  mySerial.println("AT"); //Handshaking with SIM900
	  updateSerial();

	  mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
	  updateSerial();  
	  mySerial.println("AT+CMGS=\""+DATATRUCTURE[iteration]+"\"");
	  updateSerial();
	  mySerial.print("Hello, I am Mr.Arduino"); //text content
	  updateSerial();
	  mySerial.write(26);
  
  }

I explained my idea, I still do not know if this is a good approach and due my deficiency in the language I do not know if it’s possible and will work, hopefully someone can give me some advice/piece of compatible code. Thanks !

I tryed to work with char but ended up with erros like conversion from ‘const char*’ to ‘char’ [-fpermissive].

don’t give up. working with char arrays is the way to go.

also it’s not an agenda you are building, looks more like an address book :slight_smile: