chore: reorganize source organization to a more modern style

This commit is contained in:
A.M. Rowsell 2026-06-30 06:21:52 -04:00
commit 0425836642
12 changed files with 16 additions and 10 deletions

11
include/aht.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef AHT_H
#define AHT_H
#include "hardware/i2c.h"
#include <stdint.h>
#define AHT_ADDR 0x38
void getAHTData(i2c_inst_t *i2c, double *t, double *h);
#endif // AHT_H

55
include/bmp.h Normal file
View file

@ -0,0 +1,55 @@
#ifndef BMP_H
#define BMP_H
#include "hardware/i2c.h"
#include <stdint.h>
#define BMP_ADDR 0x77
static const uint8_t BMP_STATUS = 0x03;
static const uint8_t BMP_DATA = 0x04;
static const uint8_t BMP_CAL_ADDR = 0x31;
#define BMP_CAL_LEN 21
// instead of a bunch of defines
enum {
PAR_T1,
PAR_T2,
PAR_T3,
PAR_P1,
PAR_P2,
PAR_P3,
PAR_P4,
PAR_P5,
PAR_P6,
PAR_P7,
PAR_P8,
PAR_P9,
PAR_P10,
PAR_P11
};
// raw calibration data
typedef struct {
uint16_t NVM_PAR_T1;
uint16_t NVM_PAR_T2;
int8_t NVM_PAR_T3;
int16_t NVM_PAR_P1;
int16_t NVM_PAR_P2;
int8_t NVM_PAR_P3;
int8_t NVM_PAR_P4;
uint16_t NVM_PAR_P5;
uint16_t NVM_PAR_P6;
int8_t NVM_PAR_P7;
int8_t NVM_PAR_P8;
int16_t NVM_PAR_P9;
int8_t NVM_PAR_P10;
int8_t NVM_PAR_P11;
} bmp_cal_data_t;
// floating point conversions
extern float bmp_cal_data_fp[15];
int getBMPData(i2c_inst_t *i2c, float *temperature, float *pressure);
int getBMPCalData(i2c_inst_t *i2c, bmp_cal_data_t *cal);
int initBMP(i2c_inst_t *i2c);
#endif // BMP_H

23
include/ens.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef ENS_H
#define ENS_H
#include <stdint.h>
#define ENS_ADDR 0x53
#define ENS_TEMP_IN 0x13
#define ENS_HUM_IN 0x15
#define ENS_STATUS 0x20
#define ENS_STATUS_MASK 0x0C
#define ENS_AQI 0x21
#define ENS_TVOC 0x22
#define ENS_ECO2 0x24
#define ENS_ETOH 0x26
#include "hardware/i2c.h"
void activateENS(i2c_inst_t *i2c);
void deactivateENS(i2c_inst_t *i2c);
uint8_t getENSData(i2c_inst_t *i2c, double *t, double *h, uint8_t *AQI, uint16_t *TVOC,
uint16_t *ECO2, uint16_t *ETOH);
#endif // ENS_H

109
include/lwipopts.h Normal file
View file

@ -0,0 +1,109 @@
#ifndef _LWIPOPTS_H
#define _LWIPOPTS_H
// Common settings used in most of the pico_w examples
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
// allow override in some examples
#ifndef NO_SYS
#define NO_SYS 1
#endif
// allow override in some examples
#ifndef LWIP_SOCKET
#define LWIP_SOCKET 0
#endif
#if PICO_CYW43_ARCH_POLL
#define MEM_LIBC_MALLOC 1
#else
// MEM_LIBC_MALLOC is incompatible with non polling versions
#define MEM_LIBC_MALLOC 0
#endif
#define MEM_ALIGNMENT 4
#ifndef MEM_SIZE
#define MEM_SIZE 4000
#endif
#define MEMP_NUM_TCP_SEG 32
#define MEMP_NUM_ARP_QUEUE 10
#define PBUF_POOL_SIZE 24
#define LWIP_ARP 1
#define LWIP_ETHERNET 1
#define LWIP_ICMP 1
#define LWIP_RAW 1
#define TCP_WND (8 * TCP_MSS)
#define TCP_MSS 1460
#define TCP_SND_BUF (8 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETCONN 0
#define MEM_STATS 0
#define SYS_STATS 0
#define MEMP_STATS 0
#define LINK_STATS 0
// #define ETH_PAD_SIZE 2
#define LWIP_CHKSUM_ALGORITHM 3
#define LWIP_DHCP 1
#define LWIP_IPV4 1
#define LWIP_TCP 1
#define LWIP_UDP 1
#define LWIP_DNS 1
#define LWIP_TCP_KEEPALIVE 1
#define LWIP_NETIF_TX_SINGLE_PBUF 1
#define DHCP_DOES_ARP_CHECK 0
#define LWIP_DHCP_DOES_ACD_CHECK 0
#ifndef NDEBUG
#define LWIP_DEBUG 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1
#endif
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define PPP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
/* TCP WND must be at least 16 kb to match TLS record size
or you will get a warning "altcp_tls: TCP_WND is smaller than the RX decrypion buffer, connection RX might stall!" */
#undef TCP_WND
#define TCP_WND 16384
#undef MEMP_NUM_SYS_TIMEOUT
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 8)
#undef MQTT_REQ_MAX_IN_FLIGHT
#define MQTT_REQ_MAX_IN_FLIGHT 8
#define LWIP_ALTCP 1
#define LWIP_ALTCP_TLS 1
#define LWIP_ALTCP_TLS_MBEDTLS 1
#undef LWIP_DEBUG
#define ALTCP_MBEDTLS_DEBUG LWIP_DBG_ON
#endif /* __LWIPOPTS_H__ */

75
include/mbedtls_config.h Normal file
View file

@ -0,0 +1,75 @@
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
/* Workaround for some mbedtls source files using INT_MAX without including limits.h */
#include <limits.h>
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#define MBEDTLS_SSL_OUT_CONTENT_LEN 2048
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_PLATFORM_MS_TIME_ALT
#define MBEDTLS_CIPHER_MODE_CBC
#define MBEDTLS_ECP_DP_SECP192R1_ENABLED
#define MBEDTLS_ECP_DP_SECP224R1_ENABLED
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
#define MBEDTLS_ECP_DP_SECP521R1_ENABLED
#define MBEDTLS_ECP_DP_SECP192K1_ENABLED
#define MBEDTLS_ECP_DP_SECP224K1_ENABLED
#define MBEDTLS_ECP_DP_SECP256K1_ENABLED
#define MBEDTLS_ECP_DP_BP256R1_ENABLED
#define MBEDTLS_ECP_DP_BP384R1_ENABLED
#define MBEDTLS_ECP_DP_BP512R1_ENABLED
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
#define MBEDTLS_PKCS1_V15
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SSL_SERVER_NAME_INDICATION
#define MBEDTLS_AES_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_ENTROPY_C
#define MBEDTLS_ERROR_C
#define MBEDTLS_MD_C
#define MBEDTLS_MD5_C
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS5_C
#define MBEDTLS_PK_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_RSA_C
#define MBEDTLS_SHA1_C
#define MBEDTLS_SHA224_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA512_C
#define MBEDTLS_SSL_CLI_C
#define MBEDTLS_SSL_SRV_C
#define MBEDTLS_SSL_TLS_C
#define MBEDTLS_X509_CRT_PARSE_C
#define MBEDTLS_X509_USE_C
#define MBEDTLS_AES_FEWER_TABLES
/* TLS 1.2 */
#define MBEDTLS_SSL_PROTO_TLS1_2
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#define MBEDTLS_GCM_C
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECP_C
#define MBEDTLS_ECDSA_C
#define MBEDTLS_ASN1_WRITE_C
// The following is needed to parse a certificate
#define MBEDTLS_PEM_PARSE_C
#define MBEDTLS_BASE64_C
// The following significantly speeds up mbedtls due to NIST optimizations.
#define MBEDTLS_ECP_NIST_OPTIM
#endif

29
include/mqtt.h Normal file
View file

@ -0,0 +1,29 @@
#ifndef ENSAHT_MQTT_H
#define ENSAHT_MQTT_H
#include "lwip/apps/mqtt.h"
typedef struct {
mqtt_client_t *client;
ip_addr_t server_addr;
const char *hostname;
u16_t port;
struct mqtt_connect_client_info_t client_info;
mqtt_connection_cb_t connect_cb;
void *connect_arg;
} ensaht_mqtt_t;
void ensaht_mqtt_init(ensaht_mqtt_t *mqtt);
err_t ensaht_mqtt_connect(ensaht_mqtt_t *mqtt, const char *hostname, u16_t port,
const struct mqtt_connect_client_info_t *client_info,
mqtt_connection_cb_t cb, void *arg);
void ensaht_mqtt_disconnect(ensaht_mqtt_t *mqtt);
err_t ensaht_mqtt_publish(mqtt_client_t *client, const char *topic,
const void *payload, u16_t payload_length,
mqtt_request_cb_t cb, void *arg);
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);
#endif