Problem with Softwareserial to build a LoRa GPS tracker

Hi,
I'm trying to build a LoRa GPS Tracker for short-distance tracking of sailboats. The idea is to communicate GPS coordinates via LoRa P2P with the push of a button towards a location finder device similar to an ARVA. The receiver device compares its own coordinates with those it received via LoRa.

On this receiver device, it can separately receive the LoRa data or its own GPS data, so I'm sure it is all well connected. However, when I try to run the code that gathers the GPS listening and LoRa listening, it doesn't work at all. It shows me wrong data on the serial monitor or nothing at all. I think there is a porblem with the way I am listening on tow SoftwareSerial device at once but can't find it

I'm using an Arduino Nano with a LoRa-E5 Grove 113020091 from Seeedstudio and a GPS Grove 109020022 (Air 530) also from Seeedstudio.

I tried using AltSoftSerial without success and I'm a bit at a dead end with this project. Here's the code:

User
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
#define DEFAULT_TIMEWAIT 100 

#define LORA_RX 5
#define LORA_TX 4

static const int RXPin = 8, TXPin =7 ;
static const uint32_t GPSBaud = 9600;

SoftwareSerial LoRaSerial(LORA_RX, LORA_TX);

SoftwareSerial gpsSerial(RXPin, TXPin);

TinyGPSPlus gps;

void setup() {

  Serial.begin(9600);
  
  gpsSerial.begin(9600);
  LoRaSerial.begin(9600);
  
  sendATCommand("AT+MODE=Test"); //P2P mode for the LoRa E5 
  

  sendATCommand("AT+TEST=RFCFG,868,12,125,12,15,14");
  sendATCommand("AT+TEST=RXLRPKT"); //RX MODE 
}



void loop() {
LoRaSerial.listen();
  if (LoRaSerial.available()) {
    String receivedData = LoRaSerial.readStringUntil('\n');
    Serial.print("Received Data ");
    Serial.println(receivedData);
    if (receivedData.startsWith("+TEST: RX")) {
   

      String usefulDataHex = extractUsefulData(receivedData);
      Serial.print("Uselful Data (hexadécimal) : ");
      Serial.println(usefulDataHex);
    
      String usefulDataASCII = hexToASCII(usefulDataHex);
      Serial.print("Useful Message (ASCII) : ");
      Serial.println(usefulDataASCII);
    }
  }
  
gpsSerial.listen();
  if (gpsSerial.available() > 0) {
    if (gps.encode(gpsSerial.read())) {
      displayGPSInfo();
    }
  }

}

void sendATCommand(String command) {
  LoRaSerial.println(command); 
  delay(DEFAULT_TIMEWAIT); 

String extractUsefulData(String data) {
  int startPos = data.indexOf('"') + 1; 
  int endPos = data.lastIndexOf('"');    
  return data.substring(startPos, endPos);
}
String hexToASCII(String hexString) {
  String asciiString = "";
  for (int i = 0; i < hexString.length(); i += 2) {
    
    char hexPair[3];
    hexPair[0] = hexString[i];
    hexPair[1] = hexString[i + 1];
    hexPair[2] = '\0'; 
    asciiString += (char) strtol(hexPair, NULL, 16);
  }
  return asciiString;
}

void displayGPSInfo() {
  if (gps.location.isValid()) {
    Serial.print(F("Latitude: "));
    Serial.println(gps.location.lat(), 6);
    Serial.print(F("Longitude: "));
    Serial.println(gps.location.lng(), 6);
  } else {
    Serial.println(F("Location not valid"));
  }
}

Could you help me on this project ? Thanks a lot

What happens if you create one soft serial interface with each of the two libraries instead of both with the same one which is always problematical ?

Quite apart from the problem with Serial interfaces your code won't compile anyway because you have a function definition inside another one

void sendATCommand(String command)
{
    LoRaSerial.println(command);
    delay(DEFAULT_TIMEWAIT);

    String extractUsefulData(String data)
    {
        int startPos = data.indexOf('"') + 1;
        int endPos = data.lastIndexOf('"');
        return data.substring(startPos, endPos);
    }

note that the LoRa-E5 Grove uses 3.3V logic - the Nano uses 5V logic therefore you require a level converter on the Nano Tx to LoRa-E5 Grove Rx signal
as indicated by @Delta_G and @UKHeliBob multiple instances of software serial can be a problem
recommend you move to an ESP32 (uses 3.3V logic) which has hardware serial ports

+1 on switching to an Arduino that has enough hardware serial ports.

Mixing the SPI LoRa device and just a single software serial interface can be difficult to make reliable.