Android10.0蓝牙(Realtek)MAC地址不变
程序员文章站
2022-06-22 19:11:43
USE_CONTROLLER_BDADDR改为FALSEhardware/realtek/rtkbt/code/libbt-vendor/include/bt_vendor_rtk.hThe Bluetooth Device Aaddress source switch: * * -FALSE- (default value) * Get the factory BDADDR from device's file system. Normally the BDADDR is * st....
- USE_CONTROLLER_BDADDR改为FALSE
- hardware/realtek/rtkbt/code/libbt-vendor/include/bt_vendor_rtk.h
The Bluetooth Device Aaddress source switch:
*
* -FALSE- (default value)
* Get the factory BDADDR from device's file system. Normally the BDADDR is
* stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
* btif_common.h file) property.
*
* -TRUE-
* If the Bluetooth Controller has equipped with a non-volatile memory (such
* as BCM4330's OTP memory), the factory BDADDR can be stored in there and
* retrieved by the stack while enabling BT.
* !!! WARNING !!! Make sure that the OTP feature has been enabled in the
* firmware patchram (.hcd) file.
*/
#ifndef USE_CONTROLLER_BDADDR
#define USE_CONTROLLER_BDADDR FALSE
#endif
- 修改 蓝牙接口库初始化函数
- hardware/realtek/rtkbt/code/libbt-vendor/src/bt_vendor_rtk.c
/*****************************************************************************
**
** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
**
*****************************************************************************/
static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
ALOGI("RTKBT_RELEASE_NAME: %s",RTKBT_RELEASE_NAME);
ALOGI("init");
load_rtkbt_conf();
load_rtkbt_stack_conf();
if (p_cb == NULL)
{
ALOGE("init failed with no user callbacks!");
return -1;
}
userial_vendor_init(rtkbt_device_node);
if(rtkbt_transtype & RTKBT_TRANS_UART) {
upio_init();
ALOGE("bt_wake_up_host_mode_set(1)");
bt_wake_up_host_mode_set(1);
}
/* store reference to user callbacks */
bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
/* This is handed over from the stack */
memcpy(vnd_local_bd_addr, local_bdaddr, 6);
//byte_reverse(vnd_local_bd_addr, 6); //去掉字节反转
if(rtk_btsnoop_dump)
rtk_btsnoop_open();
if(rtk_btsnoop_net_dump)
rtk_btsnoop_net_open();
return 0;
}
- 修改对蓝牙配置文件的解析
- hardware/realtek/rtkbt/code/libbt-vendor/src/hardware_uart.c
for (i=0; i<config_len;)
{
switch(le16_to_cpu(entry->offset))
{
case 0xc:
{
p = (uint8_t *)entry->entry_data;
STREAM_TO_UINT32(baudrate, p);
if (entry->entry_len >= 12)
{
hw_cfg_cb.hw_flow_cntrl |= 0x80; /* bit7 set hw flow control */
if (entry->entry_data[12] & 0x04) /* offset 0x18, bit2 */
hw_cfg_cb.hw_flow_cntrl |= 1; /* bit0 enable hw flow control */
}
ALOGI("config baud rate to :0x%08x, hwflowcontrol:0x%x, 0x%x", baudrate, entry->entry_data[12], hw_cfg_cb.hw_flow_cntrl);
break;
}
#if (USE_CONTROLLER_BDADDR == FALSE) //增加以下代码
case 0x44:
case 0x3c:
{
int j=0;
for (j=0; j<entry->entry_len; j++)
entry->entry_data[j] = bt_addr[entry->entry_len - 1- j];
ALOGI("rtk_parse_config_file: DO NOT USE_CONTROLLER_BDADDR, config has bdaddr");
ALOGI("rtk_parse_config_file : CONFIG_ADDR is: %02X:%02X:%02X:%02X:%02X:%02X",
bt_addr[0], bt_addr[1],
bt_addr[2], bt_addr[3],
bt_addr[4], bt_addr[5]);
break;
}
#endif
case 0x017a:
{
if(mac_offset == CONFIG_MAC_OFFSET_GEN_1_2)
{
p = (uint8_t *)entry->entry_data;
STREAM_TO_UINT8(heartbeat_buf, p);
if((heartbeat_buf & 0x02) && (heartbeat_buf & 0x10))
hw_cfg_cb.heartbeat = 1;
else
hw_cfg_cb.heartbeat = 0;
ALOGI("config 0x017a heartbeat = %d",hw_cfg_cb.heartbeat);
}
break;
}
case 0x01be:
{
if(mac_offset == CONFIG_MAC_OFFSET_GEN_3PLUS || mac_offset == CONFIG_MAC_OFFSET_GEN_4PLUS)
{
p = (uint8_t *)entry->entry_data;
STREAM_TO_UINT8(heartbeat_buf, p);
if((heartbeat_buf & 0x02) && (heartbeat_buf & 0x10))
hw_cfg_cb.heartbeat = 1;
else
hw_cfg_cb.heartbeat = 0;
ALOGI("config 0x01be heartbeat = %d",hw_cfg_cb.heartbeat);
}
break;
}
default:
ALOGI("config offset(0x%x),length(0x%x)", entry->offset, entry->entry_len);
break;
}
-
总结
rtk_parse_config_file函数会解析蓝牙的配置文件,配置文件中的0x44后面的字节代表地址的长度与MAC地址值。
本文地址:https://blog.csdn.net/qq_30883899/article/details/110170854
下一篇: 亚像素的对位