GPS and GSM communication doesn't seem to be working

I'm currently trying to build a custom GPS tracker using an Arduino Nano, GSM SIM900A mini module and a Neo 6M GPS module.

I've connected Arduino Nano's pins 7 and 8 to GSM's TX and RX pins respectively, and the GND pins of both the modules are connected to each other. For powering the GSM, I give a seperate power source of 5V 2A.

As for the Nano and GPS interfacing, I've connected pin 2,pin 3,5V and GND to the TX,RX,VCC and GND pins of the GPS module respectively.

My code is as follows:

#include <NeoSWSerial.h>

#include <AltSoftSerial.h>
#include <TinyGPS++.h>

AltSoftSerial mySerial(7, 8); //gsm serial

//defining GPS stuff

int RXPin = 2;
int TXPin = 3;
int GPSBaud = 9600;

TinyGPSPlus gps; // Create a TinyGPS++ object
NeoSWSerial gpsSerial(RXPin, TXPin);// Create a software serial port called "gpsSerial"

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  gpsSerial.begin(GPSBaud);
  delay(100);
}


void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}


 void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+971562427888\"\r"); // Replace x with mobile number
  delay(1000);

 while (gpsSerial.available() > 0)
    if (gps.encode(gpsSerial.read()))
      displayInfo();

  // If 5000 milliseconds pass and there are no characters coming in
  // over the software serial port, show a "No GPS detected" error
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println("No GPS detected");
    while(true);
  }
  delay(100);
  
}

void displayInfo()
{
  if (gps.location.isValid())
  {
    mySerial.print("Latitude: ");
    mySerial.println(gps.location.lat(), 6);
    mySerial.print("Longitude: ");
    mySerial.println(gps.location.lng(), 6);
    mySerial.println((char)26);// ASCII code of CTRL+Z
    delay(1000);
  }
  else
  {
    mySerial.println("Location: Not Available");
  }
  
  Serial.println();
  Serial.println();
  delay(1000);
}

I've tested my GPS and GSM modules seperately and they work perfectly fine. However, when I connect them all together and run my sketch, it doesn't give me any response. The Arduino and GSM lights up and the GPS module doesn't light up at all.I then tried using the AltSoftwareSerial along with the NeoSWSerial, and all my components light up!

#include <NeoSWSerial.h>
#include <AltSoftSerial.h>
// GPS
#include <TinyGPS.h>

// GSM
static const int RXPin = 7, TXPin = 8;
AltSoftSerial SIM900A(RXPin, TXPin);

NeoSWSerial mySerial(2, 3);
TinyGPS gps;

void setup()
{
Serial.begin(9600);
SIM900A.begin(9600);
SIM900A.println("AT+CNMI=2,2,0,0,0");
mySerial.begin(9600);
delay(1000);
}

void loop()
{
bool newdata = false;
String buffer = readSIM900A();
if(SIM900A.available() > 0)
  Serial.println(SIM900A.read());
if (buffer.startsWith("\r\n+CMT: "))
{
    // printing the number
    Serial.println(buffer.substring(9, 22)); 

    // Remove first 51 characters
    // buffer.remove(0, 51);
    int len = buffer.length();
    // Remove \r\n from tail
    // buffer.remove(len - 2, 2);
    // printing message
    Serial.println(buffer.substring(51, len-2));
    if (buffer.substring(51, len-2) == "location")
    {
      Serial.println("Sending location");

      // GPS
      if (mySerial.available()) 
      {
         char c = mySerial.read();
         if (gps.encode(c)) 
         {
            newdata = true;
         }
      }
      if (newdata)
      {
        long int lat, lon;
        unsigned long age, age1, date, time, chars;

        gps.get_position(&lat, &lon, &age);
        gps.get_datetime(&date, &time, &age);
        Serial.print("Lat/Long(10^-5 deg): ");
        Serial.print(lat);
        Serial.print(", ");
        Serial.print(lon); 
        Serial.print(" Fix age: "); 
        Serial.print(age); Serial.println("ms.");

        Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print("Time(hhmmsscc): ");
        Serial.print(time);
        Serial.print(" Fix age: "); Serial.print(age); 
        Serial.println("ms.");

        Serial.print("Alt(cm): "); Serial.print(gps.altitude());
        Serial.print(" Speed(mps): "); Serial.print(gps.f_speed_mps());

        // setting GSM module
        SIM900A.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
        delay(1000);  // Delay of 1000 milli seconds or 1 second
        // sending location from which code word had come
        SIM900A.println("AT+CMGS=\"+971562427888" + buffer.substring(9, 22) + "\"\r"); //Replace x with mobile number
        Serial.println("AT+CMGS=\"+971562427888" + buffer.substring(9, 22) + "\"\r");
        delay(1000);

        SIM900A.print("Lat/Long(10^-5 deg): ");
        SIM900A.print(lat);
        SIM900A.print(", ");
        SIM900A.print(lon); 
        SIM900A.print(" Fix age: "); 
        SIM900A.print(age); SIM900A.println("ms.");

        SIM900A.print("Date(ddmmyy): "); SIM900A.print(date); 
        SIM900A.print(" Time(hhmmsscc): ");
        SIM900A.print(time);
        SIM900A.print(" Fix age: "); SIM900A.print(age); 
        SIM900A.println("ms.");

        SIM900A.print("Alt(cm): "); SIM900A.print(gps.altitude());
        SIM900A.print(" Speed(mps): "); SIM900A.print(gps.f_speed_mps());

        SIM900A.println((char)26);// ASCII code of CTRL+Z
        delay(1000);
      }
    }
    }
    delay(100);
   }

 String readSIM900A()
{
String buffer;

while (SIM900A.available())
{
    char c = SIM900A.read();
    buffer.concat(c);
    delay(10);
}

return buffer;
}

However both the codes I've attached don't seem to work. I'm not sure what is wrong. Any help would be really appreciated.

Multiple software serial ports can be tricky to get to work and even then may not be very good. I would suggest that you use a Mega (or other board with multiple hardware serial ports). The Mega has 3 extra (besides the USB) hardware serial ports.