From 98a97a03a65618604c9d6d54212f36dd96f0a2ba Mon Sep 17 00:00:00 2001 From: Jmspencer41 Date: Wed, 13 Aug 2025 16:12:29 -0400 Subject: [PATCH] Fixed errors --- main/main.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/main/main.c b/main/main.c index 9cdb403..48f98cd 100644 --- a/main/main.c +++ b/main/main.c @@ -14,6 +14,11 @@ static const char *TAG = "SIMPLE_LIGHT_CONTROLLER"; static bool led_is_on = false; static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message); +// Helper function for scheduler callback +static void commissioning_restart_cb(uint8_t param) { + esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING); +} + static void led_task(void *pvParameters) { gpio_reset_pin(LED_PIN); // Reset pin to default state (clean slate) @@ -115,15 +120,11 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) // === NETWORK JOINING ATTEMPT RESULT === case ESP_ZB_BDB_SIGNAL_STEERING: - // Check if joining was successful if (signal_struct->esp_err_status == ESP_OK) { ESP_LOGI(TAG, "Successfully joined Zigbee network!"); - ESP_LOGI(TAG, "Your device should now appear in Home Assistant"); } else { ESP_LOGI(TAG, "Failed to join network, retrying in 5 seconds..."); - // Retry joining after 5 second delay - esp_zb_scheduler_alarm((esp_zb_callback_t)esp_zb_bdb_start_top_level_commissioning, - ESP_ZB_BDB_MODE_NETWORK_STEERING, 5000); + esp_zb_scheduler_alarm((esp_zb_callback_t)commissioning_restart_cb, 0, 5000); } break; @@ -143,12 +144,8 @@ void app_main(void) // Saves Zigbee network info so device remembers which network it joined ESP_ERROR_CHECK(nvs_flash_init()); // ESP_ERROR_CHECK = crash if this fails - esp_zb_platform_config_t config = { - .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(), // Set up 2.4GHz radio settings - .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(), // Set up processor settings - }; - - ESP_ERROR_CHECK(esp_zb_platform_config(&config)); // Apply the configuration to board + // Use default platform configuration (simpler approach) + ESP_ERROR_CHECK(esp_zb_platform_config(NULL)); // NULL = use defaults // xTaskCreate = create a new task (mini-program that runs independently) xTaskCreate(led_task, // Function to run (defined above) @@ -166,5 +163,4 @@ void app_main(void) NULL); // No handle needed ESP_LOGI(TAG, "Both tasks started - LED and Zigbee running independently!"); - } \ No newline at end of file -- 2.49.1