PL1167_nRF24.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. class PL1167_nRF24 : public AbstractPL1167 {
  15. public:
  16. PL1167_nRF24(RF24 &radio);
  17. int open();
  18. int setPreambleLength(uint8_t preambleLength);
  19. int setSyncword(uint16_t syncword0, uint16_t syncword3);
  20. int setTrailerLength(uint8_t trailerLength);
  21. int setCRC(bool crc);
  22. int setMaxPacketLength(uint8_t maxPacketLength);
  23. int writeFIFO(const uint8_t data[], size_t data_length);
  24. int transmit(uint8_t channel);
  25. int receive(uint8_t channel);
  26. int readFIFO(uint8_t data[], size_t &data_length);
  27. private:
  28. RF24 &_radio;
  29. bool _crc;
  30. uint8_t _preambleLength = 1;
  31. uint16_t _syncword0 = 0, _syncword3 = 0;
  32. uint8_t _syncwordLength = 4;
  33. uint8_t _trailerLength = 4;
  34. uint8_t _maxPacketLength = 8;
  35. uint8_t _channel = 0;
  36. uint8_t _nrf_pipe[5];
  37. uint8_t _nrf_pipe_length;
  38. uint8_t _packet_length = 0;
  39. uint8_t _receive_length = 0;
  40. uint8_t _preamble = 0;
  41. uint8_t _packet[32];
  42. bool _received = false;
  43. int recalc_parameters();
  44. int internal_receive();
  45. };
  46. #endif /* PL1167_NRF24_H_ */