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 BME280 SI1145
Diff: main.cpp
- Revision:
- 0:4354437a1033
- Child:
- 1:423c669d0306
diff -r 000000000000 -r 4354437a1033 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Jun 27 22:31:32 2017 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include <string>
+
+#define node_id (0x01)
+#define gateway_id (0xAA)
+#define tx (PA_9)
+#define rx (PA_10)
+
+Serial xb(tx, rx);
+Serial pc(D1, D0);
+
+//string node_id = "01";
+//string gateway_id = "AA"
+
+// function declarations
+void read_data(char* message);
+
+/*
+void readString(std::string& result, std::size_t& size) {
+ results.clear();
+ char data_in;
+ while(xb.readable()){
+ result.append(xb.getc());
+
+ }
+}
+*/
+int main() {
+ pc.printf("echo!!\n");
+ // initialize read data chars
+ char pc_data = 'e';
+
+ char buffer[128];
+ char message[16];
+
+ while(true){
+ if(pc.readable()){
+ pc_data = pc.getc();
+ pc.printf("%c", pc_data);
+ xb.printf("%c", pc_data);
+ }
+
+ if(xb.readable()){
+ xb.gets(buffer, 4);
+ pc.printf("%s", buffer);
+
+ }
+ }
+}
+
+void read_data(char* message){
+ int i = 0;
+
+ while(xb.readable()){
+ message[i] = xb.getc();
+ pc.printf("%c", message[i]);
+ wait(0.1);
+ }
+
+ pc.printf("%s", message);
+}
\ No newline at end of file