static void reflash_adv_tag_data(const u8 *tag_data, u8 len, u8 spec_val)
{
u8 tmp_tag_data[32];
u8 tmp8;
memcpy(tmp_tag_data, tag_data, len);
memcpy(&tmp_tag_data[14], dev_battery_level, 3);
u8 cur_ear_pos = 'L';
#if TCFG_CHARGESTORE_ENABLE
log_info(“get pos form chargesstore\n”);
cur_ear_pos = chargestore_get_earphone_pos();
#else
#if TCFG_USER_TWS_ENABLE
cur_ear_pos = bt_tws_get_local_channel();
#endif
#endif
//位置14,15,16 对应 R,L,BOX
if (cur_ear_pos != 'R') {
//switch position
ble_puts("is L pos\n");
tmp8 = tmp_tag_data[14];
tmp_tag_data[14] = tmp_tag_data[15];
tmp_tag_data[15] = tmp8;
} else {
ble_puts("is R pos\n");
}
if (spec_val != 0xff) {
tmp_tag_data[17] = spec_val;
if (spec_val != 9) {
#if TCFG_USER_TWS_ENABLE
/* memset(&tmp_tag_data[14],0xff,3); */
#endif
} else {
memset(&tmp_tag_data[14], 0xFF, 3);//关闭广播的时候不显示电量
}
}
//---
#if (!REFLASH_ICON_STATE) //
if (len == 29) {
#if TCFG_USER_TWS_ENABLE
//fixed do,start,固定分开显示电量,如不分开,可以屏蔽这段代码
ble_puts(“fixed two do\n”);
/* ble_put_buf(&tmp_tag_data[14],3); */
if ((tmp_tag_data[14] != 0xff)
&& (tmp_tag_data[15] != 0xff)) {
if ((tmp_tag_data[14]&BIT(7))
&& (tmp_tag_data[15]&BIT(7))) {
tmp_tag_data[15] &= 0x7f;
ble_puts(“fixed c1\n”);
} else {
if (((tmp_tag_data[14]&BIT(7)) == 0)
&& ((tmp_tag_data[15]&BIT(7)) == 0)) {
tmp_tag_data[14] |= BIT(7);
ble_puts(“fixed c2\n”);
}
}
}
//fixed do,end
#endif
}
#endif
//—
bt_ble_adv_enable(0);
if (send_sync_pos_flag) {
u8 pos_state[2];
//L
if (tmp_tag_data[15] == 0xff) {
pos_state[0] = PBG_POS_NOT_EXIST;
} else if (tmp_tag_data[15] & BIT(7)) {
pos_state[0] = PBG_POS_IN_BOX;
} else {
pos_state[0] = PBG_POS_OUT_BOX;
}
//R
if (tmp_tag_data[14] == 0xff) {
pos_state[1] = PBG_POS_NOT_EXIST;
} else if (tmp_tag_data[14] & BIT(7)) {
pos_state[1] = PBG_POS_IN_BOX;
} else {
pos_state[1] = PBG_POS_OUT_BOX;
}
send_sync_pos_flag = 0;
pbg_user_battery_level_sync(&tmp_tag_data[14]);
pbg_user_ear_pos_sync(pos_state[0], pos_state[1]);
}
make_set_adv_data(tmp_tag_data, len);
bt_ble_adv_enable(1);
}