Using XBee S2B units, I am trying to get them so I can set the PAN ID and Node Identification strings using rotary switches built into the device. The rotary switch (10 position) has 4 outputs.
I have figured out the programming (in C) to determine the value of the PAN ID variable by setting of the switch, and I have confirmed this by running the program in Code Blocks program (At this time, I am simulating the switches in the program so no physical switches are being used yet).
After confirming the code works in Code Blocks, I copied it to the project in the Code Warrior where I am trying to get it to work in the XBee units. I have the XBee S2B unit connected through the debugger and USB cables
signed long int panid;
// This declares the panid variable, that will get the actual value from the switches
xbee_cmd_simple(&xdev, “ID”,panid);
// This will send the value of panid to the ID in the Xbee
xbee_cmd_execute(&xdev, “NI”, panid,0x10);
//This will set the Node Identifier to the same as the panid
xbee_cmd_execute(&xdev, “WR”, NULL, 0);
// This will write the changes to the XBee X2B module
When I run the program using this code, I will get a PAN ID of 0, and some funny hieroglyphics in the Node Identification field
If I hard code the PAN ID in the program ,like this, it will set the PAN ID somewhat correctly (it will convert whatever number is entered here to a HEX value
signed long int panid=1234;
// This is a hard coded variable, that will be used as the PAN ID
xbee_cmd_simple(&xdev, “ID”,panid);
// This will send the value of panid to the ID in the Xbee
xbee_cmd_execute(&xdev, “NI”, panid,0x10);
//This will set the Node Identifier to the same as the panid
xbee_cmd_execute(&xdev, “WR”, NULL, 0);
// This will write the changes to the XBee X2B module
So, I have the 2 problems I am trying to figure out. The setting of the PAN ID, and the setting of the Node Identification string.
I am sure it is something fairly simple to get this to work, but the simplicity of it seems to be eluding me