Home/Support/Support Forum/C# Changing the frame sent to only affect XBee mac address

C# Changing the frame sent to only affect XBee mac address

0 votes
Hi.

To sent an api frame, I use the following code:

byte[] bytesToSend5 = new byte[] { 0x7E, 0x00, 0x10, 0x17, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x40, 0xA6, 0x5E, 0x23, 0xFF, 0xFE, 0x02, 0x44, 0x34, 0x05, 0x4F };
serialPort1.Write(bytesToSend5, 0, bytesToSend5.Length);

But I want to be able to change the xbee on the receiving XBee. To do this, I'm thinking it's possible to type in the new mac address into my program, and save that info in a string, translate the string into a byte array, and implement that into the middle of the existing byte array. In theory, it would look something like this:

string Xbee_macaddress = address typed by user
xbee_macaddress = string converted to bytearray

byte[] bytesToSend5 = new byte[] { 0x7E, 0x00, 0x10, 0x17, 0x01, xbee_macaddress, 0xFF, 0xFE, 0x02, 0x44, 0x34, 0x04, 0x50 };
serialPort1.Write(bytesToSend5, 0, bytesToSend5.Length);

Anyone know if this is possible, if I should take another approach or otherwise have any suggestions/advice?
asked Feb 10, 2016 in XBee Programmable Development by Lars New to the Community (5 points)

Please log in or register to answer this question.

2 Answers

0 votes
Without adjusting the Check sum accordingly, it will not work.
answered Feb 10, 2016 by mvut Veteran of the Digi Community (12,831 points)
I realize that, but I figured if I can edit the byte array with the ID bits of the xbee, and swap them, I can easily calculate the last bit and swap that as well. I've even made a formula for it.
As long as you do that you should be fine.
0 votes
What exactly are you trying to change on the remote module? Is it the 64 bit Serial number you are trying to change or the destination address you are trying to change?
answered Feb 19, 2016 by mvut Veteran of the Digi Community (12,831 points)
I'm trying to change byte 5-12 in the API frame if I recall correctly, the ones that represent the serial number on the remote xbee, the end point.

I've figured out what I have to do, and most of the code is working. All I have left is to add the formula to calculate the checksum and replace the last byte with that value. Then I have to find out how to save this information in the program so the last typed number is always loaded on program startup/closing - but that's a question more suited for C# forums if I can't figure it out myself.
you need to recalculate your packet size.  This should be 12 and not 10 for the packet length.
...