This is an example program that shows how to use the RadioHeadLite library, and does it using threads.

Dependencies:   RadioHeadLite

Files at this revision

API Documentation at this revision

Comitter:
rlanders73
Date:
Tue Jun 22 16:51:01 2021 +0000
Parent:
5:75659bdf6605
Commit message:
Added RSSI of recieved messge

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 75659bdf6605 -r 3174bb53265a main.cpp
--- a/main.cpp	Tue Jun 22 16:38:09 2021 +0000
+++ b/main.cpp	Tue Jun 22 16:51:01 2021 +0000
@@ -108,9 +108,11 @@
         if(radio.available()){
             size = sizeof(rxBuf);
             if(radio.recv(rxBuf,&size))
-//                printf("Got: %s\n", rxBuf);
-                USB.send(rxBuf, size);
-                USB.putc('\n'); // put a new line in just in case
+                rxBuf[size] = 0; // make sure to null terminate the string
+                printf("Got: %s", rxBuf);
+                if(rxBuf[size-1]!= '\n')
+                    USB.putc('\n'); // put a new line in just in case
+                printf("RSSI: %d\n",radio.lastRssi());
         }
     }
 }