Search code examples
xbee

XBEE to XBEE - Sending multiple chars from one to another


I am trying to get one Xbee to send to another Xbee. I am using the Xbees on FRDM-K64Fs. The following works but only for a single char:

Receiver code

if(xbee.readable()){
    char x = xbee.getc();
    if(x == 'W'){      
       lcd.locate (1, 1);
       lcd.printf("Received Char");
    }
    wait(1);
}

Sender code:

xbee.putc('W');
wait(0.5);

The problem is when I try to execute xbee.putc multiple times because still only one char is received. I need a way to send a string or an int(longer than one digit).

I have tried using xbee.printf in my sending code and using while(xbee.readable()) in my receiving code which doesn't seem to work either.

Is there a method which I should use?


Solution

  • What if you update your receiver code to repeatedly check for characters? Just replace the if(xbee.readable()) with while (xbee.readable()).