22#include "ArduinoLogger.h"
23#include "GPIOWrapper.h"
24#include "I2CWrapper.h"
25#include "RemoteGPIO.h"
28#include "SPIWrapper.h"
80 Logger.warning(
"GPIO, I2C, SPI set up for Remote");
89 return i2c && spi && gpio;
101 if (p_stream ==
nullptr) {
102 default_stream.
begin(port);
103 handShake(&default_stream);
105 int remote_port = default_stream.
remotePort();
108 default_stream.flush();
116 if (is_default_objects_active) {
121 if (p_stream == &default_stream) {
122 default_stream.stop();
126 HardwareGPIO* getGPIO() {
return &gpio; }
127 HardwareI2C* getI2C() {
return &i2c; }
128 HardwareSPI* getSPI() {
return &spi; }
132 Stream* p_stream =
nullptr;
137 bool is_default_objects_active =
false;
139 void handShake(Stream* s) {
141 Logger.warning(
"HardwareSetup",
"waiting for device...");
144 if (s->available() >= 16) {
148 if (strncmp(buffer,
"Arduino-Emulator", 16)==0) {
149 Logger.info(
"UDPStream",
"device found!");
152 Logger.info(
"UDPStream",
"unknown command", buffer);
156 }
catch (
const std::exception& ex) {
157 Logger.error(
"UDPStream", ex.what());
163#if !defined(SKIP_HARDWARE_SETUP)
164static HardwareSetupRemote Remote{7000};
Abstract interface for providing GPIO hardware implementations.
Definition Sources.h:66
void setGPIO(HardwareGPIO *gpio)
Set the GPIO implementation directly.
Definition GPIOWrapper.h:153
Configures and manages remote hardware interfaces for Arduino emulation.
Definition HardwareSetupRemote.h:59
void begin(int port, bool asDefault)
start with udp on the indicatd port
Definition HardwareSetupRemote.h:93
HardwareSetupRemote()=default
default constructor: you need to call begin() afterwards
HardwareSetupRemote(Stream &stream)
HardwareSetup uses the indicated stream.
Definition HardwareSetupRemote.h:65
void begin(bool asDefault=true)
start with the default udp stream.
Definition HardwareSetupRemote.h:99
bool begin(Stream *s, bool asDefault=true, bool doHandShake=true)
assigns the different protocols to the stream
Definition HardwareSetupRemote.h:71
HardwareSetupRemote(int port)
HardwareSetup that uses udp.
Definition HardwareSetupRemote.h:68
Abstract interface for providing I2C hardware implementations.
Definition Sources.h:36
void setI2C(HardwareI2C *i2c)
defines the i2c implementation: use nullptr to reset.
Definition I2CWrapper.h:75
Definition IPAddress.h:43
Abstract interface for providing SPI hardware implementations.
Definition Sources.h:51
void setSPI(HardwareSPI *spi)
defines the spi implementation: use nullptr to reset.
Definition SPIWrapper.h:72
A UDP class which makes sure that we can use UDP as simple Stream w/o additional complexity....
Definition UDPStream.h:22
uint16_t remotePort()
We use the same remote port as defined in begin for write.
Definition UDPStream.h:75
size_t readBytes(uint8_t *data, size_t len)
Reads bytes using WiFi::readBytes.
Definition UDPStream.h:104
IPAddress remoteIP()
We use the same remote ip as defined in begin for write.
Definition UDPStream.h:81
size_t write(const uint8_t *data, size_t len) override
Replys will be sent to the initial remote caller.
Definition UDPStream.h:91
bool begin(IPAddress a, uint16_t port)
Starts to send data to the indicated address / port.
Definition UDPStream.h:53
bool setTarget(IPAddress a, uint16_t port)
Alternative to begin(IPAddress a, uint16_t port)
Definition UDPStream.h:72
We provide the WiFi class to simulate the Arduino WIFI. In in Linux we can expect that networking is ...
Definition CanMsg.cpp:31
I2CWrapper Wire
Global Wire instance used by Arduino API functions and direct access.
Definition I2CWrapper.cpp:24
SPIWrapper SPI
Global SPI instance used by Arduino API and direct access.
Definition SPIWrapper.cpp:27
GPIOWrapper GPIO
Global GPIO instance used by Arduino API functions and direct access.
Definition GPIOWrapper.cpp:35