From 8bf6ad36b6cd043f3afa352c1d80c2104eebafbf Mon Sep 17 00:00:00 2001 From: VOLCA2333 Date: Mon, 19 Feb 2024 11:30:39 +0800 Subject: [PATCH] feat: allow connecting to one specific server IP without broadcasting (#301) --- platformio.ini | 11 +++++++---- src/network/connection.h | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 01e6fdd65..f76596efc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ ; See docs for configuration options and examples: ; https://docs.slimevr.dev/firmware/configuring-project.html#1-configuring-platformioini ; ================================================ - +; [env] lib_deps= https://github.com/SlimeVR/CmdParser.git @@ -26,8 +26,8 @@ build_flags = ;If you want to set hardcoded WiFi SSID and password, uncomment and edit the lines below ;To uncomment, only remove ";" and leave the two spaces in front of the tags ; '" - quotes are necessary! -; -DWIFI_CREDS_SSID='"SSID"' -; -DWIFI_CREDS_PASSWD='"PASSWORD"' + -DWIFI_CREDS_SSID='"TP-LINK_9527"' + -DWIFI_CREDS_PASSWD='"1414@1414"' ;If you want to set a static IP address, uncomment and edit the lines below ; -DWIFI_USE_STATICIP @@ -35,6 +35,9 @@ build_flags = ; -DWIFI_STATIC_GATEWAY=192,168,XXX,XXX ; -DWIFI_STATIC_SUBNET=255,255,255,0 +; -DSERVER_IP='"192.168.XXX.XXX"' +; -DSERVER_PORT=6969 + ; Uncomment below if your board are using 40MHz crystal instead of 26MHz for ESP8266 ; -DF_CRYSTAL=40000000 @@ -93,7 +96,7 @@ upload_speed = 921600 ;[env:esp32c3] ;platform = espressif32 @ 6.1.0 -;build_flags = +;build_flags = ; ${env.build_flags} ; -DESP32C3 ;board = lolin_c3_mini diff --git a/src/network/connection.h b/src/network/connection.h index 1231ee247..7b8f7b6a2 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -37,6 +37,16 @@ namespace Network { class Connection { public: + Connection() { +#ifdef SERVER_IP + m_ServerHost.fromString(SERVER_IP); +#endif + +#ifdef SERVER_PORT + m_ServerPort = SERVER_PORT; +#endif + } + void searchForServer(); void update(); void reset();