commit
						1ce7cef126
					
				
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @ -171,7 +171,7 @@ Output of sensor and peripheral data is internally switched by a bitmask registe | ||||
| 
 | ||||
| | Bit | Sensordata    | Default | ||||
| | --- | ------------- | ------- | ||||
| | 0   | GPS           | on* | ||||
| | 0   | GPS*          | on | ||||
| | 1   | Beacon alarm  | on | ||||
| | 2   | BME280/680    | on | ||||
| | 3   | Paxcounter    | on | ||||
| @ -213,6 +213,12 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering. | ||||
| [**packed_decoder.js**](src/TTN/packed_decoder.js) | | ||||
| [**packed_converter.js**](src/TTN/packed_converter.js) | ||||
| 
 | ||||
| # mobile PaxCounter via https://opensensemap.org/ | ||||
| This describes how to set up a mobile PaxCounter: | ||||
| Follow all steps so far for preparing the device, use the packed payload format. In paxcounter.conf set PAYLOAD_OPENSENSEBOX to 1. Register a new sensbox on https://opensensemap.org/. | ||||
| There in the sensor configuration select "TheThingsNetwork" and set Decoding Profil to "LoRa serialization", enter your TTN Application and Device Id. Decoding option has to be | ||||
| 	[{"decoder":"latLng"},{"decoder":"uint16","sensor_id":"yoursensorid"}]  | ||||
| 
 | ||||
| 
 | ||||
| **Port #1:** Paxcount data | ||||
| 
 | ||||
| @ -308,7 +314,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts. | ||||
| 0x03 set GPS data on/off | ||||
| 
 | ||||
| 	0 = GPS data off | ||||
| 	1 = GPS data on, sends GPS data on port 4, if GPS is present and has a fix [default] | ||||
| 	1 = GPS data on, sends GPS data on port 4 (default, use port 1 for mobile pax counter), if GPS is present and has a fix | ||||
| 
 | ||||
| 0x04 set display on/off | ||||
| 
 | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| 
 | ||||
| ; ---> SELECT THE TARGET PLATFORM HERE! <--- | ||||
| [board] | ||||
| ;halfile = generic.h | ||||
| halfile = generic.h | ||||
| ;halfile = ebox.h | ||||
| ;halfile = eboxtube.h | ||||
| ;halfile = ecopower.h | ||||
| @ -18,7 +18,7 @@ | ||||
| ;halfile = ttgov21old.h | ||||
| ;halfile = ttgov21new.h | ||||
| ;halfile = ttgofox.h | ||||
| halfile = ttgobeam.h | ||||
| ;halfile = ttgobeam.h | ||||
| ;halfile = ttgobeam10.h | ||||
| ;halfile = fipy.h | ||||
| ;halfile = lopy.h | ||||
|  | ||||
| @ -18,6 +18,14 @@ function Decoder(bytes, port) { | ||||
|         if (bytes.length === 4) { | ||||
|             return decode(bytes, [uint16, uint16], ['wifi', 'ble']); | ||||
|         } | ||||
|         // combined wifi counter and gps data, used by https://opensensemap.org
 | ||||
|         if (bytes.length === 10) { | ||||
|             return decode(bytes, [latLng, latLng, uint16], ['latitude', 'longitude', 'wifi']); | ||||
|         } | ||||
|         // combined wifi + ble counter and gps data, used by https://opensensemap.org
 | ||||
|         if (bytes.length === 12) { | ||||
|             return decode(bytes, [latLng, latLng, uint16, uint16], ['latitude', 'longitude', 'wifi', 'ble']); | ||||
|         } | ||||
|         // combined wifi counter and gps data
 | ||||
|         if (bytes.length === 15) { | ||||
|             return decode(bytes, [uint16, latLng, latLng, uint8, hdop, altitude], ['wifi', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']); | ||||
| @ -42,8 +50,12 @@ function Decoder(bytes, port) { | ||||
| 
 | ||||
|     if (port === 4) { | ||||
|         // gps data      
 | ||||
|         if (bytes.length === 8) { | ||||
|             return decode(bytes, [latLng, latLng], ['latitude', 'longitude']); | ||||
|         } else { | ||||
|             return decode(bytes, [latLng, latLng, uint8, hdop, altitude], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (port === 5) { | ||||
|         // button pressed      
 | ||||
|  | ||||
| @ -9,9 +9,9 @@ nvs_handle my_handle; | ||||
| esp_err_t err; | ||||
| 
 | ||||
| #define PAYLOADMASK                                  \ | ||||
|   (ALARM_DATA | MEMS_DATA | COUNT_DATA | GPS_DATA | SENSOR1_DATA |             \ | ||||
|    SENSOR2_DATA | SENSOR3_DATA) &                                              \ | ||||
|       (~BATT_DATA) | ||||
|   ((GPS_DATA | ALARM_DATA | MEMS_DATA | COUNT_DATA | \ | ||||
|     SENSOR1_DATA | SENSOR2_DATA | SENSOR3_DATA) &    \ | ||||
|    (~BATT_DATA) ) | ||||
| 
 | ||||
| // populate cfg vars with factory settings
 | ||||
| void defaultConfig() { | ||||
|  | ||||
| @ -47,6 +47,7 @@ | ||||
| #define MEM_LOW                         2048    // [Bytes] low memory threshold triggering a send cycle | ||||
| #define RETRANSMIT_RCMD                 5       // [seconds] wait time before retransmitting rcommand results | ||||
| #define PAYLOAD_BUFFER_SIZE             51      // maximum size of payload block per transmit | ||||
| #define PAYLOAD_OPENSENSEBOX            0       // send payload compatible to sensebox.de (swap geo position and pax data) | ||||
| #define LORADRDEFAULT                   5       // 0 .. 15, LoRaWAN datarate, according to regional LoRaWAN specs [default = 5] | ||||
| #define LORATXPOWDEFAULT                14      // 0 .. 255, LoRaWAN TX power in dBm [default = 14] | ||||
| #define MAXLORARETRY                    500     // maximum count of TX retries if LoRa busy | ||||
| @ -92,7 +93,7 @@ | ||||
| #define RCMDPORT                        2       // remote commands | ||||
| #define STATUSPORT                      2       // remote command results | ||||
| #define CONFIGPORT                      3       // config query results | ||||
| #define GPSPORT                         4       // gps - set to 1 to send combined GPS+COUNT payload | ||||
| #define GPSPORT                         4       // gps - set to 1 to send combined GPS+COUNTERPORT payload   | ||||
| #define BUTTONPORT                      5       // button pressed signal | ||||
| #define BEACONPORT                      6       // beacon alarms | ||||
| #define BMEPORT                         7       // BME680 sensor | ||||
|  | ||||
| @ -89,12 +89,14 @@ void PayloadConvert::addGPS(gpsStatus_t value) { | ||||
|   buffer[cursor++] = (byte)((value.longitude & 0x00FF0000) >> 16); | ||||
|   buffer[cursor++] = (byte)((value.longitude & 0x0000FF00) >> 8); | ||||
|   buffer[cursor++] = (byte)((value.longitude & 0x000000FF)); | ||||
| #if (!PAYLOAD_OPENSENSEBOX) | ||||
|   buffer[cursor++] = value.satellites; | ||||
|   buffer[cursor++] = highByte(value.hdop); | ||||
|   buffer[cursor++] = lowByte(value.hdop); | ||||
|   buffer[cursor++] = highByte(value.altitude); | ||||
|   buffer[cursor++] = lowByte(value.altitude); | ||||
| #endif | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| void PayloadConvert::addSensor(uint8_t buf[]) { | ||||
| @ -193,10 +195,12 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp, | ||||
| void PayloadConvert::addGPS(gpsStatus_t value) { | ||||
| #if(HAS_GPS) | ||||
|   writeLatLng(value.latitude, value.longitude); | ||||
| #if (!PAYLOAD_OPENSENSEBOX) | ||||
|   writeUint8(value.satellites); | ||||
|   writeUint16(value.hdop); | ||||
|   writeUint16(value.altitude); | ||||
| #endif | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| void PayloadConvert::addSensor(uint8_t buf[]) { | ||||
|  | ||||
| @ -58,6 +58,7 @@ void sendData() { | ||||
| 
 | ||||
|   uint8_t bitmask = cfg.payloadmask; | ||||
|   uint8_t mask = 1; | ||||
|   gpsStatus_t gps_status; | ||||
| 
 | ||||
|   while (bitmask) { | ||||
|     switch (bitmask & mask) { | ||||
| @ -65,21 +66,28 @@ void sendData() { | ||||
| #if ((WIFICOUNTER) || (BLECOUNTER)) | ||||
|     case COUNT_DATA: | ||||
|       payload.reset(); | ||||
| #if !(PAYLOAD_OPENSENSEBOX) | ||||
|       if (cfg.wifiscan) | ||||
|         payload.addCount(macs_wifi, MAC_SNIFF_WIFI); | ||||
|       if (cfg.blescan) | ||||
|         payload.addCount(macs_ble, MAC_SNIFF_BLE); | ||||
| 
 | ||||
| #if (HAS_GPS) && (GPSPORT == 1) | ||||
| #endif | ||||
| #if (HAS_GPS)  | ||||
|       if (GPSPORT == COUNTERPORT) { | ||||
|         // send GPS position only if we have a fix
 | ||||
|         if (gps.location.isValid()) { | ||||
|         gpsStatus_t gps_status; | ||||
|           gps_storelocation(&gps_status); | ||||
|           payload.addGPS(gps_status); | ||||
|         } else | ||||
|           ESP_LOGD(TAG, "No valid GPS position"); | ||||
|       } | ||||
| #endif | ||||
| #if (PAYLOAD_OPENSENSEBOX)       | ||||
|       if (cfg.wifiscan) | ||||
|         payload.addCount(macs_wifi, MAC_SNIFF_WIFI); | ||||
|       if (cfg.blescan) | ||||
|         payload.addCount(macs_ble, MAC_SNIFF_BLE); | ||||
| #endif | ||||
| 
 | ||||
|       SendPayload(COUNTERPORT, prio_normal); | ||||
|       // clear counter if not in cumulative counter mode
 | ||||
|       if (cfg.countermode != 1) { | ||||
| @ -102,17 +110,18 @@ void sendData() { | ||||
|       break; | ||||
| #endif | ||||
| 
 | ||||
| #if (HAS_GPS) && (GPSPORT != 1) | ||||
| #if (HAS_GPS)  | ||||
|     case GPS_DATA: | ||||
|       if (GPSPORT != COUNTERPORT) { | ||||
|         // send GPS position only if we have a fix
 | ||||
|         if (gps.location.isValid()) { | ||||
|         gpsStatus_t gps_status; | ||||
|           gps_storelocation(&gps_status); | ||||
|           payload.reset(); | ||||
|           payload.addGPS(gps_status); | ||||
|           SendPayload(GPSPORT, prio_high); | ||||
|         } else | ||||
|           ESP_LOGD(TAG, "No valid GPS position"); | ||||
|       } | ||||
|       break; | ||||
| #endif | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user