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.
Dependencies: mbed
Revision 0:534ef231f03a, committed 2020-04-26
- Comitter:
- saeichi
- Date:
- Sun Apr 26 08:14:19 2020 +0000
- Commit message:
- nucleo_sample_Xbee_send-and-receive
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Apr 26 08:14:19 2020 +0000
@@ -0,0 +1,58 @@
+/**
+ * @file main.cpp
+ * @brief 新入生教育用Xbee送受信プログラム
+ *
+ * <table><tr><th> 送信(PC->mbed) </th><th> 受信(mbed->PC) </th></tr>
+ * <tr><th> 's' or 'S' </th><th> "Mission Start" </th></tr>
+ * <tr><th> 't' or 'T' </th><th> 任意の文字列 (注1)</th></tr>
+ * <tr><th> 'c' or 'C' </th><th> "Mission complete" </th></tr>
+ * </table>
+ *
+ * (注1) 't' または 'T' を入力した後,任意の文字列を入力しエンターキーを押すと,その文字列がmbedからPCに送信される.
+ *
+ * @author Shuhei Kayawari
+ * @date 2018/06/13
+ *
+ */
+
+#include "mbed.h"
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+Serial xbee(PA_9, PA_10);
+
+int main()
+{
+ pc.printf("XBee Start\r\n");
+ xbee.printf("XBee Connected\r\n");
+
+ while(1) {
+ pc.printf("Waiting for data...\r\n");
+
+ int received_data = xbee.getc();
+
+ pc.printf("Received Data: %c\r\n", received_data);
+
+ if(received_data == 83 || received_data == 115) { //S or s
+ xbee.printf("%c\r\n", received_data);
+ xbee.printf("Mission Start\r\n");
+ } else if(received_data == 84 || received_data == 116) { //T or t
+ xbee.printf("%c\r\n", received_data);
+
+ char str[1024] = {};
+ int i = 0;
+
+ do
+ str[i++] = xbee.getc();
+ while(str[i-1] != 0x0d);
+
+ xbee.printf("%s\r\n", str);
+ }
+ else if(received_data == 67 || received_data == 99) { //C or c
+ xbee.printf("%c\r\n", received_data);
+ xbee.printf("Mission Complete\r\n");
+ }
+ }
+
+ return 0;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Apr 26 08:14:19 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file