how to put 2 buffer in a sketch 433 MHZ RF module

So i’ve been thinking how to put 2 buffers in a receiver sketch. Basically i want the led to blink when the condition is met but the buffer can only be one, Buf1 or buf2. The line if (rf_driver.recv(buf, &buflen)) . I can’t seem to solve the mystery??? What i want to do is when the msg received is “Bravo”, length 5, and “Charlie”, length 7. Can anyone help me with this, i would be very very gratefull

uint8_t buf1[5];
   uint8_t buflen1 = sizeof(buf1);
   uint8_t buf2[7];
   uint8_t buflen2 = sizeof(buf2);

   if (rf_driver.recv(buf, &buflen))        //I want to add another buffer to this line
   {
       Serial.println(txtMsg);                  //String txtMsg = "";
       Serial.println((char*)buf);    
       if (txtMsg.length() < 6)
       {
         digitalWrite(9, HIGH);
         delay(2000);
         digitalWrite(9, LOW);    
       } 
       
       if (txtMsg.length() > 6)
       {
         digitalWrite(8, HIGH);
         delay(2000);
         digitalWrite(8, LOW);    
       } 
   }else{
     digitalWrite(9, LOW);
     digitalWrite(8, LOW);
   }

Compare messages, not buffers. Use the function strcmp() for this, but first you must make sure that the message is properly terminated with a zero byte (a C-string).

Example code (not tested): EDIT: typo fixed

uint8_t buf[11];
uint8_t buflen=10;  //one less than the length of buf, for safety
if (rf_driver.recv(buf, &buflen)) {
   buf[buflen]=0; //make sure it is zero terminated
   if ( strcmp(buf,"Bravo") == 0 ) do_something();
   if ( strcmp(buf,"Charlie") == 0) do_another_thing();
}

Please use code tags when posting, and avoid Strings, as Strings cause memory problems and program crashes.

it says for the line
buf(buflen)=0;
exit status 1
‘buf’ cannot be used as a function

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;
String txtMsg = "";

void setup()
{
   // Initialize ASK Object
   rf_driver.init();
   // Setup Serial Monitor
   Serial.begin(9600);
   pinMode(9, OUTPUT);
   pinMode(8, OUTPUT);
}

void loop()
{
   // Set buffer to size of expected message
   uint8_t buf[11];
   uint8_t buflen=10;  //one less than the length of buf, for safety
   if (rf_driver.recv(buf, &buflen)) {
   buf(buflen)=0; //make sure it is zero terminated   
       if (strcmp(buf,"Bravo") == 0)
       {
         digitalWrite(9, HIGH);
         delay(2000);
         digitalWrite(9, LOW);    
       } 
       
       if (strcmp(buf,"Charlie") == 0)
       {
         digitalWrite(8, HIGH);
         delay(2000);
         digitalWrite(8, LOW);    
       } 

     }else{
     digitalWrite(9, LOW);
     digitalWrite(8, LOW);
   } 
}

USE CODE TAGS WHEN POSTING CODE.

Please go back and edit your posts to add them. See the “How to use this forum” post.

Also, correct the typographical error:

buf[buflen]=0;

:) Thanks a lot for your help. The code finally works. Without your help, I wasn't able to do it. Also thanks for the CODE TAG Tips. :) This forum has helped me a lot.