MeshNet  1.0.0
RFInterface.h
Go to the documentation of this file.
1 
13 #ifndef DEFAULTRF_INTERFACE_H_
14 #define DEFAULTRF_INTERFACE_H_
15 
16 #include "meshFrame.h"
17 
22 typedef enum{
24  RFI_NONE = 0,
27  //... TODO add other interface types if needed
28 }RFIType;
29 
49 public:
50 
68  RFInterface(const uint8_t maxFrameLength, const RFIType interfaceType, const bool canCheckInterference, const uint8_t maxChannelNumber, const uint8_t minChannelNumber, const uint8_t maxPowerValue, const uint8_t minPowerValue, const bool canSetSpeed, const uint32_t baseFrequency, ThreadLock *_lock);
69 
70  virtual ~RFInterface() = 0;
71 
77  virtual bool init() = 0;
78 
84  virtual bool deInit() = 0;
85 
91  virtual bool hasError() = 0;
92 
101  virtual bool send(uint8_t* data, uint8_t dataSize) = 0;
102 
112  virtual bool recv(uint8_t* data, uint8_t& dataSize, int8_t& rssi) = 0;
113 
119  virtual uint8_t available() = 0;
120 
126  virtual bool sleep() = 0;
127 
133  virtual bool wakeUp() = 0;
134 
141  virtual bool checkInterference() = 0;
142 
149  virtual bool setChannel(uint8_t channel) = 0;
150 
156  virtual bool setPower(uint8_t power) = 0;
157 
164  virtual bool setFullSpeed(bool enableFullSpeed) = 0;
165 
172  virtual bool setReceiveInterruptCallback(void(*InterruptCallback)(void)) = 0;
173 
180  virtual bool interruptHandle() = 0;
181 
186  virtual void handle() = 0;
187 
194  virtual void printDetails(OSTREAM *stream) = 0;
195 
209  virtual uint8_t scanChannels(uint8_t startChannel, uint8_t endChannel, uint8_t retries = 50, OSTREAM *stream = NULL) = 0;
210 
227  virtual uint8_t scanChannels(uint8_t startChannel, uint8_t endChannel, OSTREAM *stream = NULL) = 0;
228 
233  virtual bool scanChannelsWorking() = 0;
234 
239  virtual uint32_t getChannelsWidth() = 0;
240 
241 #ifndef RF_NO_INTERNAL_TMP_BUFFER
242 
246  virtual uint8_t* getInternalTemporaryBuffer() = 0;
247 #endif
248 
249 
252  const uint8_t MaxFrameLength;
253 
258 
262  const bool CanCheckInterference:1;
263 
267  const uint8_t MaxChannelNumber;
268 
272  const uint8_t MinChannelNumber;
273 
277  const uint8_t MaxPowerValue;
278 
282  const uint8_t MinPowerValue;
283 
287  const bool CanSetSpeed:1;
288 
292  const uint32_t BaseFrequency;
293 
297  ThreadLock* lock;
298 
299 
300 
301 #ifdef SIMULATION
302  virtual uint32_t millis() = 0;
303  virtual uint32_t micros() = 0;
304  virtual uint64_t micros64() = 0;
305  virtual void delay(uint32_t time) = 0;
306  virtual void delayMicroseconds(uint32_t time) = 0;
307  virtual std::chrono::nanoseconds PauseSimulationTimer() = 0;
308  virtual void ResumeSimulationTimer() = 0;
309  virtual std::mutex& GetStreamMutex() = 0;
310  virtual std::mutex& GetMutex() = 0;
311  virtual bool isLogOnly() = 0;
312  virtual void logTableChange(std::string& descriptor, TableChangeType changeType, const char* data) = 0;
313  virtual void OnScanResponse(const MeshNetScanResult& result) = 0;
314 #endif // SIMULATION
315 
316 };
317 
318 
319 #endif /* DEFAULTRF_INTERFACE_H_ */
RFInterface::hasError
virtual bool hasError()=0
Override this method to check if radio has some error or is not connected to MCU. If this method retu...
MeshNetScanResult
Structure, which holds network scan result.
Definition: meshPacketFlags.h:452
RFInterface::getInternalTemporaryBuffer
virtual uint8_t * getInternalTemporaryBuffer()=0
Gets pointer to internal temporary buffer with size of MaxFrameLength. This buffer can be used for te...
RFInterface
Radio frequency interface, that helps to use meshNet with different radios or communication types....
Definition: RFInterface.h:48
RFInterface::BaseFrequency
const uint32_t BaseFrequency
Frequency of channel 0 in kHz.
Definition: RFInterface.h:292
RFInterface::interruptHandle
virtual bool interruptHandle()=0
This method has to be done, when ReceiveInterrupt happened.
RFInterface::getChannelsWidth
virtual uint32_t getChannelsWidth()=0
Gets width of each channels in kHz.
RFInterface::lock
ThreadLock * lock
Thread lock, that is used to lock current methods.
Definition: RFInterface.h:297
RFInterface::setReceiveInterruptCallback
virtual bool setReceiveInterruptCallback(void(*InterruptCallback)(void))=0
Override this method to set receive message interrupt method. If interrupt cannot be set or is not su...
RFInterface::MaxPowerValue
const uint8_t MaxPowerValue
Maximum power level value. When this value is equal or lower than MinPowerValue, radio output power c...
Definition: RFInterface.h:277
RFInterface::send
virtual bool send(uint8_t *data, uint8_t dataSize)=0
Override this method to send data through radio.
RFInterface::printDetails
virtual void printDetails(OSTREAM *stream)=0
This method is used to print radio details to stream (usually to Serial port). Method is also called,...
RFInterface::CanCheckInterference
const bool CanCheckInterference
True when interference can be checked.
Definition: RFInterface.h:262
RFIType
RFIType
Interface type. Each derivation of RFInterface class has it's own type.
Definition: RFInterface.h:22
RFInterface::MaxFrameLength
const uint8_t MaxFrameLength
RF_NO_INTERNAL_TMP_BUFFER.
Definition: RFInterface.h:252
RFInterface::RFInterface
RFInterface(const uint8_t maxFrameLength, const RFIType interfaceType, const bool canCheckInterference, const uint8_t maxChannelNumber, const uint8_t minChannelNumber, const uint8_t maxPowerValue, const uint8_t minPowerValue, const bool canSetSpeed, const uint32_t baseFrequency, ThreadLock *_lock)
Constructor - has to be overridden and parameters have to be set in overridden constructor.
Definition: RFInterface.cpp:4
RFInterface::MinChannelNumber
const uint8_t MinChannelNumber
Minimum channel number. When this value is equal or higher than MaxChannelNumber, radio channel canno...
Definition: RFInterface.h:272
RFInterface::setPower
virtual bool setPower(uint8_t power)=0
Override this method to set radio output power. If radio output power cannot be set,...
RFInterface::checkInterference
virtual bool checkInterference()=0
Override this method to check, if there is currently an interference in the air. If interference chec...
RFInterface::deInit
virtual bool deInit()=0
Override this method to de-initialize radio and communication with it.
RFInterface::setChannel
virtual bool setChannel(uint8_t channel)=0
Override this method to set radio channel. If channels cannot be set on selected radio,...
RFInterface::MinPowerValue
const uint8_t MinPowerValue
Minimum power level value. When this value is equal or higher than MaxPowerValue, radio output power ...
Definition: RFInterface.h:282
OSTREAM
#define OSTREAM
Definition: meshConfig.h:41
RFInterface::scanChannelsWorking
virtual bool scanChannelsWorking()=0
Checks if channel scan is processed now.
RFInterface::recv
virtual bool recv(uint8_t *data, uint8_t &dataSize, int8_t &rssi)=0
Override this method to read data from radio buffer.
RFInterface::sleep
virtual bool sleep()=0
Override this method to temporary power off the radio. If the radio cannot sleep, just return true.
RFInterface::~RFInterface
virtual ~RFInterface()=0
Definition: RFInterface.cpp:19
RFInterface::handle
virtual void handle()=0
This method is included in meshNet::handle() method and it is included in main loop.
RFI_NONE
@ RFI_NONE
Definition: RFInterface.h:24
RFInterface::MaxChannelNumber
const uint8_t MaxChannelNumber
Maximum channel number. When this value is equal or lower than MinChannelNumber, radio channel cannot...
Definition: RFInterface.h:267
RFInterface::CanSetSpeed
const bool CanSetSpeed
True when speed (data rate) can be set.
Definition: RFInterface.h:287
RFInterface::init
virtual bool init()=0
Override this method to initialize radio and communication with it.
RFI_NRF24L01
@ RFI_NRF24L01
Definition: RFInterface.h:26
RFInterface::setFullSpeed
virtual bool setFullSpeed(bool enableFullSpeed)=0
Override this method to set full or slow speed (data rate). If speed cannot be set,...
RFInterface::InterfaceType
const RFIType InterfaceType
Interface type, see RFIType.
Definition: RFInterface.h:257
RFInterface::scanChannels
virtual uint8_t scanChannels(uint8_t startChannel, uint8_t endChannel, uint8_t retries=50, OSTREAM *stream=NULL)=0
This method has to scan all free channels and returns channel with minimum interferences....
RFInterface::wakeUp
virtual bool wakeUp()=0
Override this method to temporary power on (wake up) the radio from sleep. If the radio cannot sleep,...
meshFrame.h
This file contains classes and structures which can be used to handling mesh frames.
RFInterface::available
virtual uint8_t available()=0
Override this method to get raw size of received frame in bytes.