Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2b9138

Browse files
AresMasterfpistm
authored andcommitted
fix: for pairing with Static Random Address
Signed-off-by: Arkadiusz Ambroziak <arekambroziak@op.pl>Co-Auhthored-by: Frederic Pillon <frederic.pillon@st.com>
1 parente396a6a commitc2b9138

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎src/local/BLELocalDevice.cpp‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,22 @@ int BLELocalDevice::begin()
142142
randomAddress [4] = randomNumber[4];
143143
randomAddress [5] = randomNumber[5];
144144

145-
if (HCI.leSetRandomAddress((uint8_t*)randomNumber) !=0) {
145+
// Set Random address only when type is STATIC_RANDOM_ADDR
146+
if ((_ownBdaddrType == STATIC_RANDOM_ADDR) && (HCI.leSetRandomAddress((uint8_t*)randomNumber) !=0)) {
146147
end();
147148
return0;
148149
}
150+
// Save address to HCI.localAddr variable, which is used to encryption in pairing
151+
if(_ownBdaddrType == PUBLIC_ADDR){
152+
if (HCI.readBdAddr() !=0) {
153+
end();
154+
return0;
155+
}
156+
}else {
157+
for(int k=0; k<6; k++){
158+
HCI.localAddr[5-k] = randomAddress[k];
159+
}
160+
}
149161

150162
uint8_t hciVer;
151163
uint16_t hciRev;
@@ -301,7 +313,14 @@ bool BLELocalDevice::disconnect()
301313
StringBLELocalDevice::address()const
302314
{
303315
uint8_t addr[6] = {0x00,0x00,0x00,0x00,0x00,0x00 };
304-
HCI.readBdAddr(addr);
316+
// return correct device address when is set to STATIC RANDOM (set by HCI)
317+
if(_ownBdaddrType == PUBLIC_ADDR) {
318+
HCI.readBdAddr(addr);
319+
}else {
320+
for(int k=0; k<6; k++) {
321+
addr[k]=HCI.localAddr[5-k];
322+
}
323+
}
305324

306325
char result[18];
307326
sprintf(result,"%02x:%02x:%02x:%02x:%02x:%02x", addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);

‎src/utility/L2CAPSignaling.cpp‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,12 @@ void L2CAPSignalingClass::smCalculateLTKandConfirm(uint16_t handle, uint8_t expe
371371
uint8_t localAddress[7];
372372
uint8_t remoteAddress[7];
373373
ATT.getPeerAddrWithType(handle, remoteAddress);
374-
375-
HCI.readBdAddr();
374+
375+
// Address is taken directly from HCI.localaddress,
376+
// which is set when object DeviceLocal is created
377+
// HCI.readBdAddr();
376378
memcpy(&localAddress[1],HCI.localAddr,6);
377-
localAddress[0] =0;//IOT 33 uses a staticaddress// TODO: confirm for Nano BLE
379+
localAddress[0] =ATT.getOwnBdaddrType();//Adding bit withaddresstype (e.g. Static random or public address)
378380

379381
// Compute the LTK and MacKey
380382
uint8_t MacKey[16];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp