PL1167_nRF24.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "RF24.h"
  11. // #define DEBUG_PRINTF
  12. #ifndef PL1167_NRF24_H_
  13. #define PL1167_NRF24_H_
  14. class PL1167_nRF24 {
  15. public:
  16. PL1167_nRF24(RF24& radio);
  17. int open();
  18. int setSyncword(const uint8_t syncword[], size_t syncwordLength);
  19. int setMaxPacketLength(uint8_t maxPacketLength);
  20. int writeFIFO(const uint8_t data[], size_t data_length);
  21. int transmit(uint8_t channel);
  22. int receive(uint8_t channel);
  23. int readFIFO(uint8_t data[], size_t &data_length);
  24. private:
  25. RF24 &_radio;
  26. const uint8_t* _syncwordBytes = nullptr;
  27. uint8_t _syncwordLength = 4;
  28. uint8_t _maxPacketLength = 8;
  29. uint8_t _channel = 0;
  30. uint8_t _nrf_pipe[5];
  31. uint8_t _nrf_pipe_length;
  32. uint8_t _packet_length = 0;
  33. uint8_t _receive_length = 0;
  34. uint8_t _preamble = 0;
  35. uint8_t _packet[32];
  36. bool _received = false;
  37. int recalc_parameters();
  38. int internal_receive();
  39. };
  40. #endif /* PL1167_NRF24_H_ */