Преглед изворни кода

Version 6.1.3; see CHANGELOG for changes

platenspeler пре 5 година
родитељ
комит
cc35d841b4
5 измењених фајлова са 110 додато и 61 уклоњено
  1. 8 0
      CHANGELOG.md
  2. 7 5
      ESP-sc-gway/_loraFiles.ino
  3. 2 2
      ESP-sc-gway/_utils.ino
  4. 27 5
      ESP-sc-gway/_wwwServer.ino
  5. 66 49
      ESP-sc-gway/configGway.h

+ 8 - 0
CHANGELOG.md

@@ -16,6 +16,14 @@ Maintained by Maarten Westenberg (mw12554@hotmail.com)
 
 # Release Notes
 
+Features release 6.1.1 (November 6, 2019)
+- Made changes to _TRUSTED_NODES in _wwwServer.ino to make sure only named nodes are 
+displayed when value is 2. 
+Other messages ARE handled by gateway but not shown in the user interface under message history.
+- Used id_print in _loraFiles.ino in order to avoid _DUSB issues
+- Reorganized the conigGway.h file to move items that normally do not change to the end of file.
+- Repaired bugs and writing errors
+
 Features release 6.1.1 (November 6, 2019)
 - Added "last seen" for a node. An overview when each known node has last been seen by the gateway,
 	This would mean that a node that does not fit in the regular history overview would still be visible

+ 7 - 5
ESP-sc-gway/_loraFiles.ino

@@ -140,15 +140,15 @@ int readConfig(const char *fn, struct espGwayConfig *c) {
 			(*c).debug = (uint8_t) val.toInt();
 		}
 		else if (id == "PDEBUG") {								// pDebug Pattern
-			Serial.print(F("PDEBUG=")); Serial.println(val);
+			id_print(id, val);
 			(*c).pdebug = (uint8_t) val.toInt();
 		}
 		else if (id == "CAD") {									// CAD setting
-			Serial.print(F("CAD=")); Serial.println(val);
+			id_print(id, val);
 			(*c).cad = (uint8_t) val.toInt();
 		}
 		else if (id == "HOP") {									// HOP setting
-			Serial.print(F("HOP=")); Serial.println(val);
+			id_print(id, val);
 			(*c).hop = (uint8_t) val.toInt();
 		}
 		else if (id == "BOOTS") {								// BOOTS setting
@@ -219,12 +219,14 @@ int readConfig(const char *fn, struct espGwayConfig *c) {
 		}
 	}
 	f.close();
+	
 #if _DUSB>=1
-	if (debug>=0) {
+	if (debug>=1) {
 		Serial.println(F("readConfig:: Fini"));
 	}
-#endif
 	Serial.println();
+#endif
+
 	return(1);
 }//readConfig
 

+ 2 - 2
ESP-sc-gway/_utils.ino

@@ -238,13 +238,13 @@ int SerialName(char * a, String& response)
 				Serial.print(nodes[i].id,HEX);
 				Serial.println();
 			}
-#endif
+#endif // _DUSB
 			response += nodes[i].nm;
 			return(i);
 		}
 	}
 
-#endif
+#endif // _TRUSTED_NODES
 	return(-1);									// If no success OR is TRUSTED NODES not defined
 }
 

+ 27 - 5
ESP-sc-gway/_wwwServer.ino

@@ -829,12 +829,20 @@ static void statisticsData()
 //	- <none>
 // Returns:
 //	- <none>
+//
+// As we make the TRUSTED_NODE a dynamic parameter, it can be set/unset in the user 
+// interface. It will allow the user to only see known nodes (with a name) in the 
+// list or also nodes with only an address (Unknown nodes).
+// As a result, the size of the list will NOT be as large when only known nodes are 
+// selected, as in can be deselcted in the GUI and we have only so much space on 
+// th screen.
 // --------------------------------------------------------------------------------
 static void messageHistory() 
 {
 #if _STATISTICS >= 1
 	String response="";
-	
+
+	// PRINT HEADERS
 	response += "<h2>Message History</h2>";
 	response += "<table class=\"config_table\">";
 	response += "<tr>";
@@ -855,19 +863,32 @@ static void messageHistory()
 	response += "</tr>";
 	server.sendContent(response);
 
-	for (int i=0; i<MAX_STAT; i++) {
+	// PRINT NODE CONTENT
+	for (int i=0; i<MAX_STAT; i++) {										// For every Node in the list
 		if (statr[i].sf == 0) break;
 		
 		response = "";
 		
 		response += String() + "<tr><td class=\"cell\">";					// Tmst
-		stringTime((statr[i].tmst), response);			// XXX Change tmst not to be millis() dependent
+		stringTime((statr[i].tmst), response);								// XXX Change tmst not to be millis() dependent
 		response += "</td>";
 		
 		response += String() + "<td class=\"cell\">"; 						// Node
-		if (SerialName((char *)(& (statr[i].node)), response) < 0) {		// works with TRUSTED_NODES >= 1
+		
+#if  _TRUSTED_NODES==0														// DO nothing with TRUSTED NODES
+		printHEX((char *)(& (statr[i].node)),' ',response);
+#elif _TRUSTED_NODES>=1
+		if (SerialName((char *)(& (statr[i].node)), response) < 0) {		// works with _TRUSTED_NODES >= 1
+#if _TRUSTED_NODES>=2
+			continue;														// else next item and do not show
+#else
 			printHEX((char *)(& (statr[i].node)),' ',response);				// else
+#endif // _TRUSTED_NODES>=2
 		}
+#else
+# error Undefined value for _TRUSTED_NODES
+#endif // _TRUSTED_NODES>=1
+
 		response += "</td>";
 		
 #if _LOCALSERVER==1
@@ -957,7 +978,8 @@ static void nodeHistory()
 		server.sendContent("</table>");
 	}
 #endif
-}
+} // nodeHistory()
+
 
 // --------------------------------------------------------------------------------
 // SEND WEB PAGE() 

+ 66 - 49
ESP-sc-gway/configGway.h

@@ -1,7 +1,7 @@
 // 1-channel LoRa Gateway for ESP8266
 // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
-// Version 6.1.1 E EU868
-// Date: 2019-11-11
+// Version 6.1.3 E EU868
+// Date: 2019-11-20
 //
 // Based on work done by Thomas Telkamp for Raspberry PI 1ch gateway and many others.
 // Contibutions of Dorijan Morelj and Andreas Spies for OLED support.
@@ -17,18 +17,21 @@
 //
 // This file contains a number of compile-time settings that can be set on (=1) or off (=0)
 // The disadvantage of compile time is minor compared to the memory gain of not having
-// too much code compiled and loaded on your ESP8266.
+// too much code compiled and loaded on your ESP device.
 //
 // NOTE: 
-// If version if vor ESP32 Halard board, compile with ESP32 setting and board 
+// If version if vor ESP32 Heltec board, compile with ESP32 setting and board 
 // "ESP32 Dev Module" or "Heltec WiFi Lora 32"
 // 
-// If version is for Comresult or Halard board, compile with "Wemos R1 D1" and choose
+// For ESP8266 Wemos: compile with "Wemos R1 D1" and choose
 // the right _PIN_OUT below. Selecting OLED while that is not connected does not 
 // really matter.
-// ----------------------------------------------------------------------------------------
+//
+// ========================================================================================
 
-#define VERSION "V.6.1.1.E.EU868; 191111a"
+// Specify the correct version and date of your gateway here.
+// Normally it is provided with teh GitHub version
+#define VERSION "V.6.1.3.E.EU868; 191120a"
 
 // This value of DEBUG determines whether some parts of code get compiled.
 // Also this is the initial value of debug parameter. 
@@ -121,9 +124,6 @@
 #define _STATISTICS 3
 
 
-// Maximum number of statistics records gathered. 20 is a good maximum (memory intensive)
-// For ESP32 maybe 30 could be used as well
-#define MAX_STAT 20
 
 
 // Single channel gateways if they behave strict should only use one frequency 
@@ -151,7 +151,7 @@
 
 
 // This section defines whether we use the gateway as a repeater
-// For his, we use another output channle as the channel (default==0) we are 
+// For his, we use another output channel as the channel (default==0) we are 
 // receiving the messages on.
 #define _REPEATER 0
 
@@ -189,19 +189,7 @@
 // Of course we must store enough records to make the filesystem work
 #define STAT_LOG 1
 
-// We will log a list of LoRa nodes that was forwarded using this gateway.
-// For eacht node we record:
-//	- node Number, or known node name
-//	- Last seen 'seconds since 1/1/1970'
-//	- SF seen (8-bit integer with SF per bit)
-// The initial version _NUMMAX stores max so many nodes:
-#define _SEENMAX 100
-#define _SEENFILE "/gwayNum.txt"
 
-// Name of he configfile in SPIFFs	filesystem
-// In this file we store the configuration and other relevant info that should
-// survive a reboot of the gateway		
-#define CONFIGFILE "/gwayConfig.txt"
 
 // Set the Server Settings (IMPORTANT)
 #define _LOCUDPPORT 1700					// UDP port of gateway! Often 1700 or 1701 is used for upstream comms
@@ -214,21 +202,6 @@
 #define _WWW_INTERVAL	60					// Number of seconds before we refresh the WWW page
 
 
-// MQTT definitions, these settings should be standard for TTN
-// and need not changing
-#define _TTNSERVER "router.eu.thethings.network"
-#define _TTNPORT 1700						// Standard port for TTN
-
-
-// If you have a second back-end server defined such as Semtech or loriot.io
-// your can define _THINGPORT and _THINGSERVER with your own value.
-// If not, make sure that you do not define these, which will save CPU time
-// Port is UDP port in this program
-//
-// Default for testing: Switched off
-#define _THINGSERVER "your,webserver.com"		// Server URL of the LoRa-udp.js handler
-#define _THINGPORT 1700						// Port 1700 is old compatibility
-
 
 // This defines whether or not we would use the gateway as 
 // as sort of backend system which decodes
@@ -237,9 +210,9 @@
 #define _LOCALSERVER 1						// See server definitions for decodes
 
 
-// Gateway Ident definitions
+// Gateway Ident definitions. Where is the gateway located?
 #define _DESCRIPTION "ESP Gateway"			// Name of the gateway
-#define _EMAIL "your@mail.com"				// Owner
+#define _EMAIL "your@email.com"		// Owner
 #define _PLATFORM "ESP8266"
 #define _LAT 52.0
 #define _LON 5.0
@@ -264,6 +237,46 @@
 
 
 
+// We can put the gateway in such a mode that it will (only) recognize
+// nodes that are put in a list of trusted nodes 
+// Values:
+// 0: Do not use names for trusted Nodes
+// 1: Use the nodes as a translation table for hex codes to names (in TLN)
+// 2: Same as 1, but is nodes NOT in the nodes list below they are NOT
+//		shown! (option 2 is almost fully implemented)
+// NOTE: We probably will make this list dynamic!
+#define _TRUSTED_NODES 1
+#define _TRUSTED_DECODE 1
+
+
+
+// ========================================================================
+// DO NOT CHANGE BELOW THIS LINE
+// Probably do not change items below this line, only if lists or 
+// configurations on configNode.h are not large enough for example.
+// ========================================================================
+
+
+// Maximum number of statistics records gathered. 20 is a good maximum (memory intensive)
+// For ESP32 maybe 30 could be used as well
+#define MAX_STAT 20
+
+
+// We will log a list of LoRa nodes that was forwarded using this gateway.
+// For eacht node we record:
+//	- node Number, or known node name
+//	- Last seen 'seconds since 1/1/1970'
+//	- SF seen (8-bit integer with SF per bit)
+// The initial version _NUMMAX stores max this many nodes, please make
+// _SEENMAX==0 when not used
+#define _SEENMAX 100
+#define _SEENFILE "/gwayNum.txt"
+
+// Name of he configfile in SPIFFs	filesystem
+// In this file we store the configuration and other relevant info that should
+// survive a reboot of the gateway		
+#define CONFIGFILE "/gwayConfig.txt"
+
 
 // Define the correct radio type that you are using
 #define CFG_sx1276_radio		
@@ -274,16 +287,20 @@
 #define _BAUDRATE 115200					// Works for debug messages to serial momitor
 
 
-// We can put the gateway in such a mode that it will (only) recognize
-// nodes that are put in a list of trusted nodes 
-// Values:
-// 0: Do not use names for trusted Nodes
-// 1: Use the nodes as a translation table for hex codes to names (in TLN)
-// 2: Same as 1, but is nodes NOT in the nodes list below they are NOT
-//		forwarded or counted! (not yet fully implemented)
-#define _TRUSTED_NODES 1
-#define _TRUSTED_DECODE 1
+// MQTT definitions, these settings should be standard for TTN
+// and need no changing
+#define _TTNSERVER "router.eu.thethings.network"
+#define _TTNPORT 1700						// Standard port for TTN
+
 
+// If you have a second back-end server defined such as Semtech or loriot.io
+// your can define _THINGPORT and _THINGSERVER with your own value.
+// If not, make sure that you do not define these, which will save CPU time
+// Port is UDP port in this program
+//
+// Default for testing: Switched off
+#define _THINGSERVER "your,webserver.org"		// Server URL of the LoRa-udp.js handler
+#define _THINGPORT 1700						// Port 1700 is old compatibility