feat: 完成弹力魔盒初版固件
This commit is contained in:
@@ -66,6 +66,7 @@ void usr_ble_adv_init(void);
|
||||
void usr_ble_adv_updata(void);
|
||||
|
||||
static int le_timer_handle = 0;
|
||||
static u8 ota_process_cnt;
|
||||
|
||||
/**
|
||||
* @brief BLE 是否已连接
|
||||
@@ -301,29 +302,27 @@ void usr_ble_adv_updata_OTA(void)
|
||||
|
||||
void usr_ota_process(void)
|
||||
{
|
||||
static u8 cnt = 0;
|
||||
|
||||
if (cnt == 0)
|
||||
if (ota_process_cnt == 0)
|
||||
{
|
||||
ble_multi_trans_disconnect();
|
||||
}
|
||||
|
||||
if (!usr_ble_is_connected())
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == 2)
|
||||
ota_process_cnt++;
|
||||
if (ota_process_cnt == 2)
|
||||
{
|
||||
usr_ble_adv_updata_OTA();
|
||||
}
|
||||
if (cnt >= 60)
|
||||
if (ota_process_cnt >= 60)
|
||||
{
|
||||
cnt = 0;
|
||||
ota_process_cnt = 0;
|
||||
cpu_reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = 1;
|
||||
ota_process_cnt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,8 +332,23 @@ void usr_ota_process(void)
|
||||
void usr_app_ota_init(void)
|
||||
{
|
||||
usr_var.usr_goto_updata = 1;
|
||||
ota_process_cnt = 0;
|
||||
if (usr_var.ota_timer == 0)
|
||||
{
|
||||
usr_var.ota_timer = sys_timer_add(NULL, usr_ota_process, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
void usr_app_ota_exit(void)
|
||||
{
|
||||
if (usr_var.ota_timer) {
|
||||
sys_timer_del((u16)usr_var.ota_timer);
|
||||
usr_var.ota_timer = 0;
|
||||
}
|
||||
ota_process_cnt = 0;
|
||||
if (usr_get_ota_status() == 0) {
|
||||
usr_ota_exit();
|
||||
}
|
||||
usr_var.usr_goto_updata = 0;
|
||||
usr_ble_disconnect_and_stop_adv();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,12 @@ uint8_t usr_get_pair_flag(void);
|
||||
*/
|
||||
void usr_app_ota_init(void);
|
||||
|
||||
/** Stop the application OTA timer/advertising state without resetting. */
|
||||
void usr_app_ota_exit(void);
|
||||
|
||||
/** Select normal or DP0 standby BLE connection parameters. */
|
||||
void usr_ble_set_standby(uint8_t standby);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user