cleanup: removed dead code, fixed small issues

This commit is contained in:
A.M. Rowsell 2026-06-24 11:20:16 -04:00
commit 06626f3349
4 changed files with 5 additions and 37 deletions

View file

@ -54,6 +54,8 @@ add_custom_target(flash
-f interface/cmsis-dap.cfg -f interface/cmsis-dap.cfg
-f target/rp2040.cfg -f target/rp2040.cfg
-c "adapter speed 10000" -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 DEPENDS ensaht
) )

View file

@ -25,7 +25,7 @@ uint8_t ENS_IDLE[2] = {0x10, 0x01};
#define ENS_ECO2 0x24 #define ENS_ECO2 0x24
#define ENS_ETOH 0x26 #define ENS_ETOH 0x26
#define AVERAGES 16 #define AVERAGES 4
// MQTT and WiFi defines // MQTT and WiFi defines
#define ADAFRUIT_IO_HOST "io.adafruit.com" #define ADAFRUIT_IO_HOST "io.adafruit.com"
@ -187,7 +187,7 @@ int main() {
} }
avg_t = average_double(t_avg, sample_count); avg_t = average_double(t_avg, sample_count);
avg_h = average_double(h_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); validData = getENSData(&avg_t, &avg_h, &aqi, &tvoc, &eco2, &etoh);
tvoc_avg[i] = tvoc; tvoc_avg[i] = tvoc;
eco2_avg[i] = eco2; eco2_avg[i] = eco2;

32
mqtt.c
View file

@ -122,36 +122,4 @@ err_t ensaht_mqtt_publish_client(ensaht_mqtt_t *mqtt, const char *topic,
return err; 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;
}

2
mqtt.h
View file

@ -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, err_t ensaht_mqtt_publish_client(ensaht_mqtt_t *mqtt, const char *topic,
const void *payload, u16_t payload_length, const void *payload, u16_t payload_length,
mqtt_request_cb_t cb, void *arg); 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 #endif