Library for handling subset of coap functionality by radio transmitter.
Dependencies: nRF24L01P cantcoap
radioWrapper.h@1:1d936c763440, 2019-01-20 (annotated)
- Committer:
- Ka_myk
- Date:
- Sun Jan 20 13:48:02 2019 +0000
- Revision:
- 1:1d936c763440
- Parent:
- 0:6a6f97ca5572
- Child:
- 2:c3ca8b8526e0
try to make it work;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ka_myk | 0:6a6f97ca5572 | 1 | #pragma once |
Ka_myk | 0:6a6f97ca5572 | 2 | |
Ka_myk | 0:6a6f97ca5572 | 3 | #include "nRF24L01P.h" |
Ka_myk | 0:6a6f97ca5572 | 4 | |
Ka_myk | 0:6a6f97ca5572 | 5 | //***************************************************************************// |
Ka_myk | 0:6a6f97ca5572 | 6 | // !!! SETTINGS !!! |
Ka_myk | 0:6a6f97ca5572 | 7 | #define DATA_RATE NRF24L01P_DATARATE_1_MBPS |
Ka_myk | 0:6a6f97ca5572 | 8 | |
Ka_myk | 0:6a6f97ca5572 | 9 | #define POWER NRF24L01P_TX_PWR_ZERO_DB |
Ka_myk | 0:6a6f97ca5572 | 10 | |
Ka_myk | 0:6a6f97ca5572 | 11 | //***************************************************************************// |
Ka_myk | 0:6a6f97ca5572 | 12 | |
Ka_myk | 0:6a6f97ca5572 | 13 | class RadioWrapper { |
Ka_myk | 0:6a6f97ca5572 | 14 | private: |
Ka_myk | 1:1d936c763440 | 15 | nRF24L01P radio; // mosi, miso, sck, csn, ce, irq |
Ka_myk | 0:6a6f97ca5572 | 16 | |
Ka_myk | 0:6a6f97ca5572 | 17 | public: |
Ka_myk | 0:6a6f97ca5572 | 18 | RadioWrapper(int channel, unsigned long long rx_address, unsigned long long tx_address); |
Ka_myk | 0:6a6f97ca5572 | 19 | |
Ka_myk | 0:6a6f97ca5572 | 20 | int packetSize() { |
Ka_myk | 0:6a6f97ca5572 | 21 | return 32; |
Ka_myk | 0:6a6f97ca5572 | 22 | } |
Ka_myk | 0:6a6f97ca5572 | 23 | |
Ka_myk | 0:6a6f97ca5572 | 24 | /*a |
Ka_myk | 0:6a6f97ca5572 | 25 | read bytes and saves them to given buffer turncating it. |
Ka_myk | 0:6a6f97ca5572 | 26 | @len |
Ka_myk | 0:6a6f97ca5572 | 27 | @return number of read bytes, -1 if error |
Ka_myk | 0:6a6f97ca5572 | 28 | */ |
Ka_myk | 0:6a6f97ca5572 | 29 | int read(uint8_t* buffer, int len, int timeout); |
Ka_myk | 0:6a6f97ca5572 | 30 | /* |
Ka_myk | 0:6a6f97ca5572 | 31 | send bytes from given buffor |
Ka_myk | 0:6a6f97ca5572 | 32 | @return number of writeen bytes, -1 if error. |
Ka_myk | 0:6a6f97ca5572 | 33 | */ |
Ka_myk | 0:6a6f97ca5572 | 34 | int write(uint8_t* buffer, int len); |
Ka_myk | 1:1d936c763440 | 35 | }; |