code sanitizations
This commit is contained in:
parent
27fd296753
commit
f05acd32a8
@ -39,7 +39,6 @@
|
||||
#endif
|
||||
|
||||
class PayloadConvert {
|
||||
|
||||
public:
|
||||
PayloadConvert(uint8_t size);
|
||||
~PayloadConvert();
|
||||
@ -59,6 +58,7 @@ public:
|
||||
void addSensor(uint8_t[]);
|
||||
void addTime(time_t value);
|
||||
void addSDS(sdsStatus_t value);
|
||||
|
||||
private:
|
||||
void addChars( char* string, int len);
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <WString.h>
|
||||
|
||||
class BintrayClient {
|
||||
|
||||
public:
|
||||
BintrayClient(const String& user, const String& repository, const String& package);
|
||||
String getUser() const;
|
||||
|
@ -48,7 +48,6 @@ void setBMEIRQ() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
|
||||
// initialize MEMS sensor
|
||||
// return = 0 -> error / return = 1 -> success
|
||||
int bme_init(void) {
|
||||
|
||||
int rc = 0;
|
||||
|
||||
#ifdef HAS_BME680
|
||||
@ -77,7 +76,6 @@ int bme_init(void) {
|
||||
if (rc)
|
||||
bmecycler.attach(BMECYCLE, setBMEIRQ); // start cyclic data transmit
|
||||
return rc;
|
||||
|
||||
} // bme_init()
|
||||
|
||||
#ifdef HAS_BME680
|
||||
@ -108,7 +106,6 @@ int checkIaqSensorStatus(void) {
|
||||
|
||||
// store current BME sensor data in struct
|
||||
void bme_storedata(bmeStatus_t *bme_store) {
|
||||
|
||||
if (cfg.payloadmask & MEMS_DATA)
|
||||
|
||||
#ifdef HAS_BME680
|
||||
@ -138,7 +135,6 @@ void bme_storedata(bmeStatus_t *bme_store) {
|
||||
// bme.readAltitude(SEALEVELPRESSURE_HPA);
|
||||
bme_store->iaq = 0; // IAQ feature not present with BME280
|
||||
#endif
|
||||
|
||||
} // bme_storedata()
|
||||
|
||||
#ifdef HAS_BME680
|
||||
|
@ -75,7 +75,6 @@ void IRAM_ATTR watchdog() { xTaskResumeFromISR(RestartHandle); }
|
||||
// used for manually uploading a firmware file via wifi
|
||||
|
||||
void start_boot_menu(void) {
|
||||
|
||||
const char *host = clientId;
|
||||
const char *ssid = WIFI_SSID;
|
||||
const char *password = WIFI_PASS;
|
||||
@ -150,9 +149,7 @@ void start_boot_menu(void) {
|
||||
|
||||
// did we get a file name?
|
||||
if (upload.filename != NULL) {
|
||||
|
||||
switch (upload.status) {
|
||||
|
||||
case UPLOAD_FILE_START:
|
||||
// start file transfer
|
||||
ESP_LOGI(TAG, "Uploading %s", upload.filename.c_str());
|
||||
@ -177,7 +174,6 @@ void start_boot_menu(void) {
|
||||
case UPLOAD_FILE_ABORTED:
|
||||
default:
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
||||
// don't boot to production if update failed
|
||||
|
@ -26,7 +26,6 @@ static uint8_t buffer[cfgLen + cfgLen2];
|
||||
// 3. magicByte [cfgLen2 bytes, containing a fixed identifier]
|
||||
|
||||
static void defaultConfig(configData_t *myconfig) {
|
||||
|
||||
strncpy(myconfig->version, PROGVERSION,
|
||||
sizeof(myconfig->version) - 1); // Firmware version
|
||||
|
||||
@ -92,7 +91,6 @@ void saveConfig(bool erase) {
|
||||
|
||||
// load configuration from NVRAM into RAM and make it current
|
||||
void loadConfig(void) {
|
||||
|
||||
int readBytes = 0;
|
||||
|
||||
ESP_LOGI(TAG, "Loading device configuration from NVRAM...");
|
||||
@ -144,7 +142,6 @@ bool comp(char s1, char s2) { return (tolower(s1) < tolower(s2)); }
|
||||
// helper function to lexicographically compare two versions. Returns 1 if v2
|
||||
// is smaller, -1 if v1 is smaller, 0 if equal
|
||||
int version_compare(const String v1, const String v2) {
|
||||
|
||||
if (v1 == v2)
|
||||
return 0;
|
||||
|
||||
|
@ -13,7 +13,6 @@ void setCyclicIRQ() { xTaskNotify(irqHandlerTask, CYCLIC_IRQ, eSetBits); }
|
||||
|
||||
// do all housekeeping
|
||||
void doHousekeeping() {
|
||||
|
||||
// check if update or maintenance mode trigger switch was set by rcommand
|
||||
if ((RTC_runmode == RUNMODE_UPDATE) || (RTC_runmode == RUNMODE_MAINTENANCE))
|
||||
do_reset(true); // warmstart
|
||||
@ -125,7 +124,6 @@ void doHousekeeping() {
|
||||
#if (HAS_SDCARD)
|
||||
sdcard_flush();
|
||||
#endif
|
||||
|
||||
} // doHousekeeping()
|
||||
|
||||
uint32_t getFreeRAM() {
|
||||
|
@ -18,41 +18,33 @@ static const char TAG[] = __FILE__;
|
||||
|
||||
// triggered by second timepulse to ticker out DCF signal
|
||||
void DCF77_Pulse(uint8_t bit) {
|
||||
|
||||
TickType_t startTime;
|
||||
|
||||
// induce a DCF Pulse
|
||||
for (uint8_t pulseLength = 0; pulseLength <= 2; pulseLength++) {
|
||||
|
||||
startTime = xTaskGetTickCount(); // reference time pulse start
|
||||
|
||||
switch (pulseLength) {
|
||||
|
||||
case 0: // 0ms = start of pulse
|
||||
digitalWrite(HAS_DCF77, dcf_low);
|
||||
break;
|
||||
|
||||
case 1: // 100ms = logic 0
|
||||
if (bit == 0)
|
||||
digitalWrite(HAS_DCF77, dcf_high);
|
||||
break;
|
||||
|
||||
case 2: // 200ms = logic 1
|
||||
digitalWrite(HAS_DCF77, dcf_high);
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
||||
// delay to genrate pulseLength
|
||||
vTaskDelayUntil(&startTime, pdMS_TO_TICKS(100));
|
||||
|
||||
} // for
|
||||
} // DCF77_Pulse()
|
||||
|
||||
// helper function to convert decimal to bcd digit
|
||||
uint64_t dec2bcd(uint8_t const dec, uint8_t const startpos,
|
||||
uint8_t const endpos, uint8_t *parity) {
|
||||
|
||||
uint8_t data = dec < 10 ? dec : ((dec / 10) << 4) + dec % 10;
|
||||
uint64_t bcd = 0;
|
||||
|
||||
@ -68,7 +60,6 @@ uint64_t dec2bcd(uint8_t const dec, uint8_t const startpos,
|
||||
|
||||
// generates a 1 minute dcf pulse frame for calendar time t
|
||||
uint64_t DCF77_Frame(const struct tm t) {
|
||||
|
||||
uint8_t parity = 0, parity_sum = 0;
|
||||
uint64_t frame = 0; // start with all bits 0
|
||||
|
||||
@ -105,7 +96,6 @@ uint64_t DCF77_Frame(const struct tm t) {
|
||||
frame += parity_sum ? set_dcfbit(58) : 0;
|
||||
|
||||
return frame;
|
||||
|
||||
} // DCF77_Frame()
|
||||
|
||||
#endif // HAS_DCF77
|
@ -15,7 +15,6 @@ void i2c_init(void) {
|
||||
void i2c_deinit(void) { Wire.end(); }
|
||||
|
||||
void i2c_scan(void) {
|
||||
|
||||
// parts of the code in this function were taken from:
|
||||
//
|
||||
// Copyright (c) 2019 BitBank Software, Inc.
|
||||
@ -78,7 +77,6 @@ void i2c_scan(void) {
|
||||
|
||||
// functions for i2c r/w access, mutexing is done by Wire.cpp
|
||||
int i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
||||
|
||||
uint8_t ret = 0;
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write(reg);
|
||||
@ -100,7 +98,6 @@ finish:
|
||||
}
|
||||
|
||||
int i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
||||
|
||||
uint8_t ret = 0;
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write(reg);
|
||||
@ -110,4 +107,4 @@ int i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
||||
ret = Wire.endTransmission();
|
||||
|
||||
return ret ? ret : 0xFF;
|
||||
}
|
||||
}
|
@ -85,7 +85,6 @@ not evaluated by model BU-190, use "F" instead for this model
|
||||
static const char TAG[] = __FILE__;
|
||||
|
||||
String IF482_Frame(time_t t) {
|
||||
|
||||
char mon, out[IF482_FRAME_SIZE + 1], buf[IF482_FRAME_SIZE - 3];
|
||||
|
||||
if (sntp_get_sync_status() == SNTP_SYNC_STATUS_IN_PROGRESS)
|
||||
|
@ -7,7 +7,6 @@ TaskHandle_t irqHandlerTask = NULL;
|
||||
|
||||
// irq handler task, handles all our application level interrupts
|
||||
void irqHandler(void *pvParameters) {
|
||||
|
||||
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
||||
|
||||
uint32_t irqSource;
|
||||
|
@ -158,7 +158,6 @@ void ledLoop(void *parameter) {
|
||||
}
|
||||
// No custom blink, check LoRaWAN state
|
||||
} else {
|
||||
|
||||
#if (HAS_LORA)
|
||||
// LED indicators for viusalizing LoRaWAN state
|
||||
if (LMIC.opmode & (OP_JOINING | OP_REJOIN)) {
|
||||
|
@ -14,7 +14,6 @@
|
||||
*********************************************************************/
|
||||
|
||||
void setABPParameters() {
|
||||
|
||||
/** **************************************************************
|
||||
* ************************************************************* */
|
||||
#if defined(CFG_eu868)
|
||||
|
@ -19,7 +19,6 @@ void mqtt_deinit(void) {
|
||||
}
|
||||
|
||||
esp_err_t mqtt_init(void) {
|
||||
|
||||
// setup network connection and MQTT client
|
||||
ETH.begin();
|
||||
ETH.setHostname(clientId);
|
||||
@ -43,7 +42,6 @@ esp_err_t mqtt_init(void) {
|
||||
}
|
||||
|
||||
int mqtt_connect(const char *my_host, const uint16_t my_port) {
|
||||
|
||||
IPAddress mqtt_server_ip;
|
||||
|
||||
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
||||
@ -75,13 +73,10 @@ int mqtt_connect(const char *my_host, const uint16_t my_port) {
|
||||
}
|
||||
|
||||
void mqtt_client_task(void *param) {
|
||||
|
||||
MessageBuffer_t msg;
|
||||
|
||||
while (1) {
|
||||
|
||||
if (mqttClient.connected()) {
|
||||
|
||||
// check for incoming messages
|
||||
mqttClient.loop();
|
||||
|
||||
@ -124,11 +119,10 @@ void mqtt_client_task(void *param) {
|
||||
// process incoming MQTT messages
|
||||
void mqtt_callback(MQTTClient *client, char *topic, char *payload, int length) {
|
||||
if (strcmp(topic, MQTT_INTOPIC) == 0) {
|
||||
|
||||
// get length of base64 encoded message
|
||||
size_t out_len = 0;
|
||||
mbedtls_base64_decode(NULL, 0, &out_len, (unsigned char *)payload, length);
|
||||
|
||||
|
||||
// decode the base64 message
|
||||
unsigned char decoded[out_len];
|
||||
mbedtls_base64_decode(decoded, out_len, &out_len, (unsigned char *)payload,
|
||||
|
@ -9,7 +9,6 @@ RtcDS3231<TwoWire> Rtc(Wire); // RTC hardware i2c interface
|
||||
|
||||
// initialize RTC
|
||||
uint8_t rtc_init(void) {
|
||||
|
||||
Wire.begin(HAS_RTC);
|
||||
Rtc.Begin(MY_DISPLAY_SDA, MY_DISPLAY_SCL);
|
||||
|
||||
@ -43,7 +42,6 @@ uint8_t rtc_init(void) {
|
||||
} // rtc_init()
|
||||
|
||||
uint8_t set_rtctime(time_t t) { // t is sec epoch time
|
||||
|
||||
#ifdef RTC_INT // sync rtc 1Hz pulse on top of second
|
||||
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone); // off
|
||||
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeClock); // start
|
||||
@ -55,7 +53,6 @@ uint8_t set_rtctime(time_t t) { // t is sec epoch time
|
||||
} // set_rtctime()
|
||||
|
||||
time_t get_rtctime(uint16_t *msec) {
|
||||
|
||||
time_t t = 0;
|
||||
*msec = 0;
|
||||
if (Rtc.IsDateTimeValid() && Rtc.GetIsRunning()) {
|
||||
|
@ -72,7 +72,6 @@ void SendPayload(uint8_t port) {
|
||||
|
||||
// timer triggered function to prepare payload to send
|
||||
void sendData() {
|
||||
|
||||
uint8_t bitmask = cfg.payloadmask;
|
||||
uint8_t mask = 1;
|
||||
|
||||
@ -91,7 +90,6 @@ void sendData() {
|
||||
|
||||
while (bitmask) {
|
||||
switch (bitmask & mask) {
|
||||
|
||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||
case COUNT_DATA:
|
||||
payload.reset();
|
||||
@ -197,7 +195,6 @@ void sendData() {
|
||||
SendPayload(BATTPORT);
|
||||
break;
|
||||
#endif
|
||||
|
||||
} // switch
|
||||
bitmask &= ~mask;
|
||||
mask <<= 1;
|
||||
|
@ -9,7 +9,6 @@ static const char TAG[] = __FILE__;
|
||||
10 // max. size of user sensor data buffer in bytes [default=20]
|
||||
|
||||
void sensor_init(void) {
|
||||
|
||||
// this function is called during device startup
|
||||
// put your user sensor initialization routines here
|
||||
}
|
||||
@ -38,14 +37,11 @@ uint8_t sensor_mask(uint8_t sensor_no) {
|
||||
}
|
||||
|
||||
uint8_t *sensor_read(uint8_t sensor) {
|
||||
|
||||
static uint8_t buf[SENSORBUFFER] = {0};
|
||||
uint8_t length = 3;
|
||||
|
||||
switch (sensor) {
|
||||
|
||||
case 1:
|
||||
|
||||
// insert user specific sensor data frames here
|
||||
buf[0] = length;
|
||||
buf[1] = 0x01;
|
||||
@ -53,15 +49,12 @@ uint8_t *sensor_read(uint8_t sensor) {
|
||||
buf[3] = 0x03;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
buf[0] = length;
|
||||
buf[1] = 0x01;
|
||||
buf[2] = 0x02;
|
||||
buf[3] = 0x03;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
buf[0] = length;
|
||||
buf[1] = 0x01;
|
||||
buf[2] = 0x02;
|
||||
@ -70,4 +63,4 @@ uint8_t *sensor_read(uint8_t sensor) {
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
@ -56,7 +56,6 @@ void timesync_request(void) {
|
||||
|
||||
// task for processing time sync request
|
||||
void timesync_processReq(void *taskparameter) {
|
||||
|
||||
uint32_t rcv_seqNo = TIME_SYNC_END_FLAG;
|
||||
uint32_t time_offset_sec = 0, time_offset_ms = 0;
|
||||
|
||||
@ -68,7 +67,6 @@ void timesync_processReq(void *taskparameter) {
|
||||
// --- asnychronous part: generate and collect timestamps from gateway ---
|
||||
|
||||
while (1) {
|
||||
|
||||
// wait for kickoff
|
||||
ulTaskNotifyTake(pdFALSE, portMAX_DELAY);
|
||||
|
||||
@ -85,7 +83,6 @@ void timesync_processReq(void *taskparameter) {
|
||||
|
||||
// collect timestamp samples in timestamp array
|
||||
for (int8_t i = 0; i < TIME_SYNC_SAMPLES; i++) {
|
||||
|
||||
// send timesync request
|
||||
#if (TIME_SYNC_LORASERVER) // ask user's timeserver (for LoRAWAN < 1.0.3)
|
||||
payload.reset();
|
||||
@ -122,7 +119,6 @@ void timesync_processReq(void *taskparameter) {
|
||||
// if we are not in last cycle, pause until next cycle
|
||||
if (i < TIME_SYNC_SAMPLES - 1)
|
||||
vTaskDelay(pdMS_TO_TICKS(TIME_SYNC_CYCLE * 1000));
|
||||
|
||||
} // for i
|
||||
|
||||
// --- time critial part: evaluate timestamps and calculate time ---
|
||||
@ -174,7 +170,6 @@ void timesync_store(uint32_t timestamp, timesync_t timestamp_type) {
|
||||
|
||||
// callback function to receive time answer from network or answer
|
||||
void timesync_serverAnswer(void *pUserData, int flag) {
|
||||
|
||||
#if (HAS_LORA_TIME)
|
||||
|
||||
// if no timesync handshake is pending then exit
|
||||
|
Loading…
Reference in New Issue
Block a user