36using miosix::FastMutex;
38#ifndef USE_MOCK_PERIPHERALS
41#include <utils/TestUtils/MockGpioPin.h>
42using GpioType = Boardcore::MockGpioPin;
52static constexpr unsigned int FRAME_POLL_INTERVAL = 10;
53static constexpr unsigned int DEFAULT_TX_TIMEOUT = 5000;
56static constexpr unsigned int RX_FRAMES_BUF_SIZE = 3;
73 long long txTimeout = DEFAULT_TX_TIMEOUT);
87 GpioType rst,
long long txTimeout = DEFAULT_TX_TIMEOUT);
102 bool send(uint8_t* pkt,
size_t packetLength)
override;
111 ssize_t
receive(uint8_t* buf,
size_t bufferMaxSize)
override;
142 void sendATCommand(
const char* cmd, uint8_t* params =
nullptr,
143 size_t paramsLength = 0);
157 uint8_t* params =
nullptr,
size_t paramsLength = 0,
158 unsigned int timeout = 1000);
183 uint8_t sendATCommandInternal(
const char* cmd, uint8_t* params =
nullptr,
184 size_t paramsLength = 0);
191 uint8_t sendATCommandInternal(uint8_t frameId,
const char* cmd,
192 uint8_t* params =
nullptr,
193 size_t paramsLength = 0);
196 size_t packetLength);
201 size_t fillReceiveBuf(uint8_t* buf,
size_t bufferMaxSize);
229 uint8_t getNewFrameID();
245 bool waitForFrame(uint8_t frameType,
unsigned int pollInterval,
246 long long timeoutTick);
250 FastMutex mutexXbeeCommunication;
260 FastMutex mutexRxFrames;
265 int currRxPayloadPointer = -1;
278 uint8_t frameIdCounter = 1;
281 bool forceRcvReturn =
false;
285 Stats timeToSendStats;
288 miosix::Thread* receiveThread = 0;
static PrintLogger getLogger(const string &name)
Interface for low level access of a SPI bus as a master.
Computes on-line statistics of a dataset.
Parses a byte sequence into an Xbee APIFrame.
ParseResult
Result of the last parse operation.
void wakeReceiver(bool forceReturn=false)
Wakes the receive function without needing an interrupt.
void setOnFrameReceivedListener(OnFrameReceivedListener listener)
Set the frame received listener, called each time a new APIFrame is received from the device.
ssize_t receive(uint8_t *buf, size_t bufferMaxSize) override
Waits until a new packet is received.
void handleATTNInterrupt()
Signals the receive() function that there is new data available. Call this from the ATTN pin interrup...
std::function< void(APIFrame &frame)> OnFrameReceivedListener
void reset()
Hardware resets the Xbee.
void sendATCommand(const char *cmd, uint8_t *params=nullptr, size_t paramsLength=0)
Sends an AT Command to the Xbee (see datasheet) without waiting for a response.
bool send(uint8_t *pkt, size_t packetLength) override
Sends a packet. The function blocks until the packet is sent to the peripheral, but does not wait for...
Driver for the VN100S IMU.
SPI Bus configuration for a specific slave.
Contains information about a single SPI slave device.