Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to launch bootloader. More cleanup. #12

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/zigbee_router/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);

Expand All @@ -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);
}
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading