Skip to content

Commit e925bd7

Browse files
committed
STM32WB: Set a random static address during init
1 parent 08965e1 commit e925bd7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

features/FEATURE_BLE/targets/TARGET_STM/stm32wb_HCIDriver.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,22 @@ class HCIDriver : public cordio::CordioHCIDriver
311311
randCnt++;
312312
HciLeRandCmd();
313313
} else {
314-
/* last command in sequence; set resetting state and call callback */
315-
tr_debug("signal_reset_sequence_done\r\n");
316-
signal_reset_sequence_done();
314+
uint8_t addr[6] = { 0 };
315+
memcpy(addr, pMsg, sizeof(addr));
316+
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
317+
// note: will invoke set rand address
318+
cordio::BLE::deviceInstance().getGap().setAddress(
319+
BLEProtocol::AddressType::RANDOM_STATIC,
320+
addr
321+
);
317322
}
318323
break;
324+
325+
case HCI_OPCODE_LE_SET_RAND_ADDR:
326+
/* send next command in sequence */
327+
signal_reset_sequence_done();
328+
break;
329+
319330
default:
320331
tr_debug("Complete Event in reset seq with unknown opcode =0x%4X\r\n", opcode);
321332
break;

0 commit comments

Comments
 (0)