diff --git a/src/zigbee_router/app.c b/src/zigbee_router/app.c index 6d56963a..f8f166a9 100644 --- a/src/zigbee_router/app.c +++ b/src/zigbee_router/app.c @@ -26,8 +26,10 @@ #if (LARGE_NETWORK_TESTING == 0) +#include "btl_interface.h" #include "network-steering.h" #include "stack/include/zigbee-device-stack.h" +#include "app/framework/plugin/basic/basic.h" #if defined(SL_CATALOG_LED0_PRESENT) #include "sl_led.h" @@ -44,12 +46,12 @@ #define NWK_STEERING_COOLDOWN_MS 10000 -static sl_zigbee_af_event_t commissioning_led_event; +static sl_zigbee_af_event_t commissioning_event; //--------------- // Event handlers -static void commissioning_led_event_handler(sl_zigbee_af_event_t *event) +static void commissioning_event_handler(sl_zigbee_af_event_t *event) { led_turn_on(COMMISSIONING_STATUS_LED); @@ -73,9 +75,10 @@ void sl_zigbee_af_stack_status_cb(sl_status_t status) { if (status == SL_STATUS_NETWORK_DOWN) { led_turn_off(COMMISSIONING_STATUS_LED); - sl_zigbee_af_event_set_delay_ms(&commissioning_led_event, NWK_STEERING_COOLDOWN_MS); + sl_zigbee_af_event_set_delay_ms(&commissioning_event, NWK_STEERING_COOLDOWN_MS); } else if (status == SL_STATUS_NETWORK_UP) { - // make some noise on start for reconnect (otherwise perceived as offline until pinged) + // make some noise on start for reconnect + // (otherwise perceived as offline until pinged) sl_zigbee_send_device_announcement(); led_turn_on(COMMISSIONING_STATUS_LED); } @@ -86,9 +89,9 @@ void sl_zigbee_af_stack_status_cb(sl_status_t status) */ void sl_zigbee_af_main_init_cb(void) { - sl_zigbee_af_event_init(&commissioning_led_event, commissioning_led_event_handler); + sl_zigbee_af_event_init(&commissioning_event, commissioning_event_handler); - sl_zigbee_af_event_set_active(&commissioning_led_event); + sl_zigbee_af_event_set_active(&commissioning_event); } /** @brief Complete network steering. @@ -118,10 +121,25 @@ void sl_zigbee_af_network_steering_complete_cb(sl_status_t status, if (status != SL_STATUS_OK) { led_turn_off(COMMISSIONING_STATUS_LED); - sl_zigbee_af_event_set_delay_ms(&commissioning_led_event, NWK_STEERING_COOLDOWN_MS); + sl_zigbee_af_event_set_delay_ms(&commissioning_event, NWK_STEERING_COOLDOWN_MS); } } +/** @brief Reset To Factory Defaults + * + * This function is called by the Basic server plugin when a request to reset + * to factory defaults is received. The plugin will reset attributes managed by + * the framework to their default values. The application should perform any + * other necessary reset-related operations in this callback, including + * resetting any externally-stored attributes. + * + * @param endpoint Ver.: always + */ +void sl_zigbee_af_basic_reset_to_factory_defaults_cb(uint8_t endpoint) +{ + bootloader_rebootAndInstall(); +} + /** @brief * * Application framework equivalent of ::sl_zigbee_radio_needs_calibrating_handler