This project has moved and is read-only. For the latest updates, please go here.

Xbee send example

Jun 4, 2012 at 1:35 PM
Edited Jun 4, 2012 at 4:45 PM

Hi, I'm working with this nice framework but don't understand who send a TxRequest64 message.

Can you give me an example for send this message using 64 bit destination address ?

Jun 4, 2012 at 11:43 PM
Edited Jun 4, 2012 at 11:43 PM

I'm glad you like it. I would say the easiest way to send a TxRequest64 message is this:

xbee.Send("Hello world").To(0x0102030405060708).Invoke();

There is no documentation yet so feel free to ask questions.

Jun 4, 2012 at 11:58 PM
Ok thanks a lot to help me.
An other question is:
When use xbee.receive() i must always wait the timeout (5sec)?
Jun 5, 2012 at 12:07 AM

How about subscribing to data received event ?

xbee.DataReceived += OnDataReceived;

You can process the data like this:

private static void OnDataReceived(XBeeApi receiver, byte[] data, XBeeAddress sender)
    Debug.Print("Received: " + new string(Encoding.UTF8.GetChars(data)));
I have updated the source code this weekend and there is a major change. Main XBee.cs class has been renamed to XBeeApi. If you are using the old one with XBee class just change the XBeeApi to XBee in this example and you are good.

Jun 5, 2012 at 6:23 PM

yes it's a good idea, but can i use this method to set a textbox in my Form?


private void OnDataReceived(XBeeApi receiver, byte[] data, XBeeAddress sender)
    this.textBox.Text = new string(Encoding.UTF8.GetChars(data));
i think i must delegate the method. It's correct?

Jun 6, 2012 at 12:30 AM

The DataReceived event is fired on a separate thread so you need to invoke your action on the dispatcher (can't update UI from any other thread than the main one). 

Jun 6, 2012 at 6:33 AM
Ok i will post my solution soon
Thanks a lot