彩屏仓抖音点赞移植
📎 原始文档:https://www.kdocs.cn/l/cmbILnIPU6Fr 彩屏仓抖音点赞移植
- 相关文件修改:
- 修改earphone.c文件 bt_function_select_init函数中添加:
#if (USER_SUPPORT_PROFILE_HID==1 && TCFG_USER_EDR_ENABLE)
extern void user_hid_init(void (*user_hid_output_handler)(u8 *packet, u16 size, u16 channel));
extern void user_hid_set_ReportMap(u8 *map, u16 size);
int len = 0;
u8*buf= NULL;
printf("func:%s ,usr_get_keypage_report_map \n",__func__);
buf = usr_get_keypage_report_map(1,&len);
if(buf){
user_hid_set_ReportMap(buf,len);
user_hid_init(NULL);
}
#endif
文件中添加:
#if TCFG_USER_EDR_ENABLE
extern u8 connect_last_device_from_vm();
int bt_connect_phone_back_start(void)
{
log_info("bt_connect_phone_back_start");
if (connect_last_device_from_vm()) {
log_info("---connect_last_device_from_vm");
return 1 ;
}
return 0;
}
#endif
蓝牙连接后调用下:
sys_timeout_add(NULL, bt_connect_reset_xy, 2000);
bt_app_exit函数中添加:
#if (USER_SUPPORT_PROFILE_HID==1&& TCFG_USER_EDR_ENABLE)
log_info("hid exit\n");
//extern void user_hid_exit(void);
//user_hid_exit();
#endif
- bt_tws.c文件中添加:
#include "edr_hid_user.h"
extern void usr_set_remote_type(u8 flag );
#define TWS_FUNC_ID_SBOX_SYNC TWS_FUNC_ID('S', 'B', 'O', 'X')
static void earphone_sync_sbox_setting_receive(void *_data, u16 len, bool rx)
{
if (rx) {
u8 *data = (u8 *)_data;
log_info("%s[line:%d]\n",__func__,__LINE__);
put_buf(data, len);
switch (data[0])
{
#if TCFG_USER_EDR_ENABLE
case SYNC_CMD_HID_CHANNEL_ID:
/* code */
extern void sync_hid_channel_id_deal(u8 *data, u16 len);
sync_hid_channel_id_deal(&data[1], len-1);
break;
case SYNC_CMD_REMOTE_TYPE:
usr_set_remote_type(data[1]);
#endif
default:
break;
}
}
}
REGISTER_TWS_FUNC_STUB(sync_sbox_setting) = {
.func_id = TWS_FUNC_ID_SBOX_SYNC,
.func = earphone_sync_sbox_setting_receive,
};
void earphone_sync_sbox_setting(u8 type, u8 *data, u8 len)
{
u8 buff[1+len];
if(tws_api_get_tws_state() & TWS_STA_SIBLING_CONNECTED){
buff[0] = type;
if(len){
memcpy(buff+1, data, len);
}
tws_api_send_data_to_sibling(buff, 1+len, TWS_FUNC_ID_SBOX_SYNC);
}
}
extern u8 usr_get_remote_type(void);
extern void sync_hid_channel_id(void);
void sync_remote_type(void)
{
u8 temp_connect_remote_type = usr_get_remote_type();
//r_printf("%s, connect_remote_type:%d, size:%d\n", __func__, connect_remote_type, sizeof(connect_remote_type));
earphone_sync_sbox_setting(SYNC_CMD_REMOTE_TYPE, &temp_connect_remote_type, sizeof(temp_connect_remote_type));
}
static void sbox_sync_tws_func_t(void *data, u16 len, bool rx)
{
if (rx) {
sbox_deal_sibling_setting((u8 *)data);
}
}
void tws_conn_snyc_info(void)
{
log_info("%s[line:%d]\n",__func__,__LINE__);
if(tws_api_get_role() == TWS_ROLE_MASTER){
#if TCFG_USER_EDR_ENABLE
sync_hid_channel_id();
sync_remote_type();
#endif
}
}
在TWS_EVENT_CONNECTED的事件中调用tws_conn_snyc_info
- board_ac700_demo_cfg.h文件中添加:
#define TCFG_USER_EDR_ENABLE 1
- bt_profile_config.c文件中修改: 原地方换成:
修改前:
#if (USER_SUPPORT_PROFILE_PNP==1)
SDP_RECORD_HANDLER_REGISTER(pnp_sdp_record_item) = {
.service_record = (u8 *)sdp_pnp_service_data,
.service_record_handle = 0x1000A,
};
#endif
修改后:
#if TCFG_USER_EDR_ENABLE
//定义的产品信息,for test
#define PNP_VID_SOURCE 0x02
#define PNP_VID 0x05ac //0x05d6
#define PNP_PID 0x022C //
#define PNP_PID_VERSION 0x011b //1.1.11
static const u8 sdp_pnp_service_data_hid[] = {
0x36, 0x00, 0x34, 0x09, 0x00, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x0A, 0x09, 0x00, 0x01, 0x36, 0x00,
0x03, 0x19, 0x12, 0x00, 0x09, 0x02, 0x00, 0x09, 0x01, 0x03, 0x09, 0x02, 0x01, 0x09, PNP_VID >> 8, PNP_VID & 0xFF,
0x09, 0x02, 0x02, 0x09,PNP_PID >> 8, PNP_PID & 0xFF, 0x09, 0x02, 0x03, 0x09,PNP_PID_VERSION >> 8, PNP_PID_VERSION & 0xFF, 0x09, 0x02, 0x04, 0x28,
0x01, 0x09, 0x02, 0x05, 0x09, 0x09, PNP_VID_SOURCE >> 8, PNP_VID_SOURCE & 0xFF, 0x00, 0x00
};
/*重定义下面hid信息结构,信息用于提供给库里面接口SDP生成hid_service服务使用*/
/*用到结构体的两个接口:sdp_create_diy_device_ID_service 和 bt_sdp_create_diy_hid_service*/
#include "btstack/avctp_user.h"
static const hid_sdp_info_t hid_sdp_info_config = {
.vid_private = PNP_VID,
.pid_private = PNP_PID,
.ver_private = PNP_PID_VERSION,
.sub_class = 0x80,
.country_code = 0x21,
.virtual_cable = 0x01,
.reconnect_initiate = 0x01,
.sdp_disable = 0x00,
.battery_power = 0x01,
.remote_wake = 0x01,
.normally_connectable = 0x01,
.boot_device = 0x01,
.version = 0x0100,
.parser_version = 0x0111,
.profile_version = 0x0100,
.supervision_timeout = 0x1f40,
.language = 0x0409,
.bt_string_offset = 0x0100,
.descriptor_len = 0,
.descriptor = NULL,
.service_name = "JL_HID",
.service_description = "hid key",
.provide_name = "JIELI",
.sdp_request_respone_callback = NULL,
.extra_buf = NULL,
.extra_len = 0,
};
#define NEW_SDP_PNP_DATA_VER 1 //for 兼容性
#endif /* TCFG_USER_EDR_ENABLE */
#if (TCFG_BT_SUPPORT_HID==1)
#if TCFG_USER_EDR_ENABLE
u8 hid_profile_support = 1;
u8 sdp_make_hid_service_data[0x200];
SDP_RECORD_HANDLER_REGISTER(hid_sdp_record_item) = {
.service_record = (u8 *)sdp_make_hid_service_data,
.service_record_handle = 0x00010006,
};
#else
u8 hid_profile_support = 1;
SDP_RECORD_HANDLER_REGISTER(hid_sdp_record_item) = {
.service_record = (u8 *)sdp_hid_service_data,
.service_record_handle = 0x00010006,
};
#endif
#endif
#if (USER_SUPPORT_PROFILE_PNP==1)
#if TCFG_USER_EDR_ENABLE
SDP_RECORD_HANDLER_REGISTER(pnp_sdp_record_item) = {
.service_record = (u8 *)sdp_pnp_service_data_hid,
.service_record_handle = 0x1000A,
};
#else
SDP_RECORD_HANDLER_REGISTER(pnp_sdp_record_item) = {
.service_record = (u8 *)sdp_pnp_service_data,
.service_record_handle = 0x1000A,
};
#endif /* TCFG_USER_EDR_ENABLE */
#endif
#if TCFG_USER_EDR_ENABLE
void hid_sdp_init(const u8 *hid_descriptor, u16 size)
{
#if (USER_SUPPORT_PROFILE_HID==1)
int real_size;
#if (NEW_SDP_PNP_DATA_VER == 0)
real_size = sdp_create_diy_device_ID_service(sdp_make_pnp_service_data, sizeof(sdp_make_pnp_service_data));
printf("dy_device_id_service(%d):", real_size);
#endif
/* put_buf(sdp_make_pnp_service_data,real_size); */
real_size = bt_sdp_create_diy_hid_service(sdp_make_hid_service_data, sizeof(sdp_make_hid_service_data), hid_descriptor, size);
printf("dy_hid_service(%d):", real_size);
/* put_buf(sdp_make_hid_service_data,real_size); */
#endif
}
#endif
- 定义flash id
#define CFG_USER_TIKTOK_X 7
#define CFG_USER_TIKTOK_Y 8
- 添加文件: 抖音点赞文件