Created
February 16, 2014 18:56
-
-
Save tejainece/9038923 to your computer and use it in GitHub Desktop.
Waspmote v1.1: Broadcast a message using XBee S1 through 802.15.4 protocol.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* data="Please work! :P"; | |
| packetXBee* paq_sent; | |
| uint8_t PANID[2] = {0x33, 0x32}; | |
| uint8_t dest_addr[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}; | |
| int i = 0; | |
| void setup() { | |
| xbee802.init(XBEE_802_15_4, FREQ2_4G, NORMAL); | |
| xbee802.ON(); | |
| Utils.setLED(LED0, LED_ON); | |
| Utils.setLED(LED1, LED_ON); | |
| if(xbee802.setChannel(0x0C)) { | |
| Utils.setLED(LED0, LED_OFF); | |
| } | |
| if(xbee802.setPAN(PANID)) { | |
| Utils.setLED(LED0, LED_OFF); | |
| } | |
| if(!xbee802.setNodeIdentifier("letmework5#")) { | |
| Utils.setLED(LED0, LED_OFF); | |
| } | |
| if(!xbee802.writeValues()) { | |
| Utils.setLED(LED0, LED_OFF); | |
| } | |
| //time to verify if setting configurations worked | |
| delay(2000); | |
| for(i = 0; i < 2; i++) { | |
| Utils.blinkLEDs(1000); | |
| } | |
| } | |
| void loop() { | |
| paq_sent = (packetXBee*)calloc(1, sizeof(packetXBee)); | |
| paq_sent->mode = BROADCAST; | |
| paq_sent->MY_known = 0; | |
| paq_sent->packetID = 0x52; | |
| paq_sent->opt = 0; | |
| xbee802.hops = 0; | |
| xbee802.setOriginParams(paq_sent, MAC_TYPE); | |
| xbee802.setDestinationParams(paq_sent, dest_addr, data, MAC_TYPE, DATA_ABSOLUTE); | |
| xbee802.sendXBee(paq_sent); | |
| for(i = 0; i < 5; i++) { | |
| Utils.blinkLEDs(1000); | |
| } | |
| if( !xbee802.error_TX ) { | |
| Utils.setLED(LED0, LED_ON); | |
| } | |
| free(paq_sent); | |
| paq_sent = NULL; | |
| //time to verify if the send was succesfull | |
| delay(2000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment