Skip to content

Commit 047870f

Browse files
committed
Merge branch 'bugfix/btdm_string_to_bdaddr_error_when_opening_nano' into 'master'
component/bt: Fix bug: string_to_bdaddr() error when opening nano See merge request idf/esp-idf!1981
2 parents 55e5f8e + 54320d5 commit 047870f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

components/bt/bluedroid/btcore/bdaddr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ bool string_to_bdaddr(const char *string, bt_bdaddr_t *addr)
102102

103103
bt_bdaddr_t new_addr;
104104
uint8_t *ptr = new_addr.address;
105-
bool ret = sscanf(string, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
106-
&ptr[0], &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5]) == 6;
107-
105+
uint32_t ptr_32[6];
106+
bool ret = sscanf(string, "%02x:%02x:%02x:%02x:%02x:%02x",
107+
&ptr_32[0], &ptr_32[1], &ptr_32[2], &ptr_32[3], &ptr_32[4], &ptr_32[5]) == 6;
108108
if (ret) {
109+
for (uint8_t i = 0; i < 6; i++){
110+
ptr[i] = (uint8_t) ptr_32[i];
111+
}
109112
memcpy(addr, &new_addr, sizeof(bt_bdaddr_t));
110113
}
111114

0 commit comments

Comments
 (0)