MiLightRadioFactory.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <RF24.h>
  2. #include <PL1167_nRF24.h>
  3. #include <MiLightRadioConfig.h>
  4. #include <MiLightRadio.h>
  5. #include <NRF24MiLightRadio.h>
  6. #include <LT8900MiLightRadio.h>
  7. #include <RF24PowerLevel.h>
  8. #include <RF24Channel.h>
  9. #include <Settings.h>
  10. #include <vector>
  11. #ifndef _MILIGHT_RADIO_FACTORY_H
  12. #define _MILIGHT_RADIO_FACTORY_H
  13. class MiLightRadioFactory {
  14. public:
  15. virtual MiLightRadio* create(const MiLightRadioConfig& config) = 0;
  16. static MiLightRadioFactory* fromSettings(const Settings& settings);
  17. };
  18. class NRF24Factory : public MiLightRadioFactory {
  19. public:
  20. NRF24Factory(
  21. uint8_t cePin,
  22. uint8_t csnPin,
  23. RF24PowerLevel rF24PowerLevel,
  24. const std::vector<RF24Channel>& channels,
  25. RF24Channel listenChannel
  26. );
  27. virtual MiLightRadio* create(const MiLightRadioConfig& config);
  28. protected:
  29. RF24 rf24;
  30. const std::vector<RF24Channel>& channels;
  31. const RF24Channel listenChannel;
  32. };
  33. class LT8900Factory : public MiLightRadioFactory {
  34. public:
  35. LT8900Factory(uint8_t csPin, uint8_t resetPin, uint8_t pktFlag);
  36. virtual MiLightRadio* create(const MiLightRadioConfig& config);
  37. protected:
  38. uint8_t _csPin;
  39. uint8_t _resetPin;
  40. uint8_t _pktFlag;
  41. };
  42. #endif