Tristan Hughes
/
Xbee_Hello_world
Hello world example for xbee_lib
main.cpp@0:c61faf93bc2a, 2012-08-29 (annotated)
- Committer:
- tristanjph
- Date:
- Wed Aug 29 14:32:10 2012 +0000
- Revision:
- 0:c61faf93bc2a
- Child:
- 1:b2b2ed674cbf
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tristanjph | 0:c61faf93bc2a | 1 | #include "mbed.h" |
tristanjph | 0:c61faf93bc2a | 2 | #include "xbee.h" |
tristanjph | 0:c61faf93bc2a | 3 | |
tristanjph | 0:c61faf93bc2a | 4 | xbee xbee1(p9,p10,p11); //Initalise xbee_lib |
tristanjph | 0:c61faf93bc2a | 5 | |
tristanjph | 0:c61faf93bc2a | 6 | int main() |
tristanjph | 0:c61faf93bc2a | 7 | { |
tristanjph | 0:c61faf93bc2a | 8 | int device_serial[8]; |
tristanjph | 0:c61faf93bc2a | 9 | int security_key[8]; |
tristanjph | 0:c61faf93bc2a | 10 | int Pan_ID; |
tristanjph | 0:c61faf93bc2a | 11 | char send_data[202]; |
tristanjph | 0:c61faf93bc2a | 12 | char read_data[202]; |
tristanjph | 0:c61faf93bc2a | 13 | |
tristanjph | 0:c61faf93bc2a | 14 | xbee1.ConfigMode(); //Enter the xbee's config mode |
tristanjph | 0:c61faf93bc2a | 15 | xbee1.GetSerial(device_serial); //Read the xbee devices serial into device_serial |
tristanjph | 0:c61faf93bc2a | 16 | xbee1.SetKey(security_key); //Set the network key to security_key |
tristanjph | 0:c61faf93bc2a | 17 | xbee1.SetPanId(Pan_ID); // set the PAN network id to Pan_ID |
tristanjph | 0:c61faf93bc2a | 18 | xbee1.WriteSettings(); // Write the settings to non volatile memory |
tristanjph | 0:c61faf93bc2a | 19 | xbee1.ExitConfigMode(); //Exit config mode |
tristanjph | 0:c61faf93bc2a | 20 | xbee1.reset(); //Reset Xbee |
tristanjph | 0:c61faf93bc2a | 21 | |
tristanjph | 0:c61faf93bc2a | 22 | xbee1.SendData(send_data); //Send the data in send_data |
tristanjph | 0:c61faf93bc2a | 23 | xbee1.RevieveData(read_data); //Put recieved data into read_data |
tristanjph | 0:c61faf93bc2a | 24 | |
tristanjph | 0:c61faf93bc2a | 25 | |
tristanjph | 0:c61faf93bc2a | 26 | } |