MeshNet  1.0.0
Simulation_interface.h
Go to the documentation of this file.
1 /*
2  * Sulation_interface.h
3  *
4  * Created on: 11. 8. 2021
5  * Author: ASUS
6  */
7 
8 #ifdef SIMULATION
9 
10 #ifndef SIMULATION_INTERFACE_H_
11 #define SIMULATION_INTERFACE_H_
12 
13 #include <RFInterface.h>
14 
15 //This file have to be modified by user
16 
17 class NodeSimulator;
18 
19 
20 class Simulation_RFI: public RFInterface{
21 public:
22 
23  Simulation_RFI(const uint8_t maxMessageLength);
24 
25  ~Simulation_RFI() override;
26 
27  bool init() override;
28 
29  bool deInit() override;
30 
31  bool hasError() override;
32 
33  bool send(uint8_t* data, uint8_t dataSize) override;
34 
35  bool recv(uint8_t* data, uint8_t& dataSize, int8_t& rssi) override;
36 
37  uint8_t available() override;
38 
39  bool sleep() override;
40 
41  bool wakeUp() override;
42 
43  bool checkInterference() override;
44 
45  bool setChannel(uint8_t channel) override;
46 
47  bool setPower(uint8_t power) override;
48 
49  bool setFullSpeed(bool enableFullSpeed) override;
50 
51  bool setReceiveInterruptCallback(void(*InterruptCallback)(void)) override;
52 
53  bool interruptHandle() override;
54 
55  void handle() override;
56 
57  void printDetails(STREAM *stream) override;
58 
59  uint8_t scanChannels(uint8_t startChannel, uint8_t endChannel, uint8_t retries = 50, STREAM *stream = NULL) override;
60 
61  uint8_t scanChannels(uint8_t startChannel, uint8_t endChannel, STREAM *stream = NULL) override {
62  return scanChannels(startChannel, endChannel, 50, stream);
63  }
64 
65  bool scanChannelsWorking() override;
66 
67  uint32_t getChannelsWidth() override;
68 
69 #ifndef RF_NO_INTERNAL_TMP_BUFFER
70  uint8_t* getInternalTemporaryBuffer() override;
71  uint8_t internalTmpBuffer[32];
72 #endif
73 
74  //Never use this class without setting NodeSimulator
75  NodeSimulator* ni = NULL;
76 
77  uint32_t millis() override;
78  uint32_t micros() override;
79  uint64_t micros64() override;
80  void delay(uint32_t time) override;
81  void delayMicroseconds(uint32_t time) override;
82  std::chrono::nanoseconds PauseSimulationTimer() override;
83  void ResumeSimulationTimer() override;
84  std::mutex& GetStreamMutex() override;
85  std::mutex& GetMutex() override;
86  bool isLogOnly() override;
87  void logTableChange(std::string& descriptor, TableChangeType changeType, const char* data) override;
88  void OnScanResponse(const MeshNetScanResult& result) override;
89 
90 protected:
91  MeshMAC currentAddress = 0;
92 };
93 
94 
95 #endif /* NRF24L01_INTERFACE_H_ */
96 
97 #endif // SIMULATION
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.h
This file contains interface (pattern) class, that has to be overridden to create driver for radio wh...
RFInterface
Radio frequency interface, that helps to use meshNet with different radios or communication types....
Definition: RFInterface.h:48
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::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::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::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::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.
MeshMAC
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
RFInterface::handle
virtual void handle()=0
This method is included in meshNet::handle() method and it is included in main loop.
RFInterface::init
virtual bool init()=0
Override this method to initialize radio and communication with it.
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::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,...
RFInterface::available
virtual uint8_t available()=0
Override this method to get raw size of received frame in bytes.