Selaa lähdekoodia

Version 6.1.4

platenspeler 5 vuotta sitten
vanhempi
commit
acf49f51ab

+ 3 - 1
CHANGELOG.md

@@ -19,10 +19,12 @@ Maintained by Maarten Westenberg (mw12554@hotmail.com)
 Features release 6.1.4 (November 29, 2019)
 - Compacting Code and Solve Errors
 - Look at _DUSB define and add to Serial.print directive where not found
+- Renewed the GPS functions, changed "Serial1" to "sGps" to avoid double definitions.
+- Downloaded TinyGPS++ library. All working on my T-Beam again.
 
 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 the value of trusted nodes in "Gateways Settings" has value  2. 
+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.

+ 1 - 1
ESP-sc-gway/ESP-sc-gway.ino

@@ -1,5 +1,5 @@
 // 1-channel LoRa Gateway for ESP8266
-// Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
+// Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg
 // Version 6.1.4
 // Date: 2019-11-29
 // Author: Maarten Westenberg (mw12554@hotmail.com)

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

+ 16 - 27
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.3		
-// Date: 2019-11-20	
+// Version 6.1.4		
+// Date: 2019-11-29	
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.
@@ -486,9 +486,9 @@ int readSeen(const char *fn, struct nodeSeen *listSeen) {
 #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('\t'); listSeen[i].idSeen = (uint32_t) val.toInt();
+		val=f.readStringUntil('\t'); listSeen[i].cntSeen = (uint32_t) val.toInt();
+		val=f.readStringUntil('\t'); listSeen[i].chnSeen = (uint8_t) val.toInt();
 		val=f.readStringUntil('\n'); listSeen[i].sfSeen = (uint8_t) val.toInt();
 	}
 	f.close();
@@ -531,7 +531,8 @@ int writeSeen(const char *fn, struct nodeSeen *listSeen) {
 			// 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].cntSeen);		f.print('\t');
+			f.print(listSeen[i].chnSeen);		f.print('\t');
 			//f.print(listSeen[i].rssiSeen);	f.print('\t');
 			f.print(listSeen[i].sfSeen);		f.print('\n');		
 	}
@@ -579,27 +580,13 @@ int printSeen(struct nodeSeen *listSeen) {
 //	message. If not, create new record.
 // - With this record, update the SF settings
 // ----------------------------------------------------------------------------
-int addSeen(struct nodeSeen *listSeen, uint32_t idSeen, uint8_t sfSeen, unsigned long timSeen) {
+int addSeen(struct nodeSeen *listSeen, struct stat_t stat) {
 	int i;
 	
 //	( message[4]<<24 | message[3]<<16 | message[2]<<8 | message[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.println();
-	}
-#endif
 
 	for (i=0; i< _SEENMAX; i++) {
-		if ((listSeen[i].idSeen==idSeen) ||
+		if ((listSeen[i].idSeen==stat.node) ||
 			(listSeen[i].idSeen==0))
 		{
 #if _DUSB>=2
@@ -608,9 +595,11 @@ int addSeen(struct nodeSeen *listSeen, uint32_t idSeen, uint8_t sfSeen, unsigned
 				Serial.print(i);
 			}
 #endif
-			listSeen[i].idSeen = idSeen;
-			listSeen[i].sfSeen |= sfSeen;
-			listSeen[i].timSeen = timSeen;
+			listSeen[i].idSeen = stat.node;
+			listSeen[i].chnSeen = stat.ch;
+			listSeen[i].sfSeen |= stat.sf;			// Or the argument
+			listSeen[i].timSeen = stat.tmst;
+			listSeen[i].cntSeen++;					// Not included on functiin paras
 	
 			writeSeen(_SEENFILE, listSeen);
 			break;
@@ -624,11 +613,9 @@ int addSeen(struct nodeSeen *listSeen, uint32_t idSeen, uint8_t sfSeen, unsigned
 			Serial.println(i);
 		}
 #endif
-
 		return(0);
 	}
 
-	
 	return(1);
 }
 
@@ -642,6 +629,8 @@ int initSeen(struct nodeSeen *listSeen) {
 	for (i=0; i< _SEENMAX; i++) {
 		listSeen[i].idSeen=0;
 		listSeen[i].sfSeen=0;
+		listSeen[i].cntSeen=0;
+		listSeen[i].chnSeen=0;
 		listSeen[i].timSeen=0;
 	}
 	return(1);

+ 7 - 7
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.3
-// Date: 2019-11-20
+// Version 6.1.4
+// Date: 2019-11-29
 //
 // 	based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
 //	and many others.
@@ -1042,11 +1042,11 @@ void initLoraModem(
 #if _DUSB>=1
 		Serial.print(F("Unknown transceiver="));
 		Serial.print(version,HEX);
-		Serial.print(F(", pins.rst =")); Serial.print(pins.rst);
-		Serial.print(F(", pins.ss  =")); Serial.print(pins.ss);
-		Serial.print(F(", pins.dio0 =")); Serial.print(pins.dio0);
-		Serial.print(F(", pins.dio1 =")); Serial.print(pins.dio1);
-		Serial.print(F(", pins.dio2 =")); Serial.print(pins.dio2);
+		Serial.print(F(", pins.rst ="));	Serial.print(pins.rst);
+		Serial.print(F(", pins.ss  ="));	Serial.print(pins.ss);
+		Serial.print(F(", pins.dio0 ="));	Serial.print(pins.dio0);
+		Serial.print(F(", pins.dio1 ="));	Serial.print(pins.dio1);
+		Serial.print(F(", pins.dio2 ="));	Serial.print(pins.dio2);
 		Serial.println();
 		Serial.flush();
 #endif

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

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

@@ -511,7 +511,7 @@ void stateMachine()
 		// coming on this frequency so we wait on CDECT.
 		//
 		else if (intr == 0x00) {
-#if _DUSB>=0
+#if _DUSB>=1
 			if (( debug>=3 ) && ( pdebug & P_CAD )) {
 				Serial.println("Err CAD:: intr is 0x00");
 			}

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

@@ -337,10 +337,10 @@ int buildPacket(uint32_t tmst, uint8_t *buff_up, struct LoraUp LoraUp, bool inte
 	statr[0].tmst = now();
 	statr[0].ch= ifreq;
 	statr[0].prssi = prssi - rssicorr;
+	statr[0].sf = LoraUp.sf;
 #if RSSI==1
 	statr[0].rssi = _rssi - rssicorr;
 #endif // RSII
-	statr[0].sf = LoraUp.sf;
 #if _DUSB>=2
 	if (debug>=0) {
 		if ((message[4] != 0x26) || (message[1]==0x99)) {
@@ -602,7 +602,7 @@ int buildPacket(uint32_t tmst, uint8_t *buff_up, struct LoraUp LoraUp, bool inte
 // When we have the node address and the SF, fill the array
 // 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());
+	addSeen(listSeen, statr[0] );
 #endif
 	
 #if _DUSB>=1

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

@@ -211,7 +211,7 @@ void buttonLog()
 // BUTTONSEEN
 // List the listSeen array.
 // Read the logfiles and display info about nodes (last seend, SF used etc).
-// This is a button on the top of the GUI screen
+// This is a button on the top of the USB GUI screen
 // --------------------------------------------------------------------------------
 void buttonSeen() 
 {
@@ -916,6 +916,7 @@ static void messageHistory()
 #if _DUSB>=1
 				Serial.println("Unknow value for gwayConfig.trusted");
 #endif			
+				break;
 		}
 		
 #else // _TRUSTED_NODES
@@ -976,6 +977,7 @@ static void nodeHistory()
 		response += "<tr>";
 		response += "<th class=\"thead\" style=\"width: 220px;\">Time</th>";
 		response += "<th class=\"thead\">Node</th>";
+		response += "<th class=\"thead\">Count</th>";
 //#if _LOCALSERVER==1
 //		response += "<th class=\"thead\">Data</th>";
 //#endif
@@ -1013,17 +1015,20 @@ static void nodeHistory()
 				default:
 #if _DUSB>=1
 					Serial.println("Unknow value for gwayConfig.trusted");
-#endif			
+#endif
+					break;
 			}	
 #else // _TRUSTED_NODES
 			printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
 #endif // _TRUSTED_NODES
 			
 			response += "</td>";
+			
+			response += String() + "<td class=\"cell\">" + listSeen[i].cntSeen + "</td>";			// Counter		
 
-			response += String() + "<td class=\"cell\">" + 0 + "</td>";			// Channel
+			response += String() + "<td class=\"cell\">" + listSeen[i].chnSeen + "</td>";								// Channel
 			
-			response += String() + "<td class=\"cell\">" + listSeen[i].sfSeen + "</td>";
+			response += String() + "<td class=\"cell\">" + listSeen[i].sfSeen + "</td>";			// SF
 			
 			server.sendContent(response);
 		}
@@ -1314,7 +1319,7 @@ void setupWWW()
 	// Set Frequency of the GateWay node
 	server.on("/FREQ=1", []() {
 		uint8_t nf = sizeof(freqs)/sizeof(freqs[0]);	// Number of elements in array
-#if _DUSB==2
+#if _DUSB>=2
 		Serial.print("FREQ==1:: For freq[0] sizeof vector=");
 		Serial.print(sizeof(freqs[0]));
 		Serial.println();

+ 18 - 8
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.4 E EU868
-// Date: 2019-11-25
+// Date: 2019-11-29
 //
 // 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.
@@ -31,7 +31,7 @@
 
 // Specify the correct version and date of your gateway here.
 // Normally it is provided with teh GitHub version
-#define VERSION "V.6.1.4.E.EU868; 191125a"
+#define VERSION "V.6.1.4.E.EU868; 191129a"
 
 // This value of DEBUG determines whether some parts of code get compiled.
 // Also this is the initial value of debug parameter. 
@@ -54,9 +54,18 @@
 #define _SPIFF_FORMAT 0
 
 
-// Define the frequency band the gateway will listen on. Valid options are
-// EU863_870 (Europe), US902_928 (North America) & AU925_928 (Australia), CN470_510 (China).
+// Define the frequency band the gateway will listen on. Valid options are:
+// EU863_870	Europe 
+// US902_928	North America
+// AU925_928	Australia
+// CN470_510	China
+// IN865_867	India
+// CN779-787	(Not Used!)
+// EU433		Europe
+// AS923		(Not Used)
 // See https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html
+// You can find the definitions in "loraModem.h" and frequencies in
+
 #define EU863_870 1
  
  
@@ -114,7 +123,7 @@
 //	4: ESP32 TTGO pinning (should work for 433 and OLED too).
 //	5: ESP32 TTGO EU868/EU433 MHz with OLED
 //	6: Other, define your own in loraModem.h
-#define _PIN_OUT 5
+#define _PIN_OUT 4
 
 // Gather statistics on sensor and Wifi status
 // 0= No statistics
@@ -228,6 +237,7 @@
 
 // lora sensor code definitions
 // Defines whether the gateway will also report sensor/status value on MQTT
+// such as GPS, battery or temperature.
 // after all, a gateway can be a node to the system as well. Some sensors like GPS can be
 // sent to the backend as a parameter, some (like humidity for example) can only be sent
 // as a regular sensor value.
@@ -238,7 +248,7 @@
 
 
 // We can put the gateway in such a mode that it will (only) recognize
-// nodes that are put in a list of trusted nodes 
+// 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)
@@ -266,8 +276,8 @@
 //	- 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
+// The initial version _NUMMAX stores max this many nodes, please 
+// "define _SEENMAX 0" when not used
 #define _SEENMAX 25
 #define _SEENFILE "/gwayNum.txt"
 

+ 2 - 0
ESP-sc-gway/loraFiles.h

@@ -112,6 +112,8 @@ struct espGwayConfig {
 struct nodeSeen {
 	unsigned long timSeen;
 	uint32_t idSeen;
+	uint32_t cntSeen;
+	uint8_t chnSeen;
 	uint8_t sfSeen;
 };
 struct nodeSeen listSeen[_SEENMAX];

+ 1 - 1
README.md

@@ -93,6 +93,7 @@ can be loaded through this library section. Some cannot and are shipped with the
 - WifiManager (Version 0.12.0 by Tzapu)
 - LoRaCode (Version 1.0.0, see library shipped)
 - gBase64 (changed name from Adam Rudd's Base64 version)
+- TinyGPS++ (Version 1.0.0)
 
 Through Library Manager:
 
@@ -104,7 +105,6 @@ Through Library Manager:
 - Streaming (Version 5.0.0)
 - Ticker (Version 1.1.0)
 - Time (Version 1.5.0)
-- TinyGPS++ (Version 1.0.0)
 - Update (Version 1.0.0)
 - Webserver (Version 1.0.0)
 - WiFiClientSecure (Version 1.0.0)

+ 4 - 4
TODO.md

@@ -1,6 +1,6 @@
 # Single Channel LoRaWAN Gateway
 
-Version 6.1.2, November 14, 2019	  
+Last Updated: November 25, 2019	  
 Author: M. Westenberg (mw12554@hotmail.com)  
 Copyright: M. Westenberg (mw12554@hotmail.com)  
 
@@ -16,12 +16,12 @@ Maintained by Maarten Westenberg (mw12554@hotmail.com)
 
 # ToDo Functions
 
-Features not in release 6.1.2 
+Features not in release 6.1.4
 
 - Support FSK
 - Support for eu433 frequencies
-- Better testeing for uplink functions
-- Get HOP functions to work on yhree frequencies
+- Testing and timing of downlink functions (quiet area)
+- Get HOP functions to work on three frequencies