From 06626f33495cd82d9452e3ba4331caa839be6103 Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Wed, 24 Jun 2026 11:20:16 -0400 Subject: [PATCH] cleanup: removed dead code, fixed small issues --- CMakeLists.txt | 4 +++- ensaht.c | 4 ++-- mqtt.c | 32 -------------------------------- mqtt.h | 2 -- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4915c35..2cc8235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,8 @@ add_custom_target(flash -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 10000" - -c "program ${CMAKE_CURRENT_BINARY_DIR}/ensaht.elf verify reset exit" + -c "program ${CMAKE_CURRENT_BINARY_DIR}/ensaht.elf verify" + -c "reset init" + -c "exit" DEPENDS ensaht ) diff --git a/ensaht.c b/ensaht.c index 0e1fff9..56ee70a 100644 --- a/ensaht.c +++ b/ensaht.c @@ -25,7 +25,7 @@ uint8_t ENS_IDLE[2] = {0x10, 0x01}; #define ENS_ECO2 0x24 #define ENS_ETOH 0x26 -#define AVERAGES 16 +#define AVERAGES 4 // MQTT and WiFi defines #define ADAFRUIT_IO_HOST "io.adafruit.com" @@ -187,7 +187,7 @@ int main() { } avg_t = average_double(t_avg, sample_count); avg_h = average_double(h_avg, sample_count); - printf("\x1b[J\x1b[HTemperature %0.2f Humidity %0.2f\n", avg_t, avg_h); + printf("\x1b[H\x1b[JTemperature %0.2f Humidity %0.2f\n", avg_t, avg_h); validData = getENSData(&avg_t, &avg_h, &aqi, &tvoc, &eco2, &etoh); tvoc_avg[i] = tvoc; eco2_avg[i] = eco2; diff --git a/mqtt.c b/mqtt.c index f2a3b61..3efff24 100644 --- a/mqtt.c +++ b/mqtt.c @@ -122,36 +122,4 @@ err_t ensaht_mqtt_publish_client(ensaht_mqtt_t *mqtt, const char *topic, return err; } -err_t ensaht_mqtt_pingreq(mqtt_client_t *client) { - static const u8_t pingreq[] = {0xC0, 0x00}; - err_t err; - LWIP_ASSERT_CORE_LOCKED(); - if (client == NULL || client->conn == NULL || - !mqtt_client_is_connected(client)) { - return ERR_CONN; - } - - err = - altcp_write(client->conn, pingreq, sizeof(pingreq), TCP_WRITE_FLAG_COPY); - if (err == ERR_OK) { - client->cyclic_tick = 0; - err = altcp_output(client->conn); - } - - return err; -} - -err_t ensaht_mqtt_pingreq_client(ensaht_mqtt_t *mqtt) { - err_t err; - - if (mqtt == NULL || mqtt->client == NULL) { - return ERR_CONN; - } - - cyw43_arch_lwip_begin(); - err = ensaht_mqtt_pingreq(mqtt->client); - cyw43_arch_lwip_end(); - - return err; -} diff --git a/mqtt.h b/mqtt.h index abfb536..65f64d1 100644 --- a/mqtt.h +++ b/mqtt.h @@ -25,7 +25,5 @@ err_t ensaht_mqtt_publish(mqtt_client_t *client, const char *topic, err_t ensaht_mqtt_publish_client(ensaht_mqtt_t *mqtt, const char *topic, const void *payload, u16_t payload_length, mqtt_request_cb_t cb, void *arg); -err_t ensaht_mqtt_pingreq(mqtt_client_t *client); -err_t ensaht_mqtt_pingreq_client(ensaht_mqtt_t *mqtt); #endif