Skip to content

Commit 7b1db7a

Browse files
committed
Fix IP check and provision check
1 parent 8d31511 commit 7b1db7a

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

src/debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#define serialDebug false // Set to true to get Serial output for debugging
4949
#define serialBaudRate 115200
5050
#define USE_REMOTE_COMMAND true
51-
#define ALLOW_REMOTE_WIFI_PROV false
51+
#define ALLOW_REMOTE_WIFI_PROV true
5252
#define LED_INTERVAL_STANDBY 10000
5353
#define PRINT_STATE_EVERY_MS 60000
5454

src/logging/RemoteLogHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SlimeVR {
66
namespace Logging {
7-
bool getRemoteCmdConncted() { return networkRemoteCmd.isConnected(); }
7+
bool getRemoteCmdConncted() { return networkRemoteCmd.isConnected() && networkConnection.isConnected(); }
88

99
Stream& getRemoteCmdStream() { return networkRemoteCmd.getStream(); }
1010
} // namespace Logging

src/network/connection.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ void Connection::searchForServer() {
478478

479479
statusManager.setStatus(SlimeVR::Status::SERVER_CONNECTING, false);
480480
ledManager.off();
481+
#if USE_REMOTE_COMMAND
482+
networkRemoteCmd.reset();
483+
#endif
481484

482485
m_Logger.debug(
483486
"Handshake successful, server is %s:%d",

src/network/connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "quat.h"
3131
#include "sensors/sensor.h"
3232
#include "wifihandler.h"
33+
#include "remotecmd.h"
3334

3435
namespace SlimeVR {
3536
namespace Network {

src/network/remotecmd.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ void RemoteCmd::update() {
1818
rcmdServer.accept().stop();
1919
r_Logger.info("Remote command multi-connection dropped");
2020
} else {
21+
IPAddress rejectedIP;
2122
rcmdClient = rcmdServer.accept();
2223
if (networkConnection.isConnected()) {
2324
// Only accept if rcmdClient have the same remote IP as udpmanager
24-
if (rcmdClient.remoteIP() = networkConnection.m_ServerHost) {
25+
if (rcmdClient.remoteIP() != networkConnection.m_ServerHost) {
26+
rejectedIP = rcmdClient.remoteIP();
2527
rcmdClient.stop();
2628
}
2729
}
2830
#if !ALLOW_REMOTE_WIFI_PROV
2931
else {
32+
rejectedIP = rcmdClient.remoteIP();
3033
rcmdClient.stop();
3134
}
3235
#endif
@@ -38,7 +41,7 @@ void RemoteCmd::update() {
3841
} else {
3942
r_Logger.info(
4043
"Remote command from %s dropped",
41-
rcmdClient.remoteIP().toString().c_str()
44+
rejectedIP.toString().c_str()
4245
);
4346
}
4447
}

src/network/wifihandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ void WiFiNetwork::setUp() {
121121
void onConnected() {
122122
WiFiNetwork::stopProvisioning();
123123
statusManager.setStatus(SlimeVR::Status::WIFI_CONNECTING, false);
124-
networkRemoteCmd.reset();
125124
isWifiConnected = true;
126125
hadWifi = true;
127126
wifiHandlerLogger.info("Connected successfully to SSID '%s', ip address %s", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());

0 commit comments

Comments
 (0)