Replace BT_OCTET16 with Octet16
BT_OCTET16 was a uint8_t[16], that is a pointer.
This means that it was not copyable, and one had to be always aware of
what this type really means when passing it to function.
Octet16 is std::array<uint8_t, 16> and is copyable. It can also be
copied using "=" operator, instead of memcpy, or ARRAY_TO_STREAM.
Octet16 can also be returned from function by value. Thanks to it, some
smp functions can be simplified, by returning value instead of accepting
pointer to output.
Test: net_stack_smp_test
Change-Id: I0687a948e5807f76ec3d1b5d1d4d2ad2b50b87dd
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
index 9f2ee28..85b50b6 100644
--- a/bta/include/bta_api.h
+++ b/bta/include/bta_api.h
@@ -485,9 +485,9 @@
typedef uint8_t tBTA_DM_BLE_LOCAL_KEY_MASK;
typedef struct {
- BT_OCTET16 ir;
- BT_OCTET16 irk;
- BT_OCTET16 dhk;
+ Octet16 ir;
+ Octet16 irk;
+ Octet16 dhk;
} tBTA_BLE_LOCAL_ID_KEYS;
#define BTA_DM_SEC_GRANTED BTA_SUCCESS
@@ -512,7 +512,7 @@
RawAddress bd_addr; /* BD address peer device. */
BD_NAME bd_name; /* Name of peer device. */
bool key_present; /* Valid link key value in key element */
- LINK_KEY key; /* Link key associated with peer device. */
+ LinkKey key; /* Link key associated with peer device. */
uint8_t key_type; /* The type of Link Key */
bool success; /* true of authentication succeeded, false if failed. */
uint8_t fail_reason; /* The HCI reason/error code for when success=false */
@@ -689,7 +689,7 @@
tBTA_DM_BLE_SEC_REQ ble_req; /* BLE SMP related request */
tBTA_DM_BLE_KEY ble_key; /* BLE SMP keys used when pairing */
tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
- BT_OCTET16 ble_er; /* ER event data */
+ Octet16 ble_er; /* ER event data */
} tBTA_DM_SEC;
/* Security callback */
@@ -1289,9 +1289,10 @@
*
******************************************************************************/
extern void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
- LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
- bool is_trusted, uint8_t key_type,
- tBTA_IO_CAP io_cap, uint8_t pin_length);
+ const LinkKey& link_key,
+ tBTA_SERVICE_MASK trusted_mask, bool is_trusted,
+ uint8_t key_type, tBTA_IO_CAP io_cap,
+ uint8_t pin_length);
/*******************************************************************************
*