Hi, nice to meet you !
I'm currently building a transmitter with VirtuaWire for a little submarine Drone, i want to tell him for example "for this period of time you will go up" and some other stuff. To do that i use some radio emitter-receiver (low frequence usualy work underwater, as long i'm not too deep).
But i have a problem: when you send the message, you do not send a simple String, it is more a char buffer with the size of a String or something right?
So when i receive the message i want to do this for example (this is in loop):
if (coms.substring(3) == "M1r" && mode == 1) {
sayM("M1r reçus", MOTOR1); // Detected but never works
nombres = coms.substring(5, 8); //I'm transfering the number to an other String to be sure
M1r = nombres.toInt(); //Motor will go "on" for this amount of time
sayM("COMS recus = ", COMS); //Finish the lines so i know everything went fine
}
coms is the string that i receive from this in my virtualWire fonction :
I've got this before my setup:
typedef struct {
String commande;
int valeur;
} MaStructure;
MaStructure message;
byte taille_message = sizeof(MaStructure);
vw_wait_rx_max(5000);
//vw_wait_rx();
if (vw_get_message((byte *) &message, &taille_message)) {
radioToComs = message.commande; //I simply put the string from the message into a string more stable
}
I know this fonction is working because i try some stuff like:
if (coms == "bonjour"){
Serial.println("hello world");
}
But when i use the substring, nothing is working correctly... so i think it is a little bit tricky no?
If you have any thinking about that, i would be happy to here them