commit
						440aba71ed
					
				| @ -3,6 +3,10 @@ | ||||
| 
 | ||||
| #include "paxcounter.conf" | ||||
| 
 | ||||
| #if (HAS_SDS011) | ||||
| #include "sds011read.h" | ||||
| #endif | ||||
| 
 | ||||
| // MyDevices CayenneLPP 1.0 channels for Synamic sensor payload format
 | ||||
| // all payload goes out on LoRa FPort 1
 | ||||
| #if (PAYLOAD_ENCODER == 3) | ||||
| @ -55,6 +59,9 @@ public: | ||||
|   void addButton(uint8_t value); | ||||
|   void addSensor(uint8_t[]); | ||||
|   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
 | ||||
| 
 | ||||
| @ -95,4 +102,4 @@ private: | ||||
| 
 | ||||
| extern PayloadConvert payload; | ||||
| 
 | ||||
| #endif // _PAYLOAD_H_
 | ||||
| #endif // _PAYLOAD_H_
 | ||||
|  | ||||
| @ -16,6 +16,10 @@ | ||||
| #include "sdcard.h" | ||||
| #endif | ||||
| 
 | ||||
| #if (HAS_SDS011) | ||||
| #include "sds011read.h" | ||||
| #endif | ||||
| 
 | ||||
| extern Ticker sendcycler; | ||||
| 
 | ||||
| void SendPayload(uint8_t port, sendprio_t prio); | ||||
|  | ||||
| @ -489,5 +489,41 @@ void PayloadConvert::addTime(time_t value) { | ||||
|   buffer[cursor++] = (byte)((tx_period & 0x000000FF)); | ||||
| #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]); | ||||
| } | ||||
|  | ||||
| @ -3,6 +3,11 @@ | ||||
| 
 | ||||
| Ticker sendcycler; | ||||
| 
 | ||||
| #if (HAS_SDS011) | ||||
| extern float pm10; | ||||
| extern float pm25; | ||||
| #endif | ||||
| 
 | ||||
| void sendcycle() { | ||||
|   xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL); | ||||
| } | ||||
| @ -98,6 +103,10 @@ void sendData() { | ||||
|         payload.addCount(macs_wifi, MAC_SNIFF_WIFI); | ||||
|       if (cfg.blescan) | ||||
|         payload.addCount(macs_ble, MAC_SNIFF_BLE); | ||||
| #endif | ||||
| #if (HAS_SDS011) | ||||
|       payload.addPM10(pm10); | ||||
|       payload.addPM25(pm25); | ||||
| #endif | ||||
|       SendPayload(COUNTERPORT, prio_normal); | ||||
|       // clear counter if not in cumulative counter mode
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user