Library for handling subset of coap functionality by radio transmitter.
Dependencies: nRF24L01P cantcoap
Diff: radioWrapper.cpp
- Revision:
- 1:1d936c763440
- Parent:
- 0:6a6f97ca5572
- Child:
- 2:c3ca8b8526e0
--- a/radioWrapper.cpp Fri Jan 18 14:12:24 2019 +0000 +++ b/radioWrapper.cpp Sun Jan 20 13:48:02 2019 +0000 @@ -1,11 +1,11 @@ #include "radioWrapper.h" #include "mbed.h" -int RadioWrapper::read(uin8_t* buffer, int len, int timeout) { +int RadioWrapper::read(uint8_t* buffer, int len, int timeout) { Timer t; - t.start() + t.start(); // check if buffor is large enough to conaint packet. - if (len < TRANSFER_SIZE) { + if (len < packetSize()) { return -1; } int ret = radio.read(NRF24L01P_PIPE_P0, (char*) buffer, packetSize()); @@ -13,19 +13,21 @@ wait_ms(10); ret = radio.read(NRF24L01P_PIPE_P0, (char*) buffer, packetSize()); } + t.stop(); return ret; } -int RadioWrapper::write(uin8_t* buffer, int len) { +int RadioWrapper::write(uint8_t* buffer, int len) { // check if buffor is small enough to send in one package - if (len > TRANSFER_SIZE) { + if (len > packetSize()) { return -1; } int ret = radio.write(NRF24L01P_PIPE_P0, (char*) buffer, packetSize()); return ret; } -RadioWrapper::RadioWrapper(int channel, unsigned long long rx_address, unsigned long long tx_address) { +RadioWrapper::RadioWrapper(int channel, unsigned long long rx_address, unsigned long long tx_address) : +radio(PB_15, PB_14, PB_13, PB_12, PB_1, PB_2) { radio.powerDown(); radio.powerUp();