Merge pull request #214 from cyberman54/development

v1.6.97
This commit is contained in:
Verkehrsrot 2018-11-27 21:32:16 +01:00 committed by GitHub
commit d0390d8ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 43 additions and 30 deletions

View File

@ -181,7 +181,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
bytes 18-28: Software version (ASCII format, terminating with zero) bytes 18-28: Software version (ASCII format, terminating with zero)
**Port #4:** GPS query result (device answers only if has GPS and GPS has a fix) **Port #4:** GPS data (only if device has fature GPS, and GPS data is enabled and GPS has a fix)
bytes 1-4: Latitude bytes 1-4: Latitude
bytes 5-8: Longitude bytes 5-8: Longitude
@ -198,7 +198,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
byte 1: Beacon RSSI reception level byte 1: Beacon RSSI reception level
byte 2: Beacon identifier (0..255) byte 2: Beacon identifier (0..255)
**Port #7:** Environmental sensor query result **Port #7:** Environmental sensor data (only if device has feature BME)
bytes 1-2: Temperature [°C] bytes 1-2: Temperature [°C]
bytes 3-4: Pressure [hPa] bytes 3-4: Pressure [hPa]
@ -213,6 +213,10 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
201-300 worse 201-300 worse
301-500 very bad 301-500 very bad
**Port #8:** Battery voltage data (only if device has feature BATT)
byte 1-2: Battery or USB Voltage [mV], 0 if no battery probe
# Remote control # Remote control
The device listenes for remote control commands on LoRaWAN Port 2. Multiple commands per downlink are possible by concatenating them. The device listenes for remote control commands on LoRaWAN Port 2. Multiple commands per downlink are possible by concatenating them.
@ -315,7 +319,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
0x13 set user sensor mode 0x13 set user sensor mode
byte 1 = user sensor number (1..4) byte 1 = user sensor number (1..3)
byte 2 = sensor mode (0 = disabled / 1 = enabled [default]) byte 2 = sensor mode (0 = disabled / 1 = enabled [default])
0x80 get device configuration 0x80 get device configuration

View File

@ -17,7 +17,7 @@
#define SENSOR1_DATA (0x10) #define SENSOR1_DATA (0x10)
#define SENSOR2_DATA (0x20) #define SENSOR2_DATA (0x20)
#define SENSOR3_DATA (0x40) #define SENSOR3_DATA (0x40)
#define SENSOR4_DATA (0x80) #define BATT_DATA (0x80)
// bits in configmask for device runmode control // bits in configmask for device runmode control
#define GPS_MODE (0x01) #define GPS_MODE (0x01)

View File

@ -44,6 +44,7 @@ public:
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem, void addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem,
uint8_t reset1, uint8_t reset2); uint8_t reset1, uint8_t reset2);
void addAlarm(int8_t rssi, uint8_t message); void addAlarm(int8_t rssi, uint8_t message);
void addVoltage(uint16_t value);
void addGPS(gpsStatus_t value); void addGPS(gpsStatus_t value);
void addBME(bmeStatus_t value); void addBME(bmeStatus_t value);
void addButton(uint8_t value); void addButton(uint8_t value);

View File

@ -29,7 +29,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
[common] [common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c" ; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 1.6.95 release_version = 1.6.97
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 0 debug_level = 0

View File

@ -71,25 +71,27 @@ void start_ota_update() {
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS); WiFi.begin(WIFI_SSID, WIFI_PASS);
int i = WIFI_MAX_TRY, j = OTA_MAX_TRY; uint8_t i = WIFI_MAX_TRY;
int ret = 1; // 0 = finished, 1 = retry, -1 = abort int ret = 1; // 0 = finished, 1 = retry, -1 = abort
ESP_LOGI(TAG, "Trying to connect to %s", WIFI_SSID);
while (i--) { while (i--) {
ESP_LOGI(TAG, "Trying to connect to %s, attempt %u of %u", WIFI_SSID,
WIFI_MAX_TRY - i, WIFI_MAX_TRY);
vTaskDelay(10000 / portTICK_PERIOD_MS); // wait for stable connect
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
// we now have wifi connection and try to do an OTA over wifi update // we now have wifi connection and try to do an OTA over wifi update
ESP_LOGI(TAG, "Connected to %s", WIFI_SSID); ESP_LOGI(TAG, "Connected to %s", WIFI_SSID);
display(1, "OK", "WiFi connected"); display(1, "OK", "WiFi connected");
// do a number of tries to update firmware limited by OTA_MAX_TRY // do a number of tries to update firmware limited by OTA_MAX_TRY
uint8_t j = OTA_MAX_TRY;
while ((j--) && (ret > 0)) { while ((j--) && (ret > 0)) {
ESP_LOGI(TAG, "Starting OTA update, attempt %u of %u", OTA_MAX_TRY - j, ESP_LOGI(TAG, "Starting OTA update, attempt %u of %u", OTA_MAX_TRY - j,
OTA_MAX_TRY); OTA_MAX_TRY);
ret = do_ota_update(); ret = do_ota_update();
} }
goto end; if (WiFi.status() == WL_CONNECTED)
goto end; // OTA update finished or OTA max attemps reached
} }
vTaskDelay(5000 / portTICK_PERIOD_MS);
WiFi.reconnect(); WiFi.reconnect();
} }

View File

@ -54,16 +54,16 @@
#define RCMDPORT 2 // Port on which device listenes for remote commands #define RCMDPORT 2 // Port on which device listenes for remote commands
#define STATUSPORT 2 // Port on which device sends remote command results #define STATUSPORT 2 // Port on which device sends remote command results
#define CONFIGPORT 3 // Port on which device sends config query 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 BUTTONPORT 5 // Port on which device sends button pressed signal
#define LPP1PORT 1 // Port for Cayenne LPP 1.0 dynamic sensor encoding #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 LPP2PORT 2 // Port for Cayenne LPP 2.0 packed sensor encoding
#define BEACONPORT 6 // Port on which device sends beacon alarms #define BEACONPORT 6 // Port on which device sends beacon alarms
#define BMEPORT 7 // Port on which device sends BME680 sensor data #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 SENSOR1PORT 10 // Port on which device sends User sensor #1 data
#define SENSOR2PORT 11 // Port on which device sends User sensor #2 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 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 // Some hardware settings
#define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%] #define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%]

View File

@ -30,6 +30,11 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
buffer[cursor++] = msg; buffer[cursor++] = msg;
} }
void PayloadConvert::addVoltage(uint16_t value) {
buffer[cursor++] = highByte(value);
buffer[cursor++] = lowByte(value);
}
void PayloadConvert::addConfig(configData_t value) { void PayloadConvert::addConfig(configData_t value) {
buffer[cursor++] = value.lorasf; buffer[cursor++] = value.lorasf;
buffer[cursor++] = value.txpower; buffer[cursor++] = value.txpower;
@ -140,6 +145,8 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
writeUint8(msg); writeUint8(msg);
} }
void PayloadConvert::addVoltage(uint16_t value) { writeUint16(value); }
void PayloadConvert::addConfig(configData_t value) { void PayloadConvert::addConfig(configData_t value) {
writeUint8(value.lorasf); writeUint8(value.lorasf);
writeUint8(value.txpower); writeUint8(value.txpower);
@ -160,7 +167,7 @@ void PayloadConvert::addConfig(configData_t value) {
value.payloadmask && SENSOR1_DATA ? true : false, value.payloadmask && SENSOR1_DATA ? true : false,
value.payloadmask && SENSOR2_DATA ? true : false, value.payloadmask && SENSOR2_DATA ? true : false,
value.payloadmask && SENSOR3_DATA ? true : false, value.payloadmask && SENSOR3_DATA ? true : false,
value.payloadmask && SENSOR4_DATA ? true : false); value.payloadmask && BATT_DATA ? true : false);
writeVersion(value.version); writeVersion(value.version);
} }
@ -309,6 +316,16 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
buffer[cursor++] = rssi; 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) { void PayloadConvert::addConfig(configData_t value) {
#if (PAYLOAD_ENCODER == 3) #if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_ADR_CHANNEL; buffer[cursor++] = LPP_ADR_CHANNEL;

View File

@ -138,7 +138,6 @@ void set_sensor(uint8_t val[]) {
case 1: case 1:
case 2: case 2:
case 3: case 3:
case 4:
break; // valid sensor number -> continue break; // valid sensor number -> continue
default: default:
ESP_LOGW( ESP_LOGW(

View File

@ -72,31 +72,29 @@ void sendCounter() {
#endif #endif
#ifdef HAS_SENSORS #ifdef HAS_SENSORS
case SENSOR1_DATA: case SENSOR1_DATA:
payload.reset(); payload.reset();
payload.addSensor(sensor_read(1)); payload.addSensor(sensor_read(1));
SendPayload(SENSOR1PORT); SendPayload(SENSOR1PORT);
break; break;
case SENSOR2_DATA: case SENSOR2_DATA:
payload.reset(); payload.reset();
payload.addSensor(sensor_read(2)); payload.addSensor(sensor_read(2));
SendPayload(SENSOR2PORT); SendPayload(SENSOR2PORT);
break; break;
case SENSOR3_DATA: case SENSOR3_DATA:
payload.reset(); payload.reset();
payload.addSensor(sensor_read(3)); payload.addSensor(sensor_read(3));
SendPayload(SENSOR3PORT); SendPayload(SENSOR3PORT);
break; break;
#endif
case SENSOR4_DATA: #ifdef HAS_BATTERY_PROBE
case BATT_DATA:
payload.reset(); payload.reset();
payload.addSensor(sensor_read(4)); payload.addVoltage(read_voltage());
SendPayload(SENSOR4PORT); SendPayload(BATTPORT);
break; break;
#endif #endif
} // switch } // switch

View File

@ -24,7 +24,7 @@ uint8_t sensor_mask(uint8_t sensor_no) {
case 3: case 3:
return (uint8_t)SENSOR3_DATA; return (uint8_t)SENSOR3_DATA;
case 4: case 4:
return (uint8_t)SENSOR4_DATA; return (uint8_t)BATT_DATA;
case 5: case 5:
return (uint8_t)GPS_DATA; return (uint8_t)GPS_DATA;
case 6: case 6:
@ -64,14 +64,6 @@ uint8_t *sensor_read(uint8_t sensor) {
buf[2] = 0xa0; buf[2] = 0xa0;
buf[3] = 0x03; buf[3] = 0x03;
break; break;
case 4:
buf[0] = length;
buf[1] = 0xff;
buf[2] = 0xa0;
buf[3] = 0x04;
break;
} }
return buf; return buf;