XBee-mbed sample

Dependencies:   mbed XBee

Revision:
0:12a6db2d1600
Child:
1:f9ececd7aa01
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 22 10:38:08 2010 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "XBee.h"
+
+DigitalOut myled(LED1);
+XBee xbee(p13, p14);
+XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x40319F25);
+
+int main() {
+    uint8_t p2Cmd[] = {'D', '4'};
+    uint8_t p2Low[] = {0x04};
+    uint8_t p2High[] = {0x05};
+    RemoteAtCommandRequest remoteAtRequest;
+
+    wait(1);
+    xbee.begin(9800);
+
+    remoteAtRequest = RemoteAtCommandRequest(remoteAddress, p2Cmd, p2Low, sizeof(p2Low));
+    remoteAtRequest.setApplyChanges(true); // I/Oó‘Ԃ𑦔½‰f‚³‚¹‚é
+
+    while(1) {
+        myled = 1;
+        remoteAtRequest.setCommandValue(p2Low);
+        remoteAtRequest.setCommandValueLength(sizeof(p2Low));
+        xbee.send(remoteAtRequest);
+        myled = 0;
+        wait(1);
+
+        myled = 1;
+        remoteAtRequest.setCommandValue(p2High);
+        remoteAtRequest.setCommandValueLength(sizeof(p2High));
+        xbee.send(remoteAtRequest);
+        myled = 0;
+        wait(1);
+    }
+}