Skip to content

Commit 97b33d9

Browse files
committed
HardwareSetupRemote: cleanup
1 parent 0066a7c commit 97b33d9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#include "WiFiUdpStream.h"
1111

1212
namespace arduino {
13+
#if !defined(SKIP_HARDWARE_SETUP)
14+
#if !defined(USE_RPI)
15+
static RemoteI2C Wire;
16+
static RemoteSPI SPI;
17+
#endif
18+
#endif
1319

1420
/**
1521
* Class which is used to configure the actual Hardware APIs
@@ -42,6 +48,10 @@ class HardwareSetupRemoteClass {
4248
spi.setStream(s);
4349
gpio.setStream(s);
4450

51+
// setup global objects
52+
SPI = spi;
53+
Wire = i2c;
54+
4555
if (doHandShake) {
4656
handShake(s);
4757
}
@@ -57,13 +67,14 @@ class HardwareSetupRemoteClass {
5767
void begin() {
5868
if (p_stream == nullptr) {
5969
default_stream.begin(port);
60-
handShake(&default_stream);
6170
IPAddress ip = default_stream.remoteIP();
62-
int port = default_stream.remotePort();
63-
default_stream.setTarget(ip, port);
71+
int remote_port = default_stream.remotePort();
72+
default_stream.setTarget(ip, remote_port);
6473
default_stream.write((const uint8_t*)"OK", 2);
6574
default_stream.flush();
66-
p_stream = &default_stream;
75+
begin(&default_stream, true);
76+
} else {
77+
begin(p_stream, true);
6778
}
6879
}
6980

@@ -114,9 +125,5 @@ class HardwareSetupRemoteClass {
114125

115126
#if !defined(SKIP_HARDWARE_SETUP)
116127
static HardwareSetupRemoteClass HardwareSetupRemote{7000};
117-
#if !defined(USE_RPI)
118-
static auto& Wire = *Hardware.i2c;
119-
static auto& SPI = *Hardware.spi;
120-
#endif
121128
#endif
122129
} // namespace arduino

0 commit comments

Comments
 (0)