add feature send battery voltage data

This commit is contained in:
Klaus K Wilting committed 2018-11-27 11:21:20 +01:00
1 parent 72063b88b1
commit 207eb6bb98
9 files changed
+36 -25

No files matched your search

+3 -3
View File
@@ -11,7 +11,7 @@
// Payload send cycle and encoding
#define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec.
#define PAYLOAD_ENCODER 3 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed
#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed
// Set this to include BLE counting and vendor filter functions
#define VENDORFILTER 1 // comment out if you want to count things, not people
@@ -54,16 +54,16 @@
#define RCMDPORT 2 // Port on which device listenes for remote commands
#define STATUSPORT 2 // Port on which device sends remote command results
#define CONFIGPORT 3 // Port on which device sends config query results
#define GPSPORT 4 // Port on which device sends gps query results
#define GPSPORT 4 // Port on which device sends gps data
#define BUTTONPORT 5 // Port on which device sends button pressed signal
#define LPP1PORT 1 // Port for Cayenne LPP 1.0 dynamic sensor encoding
#define LPP2PORT 2 // Port for Cayenne LPP 2.0 packed sensor encoding
#define BEACONPORT 6 // Port on which device sends beacon alarms
#define BMEPORT 7 // Port on which device sends BME680 sensor data
#define BATTPORT 8 // Port on which device sends battery voltage data
#define SENSOR1PORT 10 // Port on which device sends User sensor #1 data
#define SENSOR2PORT 11 // Port on which device sends User sensor #2 data
#define SENSOR3PORT 12 // Port on which device sends User sensor #3 data
#define SENSOR4PORT 13 // Port on which device sends User sensor #4 data
// Some hardware settings
#define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%]
+18 -1
View File
@@ -30,6 +30,11 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
buffer[cursor++] = msg;
}
void PayloadConvert::addVoltage(uint16_t value) {
buffer[cursor++] = highByte(value);
buffer[cursor++] = lowByte(value);
}
void PayloadConvert::addConfig(configData_t value) {
buffer[cursor++] = value.lorasf;
buffer[cursor++] = value.txpower;
@@ -140,6 +145,8 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
writeUint8(msg);
}
void PayloadConvert::addVoltage(uint16_t value) { writeUint16(value); }
void PayloadConvert::addConfig(configData_t value) {
writeUint8(value.lorasf);
writeUint8(value.txpower);
@@ -160,7 +167,7 @@ void PayloadConvert::addConfig(configData_t value) {
value.payloadmask && SENSOR1_DATA ? true : false,
value.payloadmask && SENSOR2_DATA ? true : false,
value.payloadmask && SENSOR3_DATA ? true : false,
value.payloadmask && SENSOR4_DATA ? true : false);
value.payloadmask && BATT_DATA ? true : false);
writeVersion(value.version);
}
@@ -309,6 +316,16 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
buffer[cursor++] = rssi;
}
void PayloadConvert::addVoltage(uint16_t value) {
uint16_t volt = value / 10;
#if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_BATT_CHANNEL;
#endif
buffer[cursor++] = LPP_ANALOG_INPUT;
buffer[cursor++] = highByte(volt);
buffer[cursor++] = lowByte(volt);
}
void PayloadConvert::addConfig(configData_t value) {
#if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_ADR_CHANNEL;
-1
View File
@@ -138,7 +138,6 @@ void set_sensor(uint8_t val[]) {
case 1:
case 2:
case 3:
case 4:
break; // valid sensor number -> continue
default:
ESP_LOGW(
+5 -7
View File
@@ -72,31 +72,29 @@ void sendCounter() {
#endif
#ifdef HAS_SENSORS
case SENSOR1_DATA:
payload.reset();
payload.addSensor(sensor_read(1));
SendPayload(SENSOR1PORT);
break;
case SENSOR2_DATA:
payload.reset();
payload.addSensor(sensor_read(2));
SendPayload(SENSOR2PORT);
break;
case SENSOR3_DATA:
payload.reset();
payload.addSensor(sensor_read(3));
SendPayload(SENSOR3PORT);
break;
#endif
case SENSOR4_DATA:
#ifdef HAS_BATTERY_PROBE
case BATT_DATA:
payload.reset();
payload.addSensor(sensor_read(4));
SendPayload(SENSOR4PORT);
payload.addVoltage(read_voltage());
SendPayload(BATTPORT);
break;
#endif
} // switch
+1 -9
View File
@@ -24,7 +24,7 @@ uint8_t sensor_mask(uint8_t sensor_no) {
case 3:
return (uint8_t)SENSOR3_DATA;
case 4:
return (uint8_t)SENSOR4_DATA;
return (uint8_t)BATT_DATA;
case 5:
return (uint8_t)GPS_DATA;
case 6:
@@ -64,14 +64,6 @@ uint8_t *sensor_read(uint8_t sensor) {
buf[2] = 0xa0;
buf[3] = 0x03;
break;
case 4:
buf[0] = length;
buf[1] = 0xff;
buf[2] = 0xa0;
buf[3] = 0x04;
break;
}
return buf;