Skip to content

Commit

Permalink
move NCP reboot to init
Browse files Browse the repository at this point in the history
  • Loading branch information
andr-yarm committed Jan 18, 2024
1 parent 2e4dfd6 commit 2931fa0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions blynk_ncp/src/zephyr_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,30 @@ static void ncpThread(void *, void *, void *)
#if DT_HAS_CHOSEN(blynk_ncp_status_led)
gpio_pin_configure_dt(&staus_led, GPIO_OUTPUT_INACTIVE);
#endif

#if DT_HAS_CHOSEN(blynk_ncp_rst)
LOG_WRN("NCP: hard reset");
gpio_pin_configure_dt(&ncp_rst, GPIO_OUTPUT_ACTIVE);
k_msleep(100);
gpio_pin_configure_dt(&ncp_rst, GPIO_OUTPUT_INACTIVE);
k_msleep(10);
k_msleep(100);
#endif

if (!ncpSetupSerial(5000)) {
LOG_ERR("can't setup serial");
return;
}

#if !DT_HAS_CHOSEN(blynk_ncp_rst)
LOG_WRN("NCP: soft reboot");
rpc_ncp_reboot();

if (!ncpSetupSerial(5000)) {
LOG_ERR("can't setup serial");
return;
}
#endif

const char *ncpFwVer = "unknown";
if (!rpc_blynk_getNcpVersion(&ncpFwVer)) {
LOG_ERR("can't get NCP firmware version");
Expand Down Expand Up @@ -229,20 +243,6 @@ static void ncpPingHandler(struct k_work *work)
LOG_INF("NCP ping error. attempt [%d]", err_num);
} else {
err_num = 0;

#if DT_HAS_CHOSEN(blynk_ncp_rst)
LOG_WRN("NCP: hard reset");
gpio_pin_configure_dt(&ncp_rst, GPIO_OUTPUT_ACTIVE);
k_msleep(100);
gpio_pin_configure_dt(&ncp_rst, GPIO_OUTPUT_INACTIVE);
k_msleep(100);
#endif

#if !DT_HAS_CHOSEN(blynk_ncp_rst)
LOG_WRN("NCP: soft reboot");
rpc_ncp_reboot();
k_msleep(50);
#endif
k_timer_start(&ncpReinitTimer, K_SECONDS(1), K_NO_WAIT);
}
} else {
Expand Down

0 comments on commit 2931fa0

Please sign in to comment.