From c93da859346d499a22d24ae44471f963eabbdb57 Mon Sep 17 00:00:00 2001 From: Scott <5125421+BeldrothTheGold@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:24:19 -0600 Subject: [PATCH 1/3] move secrets to secrets.h --- include/network.h | 5 +---- include/ntptimeclient.h | 5 ++++- include/secrets.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 include/secrets.h diff --git a/include/network.h b/include/network.h index 4f6ac65ae..67bf4c0a4 100644 --- a/include/network.h +++ b/include/network.h @@ -29,6 +29,7 @@ #include "remotecontrol.h" #include "socketserver.h" #include "ntptimeclient.h" +#include "secrets.h" extern byte g_Brightness; extern bool g_bUpdateStarted; @@ -42,9 +43,5 @@ void processRemoteDebugCmd(); extern RemoteControl g_RemoteControl; #endif -#define cszSSID "Your SSID" -#define cszPassword "Your PASS" -#define cszHostname "NightDriverStrip" - bool ConnectToWiFi(uint cRetries); void SetupOTA(const char *pszHostname); \ No newline at end of file diff --git a/include/ntptimeclient.h b/include/ntptimeclient.h index 14cd7e029..9739aa427 100644 --- a/include/ntptimeclient.h +++ b/include/ntptimeclient.h @@ -31,6 +31,7 @@ #pragma once #include "globals.h" +#include "secrets.h" #include #include #include @@ -44,6 +45,8 @@ // worked and wrapped it in a class. As expected, it works, but it could likely // benefit from cleanup or even wholesale replacement. + + class NTPTimeClient { static bool _bClockSet; @@ -93,7 +96,7 @@ class NTPTimeClient // Send the ntp packet. - IPAddress ipNtpServer(192, 168, 1, 2); // My Synology NAS + IPAddress ipNtpServer(cszNTPServer); // cszNTPServer defined in secrets.h //IPAddress ipNtpServer(216, 239, 35, 12); // 216.239.35.12 Google Time //IPAddress ipNtpServer(17, 253, 16, 253); // Apple time diff --git a/include/secrets.h b/include/secrets.h new file mode 100644 index 000000000..d4b25e1c3 --- /dev/null +++ b/include/secrets.h @@ -0,0 +1,34 @@ +//+-------------------------------------------------------------------------- +// +// File: network.h +// +// NightDriverStrip - (c) 2018 Plummer's Software LLC. All Rights Reserved. +// +// This file is part of the NightDriver software project. +// +// NightDriver is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// NightDriver is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Nightdriver. It is normally found in copying.txt +// If not, see . +// +// Description: +// +// secret definations +// +//--------------------------------------------------------------------------- + +#define cszSSID "Your SSID" +#define cszPassword "Your PASS" +#define cszHostname "NightDriverStrip" +#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org +//#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org +//#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org From dd2a9d10be7d08e68b4d9d1557f9e9a13a11446c Mon Sep 17 00:00:00 2001 From: Scott <5125421+BeldrothTheGold@users.noreply.github.com> Date: Fri, 15 Oct 2021 15:01:36 -0600 Subject: [PATCH 2/3] add secrets.h to gitignore, fix some comments and move NTP server back to ntptimeclient.h so it's consistent with the rest of the project (with the exception of secrets) --- .gitignore | 3 ++- include/ntptimeclient.h | 14 +++++++------- include/secrets.h | 14 ++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 45706d050..dc570c6d2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ NightDriverStrip.code-workspace src/uzlib/src/*.o .history - +lib/* +include/secrets.h diff --git a/include/ntptimeclient.h b/include/ntptimeclient.h index 9739aa427..bc741d4ed 100644 --- a/include/ntptimeclient.h +++ b/include/ntptimeclient.h @@ -31,7 +31,6 @@ #pragma once #include "globals.h" -#include "secrets.h" #include #include #include @@ -39,14 +38,18 @@ #include #include +// define the NTP server to connect too (replace . [dots] in IP addresses with , [commas]) +#define cszNTPServer 94, 199, 173, 123 // 0.pool.ntp.org +//#define cszNTPServer 216, 239, 35, 12 // google time +//#define cszNTPServer 17, 253, 16, 253 // apple time + + // NTPTimeClient // // Basically, I took some really ancient NTP code that I had on hand that I knew // worked and wrapped it in a class. As expected, it works, but it could likely // benefit from cleanup or even wholesale replacement. - - class NTPTimeClient { static bool _bClockSet; @@ -95,10 +98,7 @@ class NTPTimeClient chNtpPacket[0] = 0b00011011; // Send the ntp packet. - - IPAddress ipNtpServer(cszNTPServer); // cszNTPServer defined in secrets.h - //IPAddress ipNtpServer(216, 239, 35, 12); // 216.239.35.12 Google Time - //IPAddress ipNtpServer(17, 253, 16, 253); // Apple time + IPAddress ipNtpServer(cszNTPServer); pUDP->beginPacket(ipNtpServer, 123); pUDP->write((const uint8_t *)chNtpPacket, NTP_PACKET_LENGTH); diff --git a/include/secrets.h b/include/secrets.h index d4b25e1c3..4665376ef 100644 --- a/include/secrets.h +++ b/include/secrets.h @@ -1,6 +1,6 @@ //+-------------------------------------------------------------------------- // -// File: network.h +// File: secrets.h // // NightDriverStrip - (c) 2018 Plummer's Software LLC. All Rights Reserved. // @@ -22,13 +22,11 @@ // // Description: // -// secret definations +// secret definitions, at the moment this is just network secrets, +// but could be expanded in the future // //--------------------------------------------------------------------------- -#define cszSSID "Your SSID" -#define cszPassword "Your PASS" -#define cszHostname "NightDriverStrip" -#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org -//#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org -//#define cszNTPServer 192, 168, 1, 2 // 0.pool.ntp.org +#define cszSSID "Your SSID" +#define cszPassword "Your PASS" +#define cszHostname "NightDriverStrip" From 30843c2168feb8cfe7db42207f6963d3e993fe48 Mon Sep 17 00:00:00 2001 From: Scott <5125421+BeldrothTheGold@users.noreply.github.com> Date: Fri, 15 Oct 2021 15:19:30 -0600 Subject: [PATCH 3/3] remove extraneous lib from .gitignore removes lib/* from this version of .gitignore it's not part of this PR --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index dc570c6d2..c259bf839 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ NightDriverStrip.code-workspace src/uzlib/src/*.o .history -lib/* include/secrets.h