diff --git a/include/payload.h b/include/payload.h index e8376bf6..43bbb1d8 100644 --- a/include/payload.h +++ b/include/payload.h @@ -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); diff --git a/lib/BintrayClient/src/BintrayClient.h b/lib/BintrayClient/src/BintrayClient.h index d0b7e67d..ec478893 100644 --- a/lib/BintrayClient/src/BintrayClient.h +++ b/lib/BintrayClient/src/BintrayClient.h @@ -23,7 +23,6 @@ #include class BintrayClient { - public: BintrayClient(const String& user, const String& repository, const String& package); String getUser() const; diff --git a/src/bmesensor.cpp b/src/bmesensor.cpp index edda04f8..f790051b 100644 --- a/src/bmesensor.cpp +++ b/src/bmesensor.cpp @@ -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 diff --git a/src/boot.cpp b/src/boot.cpp index 28202243..6d271132 100644 --- a/src/boot.cpp +++ b/src/boot.cpp @@ -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 diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 6112444d..77557281 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -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; diff --git a/src/cyclic.cpp b/src/cyclic.cpp index f5d905c0..ef2f2d5c 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -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() { diff --git a/src/dcf77.cpp b/src/dcf77.cpp index 8b30dcf4..794ff5a6 100644 --- a/src/dcf77.cpp +++ b/src/dcf77.cpp @@ -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 \ No newline at end of file diff --git a/src/i2c.cpp b/src/i2c.cpp index 1d7a3dd7..02c307f0 100644 --- a/src/i2c.cpp +++ b/src/i2c.cpp @@ -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; -} +} \ No newline at end of file diff --git a/src/if482.cpp b/src/if482.cpp index 81add69a..14592470 100644 --- a/src/if482.cpp +++ b/src/if482.cpp @@ -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) diff --git a/src/irqhandler.cpp b/src/irqhandler.cpp index b971aeac..81b24304 100644 --- a/src/irqhandler.cpp +++ b/src/irqhandler.cpp @@ -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; diff --git a/src/led.cpp b/src/led.cpp index 8095a3a9..ecd5b99a 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -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)) { diff --git a/src/loraconf_abp.cpp b/src/loraconf_abp.cpp index 675b90fa..84a7ed44 100644 --- a/src/loraconf_abp.cpp +++ b/src/loraconf_abp.cpp @@ -14,7 +14,6 @@ *********************************************************************/ void setABPParameters() { - /** ************************************************************** * ************************************************************* */ #if defined(CFG_eu868) diff --git a/src/mqttclient.cpp b/src/mqttclient.cpp index c8d85ceb..f490fd85 100644 --- a/src/mqttclient.cpp +++ b/src/mqttclient.cpp @@ -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, diff --git a/src/rtctime.cpp b/src/rtctime.cpp index 0de8e176..23b3ad20 100644 --- a/src/rtctime.cpp +++ b/src/rtctime.cpp @@ -9,7 +9,6 @@ RtcDS3231 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()) { diff --git a/src/senddata.cpp b/src/senddata.cpp index 518fd30f..1d4bd81b 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -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; diff --git a/src/sensor.cpp b/src/sensor.cpp index 2d077175..7189b6fa 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -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; -} +} \ No newline at end of file diff --git a/src/timesync.cpp b/src/timesync.cpp index 8660c597..917afef4 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -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