From 8738b4ea71100b400bbcadc6386ee8dac69a4f9f Mon Sep 17 00:00:00 2001 From: Stefan de Bruijn Date: Wed, 2 Jun 2021 22:12:15 +0200 Subject: [PATCH] Fixed reverse parsing of IP addresses from Yaml. --- Grbl_Esp32/data/config.yaml | 5 ----- Grbl_Esp32/src/MachineConfig.h | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Grbl_Esp32/data/config.yaml b/Grbl_Esp32/data/config.yaml index c12a7ebc..6da31381 100644 --- a/Grbl_Esp32/data/config.yaml +++ b/Grbl_Esp32/data/config.yaml @@ -73,8 +73,3 @@ comms: wifi_ap: ssid: ScratchThat ip_address: "192.168.0.1" - gateway: "192.168.0.1" - netmask: "255.255.255.0" - - wifi_sta: - ssid: StefanMieke diff --git a/Grbl_Esp32/src/MachineConfig.h b/Grbl_Esp32/src/MachineConfig.h index 7e93f638..a8f1ab71 100644 --- a/Grbl_Esp32/src/MachineConfig.h +++ b/Grbl_Esp32/src/MachineConfig.h @@ -240,6 +240,7 @@ public: if (ip.begin() != nullptr) { uint32_t value = 0; uint32_t tmp = 0; + int shift = 0; int c = 0; for (auto ch : ip) { if (ch >= '0' && ch <= '9') { @@ -252,7 +253,8 @@ public: if (tmp > 255) { return false; } - value = (value << 8) + tmp; + value = value | (tmp << shift); + shift += 8; tmp = 0; } else if (ch != ' ') { // For convenience / layouting. @@ -262,7 +264,7 @@ public: if (tmp > 255) { return false; } - value = (value << 8) + tmp; + value = value | (tmp << shift); // Correct. dst = value;