|
|
@ -9,11 +9,15 @@
|
|
|
|
#include <zigbee/zigbee_app_utils.h>
|
|
|
|
#include <zigbee/zigbee_app_utils.h>
|
|
|
|
#include <zb_nrf_platform.h>
|
|
|
|
#include <zb_nrf_platform.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <zigbee/zigbee_fota.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <zephyr/sys/reboot.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "switch.h"
|
|
|
|
#include "switch.h"
|
|
|
|
|
|
|
|
|
|
|
|
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
|
|
|
|
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
|
|
|
|
|
|
|
|
|
|
|
|
#define INFO_ENDPOINT CONFIG_ZIGBEE_SHELL_ENDPOINT
|
|
|
|
#define INFO_ENDPOINT 64
|
|
|
|
#define SW0_EP 1
|
|
|
|
#define SW0_EP 1
|
|
|
|
#define SW1_EP 2
|
|
|
|
#define SW1_EP 2
|
|
|
|
#define SW2_EP 3
|
|
|
|
#define SW2_EP 3
|
|
|
@ -94,13 +98,16 @@ ZB_DECLARE_SW_EP(sw1_ep, SW1_EP, app_ram.states[1], app_static.types[1], app_nvr
|
|
|
|
ZB_DECLARE_SW_EP(sw2_ep, SW2_EP, app_ram.states[2], app_static.types[2], app_nvram.actions[2]);
|
|
|
|
ZB_DECLARE_SW_EP(sw2_ep, SW2_EP, app_ram.states[2], app_static.types[2], app_nvram.actions[2]);
|
|
|
|
ZB_DECLARE_SW_EP(sw3_ep, SW3_EP, app_ram.states[3], app_static.types[3], app_nvram.actions[3]);
|
|
|
|
ZB_DECLARE_SW_EP(sw3_ep, SW3_EP, app_ram.states[3], app_static.types[3], app_nvram.actions[3]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern zb_af_endpoint_desc_t zigbee_fota_client_ep;
|
|
|
|
|
|
|
|
|
|
|
|
ZBOSS_DECLARE_DEVICE_CTX_EP_VA(
|
|
|
|
ZBOSS_DECLARE_DEVICE_CTX_EP_VA(
|
|
|
|
zigbee_ctx,
|
|
|
|
zigbee_ctx,
|
|
|
|
&info_ep,
|
|
|
|
&info_ep,
|
|
|
|
&sw0_ep,
|
|
|
|
&sw0_ep,
|
|
|
|
&sw1_ep,
|
|
|
|
&sw1_ep,
|
|
|
|
&sw2_ep,
|
|
|
|
&sw2_ep,
|
|
|
|
&sw3_ep);
|
|
|
|
&sw3_ep,
|
|
|
|
|
|
|
|
&zigbee_fota_client_ep);
|
|
|
|
|
|
|
|
|
|
|
|
static const struct gpio_dt_spec network_led = GPIO_DT_SPEC_GET(DT_NODELABEL(network_led), gpios);
|
|
|
|
static const struct gpio_dt_spec network_led = GPIO_DT_SPEC_GET(DT_NODELABEL(network_led), gpios);
|
|
|
|
static const struct gpio_dt_spec sw[4] = {
|
|
|
|
static const struct gpio_dt_spec sw[4] = {
|
|
|
@ -191,6 +198,7 @@ static void configure_gpio(void)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void zboss_signal_handler(zb_bufid_t bufid)
|
|
|
|
void zboss_signal_handler(zb_bufid_t bufid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
zigbee_fota_signal_handler(bufid);
|
|
|
|
gpio_pin_toggle_dt(&network_led);
|
|
|
|
gpio_pin_toggle_dt(&network_led);
|
|
|
|
|
|
|
|
|
|
|
|
zb_zdo_app_signal_hdr_t *sig_handler = NULL;
|
|
|
|
zb_zdo_app_signal_hdr_t *sig_handler = NULL;
|
|
|
@ -297,6 +305,23 @@ static void zcl_device_cb(zb_bufid_t bufid) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**@brief Callback function for handling OTA events.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param[in] *evt Structure containing event information
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void ota_evt_handler(const struct zigbee_fota_evt *evt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (evt->id) {
|
|
|
|
|
|
|
|
case ZIGBEE_FOTA_EVT_FINISHED:
|
|
|
|
|
|
|
|
LOG_INF("Reboot application.");
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_RAM_POWER_DOWN_LIBRARY)) {
|
|
|
|
|
|
|
|
power_up_unused_ram();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sys_reboot(SYS_REBOOT_COLD);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_INF("Starting jamie");
|
|
|
|
LOG_INF("Starting jamie");
|
|
|
@ -310,9 +335,15 @@ int main(void)
|
|
|
|
/* Register device context (endpoints). */
|
|
|
|
/* Register device context (endpoints). */
|
|
|
|
ZB_AF_REGISTER_DEVICE_CTX(&zigbee_ctx);
|
|
|
|
ZB_AF_REGISTER_DEVICE_CTX(&zigbee_ctx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize Zigbee FOTA download service. */
|
|
|
|
|
|
|
|
zigbee_fota_init(ota_evt_handler);
|
|
|
|
|
|
|
|
/* Register callback for handling ZCL commands. */
|
|
|
|
|
|
|
|
ZB_ZCL_REGISTER_DEVICE_CB(zigbee_fota_zcl_cb);
|
|
|
|
|
|
|
|
|
|
|
|
zigbee_init_clusters();
|
|
|
|
zigbee_init_clusters();
|
|
|
|
|
|
|
|
|
|
|
|
ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(INFO_ENDPOINT, identify_cb);
|
|
|
|
ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(INFO_ENDPOINT, identify_cb);
|
|
|
|
|
|
|
|
ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(CONFIG_ZIGBEE_FOTA_ENDPOINT, identify_cb);
|
|
|
|
|
|
|
|
|
|
|
|
zb_nvram_register_app1_read_cb(app_nvram_read);
|
|
|
|
zb_nvram_register_app1_read_cb(app_nvram_read);
|
|
|
|
zb_nvram_register_app1_write_cb(app_nvram_write, app_nvram_size);
|
|
|
|
zb_nvram_register_app1_write_cb(app_nvram_write, app_nvram_size);
|
|
|
@ -321,6 +352,10 @@ int main(void)
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INF("Zigbee Stack Initialized");
|
|
|
|
LOG_INF("Zigbee Stack Initialized");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boot_write_img_confirmed();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INF("Confirmed firmware");
|
|
|
|
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
while(true) {
|
|
|
|
queue_item_t* item = (queue_item_t*) k_queue_get(&switch_queue, K_FOREVER);
|
|
|
|
queue_item_t* item = (queue_item_t*) k_queue_get(&switch_queue, K_FOREVER);
|
|
|
|
if(item != NULL) {
|
|
|
|
if(item != NULL) {
|
|
|
|