chore: cleanup
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
// 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)) // USART1
|
||||
(((FUNCONF_SYSTEM_CORE_CLOCK) + (UART1_BAUD_RATE / 2)) / (UART1_BAUD_RATE))
|
||||
|
||||
// Function prototypes
|
||||
|
||||
void init_uart(int uart_brr);
|
||||
|
||||
#endif // UART_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);
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user