Merge pull request #536 from AugustQu/SDS011

SDS011
This commit is contained in:
Verkehrsrot 2020-01-22 19:11:38 +01:00 committed by GitHub
commit 440aba71ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 2 deletions

View File

@ -3,6 +3,10 @@
#include "paxcounter.conf" #include "paxcounter.conf"
#if (HAS_SDS011)
#include "sds011read.h"
#endif
// MyDevices CayenneLPP 1.0 channels for Synamic sensor payload format // MyDevices CayenneLPP 1.0 channels for Synamic sensor payload format
// all payload goes out on LoRa FPort 1 // all payload goes out on LoRa FPort 1
#if (PAYLOAD_ENCODER == 3) #if (PAYLOAD_ENCODER == 3)
@ -55,6 +59,9 @@ public:
void addButton(uint8_t value); void addButton(uint8_t value);
void addSensor(uint8_t[]); void addSensor(uint8_t[]);
void addTime(time_t value); void addTime(time_t value);
void addPM10(float value);
void addPM25(float value);
void addChars( char* string, int len);
#if (PAYLOAD_ENCODER == 1) // format plain #if (PAYLOAD_ENCODER == 1) // format plain
@ -95,4 +102,4 @@ private:
extern PayloadConvert payload; extern PayloadConvert payload;
#endif // _PAYLOAD_H_ #endif // _PAYLOAD_H_

View File

@ -16,6 +16,10 @@
#include "sdcard.h" #include "sdcard.h"
#endif #endif
#if (HAS_SDS011)
#include "sds011read.h"
#endif
extern Ticker sendcycler; extern Ticker sendcycler;
void SendPayload(uint8_t port, sendprio_t prio); void SendPayload(uint8_t port, sendprio_t prio);

View File

@ -489,5 +489,41 @@ void PayloadConvert::addTime(time_t value) {
buffer[cursor++] = (byte)((tx_period & 0x000000FF)); buffer[cursor++] = (byte)((tx_period & 0x000000FF));
#endif #endif
} }
#endif // PAYLOAD_ENCODER
#endif void PayloadConvert::addPM10( float value) {
#if (HAS_SDS011)
#if (PAYLOAD_ENCODER == 1) // plain
char tempBuffer[10+1];
sprintf( tempBuffer, ",%5.1f", value);
addChars(tempBuffer, strlen(tempBuffer));
#elif (PAYLOAD_ENCODER == 2 ) // packed
writeUint16( (uint16_t) (value*10) );
#elif (PAYLOAD_ENCODER == 3 ) // Cayenne LPP dynamic
// TODO
#elif (PAYLOAD_ENCODER == 4 ) // Cayenne LPP packed
// TODO
#endif
#endif // HAS_SDS011
}
void PayloadConvert::addPM25( float value) {
#if (HAS_SDS011)
#if (PAYLOAD_ENCODER == 1) // plain
char tempBuffer[10+1];
sprintf( tempBuffer, ",%5.1f", value);
addChars(tempBuffer, strlen(tempBuffer));
#elif (PAYLOAD_ENCODER == 2 ) // packed
writeUint16( (uint16_t) (value*10) );
#elif (PAYLOAD_ENCODER == 3 ) // Cayenne LPP dynamic
// TODO
#elif (PAYLOAD_ENCODER == 4 ) // Cayenne LPP packed
// TODO
#endif
#endif // HAS_SDS011
}
void PayloadConvert::addChars( char * string, int len) {
for (int i=0; i < len; i++)
addByte(string[i]);
}

View File

@ -3,6 +3,11 @@
Ticker sendcycler; Ticker sendcycler;
#if (HAS_SDS011)
extern float pm10;
extern float pm25;
#endif
void sendcycle() { void sendcycle() {
xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL); xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL);
} }
@ -98,6 +103,10 @@ void sendData() {
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);
#endif
#if (HAS_SDS011)
payload.addPM10(pm10);
payload.addPM25(pm25);
#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