receive function provided by ese350
Revision 0:4bfdf497f75e, committed 2016-03-28
- Comitter:
- ivo_david_michelle
- Date:
- Mon Mar 28 21:02:57 2016 +0000
- Commit message:
- merging trees
Changed in this revision
receiver.cpp | Show annotated file Show diff for this revision Revisions of this file |
receiver.h | Show annotated file Show diff for this revision Revisions of this file |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/receiver.h Mon Mar 28 21:02:57 2016 +0000 @@ -0,0 +1,8 @@ +/** +* 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); \ No newline at end of file