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.
Diff: receiver.cpp
- Revision:
- 0:4bfdf497f75e
diff -r 000000000000 -r 4bfdf497f75e receiver.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/receiver.cpp Mon Mar 28 21:02:57 2016 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "MRF24J40.h"
+
+/**
+* Receive data from the MRF24J40.
+*
+* @param mrf, RF tranceiver to link with
+* @param data A pointer to a char array to hold the data
+* @param maxLength The max amount of data to read.
+*/
+int rf_receive_rssi(MRF24J40 mrf, char *data, uint8_t *rssi, uint8_t maxLength) {
+ uint8_t len = mrf.Receive_RSSI((uint8_t *)data, rssi, maxLength);
+ uint8_t header[8]= {1, 8, 0, 0xA1, 0xB2, 0xC3, 0xD4, 0x00};
+
+ if(len > 10) {
+ //Remove the header and footer of the message
+ for(uint8_t i = 0; i < len-2; i++) {
+ if(i<8) {
+ //Make sure our header is valid first
+ if(data[i] != header[i])
+ return 0;
+ } else {
+ data[i-8] = data[i];
+ }
+ }
+ //pc.printf("Received: %s length:%d\r\n", data, ((int)len)-10);
+ }
+ return ((int)len)-10;
+}
\ No newline at end of file