Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Coordinator_node Router_node
Diff: xbee.cpp
- Revision:
- 6:3b97770f30e6
- Parent:
- 4:e8f4d41c0fbc
- Child:
- 7:78985e92c1c5
diff -r e8f4d41c0fbc -r 3b97770f30e6 xbee.cpp
--- a/xbee.cpp Tue Feb 14 02:47:56 2017 +0000
+++ b/xbee.cpp Tue Feb 14 04:03:55 2017 +0000
@@ -285,4 +285,80 @@
}
// Validate checksum TODO
+}
+
+void XBee::ZigBeeTransmit(int adresse16, int adresse64, char *data, int dataLength)
+{
+ // Frame Type 0x10
+ // 0x0000000000000000 - Reserved 64-bit address for the coordinator
+ // 0x000000000000FFFF - Broadcast address
+
+ // The Transmit Status frame (0x8B) est la reponse
+ char cmdtosend[25];
+ char checksum = 0x00;
+ int cmdlength = 18;
+ int i = 3;
+
+ //ID command to set/read operating 64 bit PAN ID
+ //WR command to set operating 64 bit PAN ID across reboot
+ //OI command to read operating 16 bit PAN ID
+ //II command to set operating 16 bit PAN ID
+
+ cmdtosend[0] = FRAMEDELIMITER;
+ cmdtosend[1] = 0x00;
+ cmdtosend[2] = 0x0E + dataLength;
+ cmdtosend[3] = 0x10; // Frame type
+ cmdtosend[4] = 0x01; // Frame number
+ cmdtosend[5] = 0x00; // MSB adresse 64-bit
+ cmdtosend[6] = 0x00;
+ cmdtosend[7] = 0x00;
+ cmdtosend[8] = 0x00;
+ cmdtosend[9] = 0x00;
+ cmdtosend[10] = 0x00;
+ cmdtosend[11] = 0xFF;
+ cmdtosend[12] = 0xFF; // LSB adresse 64-bit
+ cmdtosend[13] = adresse16 >> 16; // MSB adresse 16-bit
+ cmdtosend[14] = adresse16 && 0b0000000011111111; // LSB adresse 16-bit
+ cmdtosend[15] = 0x00; // Broadcast Radius
+ cmdtosend[16] = 0x00; // Options
+
+ // Set RF DATA
+ if(data != NULL)
+ {
+ i = 0;
+ cmdlength += dataLength;
+
+ while (i < dataLength)
+ {
+ cmdtosend[17 + i] = (data)[i];
+ i++;
+ }
+ }
+
+ //cmdtosend[17] = 0x00; // Start RF DATA
+ //cmdtosend[18] = 0x00;
+ //cmdtosend[19] = 0x00;
+ //cmdtosend[20] = 0x00;
+ //cmdtosend[21] = 0x00;
+ //cmdtosend[22] = 0x00;
+ //cmdtosend[23] = 0x00;
+ //cmdtosend[24] = 0x00; // End RF DATA
+
+ // Calculate checksum
+ i = 3;
+ while (i < (cmdlength - 1))
+ {
+ checksum += cmdtosend[i];
+ i++;
+ }
+ cmdtosend[cmdlength - 1] = 0xFF - checksum;
+
+ // Envoyer la commande sur UART
+ i = 0;
+ while (i < cmdlength)
+ {
+ comm.putc(cmdtosend[i]);
+ i++;
+ }
+ wait(0.1);
}
\ No newline at end of file