diff --git a/include/mqtt_handler.h b/include/mqtt_handler.h index 993409c..6f5da85 100644 --- a/include/mqtt_handler.h +++ b/include/mqtt_handler.h @@ -6,6 +6,14 @@ #include "ch32v003fun.h" #include "w5500.h" +// Options structure for client identification +typedef struct { + char* clientid; + char* username; + char* password; + int qos; +} ch32_mqtt_options_t; + typedef struct { Network network; MQTTClient client; diff --git a/include/spi_dma.h b/include/spi_dma.h index 6e718cc..024259c 100644 --- a/include/spi_dma.h +++ b/include/spi_dma.h @@ -20,11 +20,11 @@ void spidma_read_buffer(uint8_t *buf, uint16_t len); // SPI DMA buffer write void spidma_write_buffer(uint8_t *buf, uint16_t len); -// SPI (non-DMA) byte read -uint8_t spi_read_byte(); +// // SPI (non-DMA) byte read +// uint8_t spi_read_byte(); -// SPI (non-DMA) byte write -void spi_write_byte(uint8_t byte); +// // SPI (non-DMA) byte write +// void spi_write_byte(uint8_t byte); // activate CS void spi_select(void); diff --git a/include/uart.h b/include/uart.h index c69c9a7..d3bdec0 100644 --- a/include/uart.h +++ b/include/uart.h @@ -7,13 +7,16 @@ // Macro definitions #define APB1_CLOCK (FUNCONF_SYSTEM_CORE_CLOCK / 2) // APB1 is divided by 2 -#define UART_BRR_APB1 \ - (((APB1_CLOCK) + (UART_BAUD_RATE / 2)) / (UART_BAUD_RATE)) // USART2 -#define UART_BRR_APB2 \ - (((FUNCONF_SYSTEM_CORE_CLOCK) + (UART1_BAUD_RATE / 2)) / \ - (UART1_BAUD_RATE)) // USART1 + +// USART2 +#define UART_BRR_APB1 (((APB1_CLOCK) + (UART_BAUD_RATE / 2)) / (UART_BAUD_RATE)) + +// USART1 +#define UART_BRR_APB2 \ + (((FUNCONF_SYSTEM_CORE_CLOCK) + (UART1_BAUD_RATE / 2)) / (UART1_BAUD_RATE)) // Function prototypes + void init_uart(int uart_brr); #endif // UART_H diff --git a/include/w5500.h b/include/w5500.h index 37b36ee..9ee2d11 100644 --- a/include/w5500.h +++ b/include/w5500.h @@ -9,23 +9,11 @@ #define DNS_SOCKET 1 #define TCP_SOCKET 2 -// Options structure for client identification -typedef struct { - char* clientid; - char* username; - char* password; - int qos; -} ch32_mqtt_options_t; - extern volatile int ip_assigned; // Initializes the W5500 chip void configure_network(void); -// void configure_dhcp(void); -void dhcp_init(void); -void dhcp_process(void); - // resolves a domain name // void resolve_domain_name(const char* domain_name); diff --git a/src/modbus_handler.c b/src/modbus_handler.c index 169bc1b..707bff9 100644 --- a/src/modbus_handler.c +++ b/src/modbus_handler.c @@ -12,7 +12,9 @@ static struct { char last_property[16]; } handler; -static void on_modbus_response(uint8_t* buf, uint16_t len, uint16_t value) { +static void on_modbus_response(uint8_t* buf __attribute__((unused)), + uint16_t len __attribute__((unused)), + uint16_t value) { if (handler.last_device_idx >= RS485_DEVICE_COUNT || !handler.value_cb) { return; } @@ -25,7 +27,7 @@ static void on_modbus_response(uint8_t* buf, uint16_t len, uint16_t value) { handler.last_property[0] = '\0'; } -static void on_modbus_error(uint8_t error_code) { +static void on_modbus_error(uint8_t error_code __attribute__((unused))) { // clear the context on error handler.last_device_idx = 0xFF; handler.last_property[0] = '\0'; diff --git a/src/mqtt_handler.c b/src/mqtt_handler.c index 9c7b1f2..9f32dc8 100644 --- a/src/mqtt_handler.c +++ b/src/mqtt_handler.c @@ -21,14 +21,6 @@ #define HOMIE_STATE_DISCONNECTED "disconnected" #define MAX_PAYLOAD_LENGTH 256 -// TODO: -// Property definitions -typedef enum { - PROP_STATE, // for relay - PROP_MOISTURE, // for soil sensor - PROP_TEMPERATURE, // for soil sensor and thermometer -} device_property_t; - // Parse Homie topic format: homie/node-id/device-name/property/[set|get] // Returns: 1 if successful, 0 if invalid format or buffer overflow static uint8_t parse_homie_topic(const char* topic, size_t topic_len,