E45_TTL_100, Lora transceiver, tested on KL25Z connection with E45 via RS232. Power 100 mW, 868 MHz, range 2 km
Revision 4:1249c317e7f3, committed 2018-02-18
- Comitter:
- GerritPathuis
- Date:
- Sun Feb 18 13:33:50 2018 +0000
- Parent:
- 3:19a244789b2b
- Child:
- 5:3b737b1cedf5
- Commit message:
- Number bounces between Radio's and is increased each time it is transmitted
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Feb 17 16:24:58 2018 +0000
+++ b/main.cpp Sun Feb 18 13:33:50 2018 +0000
@@ -1,5 +1,8 @@
#include "mbed.h"
#include "MODSERIAL.h"
+#include <string>
+#include <ctype.h>
+
// E45-TTL-100 RADIO------KL25Z
// AUX--------------------PTD4
@@ -19,6 +22,7 @@
DigitalOut m0(PTA4, PullUp); // M0 the E45 radio
DigitalOut myled(LED_BLUE); // KL25x BLUE led
+int ping=1; // this number bounces between radios and is incremented
void flank_up()
{
@@ -34,18 +38,22 @@
{
if (myled == 1) { // AUX is high (Buffer empty), send something
wait_ms(3);
- e45.puts("123");
+
+ ping++; // Increase the value
+ e45.printf("%04d\n\r", ping);
while(myled==0) {
pc.puts("Wait for end Transmission\n\r");
wait_ms(1);
}
- pc.puts("\n\rRadio has sent 123\n\r");
+ pc.printf("\n\rRadio has sent %04d\n\r", ping);
}
}
int main()
{
int count=0;
+ string incoming;
+ char c;
pc.baud(115200);
e45.baud(9600); // Default for E45
@@ -60,7 +68,7 @@
if (myled ==1) { //Check ready or not
while(myled==0) { //Wait when not yet ready
count++;
- if (count > 2000000) {
+ if (count > 2000000) { //Kill time
count=0;
pc.puts("Wait for AUX Rising edge ");
}
@@ -75,13 +83,24 @@
timer.attach(&timer_func, 3.0);
while(1) {
- if (myled == 0) { // AUX is low, Chars received
+ if (ping>9999) ping=1;
+
+ if (myled == 0) { // AUX is low, Chars received
+ //incoming= ""; // Clear the string
while(myled==0) {
if (e45.readable()) {
- pc.putc(e45.getc()); //send to pc
+ c=e45.getc();
+ if (isdigit(c))
+ incoming += c;
+ //pc.putc(c); //send to pc
+ } else { // End transmission
+ if (incoming.length()==4) {
+ ping= atoi(incoming.c_str());
+ pc.printf("incoming value %4d \n\r", ping);
+ incoming= ""; // Clear the string
+ }
}
}
}
}
}
-