Help! program gps and GSM to send messages some time

Today at 01:40 am

hello I am new to all this arduino and obviously programming I want to ask you for help with a project. I already have the programming so that a neo-m6v2 gps device and the sim800l send messages with the location but I want it to be activated when a menja is sent that says "activate" and that it stops sending a message when it says "Deactivate". Beforehand Thank you very much

This does not work for me

#include <TinyGPS.h>
#include <SoftwareSerial.h>
SoftwareSerial Gsm(7, 8);
char phone_no[] = "81xxxxxxx"; //replace with phone no. to get sms
TinyGPS gps;  //Creates a new instance of the TinyGPS object
int enviar =0;
String Mensaje;


void setup()

{
  Serial.begin(9600);
  Gsm.begin(9600);  
  Gsm.println("AT+CMGF=1");         // Configurar el módulo en modo de texto
  delay(500);                           //Tiempo de espera para que el modulo se conecte a una red
  Gsm.println("AT+CNMI=2,2,0,0,0"); //Configuracion de la forma como recibir mensajes
  Mensaje.reserve(100);
  delay(10000);

}

void loop()
{
    if(Mensaje.indexOf ("Active") >= 0 || Mensaje.indexOf ("Star") >= 0) 
    {
 
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values

  for (unsigned long start = millis(); millis() - start < 2000;)

  {

    while (Serial.available())

    {
      char c = Serial.read();
      Serial.print(c);
      if (gps.encode(c))
        newData = true;  

    }
 

  if (newData)      //If newData is true
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Gsm.print("AT+CMGF=1\r");
    delay(800);
    Gsm.print("AT+CMGS=\"");
    Gsm.print(phone_no);
    Gsm.println("\"");

    delay(600);
    Gsm.print("http://maps.google.com/maps?q=loc:");
   // Gsm.print("Latitude = ");
    Gsm.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    //Gsm.print(" Longitude = ");
    Gsm.print(",");
    Gsm.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    delay(400);
    Gsm.println((char)26); // End AT command with a ^Z, ASCII code 26
    delay(400);
    Gsm.println();
    delay(20000);
  }

  Serial.println(failed);
 // if (chars == 0)
   // 
}}}

This yes, but I can not activate or deactivate it

#include <TinyGPS.h>
#include <SoftwareSerial.h>
SoftwareSerial Gsm(7, 8);
char phone_no[] = "81xxxxxxx"; //replace with phone no. to get sms
TinyGPS gps;  //Creates a new instance of the TinyGPS object


void setup()

{

  Serial.begin(9600);
  Gsm.begin(9600);  

}

void loop()




{

  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values

  for (unsigned long start = millis(); millis() - start < 4000;)

  {

    while (Serial.available())

    {
      char c = Serial.read();
      Serial.print(c);
      if (gps.encode(c))
        newData = true;  

    }

  }

  if (newData)      //If newData is true
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Gsm.print("AT+CMGF=1\r");
    delay(1600);
    Gsm.print("AT+CMGS=\"");
    Gsm.print(phone_no);
    Gsm.println("\"");

    delay(1200);
    Gsm.print("http://maps.google.com/maps?q=loc:");
   // Gsm.print("Latitude = ");
    Gsm.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    //Gsm.print(" Longitude = ");
    Gsm.print(",");
    Gsm.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    delay(800);
    Gsm.println((char)26); // End AT command with a ^Z, ASCII code 26
    delay(800);
    Gsm.println();
    delay(40000);
  }

  Serial.println(failed);
 // if (chars == 0)
   // Serial.println("** No characters received from GPS: check wiring **");
}