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.
Fork of Xbee_Hello_world_A by
Revision 2:c28639345230, committed 2017-11-11
- Comitter:
- mdo131
- Date:
- Sat Nov 11 18:55:21 2017 +0000
- Parent:
- 1:114432971517
- Commit message:
- ..
Changed in this revision
--- a/main.cpp Fri Nov 03 00:06:52 2017 +0000
+++ b/main.cpp Sat Nov 11 18:55:21 2017 +0000
@@ -1,19 +1,86 @@
#include "mbed.h"
#include "xbee.h"
-xbee xbee1(p9,p10,p11); //Initalise xbee_lib
+//xbee xbee1(D1,D0,D3); //Initalise xbee_lib
Serial pc(USBTX, USBRX); //Initalise PC serial comms
+Serial xbee(D1,D0);
+
+unsigned char input;
+char buff[100];
int main()
{
- char send_data[202]; //Xbee buffer size is 202 bytes
- char read_data[202]; //Xbee buffer size is 202 bytes
-
+
+ pc.printf("hahaha\r\n");
+
while(1) {
- pc.scanf("%s",send_data); //Read data from serial console
- xbee1.SendData(send_data); //Send data to XBee
- xbee1.RecieveData(read_data,0); //Read data from the XBee
- pc.printf("You said:%s",read_data);
+
+ if(pc.readable())
+ {
+ pc.printf("ho\r\n");
+ input = pc.getc();
+
+ if(input=='a')
+ {
+ xbee.putc('a');
+ xbee.getc();
+ wait(0.1);
+ xbee.printf("+++");
+
+ xbee.getc();
+ xbee.getc();
+ xbee.getc();
+
+ xbee.printf("ATDB\r");
+ xbee.scanf("%s",buff);
+ pc.printf("%s",buff);
+ }
+ else if(input=='s')
+ {
+ xbee.putc('b');
+ xbee.getc();
+ wait(0.1);
+ xbee.printf("+++");
+
+ xbee.getc();
+ xbee.getc();
+ xbee.getc();
+
+ xbee.printf("ATDB\r");
+ xbee.scanf("%s",buff);
+ pc.printf("%s",buff);
+ }
+ else if(input=='d')
+ {
+ xbee.putc('c');
+ xbee.getc();
+ wait(0.1);
+ xbee.printf("+++");
+
+ xbee.getc();
+ xbee.getc();
+ xbee.getc();
+
+ xbee.printf("ATDB\r");
+ xbee.scanf("%s",buff);
+ pc.printf("%s",buff);
+ }
+ else if(input=='f')
+ {
+ xbee.putc('d');
+ xbee.getc();
+ wait(0.1);
+ xbee.printf("+++");
+
+ xbee.getc();
+ xbee.getc();
+ xbee.getc();
+
+ xbee.printf("ATDB\r");
+ xbee.scanf("%s",buff);
+ pc.printf("%s",buff);
+ }
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Sat Nov 11 18:55:21 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a
--- a/mbed.bld Fri Nov 03 00:06:52 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc \ No newline at end of file
--- a/xbee_lib.lib Fri Nov 03 00:06:52 2017 +0000 +++ b/xbee_lib.lib Sat Nov 11 18:55:21 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/tristanjph/code/xbee_lib/#ede20c047d8b +http://mbed.org/users/tristanjph/code/xbee_lib/#6455a079bdb3
