Explorar o código

Version 6.1.3

platenspeler %!s(int64=5) %!d(string=hai) anos
pai
achega
9c46ead306

+ 8 - 4
CHANGELOG.md

@@ -1,6 +1,6 @@
 # Single Channel LoRaWAN Gateway
 
-Version 6.1.1, November 6	, 2019	  
+Version 6.1.3, November 20, 2019	  
 Author: M. Westenberg (mw12554@hotmail.com)  
 Copyright: M. Westenberg (mw12554@hotmail.com)  
 
@@ -16,10 +16,14 @@ Maintained by Maarten Westenberg (mw12554@hotmail.com)
 
 # Release Notes
 
-Features release 6.1.1 (November 6, 2019)
+Features release 6.1.3 (November 20, 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.
+displayed when the value of trusted nodes in "Gateways Settings" has value  2. 
+The value of this vaiable is stored in the filesystem of the Gateway SPIFFS andwith every startup of 
+the Gateway it is read so that users can access when sensors last were seen by the Gateway 
+even after reboots.
+Note: all messages ARE handled by gateway but not shown in the user interface "Last Seen" 
+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

+ 7 - 3
ESP-sc-gway/ESP-sc-gway.ino

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 // Author: Maarten Westenberg (mw12554@hotmail.com)
 //
 // Based on work done by Thomas Telkamp for Raspberry PI 1-ch gateway and many others.
@@ -486,6 +486,7 @@ void setup() {
 	// other configuration parameters are used.
 	//
 	readConfig(CONFIGFILE, &gwayConfig);
+	readSeen(_SEENFILE, listSeen);							// read the seenFile records
 
 	Serial.print(F("Assert="));
 #if defined CFG_noassert
@@ -705,7 +706,10 @@ void setup() {
 	}
 	
 	writeConfig(CONFIGFILE, &gwayConfig);					// Write config
-
+	writeSeen( _SEENFILE, listSeen);						// Write the last time record  is seen
+#if _DUSB>=1
+	printSeen(listSeen);
+#endif	
 	// activate OLED display
 #if OLED>=1
 	acti_oLED();

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

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

@@ -1,7 +1,7 @@
 // 1-channel LoRa Gateway for ESP8266
 // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg 
-// Version 6.1.1
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // Based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 // and many others.

+ 116 - 33
ESP-sc-gway/_loraFiles.ino

@@ -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		
-// Date: 2019-11-06	
+// Version 6.1.3		
+// Date: 2019-11-20	
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.
@@ -51,6 +51,7 @@ int initConfig(struct espGwayConfig *c) {
 	(*c).hop = false;
 	(*c).expert = false;
 	(*c).txDelay = 0;					// First Value without saving is 0;
+	(*c).trusted = 1;
 }
 
 
@@ -211,6 +212,10 @@ int readConfig(const char *fn, struct espGwayConfig *c) {
 			id_print(id, val);
 			(*c).txDelay = (int32_t) val.toInt();
 		}
+		else if (id == "TRUSTED") {								// TRUSTED setting
+			id_print(id, val);
+			(*c).trusted= (int32_t) val.toInt();
+		}
 		else {
 #if _DUSB>=1
 			Serial.print(F("readConfig:: tries++"));
@@ -266,6 +271,9 @@ int writeGwayCfg(const char *fn) {
 // ----------------------------------------------------------------------------
 int writeConfig(const char *fn, struct espGwayConfig *c) {
 
+	// Assuming the cibfug file is the first we write...
+	// If it is not there we should format first.
+	// NOTE: Do not format for other files!
 	if (!SPIFFS.exists(fn)) {
 		Serial.print("WARNING:: writeConfig, file not exists, formatting ");
 		SPIFFS.format();
@@ -274,7 +282,7 @@ int writeConfig(const char *fn, struct espGwayConfig *c) {
 	}
 	File f = SPIFFS.open(fn, "w");
 	if (!f) {
-		Serial.print("ERROR:: writeConfig, open file=");
+		Serial.print("writeConfig: ERROR open file=");
 		Serial.print(fn);
 		Serial.println();
 		return(-1);
@@ -303,6 +311,7 @@ int writeConfig(const char *fn, struct espGwayConfig *c) {
 	f.print("FILENO");  f.print('='); f.print((*c).logFileNo); f.print('\n');
 	f.print("FILENUM");  f.print('='); f.print((*c).logFileNum); f.print('\n');
 	f.print("DELAY");  f.print('='); f.print((*c).txDelay); f.print('\n');
+	f.print("TRUSTED");  f.print('='); f.print((*c).trusted); f.print('\n');
 	f.print("EXPERT");  f.print('='); f.print((*c).expert); f.print('\n');
 	
 	f.close();
@@ -446,12 +455,89 @@ void printLog()
 #if _SEENMAX>0
 
 // ----------------------------------------------------------------------------
-// writeSeen
-// - Once every few messages, update the SPIFFS file and write the array.
+// readSeen
+// This function read the stored information from writeSeen.
 //
+// Parameters:
+// Return:
 // ----------------------------------------------------------------------------
-int writeSeen(struct nodeSeen *listSeen) {
+int readSeen(const char *fn, struct nodeSeen *listSeen) {
+	int i;
+	if (!SPIFFS.exists(fn)) {
+#if _DUSB>=1
+		Serial.print("WARNING:: readSeen, history file not exists ");
+#endif
+		initSeen(listSeen);		// XXX make all initial declarations here if config vars need to have a value
+		Serial.println(fn);
+		return(-1);
+	}
+	File f = SPIFFS.open(fn, "r");
+	if (!f) {
+		Serial.print("readConfig:: ERROR open file=");
+		Serial.print(fn);
+		Serial.println();
+		return(-1);
+	}
+	for (i=0; i<_SEENMAX; i++) {
+		String val;
+		if (!f.available()) {
+#if _DUSB>=1
+			Serial.println(F("readSeen:: No more info left in file"));
+#endif
+		}
+		val=f.readStringUntil('\t'); listSeen[i].timSeen = (uint32_t) val.toInt();
+		val=f.readStringUntil('\t'); 
+					listSeen[i].idSeen = (uint32_t) val.toInt();
+					//listSeen[i].idSeen = strtoul(val, val.length()+1, 10);
+		val=f.readStringUntil('\n'); listSeen[i].sfSeen = (uint8_t) val.toInt();
+	}
+	f.close();
+#if _DUSB>=1
+	printSeen(listSeen);
+#endif
+}
+
+
+// ----------------------------------------------------------------------------
+// writeSeen
+// Once every few messages, update the SPIFFS file and write the array.
+// Parameters:
+// - fn contains the filename to write
+// - listSeen contains the _SEENMAX array of list structures 
+// Return values:
+// - return 1 on success
+// ----------------------------------------------------------------------------
+int writeSeen(const char *fn, struct nodeSeen *listSeen) {
+	int i;
+	if (!SPIFFS.exists(fn)) {
+#if _DUSB>=1
+		Serial.print("WARNING:: writeSeen, file not exists, formatting ");
+#endif
+		initSeen(listSeen);		// XXX make all initial declarations here if config vars need to have a value
+		Serial.println(fn);
+	}
+	File f = SPIFFS.open(fn, "w");
+	if (!f) {
+		Serial.print("writeConfig:: ERROR open file=");
+		Serial.print(fn);
+		Serial.println();
+		return(-1);
+	}
+
+	for (i=0; i<_SEENMAX; i++) {
 
+			unsigned long timSeen;
+			f.print(listSeen[i].timSeen);		f.print('\t');
+			// Typecast to long to avoid errors in unsigned conversion.
+			f.print((long) listSeen[i].idSeen);		f.print('\t');
+			//f.print(listSeen[i].datSeen);		f.print('\t');
+			//f.print(listSeen[i].chanSeen);	f.print('\t');
+			//f.print(listSeen[i].rssiSeen);	f.print('\t');
+			f.print(listSeen[i].sfSeen);		f.print('\n');		
+	}
+	
+	f.close();
+	
 	return(1);
 }
 
@@ -460,16 +546,10 @@ int writeSeen(struct nodeSeen *listSeen) {
 // - Once every few messages, update the SPIFFS file and write the array.
 // ----------------------------------------------------------------------------
 int printSeen(struct nodeSeen *listSeen) {
-
-#if _DUSB>=1
-	if (( debug>=0 ) && ( pdebug & P_MAIN )) {
-		Serial.print(F("printSeen:: print list"));
-		Serial.println();
-	}
-#endif
     int i;
 #if _DUSB>=1
 	if (( debug>=0 ) && ( pdebug & P_MAIN )) {
+		Serial.println(F("printSeen:: "));
 		for (i=0; i<_SEENMAX; i++) {
 			if (listSeen[i].idSeen != 0) {
 				String response;
@@ -504,18 +584,16 @@ int addSeen(struct nodeSeen *listSeen, uint32_t idSeen, uint8_t sfSeen, unsigned
 	
 //	( message[4]<<24 | message[3]<<16 | message[2]<<8 | message[1] )
 	
-#if _DUSB>=1
+#if _DUSB>=2
 	if (( debug>=1 ) && ( pdebug & P_MAIN )) {
 		Serial.print(F("addSeen:: "));
 //		Serial.print(F(" listSeen[0]="));
 //		Serial.print(listSeen[0].idSeen,HEX);
 //		Serial.print(F(", "));
-		Serial.print(F("tim="));
-		Serial.print(timSeen);
-		Serial.print(F(", idSeen="));
-		Serial.print(idSeen,HEX);
-		Serial.print(F(", sfSeen="));
-		Serial.print(sfSeen,HEX);
+
+		Serial.print(F("tim="));		Serial.print(timSeen);
+		Serial.print(F(", idSeen="));	Serial.print(idSeen,HEX);
+		Serial.print(F(", sfSeen="));	Serial.print(sfSeen,HEX);
 		Serial.println();
 	}
 #endif
@@ -524,32 +602,37 @@ int addSeen(struct nodeSeen *listSeen, uint32_t idSeen, uint8_t sfSeen, unsigned
 		if ((listSeen[i].idSeen==idSeen) ||
 			(listSeen[i].idSeen==0))
 		{
+#if _DUSB>=2
+			if (( debug>=0 ) && ( pdebug & P_MAIN )) {
+				Serial.print(F("addSeen:: index="));
+				Serial.print(i);
+			}
+#endif
+			listSeen[i].idSeen = idSeen;
+			listSeen[i].sfSeen |= sfSeen;
+			listSeen[i].timSeen = timSeen;
+	
+			writeSeen(_SEENFILE, listSeen);
 			break;
 		}
 	}
 	
 	if (i>=_SEENMAX) {
 #if _DUSB>=1
-	if (( debug>=0 ) && ( pdebug & P_MAIN )) {
-		Serial.print(F("addSeen:: exit=0, index="));
-		Serial.println(i);
-	}
+		if (( debug>=0 ) && ( pdebug & P_MAIN )) {
+			Serial.print(F("addSeen:: exit=0, index="));
+			Serial.println(i);
+		}
 #endif
+
 		return(0);
 	}
-#if _DUSB>=2
-	if (( debug>=0 ) && ( pdebug & P_MAIN )) {
-		Serial.print(F("addSeen:: index="));
-		Serial.print(i);
-	}
-#endif
-	listSeen[i].idSeen = idSeen;
-	listSeen[i].sfSeen |= sfSeen;
-	listSeen[i].timSeen = timSeen;
+
 	
 	return(1);
 }
 
+
 // ----------------------------------------------------------------------------
 // initSeen
 // Init the lisrScreen array

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

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

@@ -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
-// Date: 2019-11-12	
+// Version 6.1.3
+// Date: 2019-11-20	
 //
 //
 // All rights reserved. This program and the accompanying materials

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

@@ -1,7 +1,7 @@
 // 1-channel LoRa Gateway for ESP8266
 // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg
-// Verison 6.1.1
-// Date: 2019-11-06
+// Verison 6.1.3
+// Date: 2019-11-20
 //
 // All rights reserved. This program and the accompanying materials
 // are made available under the terms of the MIT License

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

@@ -1,7 +1,7 @@
 // sensor.ino; 1-channel LoRa Gateway for ESP8266
 // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg
-// Verison 6.1.1
-// Date: 2019-11-06
+// Verison 6.1.3
+// Date: 2019-11-20
 //
 // All rights reserved. This program and the accompanying materials
 // are made available under the terms of the MIT License

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

+ 3 - 3
ESP-sc-gway/_txRx.ino

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.
@@ -600,7 +600,7 @@ int buildPacket(uint32_t tmst, uint8_t *buff_up, struct LoraUp LoraUp, bool inte
 #endif	
 
 // When we have the node address and the SF, fill the array
-// listSeen with the required data. SEENMAX must be >0 for this ro happen.
+// listSeen with the required data. SEENMAX must be >0 for this to happen.
 #if  _SEENMAX > 0
 	addSeen(listSeen, statr[0].node, statr[0].sf, now());
 #endif

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

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

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.

+ 94 - 21
ESP-sc-gway/_wwwServer.ino

@@ -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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by many people and making use of several libraries.
 //
@@ -215,7 +215,6 @@ void buttonLog()
 // --------------------------------------------------------------------------------
 void buttonSeen() 
 {
-	
 	String fn = "";
 	int i = 0;
 	
@@ -296,10 +295,25 @@ static void setVariables(const char *cmd, const char *arg) {
 		writeGwayCfg(CONFIGFILE);									// Save configuration to file
 	}
 	
+	// DELAY, write txDelay for transmissions
+	//
 	if (strcmp(cmd, "DELAY")==0) {									// Set delay usecs
 		gwayConfig.txDelay+=atoi(arg)*1000;
 		writeGwayCfg(CONFIGFILE);									// Save configuration to file
 	}
+
+	// TRUSTED, write node trusted value 
+	//
+	if (strcmp(cmd, "TRUSTED")==0) {									// Set delay usecs
+		gwayConfig.trusted=atoi(arg);
+		if (atoi(arg) == 1) {
+			gwayConfig.trusted = (gwayConfig.trusted +1)%4;
+		}	
+		else if (atoi(arg) == -1) {
+			gwayConfig.trusted = (gwayConfig.trusted -1)%4;
+		}
+		writeGwayCfg(CONFIGFILE);									// Save configuration to file
+	}
 	
 	// SF; Handle Spreading Factor Settings
 	//
@@ -527,6 +541,16 @@ static void gatewaySettings()
 	}
 	response +="</tr>";
 
+	// Trusted options, when TRUSTED_NODE is set
+#ifdef _TRUSTED_NODES
+	response +="<tr><td class=\"cell\">Trusted Nodes</td><td class=\"cell\" colspan=\"2\">"; 
+	response +=gwayConfig.trusted; 
+	response +="</td>";
+	response +="<td class=\"cell\"><a href=\"TRUSTED=-1\"><button>-</button></a></td>";
+	response +="<td class=\"cell\"><a href=\"TRUSTED=1\"><button>+</button></a></td>";
+	response +="</tr>";
+#endif
+
 	// Debugging options, only when _DUSB is set, otherwise no
 	// serial activity
 #if _DUSB>=1	
@@ -875,19 +899,28 @@ static void messageHistory()
 		
 		response += String() + "<td class=\"cell\">"; 						// Node
 		
-#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
+#ifdef  _TRUSTED_NODES														// DO nothing with TRUSTED NODES
+		switch (gwayConfig.trusted) {
+			case 0: printHEX((char *)(& (statr[i].node)),' ',response); 
+				break;
+			case 1: if (SerialName((char *)(& (statr[i].node)), response) < 0) {
+						printHEX((char *)(& (statr[i].node)),' ',response);
+					};
+				break;
+			case 2: if (SerialName((char *)(& (statr[i].node)), response) < 0) {
+						continue;
+					};
+				break;
+			case 3: // Value and we do not print unless also defined for LOCAL_SERVER
+			default:
+#if _DUSB>=1
+				Serial.println("Unknow value for gwayConfig.trusted");
+#endif			
 		}
-#else
-# error Undefined value for _TRUSTED_NODES
-#endif // _TRUSTED_NODES>=1
+		
+#else // _TRUSTED_NODES
+		printHEX((char *)(& (statr[i].node)),' ',response);
+#endif // _TRUSTED_NODES
 
 		response += "</td>";
 		
@@ -964,9 +997,28 @@ static void nodeHistory()
 			response += "</td>";
 		
 			response += String() + "<td class=\"cell\">"; 						// Node
-			if (SerialName((char *)(& (listSeen[i].idSeen)), response) < 0) {	// works with TRUSTED_NODES >= 1
-				printHEX((char *)(& (listSeen[i].idSeen)),' ',response);		// else
-			}
+#ifdef  _TRUSTED_NODES														// DO nothing with TRUSTED NODES
+			switch (gwayConfig.trusted) {
+				case 0: printHEX((char *)(& (listSeen[i].idSeen)),' ',response); 
+					break;
+				case 1: if (SerialName((char *)(& (listSeen[i].idSeen)), response) < 0) {
+							printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
+						};
+					break;
+				case 2: if (SerialName((char *)(& (listSeen[i].idSeen)), response) < 0) {
+							continue;
+						};
+					break;
+				case 3: // Value 3 and we do not print unless also defined for LOCAL_SERVER
+				default:
+#if _DUSB>=1
+					Serial.println("Unknow value for gwayConfig.trusted");
+#endif			
+			}	
+#else // _TRUSTED_NODES
+			printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
+#endif // _TRUSTED_NODES
+			
 			response += "</td>";
 
 			response += String() + "<td class=\"cell\">" + 0 + "</td>";			// Channel
@@ -977,7 +1029,7 @@ static void nodeHistory()
 		}
 		server.sendContent("</table>");
 	}
-#endif
+#endif //_SEENMAX
 } // nodeHistory()
 
 
@@ -1050,9 +1102,10 @@ void setupWWW()
 	server.on("/FORMAT", []() {
 		Serial.print(F("FORMAT ..."));
 		
-		SPIFFS.format();								// Normally disabled. Enable only when SPIFFS corrupt
+		SPIFFS.format();							// Normally disabled. Enable only when SPIFFS corrupt
 		initConfig(&gwayConfig);
 		writeConfig( CONFIGFILE, &gwayConfig);
+		writeSeen( _SEENFILE, listSeen);			// Write the last time record  is seen
 #if _DUSB>=1
 		Serial.println(F("DONE"));
 #endif
@@ -1226,6 +1279,25 @@ void setupWWW()
 		server.send ( 302, "text/plain", "");
 	});
 
+	// Set Trusted Node Parameter
+	server.on("/TRUSTED=1", []() {
+	gwayConfig.trusted = (gwayConfig.trusted +1)%4;
+		writeGwayCfg(CONFIGFILE);				// Save configuration to file
+#if _DUSB>=2
+		Serial.println(F("TRUSTED +, config written"));
+#endif
+		server.sendHeader("Location", String("/"), true);
+		server.send ( 302, "text/plain", "");
+	});
+	server.on("/TRUSTED=-1", []() {
+		gwayConfig.trusted = (gwayConfig.trusted -1)%4;
+		writeGwayCfg(CONFIGFILE);				// Save configuration to file
+#if _DUSB>=2
+		Serial.println(F("TRUSTED +, config written"));
+#endif
+		server.sendHeader("Location", String("/"), true);
+		server.send ( 302, "text/plain", "");
+	});
 
 	// Spreading Factor setting
 	server.on("/SF=1", []() {
@@ -1378,8 +1450,9 @@ void setupWWW()
 	// Display the SEEN statistics
 	server.on("/SEEN", []() {
 		server.sendHeader("Location", String("/"), true);
-#if _DUSB>=2
+#if _DUSB>=1
 		Serial.println(F("SEEN button"));
+		printSeen(listSeen);
 #endif
 		buttonSeen();
 		server.send ( 302, "text/plain", "");

+ 2 - 2
ESP-sc-gway/configNode.h

@@ -1,7 +1,7 @@
 // sensor.h; 1-channel LoRa Gateway for ESP8266
 // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
-// Version 6.1.1
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 // and many other contributors.

+ 13 - 9
ESP-sc-gway/loraFiles.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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.
@@ -50,6 +50,10 @@
 // when settings are changed.
 
 struct espGwayConfig {
+
+	int32_t txDelay;			// Init 0 at setup
+	uint32_t ntpErrTime;		// Record the time of the last NTP error
+
 	uint16_t fcnt;				// =0 as init value	XXX Could be 32 bit in size
 	uint16_t boots;				// Number of restarts made by the gateway after reset
 	uint16_t resets;			// Number of statistics resets
@@ -58,17 +62,17 @@ struct espGwayConfig {
 	uint16_t reents;			// Number of re-entrant interrupt handler calls
 	uint16_t ntpErr;			// Number of UTP requests that failed
 	uint16_t ntps;
-
-	int32_t txDelay;			// Init 0 at setup
-	uint32_t ntpErrTime;		// Record the time of the last NTP error
+	uint16_t logFileRec;		// Logging File Record number
+	uint16_t logFileNo;			// Logging File Number
+	uint16_t logFileNum;		// Number of log files
+	
 	uint8_t ch;					// index to freqs array, freqs[ifreq]=868100000 default
 	uint8_t sf;					// range from SF7 to SF12
 	uint8_t debug;				// range 0 to 4
 	uint8_t pdebug;				// pattern debug, 
+	uint8_t trusted;				// pattern debug, 
+
 
-	uint16_t logFileRec;		// Logging File Record number
-	uint16_t logFileNo;			// Logging File Number
-	uint16_t logFileNum;		// Number of log files
 	
 	bool cad;					// is CAD enabled?
 	bool hop;					// Is HOP enabled (Note: default be disabled)
@@ -106,9 +110,9 @@ struct espGwayConfig {
 #define nFSK	0x80
 
 struct nodeSeen {
+	unsigned long timSeen;
 	uint32_t idSeen;
 	uint8_t sfSeen;
-	unsigned long timSeen;
 };
 struct nodeSeen listSeen[_SEENMAX];
 

+ 2 - 2
ESP-sc-gway/loraModem.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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many other contributors.

+ 2 - 2
ESP-sc-gway/oLED.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
-// Date: 2019-11-06
+// Version 6.1.3
+// Date: 2019-11-20
 //
 // based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 // and many others.

+ 2 - 2
README.md

@@ -1,7 +1,7 @@
 # Single Channel LoRaWAN Gateway
 
-Version 6.1.1, 
-Data: November 6, 2019  
+Version 6.1.3, 
+Data: November 20, 2019  
 Author: M. Westenberg (mw12554@hotmail.com)  
 Copyright: M. Westenberg (mw12554@hotmail.com)