Skip to content

Latest commit

 

History

History
77 lines (48 loc) · 2.39 KB

蓝牙地址.md

File metadata and controls

77 lines (48 loc) · 2.39 KB
RTK的蓝牙地址是由config文件下发下去设置的offset是0x44,上层由打开vendor.so的时候由init()函数带进去,真正设置的上层在rtk bt_stack上面,
android8.0之后,rtk不再出自己的bt_stack就放在hal interface,是由一个属性决定

#define USE_CONTROLLER_BDADDR   TRUE
那么就使用config自带的地址

#define USE_CONTROLLER_BDADDR   FALSE
那么就使用属性的地址,属性没有设置就自动生成一个并设置在persist.service.bdroid.bdaddr,下次开机就可以继续使用这个生成的地址




hardware/interfaces/bluetooth/1.0/default/bluetooth_address.cc


  /* Generate new BDA if necessary */
  if (!valid_bda) {
    char bdstr[kStringLength + 1];
    struct	timeval    tv;
    struct	timezone   tz;
    gettimeofday(&tv,&tz);

    /* No autogen BDA. Generate one now. */
    local_addr[0] = 0x22;
    local_addr[1] = 0x22;
    //local_addr[2] = (uint8_t)rand();
    //local_addr[3] = (uint8_t)rand();
    //local_addr[4] = (uint8_t)rand();
    //local_addr[5] = (uint8_t)rand();
    local_addr[2]	= (uint8_t) (tv.tv_usec & 0xFF);
    local_addr[3]	= (uint8_t) ((tv.tv_usec >> 8) & 0xFF);
    local_addr[4] = (uint8_t) ((tv.tv_usec >> 16) & 0xFF);
    local_addr[5] = (uint8_t) ((tv.tv_usec >> 24) & 0xFF);

    /* Convert to ascii, and store as a persistent property */
    bytes_to_string(local_addr, bdstr);

    ALOGE("%s: No preset BDA! Generating BDA: %s for prop %s", __func__,
          (char*)bdstr, PERSIST_BDADDR_PROPERTY);
    ALOGE("%s: This is a bug in the platform!  Please fix!", __func__);

    if (property_set(PERSIST_BDADDR_PROPERTY, (char*)bdstr) < 0) {



首先会去各种地方拿
/dev/vendor_storage
/dev/vflash
ro.bt.bdaddr_path
ro.boot.btmacaddr
persist.service.bdroid.bdaddr


拿不到就会自动生成一个然后设置在persist.service.bdroid.bdaddr



有一个问题,persist.service.bdroid.bdaddr恢复出厂设置后清零,可以将地址设置在ro.bt.bdaddr_path

/data/misc/bluetooth/bdaddr

不知道bdaddr这个文件恢复出厂设置会不会清零了..


7.1的话
hardware/realtek/rtkbt/code/bt/btif/src/btif_core.c

static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)


地址修改的地方在这里,默认是修改0x44
hardware/realtek/rtkbt/code/libbt-vendor/uart/src/hardware.c

uint32_t rtk_parse_config_file(unsigned char** config_buf, size_t* filelen, uint8_t bt_addr[6], uint16_t mac_offset)