OpenSenseBox specific payload
This commit is contained in:
parent
40248d60c3
commit
be448a37a3
@ -94,9 +94,11 @@ typedef struct {
|
||||
typedef struct {
|
||||
int32_t latitude;
|
||||
int32_t longitude;
|
||||
#if !(PAYLOAD_OPENSENSEBOX)
|
||||
uint8_t satellites;
|
||||
uint16_t hdop;
|
||||
int16_t altitude;
|
||||
#endif
|
||||
} gpsStatus_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -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']);
|
||||
|
@ -76,9 +76,11 @@ void gps_storelocation(gpsStatus_t *gps_store) {
|
||||
(gps.location.age() < 1500)) {
|
||||
gps_store->latitude = (int32_t)(gps.location.lat() * 1e6);
|
||||
gps_store->longitude = (int32_t)(gps.location.lng() * 1e6);
|
||||
#if !(PAYLOAD_OPENSENSEBOX)
|
||||
gps_store->satellites = (uint8_t)gps.satellites.value();
|
||||
gps_store->hdop = (uint16_t)gps.hdop.value();
|
||||
gps_store->altitude = (int16_t)gps.altitude.meters();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 1 // 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 1 // gps - set to 1 to send combined GPS+COUNT payload
|
||||
#define BUTTONPORT 5 // button pressed signal
|
||||
#define BEACONPORT 6 // beacon alarms
|
||||
#define BMEPORT 7 // BME680 sensor
|
||||
|
@ -193,10 +193,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[]) {
|
||||
|
@ -65,10 +65,11 @@ void sendData() {
|
||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||
case COUNT_DATA:
|
||||
payload.reset();
|
||||
#if !(PAYLOAD_OPENSENSEBOX)
|
||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||
if (cfg.blescan)
|
||||
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
||||
#if (HAS_GPS) && (GPSPORT==1)
|
||||
#endif
|
||||
// send GPS position only if we have a fix
|
||||
if (gps.location.isValid()) {
|
||||
gpsStatus_t gps_status;
|
||||
@ -76,6 +77,11 @@ void sendData() {
|
||||
payload.addGPS(gps_status);
|
||||
} else
|
||||
ESP_LOGD(TAG, "No valid GPS position");
|
||||
#endif
|
||||
#if (PAYLOAD_OPENSENSEBOX)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user