Identification of nodes via Arduino sketch
Hi,
I am trying to implement key distribution scheme in 3 Xbee+Arduino based nodes. If I assume one node as Node 1 (A) and another 2 as Node 2 (B) and Node 3 (C), I want to distribute the authentication to these nodes.
My main concern now is Identification of the nodes. I dont know how Node 1 will refer to Node 2 and 3. I will be using other related sketch in arduino and thats why I need to know arduino sketch by which I can identify a particular node and when needed refer to that node only. As an example if B wants to communicate with A only and then again wants to send some data to C only instead of A, how will it know the ID of the nodes and accomplish its job?
I am trying to implement key distribution scheme in 3 Xbee+Arduino based nodes. If I assume one node as Node 1 (A) and another 2 as Node 2 (B) and Node 3 (C), I want to distribute the authentication to these nodes.
My main concern now is Identification of the nodes. I dont know how Node 1 will refer to Node 2 and 3. I will be using other related sketch in arduino and thats why I need to know arduino sketch by which I can identify a particular node and when needed refer to that node only. As an example if B wants to communicate with A only and then again wants to send some data to C only instead of A, how will it know the ID of the nodes and accomplish its job?
Comments
Here's some code I wrote several years ago to change the destination serial number. Hopefully it offers you some clues.
PUB SetDestination(xbeeToChange, NewDestination) Debug.str(string("Press any key each time you see XBee respond.", 13)) okFlag := 0 count := 0 XBee.str(string("+++")) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string("XBee #")) Debug.dec(xbeeToChange) Debug.str(string(" SH = ")) okFlag := 0 count := 0 XBee.str(string("ATSH")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "SL = ")) okFlag := 0 count := 0 XBee.str(string("ATSL")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "DH = ")) okFlag := 0 count := 0 XBee.str(string("ATDH")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "DL = ")) okFlag := 0 count := 0 XBee.str(string("ATDL")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "Set DH = ")) Debug.str(@shCoordinator + (NewDestination * 9)) okFlag := 0 count := 0 XBee.str(string("ATDH ")) XBee.str(@shCoordinator + (NewDestination * 9)) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "Set DL = ")) Debug.str(@slCoordinator + (NewDestination * 9)) Debug.tx(13) okFlag := 0 count := 0 XBee.str(string("ATDL ")) XBee.str(@slCoordinator + (NewDestination * 9)) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "Check DH = ")) okFlag := 0 count := 0 XBee.str(string("ATDH")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "Check DL = ")) okFlag := 0 count := 0 XBee.str(string("ATDL")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) Debug.str(string(13, "End Command Mode")) okFlag := 0 count := 0 XBee.str(string("ATCN")) XBee.tx(13) repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt) DAT shCoordinator byte "0013A200", 0 shBarcode byte "0013A200", 0 shBackup byte "0013A200", 0 shSam byte "0013A200", 0 shFred byte "0013A200", 0 shBroadcast byte "00000000", 0 slCoordinator byte "403BCDDD", 0 slBarcode byte "400A2CCC", 0 slBackup byte "403BCEEE", 0 slSam byte "403DDAAA", 0 slFred byte "403DDBBB", 0 slBroadcast byte "0000FFFF", 0
The lines:
XBee.str(string("ATDH ")) XBee.str(@shCoordinator + (NewDestination * 9)) XBee.tx(13)
and
XBee.str(string("ATDL ")) XBee.str(@slCoordinator + (NewDestination * 9)) XBee.tx(13)
would send the appropriate serial numbers listed at the bottom of the top block of code.
The code:
repeat while okFlag == 0 and count < _TimeoutCount waitcnt(clkfreq / 100 + cnt)
Would wait for either a timeout period to occur or for the characters "OK" to be received. The variable "count" and "okFlag" were changed in a different cog than the one running the above method.
I was using Series 2 XBee but I think the destination serial number can also be set Series 1 XBees (though I'm not sure).