程序使用 ac69_emitter_sdk_v107 SDK 版本测试。
在 emitter_user.c 文件加入如下程序。
#define BD_INQUIRY_RESULT_CUSTOM
#ifdef BD_INQUIRY_RESULT_CUSTOM
#define CONNECT_BY_NAME
//#define CONNECT_BY_ADDR
u8 bd_addr_filt1[][6] =
{
{0xF4, 0x4E , 0xFD , 0x00 , 0x63 , 0x45},
{0x78, 0x79 , 0x99 , 0xA4 , 0x8E , 0xDE},
{0x03, 0x18 , 0x17 , 0x15 , 0x7A, 0xE5 },
};
u8 search_bd_addr_filt1(u8 *addr)
{
u8 i;
puts(“bd_addr:”);
put_buf(addr,6);
for(i=0;i<(sizeof(bd_addr_filt1)/sizeof(bd_addr_filt1[0]));i++)
{
if(memcmp(addr,bd_addr_filt1[i],6) == 0) {
printf(“bd_addr match:%d\n”,i);
return 1;
}
}
puts(“bd_addr not match\n”);
return 0;
}
u8 bd_name_filt1[][32] =
{
“AC691x_SDK”,
};
u8 search_bd_by_name_filt1(u8 data,u8 len)
{
char bd_name[32] = {0};
u8 i,bd_name_len;
if(len >(sizeof(bd_name))) {
printf(“bd_name_len error:%d\n”,len);
return 0;
}
memcpy(bd_name,data,len);
bd_name_len = len;
printf(“inquiry_bd_name:%s,len:%d\n”,bd_name,len);
for(i=0;i<(sizeof(bd_name_filt)/sizeof(bd_name_filt[0]));i++)
{
if(memcmp(data,bd_name_filt[i],bd_name_len) == 0) {
puts("\nfind dev ok\n");
return 1;
}
}
return 0;
}
u8 bd_inquiry_result_custom(char *bd_name,u8 name_len,u8 addr)
{
char bt_name[32] = {0};
u8 len;
if(name_len == 0) {
puts(“No_eir\n”);
}
else {
len = name_len;
if(len > 32)
len = 31;
/ display bd_name /
memcpy(bt_name,bd_name,len);
printf(“inquiry_bd_name:%s,len:%d\n”,bt_name,name_len);
}
/ display bd_addr /
put_buf(addr,6);
/ You can connect the specified bd_addr by below api */
#ifdef CONNECT_BY_ADDR
if(search_bd_addr_filt1(addr))
{
puts(“if(search_bd_addr_filt1(addr))\n”);
user_send_cmd_prepare(USER_CTRL_START_CONNEC_VIA_ADDR,6,addr);
}
#elif defined CONNECT_BY_NAME
if(search_bd_by_name_filt1(bt_name, name_len))
{
puts(“if(search_bd_addr_filt1(addr))\n”);
user_send_cmd_prepare(USER_CTRL_START_CONNEC_VIA_ADDR,6,addr);
}
#endif
return 0;
}
#endif