Browse code

minor revision 20180225

fractalxaos authored on 02/26/2018 00:19:05
Showing 1 changed files
... ...
@@ -12,7 +12,7 @@
12 12
  network interface IP address, NTP server address, or configure a
13 13
  verbose output mode.
14 14
  
15
- Copyright 2017 Jeff Owrey
15
+ Copyright 2018 Jeff Owrey
16 16
     This program is free software: you can redistribute it and/or modify
17 17
     it under the terms of the GNU General Public License as published by
18 18
     the Free Software Foundation, either version 3 of the License, or
... ...
@@ -79,7 +79,7 @@
79 79
  Define the header and version number displayed at startup
80 80
  and also by the 'view settings' command.
81 81
 */
82
-#define STARTUP_HEADER "\n\rRadmon v1.6 (c) 2017\n"
82
+#define STARTUP_HEADER "\n\rRadmon v1.6 (c) 2018\n"
83 83
 #define RADMON_VERSION "v1.6"
84 84
 /*
85 85
  The following define sets the MAC address of the device.  This
... ...
@@ -100,7 +100,7 @@
100 100
  out over the device's USB port.  This heartbeat consists of a serial
101 101
  data string containing the current radiation reading and GM time.
102 102
 */
103
-#define SERIAL_UPDATE_INTERVAL 10000  //milli-seconds
103
+#define SERIAL_UPDATE_INTERVAL 5000  //milli-seconds
104 104
 /*
105 105
  The following define sets the port number the HTTP service will use to
106 106
  listen for requests from Internet clients.  Normally HTTP requests use
... ...
@@ -186,13 +186,15 @@ time_t nextClockSynchTime;
186 186
  and the IP address mode state (static or DHCP).
187 187
 */
188 188
 boolean bVerbose;
189
-boolean bUseDHCP;
189
+boolean bUseStaticIP;
190 190
 /*
191 191
  Create and initialize global arrays to hold the current IP address
192 192
  and the NTP server IP address.
193 193
 */
194
-byte ipAddr[4] = {};
195
-byte ntpIpAddr[4] = {};
194
+//byte ipAddr[4] = {};
195
+//byte ntpIpAddr[4] = {};
196
+byte ipAddr[4];
197
+byte ntpIpAddr[4];
196 198
 
197 199
 /*** SYSTEM STARTUP  ***/
198 200
 
... ...
@@ -215,8 +217,10 @@ void setup()
215 217
    Start up the Ethernet interface using either a static or
216 218
    DHCP supplied address (depending on stored system configuration).
217 219
   */
218
-  if(bUseDHCP)
220
+  if(bUseStaticIP)
219 221
   {
222
+    Ethernet.begin(mac, ipAddr);
223
+  } else {
220 224
     if ( Ethernet.begin(mac) == 0 )
221 225
     {
222 226
       /* DHCP not responding so use APIPA address */
... ...
@@ -224,14 +228,6 @@ void setup()
224 228
       Ethernet.begin(mac, ipAddr);
225 229
       Serial.println(F("DHCP failed - using APIPA "));
226 230
     }
227
-    else
228
-    {
229
-      Serial.print(F("DHCP "));
230
-    }
231
-  }
232
-  else
233
-  {
234
-    Ethernet.begin(mac, ipAddr);
235 231
   }
236 232
   Serial.print(F("IP address: ")); Serial.println(Ethernet.localIP());
237 233
   /*
... ...
@@ -796,13 +792,13 @@ void displaySettings()
796 792
 
797 793
   // Display local IP address
798 794
   sprintf(sBuf, "%d.%d.%d.%d", ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3]);
799
-  if (bUseDHCP)
795
+  if (bUseStaticIP)
800 796
   {
801
-    Serial.print(F("DHCP IP: "));
797
+    Serial.print(F("Static IP: "));
802 798
   }
803 799
   else
804 800
   {
805
-    Serial.print(F("Static IP: "));
801
+    Serial.print(F("DHCP IP: "));
806 802
   }
807 803
   Serial.println(sBuf);
808 804
   
... ...
@@ -830,12 +826,13 @@ void setIP()
830 826
   
831 827
   if(strlen(sBuf) == 0)
832 828
   {
833
-    bUseDHCP = true;
834
-    parseIpAddress(ipAddr, "0.0.0.0");
829
+    bUseStaticIP = false;
830
+    strcpy(sBuf, "0.0.0.0");
831
+    parseIpAddress(ipAddr, sBuf);
835 832
   }
836 833
   else
837 834
   {
838
-    bUseDHCP = false;
835
+    bUseStaticIP = true;
839 836
     parseIpAddress(ipAddr, sBuf);
840 837
   }
841 838
   Serial.println();
... ...
@@ -851,12 +848,13 @@ void setNTPIP()
851 848
 {
852 849
   char sBuf[16];
853 850
   
854
-  Serial.print(F("enter IP: "));
851
+  Serial.print(F("enter IP (<CR> for default): "));
855 852
   getSerialLine(sBuf, 16);
856 853
   
857 854
   if (strlen(sBuf) == 0)
858 855
   {
859
-    parseIpAddress(ntpIpAddr, DEFAULT_NTP_SERVER_IP_ADDR);
856
+    strcpy(sBuf, DEFAULT_NTP_SERVER_IP_ADDR);
857
+    parseIpAddress(ntpIpAddr, sBuf);
860 858
   }
861 859
   else
862 860
   {
... ...
@@ -1001,7 +999,7 @@ void writeSettingsToEEPROM()
1001 999
     EEPROM.write(ix + 4, ntpIpAddr[ix]);
1002 1000
   }
1003 1001
   EEPROM.write(8, bVerbose);
1004
-  EEPROM.write(9, bUseDHCP);
1002
+  EEPROM.write(9, bUseStaticIP);
1005 1003
   return;
1006 1004
 }
1007 1005
 
... ...
@@ -1020,7 +1018,7 @@ void readSettingsFromEEPROM()
1020 1018
     ntpIpAddr[ix] = EEPROM.read(ix + 4);
1021 1019
   }
1022 1020
   bVerbose = EEPROM.read(8);
1023
-  bUseDHCP = EEPROM.read(9);
1021
+  bUseStaticIP = EEPROM.read(9);
1024 1022
   return;
1025 1023
 }
1026 1024