NRF24MiLightRadio.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifdef ARDUINO
  2. #include "Arduino.h"
  3. #else
  4. #include <stdint.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #endif
  8. #include <RF24.h>
  9. #include <PL1167_nRF24.h>
  10. #include <MiLightRadioConfig.h>
  11. #include <MiLightRadio.h>
  12. #include <RF24Channel.h>
  13. #include <vector>
  14. #ifndef _NRF24_MILIGHT_RADIO_H_
  15. #define _NRF24_MILIGHT_RADIO_H_
  16. class NRF24MiLightRadio : public MiLightRadio {
  17. public:
  18. NRF24MiLightRadio(
  19. RF24& rf,
  20. const MiLightRadioConfig& config,
  21. const std::vector<RF24Channel>& channels,
  22. RF24Channel listenChannel
  23. );
  24. int begin();
  25. bool available();
  26. int read(uint8_t frame[], size_t &frame_length);
  27. int dupesReceived();
  28. int write(uint8_t frame[], size_t frame_length);
  29. int resend();
  30. int configure();
  31. const MiLightRadioConfig& config();
  32. private:
  33. const std::vector<RF24Channel>& channels;
  34. const size_t listenChannelIx;
  35. PL1167_nRF24 _pl1167;
  36. const MiLightRadioConfig& _config;
  37. uint32_t _prev_packet_id;
  38. uint8_t _packet[10];
  39. uint8_t _out_packet[10];
  40. bool _waiting;
  41. int _dupes_received;
  42. };
  43. #endif