Good Morning Folks, so from several times i'm play with virtual wire for send data via "ASK Amplitude Shift Keying".
What I have learned is that:
- the library send-out data using:
const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg));
Where msg could be defined in this way:
char msg[6] = "hello";
or in this way:
char msg[6];
msg[0]='h';
msg[1]='e';
msg[2]='l';
msg[3]='l';
msg[4]='0';
msg[5]='\0';
and Receive message in this way:
char msgrx[10];
uint8_t buf[VW_MAX_MESSAGE_LEN]; // define the buffer
uint8_t buflen = VW_MAX_MESSAGE_LEN; // buffer length
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
msgrx[i]=buf[i];
}
}
Well at the end inside my variable msgrx I will have "hello" + 5 + '\0' .
Then when I have my message into the variable i did all my check for example:
if (strcmp(msgrx, "hello") == 0)
{
Serial.println("Work are equal..."
}
- Is this the correct use for the library ?
- Could I improve in something ?
VirtualWire is the only library that can be used for send data via ASK Amplitude Shift Keying or could be used something else ?
thanks have nice day,
gnux