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
main.cpp
- Committer:
- jonathanyost
- Date:
- 2017-06-27
- Revision:
- 0:4354437a1033
- Child:
- 1:423c669d0306
File content as of revision 0:4354437a1033:
#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);
}