This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Resolvable Private Address



我在peripheral.c文件中加入如下代码,使能 Resolvable Private Address模式

stat = GAP_ConfigDeviceAddr(ADDRMODE_PRIVATE_RESOLVE, NULL);

if (stat != SUCCESS)
{
gapRole_state = GAPROLE_ERROR;
}
//Set timeout value to 5 minute
GAP_SetParamValue( TGAP_PRIVATE_ADDR_INT , 5);

我的问题是,本机如何获取这个Resolvable Private Address。

我用这个函数 GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress) 获取到的都是public address, 固定的。

万分感谢!!

  • 使用LE Read Local Resolvable Address Command

    /**
     * Read Local Resolvable Private Address
     *
     * Get the current local Resolvable Private Address being used for the
     * corresponding local Public or Random (Static) Identity Address.
     *
     * @warning The local Resolvable Private Address being used may change after
     * this command is called.
     *
     * @par Corresponding Events
     * @ref hciEvt_CmdComplete_t with cmdOpcode
     *      @ref HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS
     *
     * @param localIdAddrType @ref Addr_type
     * @param localIdAddr     Local device Identity Address.
     *
     * @return @ref HCI_SUCCESS
     */
    extern hciStatus_t HCI_LE_ReadLocalResolvableAddressCmd( uint8  localIdAddrType,
                                                             uint8 *localIdAddr );

  • 还有我想再请教一个问题,peripheral怎么获取center设备的public Address?
  • 比如说从机想获取手机安卓端的蓝牙Public 地址。我查询连接的蓝牙设备地址返回的是Private地址
  • gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg;
    
    if ( pPkt->hdr.status == SUCCESS )
    {
    VOID osal_memcpy( gapRole_ConnectedDevAddr, pPkt->devAddr, B_ADDR_LEN );

    这取决于central 设备,如果central设备本身用的是public 地址的话,那么得到的肯定就是public 地址。如果用的是random 的话,那么你每次得到都会不一样

  • 也就是说如果central设备使用random地址的话,是无法获取central的public地址,是吗?即使在配对绑定后?
    另外,我 调用 extern hciStatus_t HCI_LE_ReadLocalResolvableAddressCmd( uint8 localIdAddrType,
    uint8 *localIdAddr );
    读取本机的Random地址,发现根本没有读出来,全是0
  • 我是这样使用的
    /*获取本机蓝牙地址*/
    //GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);//public address
    flag = HCI_LE_ReadLocalResolvableAddressCmd(HCI_RANDOM_DEVICE_ADDRESS, ownAddress);//private resolvable address
  • 如果central设备使用random其他地址的话,用ReadLocalResolvableAddressCmd是无法获取地址的

  • 我想知道的是本机(peripheral)使用的是ramdom地址,如何获取本机当前的Ramdom地址?是自己获取自己当前的Ramdom地址。
  • Random Device Address分为Static Device Address和Private Device Address,是设备设定后才会有的

    可以查一下关于Random Device Address的说明

  • 回到前面的问题
    我在peripheral.c文件中加入如下代码,使能 Resolvable Private Address模式

    stat = GAP_ConfigDeviceAddr(ADDRMODE_PRIVATE_RESOLVE, NULL);

    if (stat != SUCCESS)
    {
    gapRole_state = GAPROLE_ERROR;
    }
    //Set timeout value to 5 minute
    GAP_SetParamValue( TGAP_PRIVATE_ADDR_INT , 5);

    设置好了以后,用手机的BLE_scanner APP去扫描设备,是不是扫描得到的设备蓝牙地址是变化的?(每5min改变)
    我现在的问题是,我设备本身也需要获得这个变化的蓝牙地址,如何获取?
  • 产生的地址以T_GAP(private_addr_int)为周期,定时更新,获取用我上面回复的命令



    /** * @brief Configure Device Address * * Setup the device's address type. If @ref ADDRMODE_PRIVATE_RESOLVE * is selected, the address will change periodically. * * @note * If return value isn't SUCCESS, the address type remains * the same as before this call * * @par Corresponding Events: * If the device is correctly configured for @ref ADDRMODE_PRIVATE_NONRESOLVE , * the calling task will receive in case PRIVACY_1_2_CFG Flag is Disabled * a @ref GAP_RANDOM_ADDR_CHANGED_EVENT of type * @ref gapRandomAddrEvent_t when the random address changes * * @param addrMode - @ref Gap_Addr_Modes * @param pStaticAddr - Only used with ADDRMODE_STATIC * or @ref ADDRMODE_PRIVATE_NONRESOLVE type.<BR> * NULL to auto generate otherwise the application * can specify the address value * * @return @ref SUCCESS : address type updated * @return @ref bleNotReady : Can't be called until @ref GAP_DeviceInit is called * and the init process is completed * @return @ref bleIncorrectMode : can't change with an active connection * @return or INVALIDPARAMETER */ extern bStatus_t GAP_ConfigDeviceAddr( uint8 addrMode, uint8 *pStaticAddr );

  • 我尝试用 HCI_LE_ReadLocalResolvableAddressCmd函数去获取,结果是全0
  • 设置断点单步运行,看下进入 HCI_LE_ReadLocalResolvableAddressCmd的情况,参数有没有设置正确
  • uint8 RandomAddress[B_ADDR_LEN];
    HCI_LE_ReadLocalResolvableAddressCmd(HCI_RANDOM_DEVICE_ADDRESS, RandomAddress);//private resolvable address
  • linghua liu 说:
    uint8 RandomAddress[B_ADDR_LEN];

    你这里面有数据吗

  • 初始值全是0, 调用函数HCI_LE_ReadLocalResolvableAddressCmd还是一样


  • * @param localIdAddrType @ref Addr_type * @param localIdAddr Local device Identity Address. * * @return @ref HCI_SUCCESS */ extern hciStatus_t HCI_LE_ReadLocalResolvableAddressCmd( uint8 localIdAddrType, uint8 *localIdAddr );
    第二个参数是要传入地址的,你传入的参数中没有数,读出来肯定是0
  • 第二个参数我输入本机的固定的那个蓝牙地址,出来也是一样。第二个参数又是输入又是输出?或者本机的RPA在哪里输出?
  • 看下这里关于RPA的详细说明:file:///C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/docs/ble5stack/ble_user_guide/html/ble-stack-5.x/privacy.html