BLE 上报自动分包 + 切慢广播宏
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
* @file usr_le_adv.c
|
||||
* @brief BLE 广播 / 配对 / OTA 广播切换
|
||||
* @author cyWu <1917507415@qq.com>
|
||||
* @date 2026.08.19
|
||||
* @version V1.1.0
|
||||
* @date 2026.09.09
|
||||
* @version V1.2.0
|
||||
* @history
|
||||
* - V1.2.0, 2026.09.09, cyWu, 切慢广播由 BOARD_BLE_SLOW_ADV_ENABLE / _SEC 控制
|
||||
* - V1.0.0, 2026.08.03, cyWu, 首次发布
|
||||
* - V1.1.0, 2026.08.19, cyWu, 对齐模组注释与助手;保留 SOC 上电绑广播策略
|
||||
******************************************************************************/
|
||||
@@ -16,6 +17,7 @@
|
||||
#include "bleproto.h"
|
||||
#include "bleproto_api.h"
|
||||
#include "usr_le_product.h"
|
||||
#include "board_pin.h"
|
||||
|
||||
#define LOG_TAG_CONST APP
|
||||
#define LOG_TAG "[LE_ADV]"
|
||||
@@ -222,7 +224,11 @@ u8 usr_get_pair_flag(void)
|
||||
*/
|
||||
void usr_ble_adv_updata(void)
|
||||
{
|
||||
#if BOARD_BLE_SLOW_ADV_ENABLE
|
||||
static u16 usr_goto_slow_adv = 0;
|
||||
/* usr_ble_adv_updata 周期 500ms → 秒数换拍 */
|
||||
const u16 slow_ticks = (u16)((BOARD_BLE_SLOW_ADV_SEC) * (1000u / 500u));
|
||||
#endif
|
||||
|
||||
if (usr_var.usr_adv_flag)
|
||||
{
|
||||
@@ -234,9 +240,10 @@ void usr_ble_adv_updata(void)
|
||||
ble_trans_module_enable(1);
|
||||
}
|
||||
|
||||
#if BOARD_BLE_SLOW_ADV_ENABLE
|
||||
if (!usr_ble_is_connected())
|
||||
{
|
||||
/* 未连接:回连快广播(80)持续约 60s(500ms×120)后切慢广播 */
|
||||
/* 已配对断连:快广播 80 持续 BOARD_BLE_SLOW_ADV_SEC 后切 800 */
|
||||
if (usr_get_adv_interval() == 80)
|
||||
{
|
||||
if ((usr_var.usr_goto_pair == 0) && usr_auth_data.paired_flag)
|
||||
@@ -244,13 +251,14 @@ void usr_ble_adv_updata(void)
|
||||
if (usr_var.usr_ota_succ_flag == 0)
|
||||
{
|
||||
usr_goto_slow_adv++;
|
||||
printf("usr_goto_slow_adv = %d\n", usr_goto_slow_adv);
|
||||
}
|
||||
if (usr_goto_slow_adv >= 120)
|
||||
{
|
||||
usr_goto_slow_adv = 0;
|
||||
usr_set_adv_interval(80 * 10);
|
||||
usr_var.usr_adv_flag = 1;
|
||||
if ((slow_ticks != 0) && (usr_goto_slow_adv >= slow_ticks))
|
||||
{
|
||||
usr_goto_slow_adv = 0;
|
||||
usr_set_adv_interval(80 * 10);
|
||||
usr_var.usr_adv_flag = 1;
|
||||
log_info("ble adv -> slow after %us\n",
|
||||
(unsigned)BOARD_BLE_SLOW_ADV_SEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,6 +271,7 @@ void usr_ble_adv_updata(void)
|
||||
{
|
||||
usr_goto_slow_adv = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (usr_get_ota_status() == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user