Cayenne LPP payload added (experimental)
This commit is contained in:
parent
b47c58436f
commit
013222ed73
@ -119,12 +119,7 @@ void do_send(osjob_t *j) {
|
|||||||
|
|
||||||
// Prepare payload with counter and, if applicable, gps data
|
// Prepare payload with counter and, if applicable, gps data
|
||||||
payload.reset();
|
payload.reset();
|
||||||
|
payload.addCount(macs_wifi, cfg.blescan ? macs_ble : 0);
|
||||||
if (cfg.blescan) {
|
|
||||||
payload.addCount(macs_wifi, macs_ble);
|
|
||||||
} else {
|
|
||||||
payload.addCount(macs_wifi, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
if ((cfg.gpsmode) && (gps.location.isValid())) {
|
if ((cfg.gpsmode) && (gps.location.isValid())) {
|
||||||
|
@ -692,8 +692,8 @@ void loop() {
|
|||||||
gps_read();
|
gps_read();
|
||||||
ESP_LOGI(TAG,
|
ESP_LOGI(TAG,
|
||||||
"lat=%.6f | lon=%.6f | %u Sats | HDOP=%.1f | Altitude=%um",
|
"lat=%.6f | lon=%.6f | %u Sats | HDOP=%.1f | Altitude=%um",
|
||||||
gps_status.latitude / (float)1000000,
|
gps_status.latitude / (float)1e6,
|
||||||
gps_status.longitude / (float)1000000, gps_status.satellites,
|
gps_status.longitude / (float)1e6, gps_status.satellites,
|
||||||
gps_status.hdop / (float)100, gps_status.altitude);
|
gps_status.hdop / (float)100, gps_status.altitude);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "No valid GPS position or GPS disabled");
|
ESP_LOGI(TAG, "No valid GPS position or GPS disabled");
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#define SEND_SECS 30 // [seconds/2] -> 60 sec.
|
#define SEND_SECS 30 // [seconds/2] -> 60 sec.
|
||||||
#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_ENCODER 1 // select payload encoder: 1 = Plain [default], 2 = Lora-serialized, 3 = CayenneLPP
|
#define PAYLOAD_ENCODER 3 // select payload encoder: 1 = Plain [default], 2 = Lora-serialized, 3 = CayenneLPP
|
||||||
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
||||||
|
|
||||||
// Default LoRa Spreadfactor
|
// Default LoRa Spreadfactor
|
||||||
|
@ -79,13 +79,11 @@ void TTNplain::addStatus(uint16_t voltage, uint64_t uptime, float cputemp) {
|
|||||||
|
|
||||||
/* ---------------- packed format with LoRa serialization Encoder ---------- */
|
/* ---------------- packed format with LoRa serialization Encoder ---------- */
|
||||||
|
|
||||||
TTNserialized::TTNserialized(uint8_t size) {
|
TTNserialized::TTNserialized(uint8_t size) { buffer = (uint8_t *)malloc(size); }
|
||||||
buffer = (uint8_t *)malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
TTNserialized::~TTNserialized(void) { free(buffer); }
|
TTNserialized::~TTNserialized(void) { free(buffer); }
|
||||||
|
|
||||||
void TTNserialized::reset(void) { }
|
void TTNserialized::reset(void) { } // buggy! to be done, we need to clear the buffer here, but how?
|
||||||
|
|
||||||
uint8_t TTNserialized::getSize(void) { return sizeof(buffer); }
|
uint8_t TTNserialized::getSize(void) { return sizeof(buffer); }
|
||||||
|
|
||||||
@ -145,20 +143,19 @@ uint8_t *CayenneLPP::getBuffer(void) { return buffer; }
|
|||||||
|
|
||||||
void CayenneLPP::addCount(uint16_t value1, uint16_t value2) {
|
void CayenneLPP::addCount(uint16_t value1, uint16_t value2) {
|
||||||
buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL;
|
buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL;
|
||||||
buffer[cursor++] = LPP_ANALOG_INPUT;
|
buffer[cursor++] = LPP_LUMINOSITY; // workaround, type meter not found?
|
||||||
buffer[cursor++] = value1 >> 8;
|
buffer[cursor++] = value1 >> 8;
|
||||||
buffer[cursor++] = value1;
|
buffer[cursor++] = value1;
|
||||||
buffer[cursor++] = LPP_COUNT_BLE_CHANNEL;
|
buffer[cursor++] = LPP_COUNT_BLE_CHANNEL;
|
||||||
buffer[cursor++] = LPP_ANALOG_INPUT;
|
buffer[cursor++] = LPP_LUMINOSITY; // workaround, type meter not found?
|
||||||
buffer[cursor++] = value2 >> 8;
|
buffer[cursor++] = value2 >> 8;
|
||||||
buffer[cursor++] = value2;
|
buffer[cursor++] = value2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CayenneLPP::addGPS(gpsStatus_t value) {
|
void CayenneLPP::addGPS(gpsStatus_t value) {
|
||||||
int32_t lat = value.latitude * (int32_t) 10000;
|
int32_t lat = value.latitude / 100;
|
||||||
int32_t lon = value.longitude * (int32_t) 10000;
|
int32_t lon = value.longitude / 100;
|
||||||
int32_t alt = value.altitude * (int32_t) 100;
|
int32_t alt = value.altitude;
|
||||||
|
|
||||||
buffer[cursor++] = LPP_GPS_CHANNEL;
|
buffer[cursor++] = LPP_GPS_CHANNEL;
|
||||||
buffer[cursor++] = LPP_GPS;
|
buffer[cursor++] = LPP_GPS;
|
||||||
buffer[cursor++] = lat >> 16;
|
buffer[cursor++] = lat >> 16;
|
||||||
@ -183,9 +180,8 @@ void CayenneLPP::addStatus(uint16_t voltage, uint64_t uptime, float cputemp) {
|
|||||||
buffer[cursor++] = LPP_ANALOG_INPUT;
|
buffer[cursor++] = LPP_ANALOG_INPUT;
|
||||||
buffer[cursor++] = voltage >> 8;
|
buffer[cursor++] = voltage >> 8;
|
||||||
buffer[cursor++] = voltage;
|
buffer[cursor++] = voltage;
|
||||||
|
|
||||||
buffer[cursor++] = LPP_TEMP_CHANNEL;
|
buffer[cursor++] = LPP_TEMP_CHANNEL;
|
||||||
buffer[cursor++] = LPP_TEMPERATURE;
|
buffer[cursor++] = LPP_TEMPERATURE;
|
||||||
buffer[cursor++] = (uint16_t) cputemp >> 8;
|
buffer[cursor++] = (uint16_t)cputemp >> 8;
|
||||||
buffer[cursor++] = (uint16_t) cputemp;
|
buffer[cursor++] = (uint16_t)cputemp;
|
||||||
}
|
}
|
@ -18,6 +18,7 @@
|
|||||||
#define LPP_DIGITAL_INPUT 0 // 1 byte
|
#define LPP_DIGITAL_INPUT 0 // 1 byte
|
||||||
#define LPP_DIGITAL_OUTPUT 1 // 1 byte
|
#define LPP_DIGITAL_OUTPUT 1 // 1 byte
|
||||||
#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed
|
#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed
|
||||||
|
#define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned
|
||||||
|
|
||||||
class TTNplain {
|
class TTNplain {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user