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
|
| Bit | Sensordata | Default
|
||||||
| --- | ------------- | -------
|
| --- | ------------- | -------
|
||||||
| 0 | GPS | on*
|
| 0 | GPS* | on
|
||||||
| 1 | Beacon alarm | on
|
| 1 | Beacon alarm | on
|
||||||
| 2 | BME280/680 | on
|
| 2 | BME280/680 | on
|
||||||
| 3 | Paxcounter | 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_decoder.js**](src/TTN/packed_decoder.js) |
|
||||||
[**packed_converter.js**](src/TTN/packed_converter.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
|
**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
|
0x03 set GPS data on/off
|
||||||
|
|
||||||
0 = GPS data 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
|
0x04 set display on/off
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
||||||
[board]
|
[board]
|
||||||
;halfile = generic.h
|
halfile = generic.h
|
||||||
;halfile = ebox.h
|
;halfile = ebox.h
|
||||||
;halfile = eboxtube.h
|
;halfile = eboxtube.h
|
||||||
;halfile = ecopower.h
|
;halfile = ecopower.h
|
||||||
@ -18,7 +18,7 @@
|
|||||||
;halfile = ttgov21old.h
|
;halfile = ttgov21old.h
|
||||||
;halfile = ttgov21new.h
|
;halfile = ttgov21new.h
|
||||||
;halfile = ttgofox.h
|
;halfile = ttgofox.h
|
||||||
halfile = ttgobeam.h
|
;halfile = ttgobeam.h
|
||||||
;halfile = ttgobeam10.h
|
;halfile = ttgobeam10.h
|
||||||
;halfile = fipy.h
|
;halfile = fipy.h
|
||||||
;halfile = lopy.h
|
;halfile = lopy.h
|
||||||
|
@ -18,6 +18,14 @@ function Decoder(bytes, port) {
|
|||||||
if (bytes.length === 4) {
|
if (bytes.length === 4) {
|
||||||
return decode(bytes, [uint16, uint16], ['wifi', 'ble']);
|
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
|
// combined wifi counter and gps data
|
||||||
if (bytes.length === 15) {
|
if (bytes.length === 15) {
|
||||||
return decode(bytes, [uint16, latLng, latLng, uint8, hdop, altitude], ['wifi', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
return decode(bytes, [uint16, latLng, latLng, uint8, hdop, altitude], ['wifi', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
||||||
@ -42,7 +50,11 @@ function Decoder(bytes, port) {
|
|||||||
|
|
||||||
if (port === 4) {
|
if (port === 4) {
|
||||||
// gps data
|
// gps data
|
||||||
return decode(bytes, [latLng, latLng, uint8, hdop, altitude], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
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) {
|
if (port === 5) {
|
||||||
|
@ -8,10 +8,10 @@ static const char TAG[] = "flash";
|
|||||||
nvs_handle my_handle;
|
nvs_handle my_handle;
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
|
|
||||||
#define PAYLOADMASK \
|
#define PAYLOADMASK \
|
||||||
(ALARM_DATA | MEMS_DATA | COUNT_DATA | GPS_DATA | SENSOR1_DATA | \
|
((GPS_DATA | ALARM_DATA | MEMS_DATA | COUNT_DATA | \
|
||||||
SENSOR2_DATA | SENSOR3_DATA) & \
|
SENSOR1_DATA | SENSOR2_DATA | SENSOR3_DATA) & \
|
||||||
(~BATT_DATA)
|
(~BATT_DATA) )
|
||||||
|
|
||||||
// populate cfg vars with factory settings
|
// populate cfg vars with factory settings
|
||||||
void defaultConfig() {
|
void defaultConfig() {
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle
|
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle
|
||||||
#define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results
|
#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_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 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 LORATXPOWDEFAULT 14 // 0 .. 255, LoRaWAN TX power in dBm [default = 14]
|
||||||
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
|
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
|
||||||
@ -92,7 +93,7 @@
|
|||||||
#define RCMDPORT 2 // remote commands
|
#define RCMDPORT 2 // remote commands
|
||||||
#define STATUSPORT 2 // remote command results
|
#define STATUSPORT 2 // remote command results
|
||||||
#define CONFIGPORT 3 // config query 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 BUTTONPORT 5 // button pressed signal
|
||||||
#define BEACONPORT 6 // beacon alarms
|
#define BEACONPORT 6 // beacon alarms
|
||||||
#define BMEPORT 7 // BME680 sensor
|
#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 & 0x00FF0000) >> 16);
|
||||||
buffer[cursor++] = (byte)((value.longitude & 0x0000FF00) >> 8);
|
buffer[cursor++] = (byte)((value.longitude & 0x0000FF00) >> 8);
|
||||||
buffer[cursor++] = (byte)((value.longitude & 0x000000FF));
|
buffer[cursor++] = (byte)((value.longitude & 0x000000FF));
|
||||||
|
#if (!PAYLOAD_OPENSENSEBOX)
|
||||||
buffer[cursor++] = value.satellites;
|
buffer[cursor++] = value.satellites;
|
||||||
buffer[cursor++] = highByte(value.hdop);
|
buffer[cursor++] = highByte(value.hdop);
|
||||||
buffer[cursor++] = lowByte(value.hdop);
|
buffer[cursor++] = lowByte(value.hdop);
|
||||||
buffer[cursor++] = highByte(value.altitude);
|
buffer[cursor++] = highByte(value.altitude);
|
||||||
buffer[cursor++] = lowByte(value.altitude);
|
buffer[cursor++] = lowByte(value.altitude);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayloadConvert::addSensor(uint8_t buf[]) {
|
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) {
|
void PayloadConvert::addGPS(gpsStatus_t value) {
|
||||||
#if(HAS_GPS)
|
#if(HAS_GPS)
|
||||||
writeLatLng(value.latitude, value.longitude);
|
writeLatLng(value.latitude, value.longitude);
|
||||||
|
#if (!PAYLOAD_OPENSENSEBOX)
|
||||||
writeUint8(value.satellites);
|
writeUint8(value.satellites);
|
||||||
writeUint16(value.hdop);
|
writeUint16(value.hdop);
|
||||||
writeUint16(value.altitude);
|
writeUint16(value.altitude);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayloadConvert::addSensor(uint8_t buf[]) {
|
void PayloadConvert::addSensor(uint8_t buf[]) {
|
||||||
|
@ -58,6 +58,7 @@ void sendData() {
|
|||||||
|
|
||||||
uint8_t bitmask = cfg.payloadmask;
|
uint8_t bitmask = cfg.payloadmask;
|
||||||
uint8_t mask = 1;
|
uint8_t mask = 1;
|
||||||
|
gpsStatus_t gps_status;
|
||||||
|
|
||||||
while (bitmask) {
|
while (bitmask) {
|
||||||
switch (bitmask & mask) {
|
switch (bitmask & mask) {
|
||||||
@ -65,21 +66,28 @@ void sendData() {
|
|||||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||||
case COUNT_DATA:
|
case COUNT_DATA:
|
||||||
payload.reset();
|
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);
|
||||||
|
#endif
|
||||||
|
#if (HAS_GPS)
|
||||||
|
if (GPSPORT == COUNTERPORT) {
|
||||||
|
// send GPS position only if we have a fix
|
||||||
|
if (gps.location.isValid()) {
|
||||||
|
gps_storelocation(&gps_status);
|
||||||
|
payload.addGPS(gps_status);
|
||||||
|
} else
|
||||||
|
ESP_LOGD(TAG, "No valid GPS position");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if (PAYLOAD_OPENSENSEBOX)
|
||||||
if (cfg.wifiscan)
|
if (cfg.wifiscan)
|
||||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||||
if (cfg.blescan)
|
if (cfg.blescan)
|
||||||
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
||||||
|
|
||||||
#if (HAS_GPS) && (GPSPORT == 1)
|
|
||||||
// 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
|
#endif
|
||||||
|
|
||||||
SendPayload(COUNTERPORT, prio_normal);
|
SendPayload(COUNTERPORT, prio_normal);
|
||||||
// clear counter if not in cumulative counter mode
|
// clear counter if not in cumulative counter mode
|
||||||
if (cfg.countermode != 1) {
|
if (cfg.countermode != 1) {
|
||||||
@ -102,17 +110,18 @@ void sendData() {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (HAS_GPS) && (GPSPORT != 1)
|
#if (HAS_GPS)
|
||||||
case GPS_DATA:
|
case GPS_DATA:
|
||||||
// send GPS position only if we have a fix
|
if (GPSPORT != COUNTERPORT) {
|
||||||
if (gps.location.isValid()) {
|
// send GPS position only if we have a fix
|
||||||
gpsStatus_t gps_status;
|
if (gps.location.isValid()) {
|
||||||
gps_storelocation(&gps_status);
|
gps_storelocation(&gps_status);
|
||||||
payload.reset();
|
payload.reset();
|
||||||
payload.addGPS(gps_status);
|
payload.addGPS(gps_status);
|
||||||
SendPayload(GPSPORT, prio_high);
|
SendPayload(GPSPORT, prio_high);
|
||||||
} else
|
} else
|
||||||
ESP_LOGD(TAG, "No valid GPS position");
|
ESP_LOGD(TAG, "No valid GPS position");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user