mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: fixbug_set_rand_addr()
- The two most significant bits of the address shall be equal to 1 - All bits of the random part of the address shall not be equal to 1 - All bits of the random part of the address shall not be equal to 0
This commit is contained in:
parent
5c3f2bdd00
commit
974cff4773
@ -761,16 +761,27 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr)
|
||||
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_SUCCESS;
|
||||
|
||||
if (rand_addr != NULL) {
|
||||
if((rand_addr[BD_ADDR_LEN - 1] & BT_STATIC_RAND_ADDR_MASK)
|
||||
== BT_STATIC_RAND_ADDR_MASK) {
|
||||
/*
|
||||
A static address is a 48-bit randomly generated address and shall meet the following requirements:
|
||||
• The two most significant bits of the address shall be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 0
|
||||
*/
|
||||
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
|
||||
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
|
||||
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
|
||||
invalid_rand_addr_b[BD_ADDR_LEN - 1] = invalid_rand_addr_b[BD_ADDR_LEN - 1] | BT_STATIC_RAND_ADDR_MASK;
|
||||
if((rand_addr[BD_ADDR_LEN - 1] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK
|
||||
&& memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0
|
||||
&& memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0){
|
||||
BTA_DmSetRandAddress(rand_addr);
|
||||
} else {
|
||||
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
|
||||
LOG_ERROR("Invalid randrom address, the high bit should be 0x11xx");
|
||||
LOG_ERROR("Invalid random address, the high bit should be 0b11, the random part shall not be to 1 or 0");
|
||||
}
|
||||
} else {
|
||||
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
|
||||
LOG_ERROR("Invalid randrom addressm, the address value is NULL");
|
||||
LOG_ERROR("Invalid random addressm, the address value is NULL");
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
|
Loading…
x
Reference in New Issue
Block a user