gps neo 6M + 433hz rf + arduino nano

I would like to carry out the following project: Using data received by my GPS, I must send it as a message via a transmitter. The coordinates must be received by my radio receiver.
I tried this code implanted in my arduino nano card connected to the gps module and the transmitter:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <RH_ASK.h>
#include <SPI.h>

RH_ASK driver;

TinyGPSPlus gps;

#define S_RX 4
#define S_TX 3

SoftwareSerial SoftSerial(S_RX, S_TX);

void setup(void) {
Serial.begin(9600);
SoftSerial.begin(9600);
Serial.begin(9600);
if (!driver.init())
Serial.println(“init failed”);
}

void loop() {

while (SoftSerial.available() > 0) {

if (gps.encode(SoftSerial.read())) {

if (gps.location.isValid()) {
Serial.print("Latitude = ");
Serial.println(gps.location.lat(), 6);
Serial.print("Longitude = ");
Serial.println(gps.location.lng(), 6);
}
else
Serial.println(“Location Invalid”);
}
const char *msg =("Longitude = ", "Latitude = ");
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
}

}

after I must receive my contact details with this program:
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver;

void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println(“init failed”);
}

void loop()
{
uint8_t buf[9]; // a classic latitude coordinate has 9 characters
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
Serial.print("Message: ");
Serial.println((char*)buf);
}
}

the problem is that I will not impose a maximum character " uint8_t buf[9]; " but I don’t think we can do it via the RH_ASK.h library.
→https://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html
I would like to know if my code is valid knowing that I need the longitude and the latitude in the reception message. Thanks

I don’t think you are using the receive properly. It’s been a while since I used RH, but if I recall correctly, it will receive variable length packets. So you should allocate ‘buf’ size greater than the longest packet that you expect to receive. When a packet is received, it will just fill ‘buf’ and report back to you the length of the received packet.

I have to say, ASCII strings are a crude way to transmit coordinates. You should investigate sending them as long or float types, because they have a fixed length and are shorter in size.

By the way, you have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don’t do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The “Code: [Select]” feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.
If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower right corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Since you have posted two sketches, you should place separate code tags for each sketch.