Skip to content

Commit

Permalink
Fix IP check and provision check
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomona authored and ImUrX committed Jul 15, 2023
1 parent 249c183 commit 10401af
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define serialDebug false // Set to true to get Serial output for debugging
#define serialBaudRate 115200
#define USE_REMOTE_COMMAND true
#define ALLOW_REMOTE_WIFI_PROV false
#define ALLOW_REMOTE_WIFI_PROV true
#define LED_INTERVAL_STANDBY 10000
#define PRINT_STATE_EVERY_MS 60000

Expand Down
2 changes: 1 addition & 1 deletion src/logging/RemoteLogHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SlimeVR {
namespace Logging {
bool getRemoteCmdConncted() { return networkRemoteCmd.isConnected(); }
bool getRemoteCmdConncted() { return networkRemoteCmd.isConnected() && networkConnection.isConnected(); }

Stream& getRemoteCmdStream() { return networkRemoteCmd.getStream(); }
} // namespace Logging
Expand Down
3 changes: 3 additions & 0 deletions src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ void Connection::searchForServer() {

statusManager.setStatus(SlimeVR::Status::SERVER_CONNECTING, false);
ledManager.off();
#if USE_REMOTE_COMMAND
networkRemoteCmd.reset();
#endif

m_Logger.debug(
"Handshake successful, server is %s:%d",
Expand Down
1 change: 1 addition & 0 deletions src/network/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "quat.h"
#include "sensors/sensor.h"
#include "wifihandler.h"
#include "remotecmd.h"

namespace SlimeVR {
namespace Network {
Expand Down
7 changes: 5 additions & 2 deletions src/network/remotecmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ void RemoteCmd::update() {
rcmdServer.accept().stop();
r_Logger.info("Remote command multi-connection dropped");
} else {
IPAddress rejectedIP;
rcmdClient = rcmdServer.accept();
if (networkConnection.isConnected()) {
// Only accept if rcmdClient have the same remote IP as udpmanager
if (rcmdClient.remoteIP() = networkConnection.m_ServerHost) {
if (rcmdClient.remoteIP() != networkConnection.m_ServerHost) {
rejectedIP = rcmdClient.remoteIP();
rcmdClient.stop();
}
}
#if !ALLOW_REMOTE_WIFI_PROV
else {
rejectedIP = rcmdClient.remoteIP();
rcmdClient.stop();
}
#endif
Expand All @@ -38,7 +41,7 @@ void RemoteCmd::update() {
} else {
r_Logger.info(
"Remote command from %s dropped",
rcmdClient.remoteIP().toString().c_str()
rejectedIP.toString().c_str()
);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/network/wifihandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ void WiFiNetwork::setUp() {
void onConnected() {
WiFiNetwork::stopProvisioning();
statusManager.setStatus(SlimeVR::Status::WIFI_CONNECTING, false);
networkRemoteCmd.reset();
isWifiConnected = true;
hadWifi = true;
wifiHandlerLogger.info("Connected successfully to SSID '%s', ip address %s", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
Expand Down

0 comments on commit 10401af

Please sign in to comment.