PL1167_nRF24.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * PL1167_nRF24.h
  3. *
  4. * Created on: 29 May 2015
  5. * Author: henryk
  6. */
  7. #ifdef ARDUINO
  8. #include "Arduino.h"
  9. #endif
  10. #include "AbstractPL1167.h"
  11. #include "RF24.h"
  12. #ifndef PL1167_NRF24_H_
  13. #define PL1167_NRF24_H_
  14. #define DEBUG_PRINTF
  15. class PL1167_nRF24 : public AbstractPL1167 {
  16. public:
  17. PL1167_nRF24(RF24 &radio);
  18. int open();
  19. int setPreambleLength(uint8_t preambleLength);
  20. int setSyncword(uint16_t syncword0, uint16_t syncword3);
  21. int setTrailerLength(uint8_t trailerLength);
  22. int setCRC(bool crc);
  23. int setMaxPacketLength(uint8_t maxPacketLength);
  24. int writeFIFO(const uint8_t data[], size_t data_length);
  25. int transmit(uint8_t channel);
  26. int receive(uint8_t channel);
  27. int readFIFO(uint8_t data[], size_t &data_length);
  28. private:
  29. RF24 &_radio;
  30. bool _crc;
  31. uint8_t _preambleLength = 1;
  32. uint16_t _syncword0 = 0, _syncword3 = 0;
  33. uint8_t _syncwordLength = 4;
  34. uint8_t _trailerLength = 4;
  35. uint8_t _maxPacketLength = 8;
  36. uint8_t _channel = 0;
  37. uint8_t _nrf_pipe[5];
  38. uint8_t _nrf_pipe_length;
  39. uint8_t _packet_length = 0;
  40. uint8_t _receive_length = 0;
  41. uint8_t _preamble = 0;
  42. uint8_t _packet[32];
  43. bool _received = false;
  44. int recalc_parameters();
  45. int internal_receive();
  46. };
  47. #endif /* PL1167_NRF24_H_ */