new buzzer component

This commit is contained in:
2025-07-22 00:09:58 +01:00
parent 84f106eee5
commit bd587a10c0
58 changed files with 3215 additions and 6961 deletions

View File

@@ -62,29 +62,56 @@ static void publish_message(const char* topic, cJSON* root)
free((void*)json);
}
static void handle_message(const char* topic, const char* data)
{
char base_topic[32];
mqtt_get_base_topic(base_topic);
ESP_LOGI(TAG, "[MQTT] Message received");
ESP_LOGI(TAG, " > Topic: %s", topic);
ESP_LOGI(TAG, " > Payload: %s", data);
ESP_LOGI(TAG, "Topic: %s", topic);
ESP_LOGI(TAG, "data: %s", data);
ESP_LOGI(TAG, "base_topic: %s", base_topic);
if (strncmp(topic, base_topic, strlen(base_topic)) == 0) {
const char* sub_topic = &topic[strlen(base_topic)];
ESP_LOGI(TAG, " > Subtopic detected: %s", sub_topic);
ESP_LOGI(TAG, "Sub_topic: %s", sub_topic);
if (strcmp(sub_topic, "/request/config/evse") == 0) {
ESP_LOGI(TAG, " → Responding with EVSE configuration");
cJSON* root = json_get_evse_config();
publish_message("/response/config/evse", root);
cJSON_Delete(root);
} else {
ESP_LOGW(TAG, " ! Unknown command: %s", sub_topic);
}
} else {
ESP_LOGW(TAG, " ! Topic does not match base: %s", topic);
} else if (strcmp(sub_topic, "/request/config/wifi") == 0) {
//cJSON* root = json_get_wifi_config();
//publish_message("/response/config/wifi", root);
//cJSON_Delete(root);
} else if (strcmp(sub_topic, "/request/config/mqtt") == 0) {
cJSON* root = json_get_mqtt_config();
publish_message("/response/config/mqtt", root);
cJSON_Delete(root);
} else if (strcmp(sub_topic, "/request/boardConfig") == 0) {
cJSON* root = json_get_board_config();
publish_message("/response/boardConfig", root);
cJSON_Delete(root);
} else if (strcmp(sub_topic, "/request/info") == 0) {
cJSON* root = json_get_info();
publish_message("/response/info", root);
cJSON_Delete(root);
} else if (strcmp(sub_topic, "/request/restart") == 0) {
timeout_restart();
} else if (strcmp(sub_topic, "/set/config/evse") == 0) {
cJSON* root = cJSON_Parse(data);
json_set_evse_config(root);
cJSON_Delete(root);
} else if (strcmp(sub_topic, "/set/config/wifi") == 0) {
//cJSON* root = cJSON_Parse(data);
//json_set_wifi_config(root, true);
//cJSON_Delete(root);
} else if (strcmp(sub_topic, "/set/config/mqtt") == 0) {
cJSON* root = cJSON_Parse(data);
json_set_mqtt_config(root);
cJSON_Delete(root);
}
}
}