feat: 完成弹力魔盒初版固件
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include "classic/tws_api.h"
|
||||
#include "rcsp_adv_user_update.h"
|
||||
#include "bt_tws.h"
|
||||
#include "usr_le_api.h"
|
||||
|
||||
#if (TCFG_BLE_DEMO_SELECT == DEF_BLE_DEMO_ADV_RCSP)
|
||||
|
||||
@@ -106,6 +107,14 @@ static const struct conn_update_param_t connection_param_table[] = {
|
||||
/* {12, 28, 4, 600},//3.7 */
|
||||
/* {12, 24, 30, 600},//3.05 */
|
||||
};
|
||||
/* DP0=0 keeps BLE connected, but can trade a little command latency for much
|
||||
* fewer idle RF events. The preferred setting has a worst-case idle response
|
||||
* interval of about 640 ms; later entries are gateway compatibility fallbacks. */
|
||||
static const struct conn_update_param_t connection_param_table_standby[] = {
|
||||
{24, 32, 15, 600},
|
||||
{20, 32, 15, 600},
|
||||
{16, 24, 10, 600},
|
||||
};
|
||||
static const struct conn_update_param_t connection_param_table_ota[] = {
|
||||
{16, 24, 0, 600},
|
||||
{12, 28, 0, 600},//11
|
||||
@@ -129,6 +138,8 @@ static u8 scan_rsp_data[ADV_RSP_PACKET_MAX];//max is 31
|
||||
/* #define scan_rsp_data &att_ram_buffer[32] */
|
||||
|
||||
static u32 ble_timer_handle = 0;
|
||||
static u16 connection_update_timer;
|
||||
static uint8_t connection_standby_mode;
|
||||
static char *gap_device_name = "br22_ble_test";
|
||||
static u8 gap_device_name_len = 0;
|
||||
volatile static u8 ble_work_state = 0;
|
||||
@@ -165,7 +176,10 @@ static int get_buffer_vaild_len(void *priv);
|
||||
//------------------------------------------------------
|
||||
static void send_request_connect_parameter(u8 table_index)
|
||||
{
|
||||
struct conn_update_param_t *param = (void *)&connection_param_table[table_index];//static ram
|
||||
const struct conn_update_param_t *table = connection_standby_mode ?
|
||||
connection_param_table_standby :
|
||||
connection_param_table;
|
||||
struct conn_update_param_t *param = (void *)&table[table_index];//static ram
|
||||
|
||||
log_info("update_request:-%d-%d-%d-%d-\n", param->interval_min, param->interval_max, param->latency, param->timeout);
|
||||
if (con_handle) {
|
||||
@@ -182,6 +196,35 @@ static void check_connetion_updata_deal(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void connection_param_update_apply(void *priv)
|
||||
{
|
||||
(void)priv;
|
||||
connection_update_timer = 0;
|
||||
connection_update_cnt = 0;
|
||||
check_connetion_updata_deal();
|
||||
}
|
||||
|
||||
void usr_ble_set_standby(uint8_t standby)
|
||||
{
|
||||
standby = !!standby;
|
||||
if (connection_standby_mode == standby) {
|
||||
return;
|
||||
}
|
||||
|
||||
connection_standby_mode = standby;
|
||||
connection_update_cnt = 0;
|
||||
if (!con_handle) {
|
||||
return;
|
||||
}
|
||||
if (connection_update_timer) {
|
||||
sys_timeout_del(connection_update_timer);
|
||||
connection_update_timer = 0;
|
||||
}
|
||||
/* DP writes are consumed from a usr_timer callback. Defer the controller
|
||||
* command to system-timer context. */
|
||||
connection_update_timer = sys_timeout_add(NULL, connection_param_update_apply, 100);
|
||||
}
|
||||
|
||||
|
||||
static void send_request_connect_parameter_ota(u8 table_index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user