RadioStack.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <RF24.h>
  2. #include <PL1167_nRF24.h>
  3. #include <MiLightRadioConfig.h>
  4. #include <MiLightRadio.h>
  5. #include <MiLightRadioPL1167_LT8900.h>
  6. #include <MiLightRadioInterface.h>
  7. #include <Settings.h>
  8. #ifndef _RADIO_STACK_H
  9. #define _RADIO_STACK_H
  10. class RadioStack {
  11. public:
  12. RadioStack(RF24& rf, const MiLightRadioConfig& config)
  13. : config(config),UsedInterfaceType(nRF24)
  14. {
  15. nrf = new PL1167_nRF24(rf);
  16. radio = new MiLightRadio(*nrf, config);
  17. }
  18. RadioStack(byte byCSPin, byte byResetPin, byte byPktFlag, const MiLightRadioConfig& config)
  19. : config(config),UsedInterfaceType(PL1167_LT8900)
  20. {
  21. radioPL1167_LT8900 = new MiLightRadioPL1167_LT8900(byCSPin, byResetPin, byPktFlag, config);
  22. }
  23. ~RadioStack() {
  24. delete radio;
  25. delete nrf;
  26. delete radioPL1167_LT8900;
  27. }
  28. inline MiLightRadioInterface* getRadioInterface()
  29. {
  30. if(UsedInterfaceType == nRF24)
  31. {
  32. return this->radio;
  33. }
  34. else if(UsedInterfaceType == PL1167_LT8900)
  35. {
  36. return this->radioPL1167_LT8900;
  37. }
  38. }
  39. const MiLightRadioConfig& config;
  40. private:
  41. PL1167_nRF24 *nrf;
  42. MiLightRadio *radio;
  43. MiLightRadioPL1167_LT8900 *radioPL1167_LT8900;
  44. eRadioInterfaceType UsedInterfaceType;
  45. };
  46. #endif