This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit acf9f156fedd975f0459001de73af78bdb43e67f
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Tue Jul 11 08:36:47 2023 +0200

    apps/bttester: use ble_addr_t whenever possible
    
    We should use ble_addr_t instead of pair {address_type, address}
    whenever possible, as suggested in 35c71a4dcd2ad859e66746088042c50b8a0add39
    
    This simplifies code to single memcpy.
---
 apps/bttester/src/btp/btp_gap.h   | 65 +++++++++++---------------------
 apps/bttester/src/btp/btp_gatt.h  | 54 +++++++++------------------
 apps/bttester/src/btp/btp_gattc.h | 78 +++++++++++++--------------------------
 apps/bttester/src/btp/btp_l2cap.h | 15 +++-----
 apps/bttester/src/btp_gap.c       | 55 +++++++++++----------------
 apps/bttester/src/btp_gatt_cl.c   | 72 ++++++------------------------------
 apps/bttester/src/btp_l2cap.c     |  8 +---
 7 files changed, 106 insertions(+), 241 deletions(-)

diff --git a/apps/bttester/src/btp/btp_gap.h b/apps/bttester/src/btp/btp_gap.h
index ca60b8103..5e3e1b837 100644
--- a/apps/bttester/src/btp/btp_gap.h
+++ b/apps/bttester/src/btp/btp_gap.h
@@ -167,15 +167,13 @@ struct btp_gap_start_discovery_cmd {
 
 #define BTP_GAP_CONNECT            0x0e
 struct btp_gap_connect_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t own_addr_type;
 } __packed;
 
 #define BTP_GAP_DISCONNECT            0x0f
 struct btp_gap_disconnect_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_IO_CAP_DISPLAY_ONLY        0
@@ -191,41 +189,35 @@ struct btp_gap_set_io_cap_cmd {
 
 #define BTP_GAP_PAIR            0x11
 struct btp_gap_pair_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_UNPAIR            0x12
 struct btp_gap_unpair_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_PASSKEY_ENTRY        0x13
 struct btp_gap_passkey_entry_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint32_t passkey;
 } __packed;
 
 #define BTP_GAP_PASSKEY_CONFIRM        0x14
 struct btp_gap_passkey_confirm_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t match;
 } __packed;
 
 #define BTP_GAP_START_DIRECT_ADV        0x15
 struct btp_gap_start_direct_adv_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t high_duty;
 } __packed;
 
 #define BTP_GAP_CONN_PARAM_UPDATE        0x16
 struct btp_gap_conn_param_update_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t conn_itvl_min;
     uint16_t conn_itvl_max;
     uint16_t conn_latency;
@@ -234,8 +226,7 @@ struct btp_gap_conn_param_update_cmd {
 
 #define BTP_GAP_PAIRING_CONSENT_RSP        0x17
 struct btp_gap_pairing_consent_rsp_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t consent;
 } __packed;
 
@@ -278,8 +269,7 @@ struct btp_gap_new_settings_ev {
 
 #define BTP_GAP_EV_DEVICE_FOUND        0x81
 struct btp_gap_device_found_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     int8_t rssi;
     uint8_t flags;
     uint16_t eir_data_len;
@@ -288,8 +278,7 @@ struct btp_gap_device_found_ev {
 
 #define BTP_GAP_EV_DEVICE_CONNECTED        0x82
 struct btp_gap_device_connected_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
@@ -297,42 +286,36 @@ struct btp_gap_device_connected_ev {
 
 #define BTP_GAP_EV_DEVICE_DISCONNECTED    0x83
 struct btp_gap_device_disconnected_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_EV_PASSKEY_DISPLAY        0x84
 struct btp_gap_passkey_display_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint32_t passkey;
 } __packed;
 
 #define BTP_GAP_EV_PASSKEY_ENTRY_REQ    0x85
 struct btp_gap_passkey_entry_req_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_EV_PASSKEY_CONFIRM_REQ    0x86
 struct btp_gap_passkey_confirm_req_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint32_t passkey;
 } __packed;
 
 #define BTP_GAP_EV_IDENTITY_RESOLVED    0x87
 struct btp_gap_identity_resolved_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t identity_address_type;
-    uint8_t identity_address[6];
+    uint8_t identity_address;
 } __packed;
 
 #define BTP_GAP_EV_CONN_PARAM_UPDATE    0x88
 struct btp_gap_conn_param_update_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
@@ -340,26 +323,22 @@ struct btp_gap_conn_param_update_ev {
 
 #define BTP_GAP_EV_SEC_LEVEL_CHANGED    0x89
 struct btp_gap_sec_level_changed_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t level;
 } __packed;
 
 #define BTP_GAP_EV_PAIRING_CONSENT_REQ    0x8a
 struct btp_gap_pairing_consent_req_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_EV_BOND_LOST            0x8b
 struct btp_gap_bond_lost_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GAP_EV_SEC_PAIRING_FAILED    0x8c
 struct btp_gap_sec_pairing_failed_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t reason;
 } __packed;
diff --git a/apps/bttester/src/btp/btp_gatt.h b/apps/bttester/src/btp/btp_gatt.h
index 6e2336646..41f5ae7ec 100644
--- a/apps/bttester/src/btp/btp_gatt.h
+++ b/apps/bttester/src/btp/btp_gatt.h
@@ -131,8 +131,7 @@ struct btp_gatt_descriptor {
 
 #define BTP_GATT_DISC_ALL_PRIM_SVCS        0x0b
 struct btp_gatt_disc_all_prim_svcs_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 struct btp_gatt_disc_all_prim_svcs_rp {
     uint8_t services_count;
@@ -141,8 +140,7 @@ struct btp_gatt_disc_all_prim_svcs_rp {
 
 #define BTP_GATT_DISC_PRIM_UUID        0x0c
 struct btp_gatt_disc_prim_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t uuid_length;
     uint8_t uuid[0];
 } __packed;
@@ -153,8 +151,7 @@ struct btp_gatt_disc_prim_uuid_rp {
 
 #define BTP_GATT_FIND_INCLUDED        0x0d
 struct btp_gatt_find_included_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
@@ -165,8 +162,7 @@ struct btp_gatt_find_included_rp {
 
 #define BTP_GATT_DISC_ALL_CHRC        0x0e
 struct btp_gatt_disc_all_chrc_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
@@ -177,8 +173,7 @@ struct btp_gatt_disc_chrc_rp {
 
 #define BTP_GATT_DISC_CHRC_UUID        0x0f
 struct btp_gatt_disc_chrc_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
     uint8_t uuid_length;
@@ -187,8 +182,7 @@ struct btp_gatt_disc_chrc_uuid_cmd {
 
 #define BTP_GATT_DISC_ALL_DESC        0x10
 struct btp_gatt_disc_all_desc_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
@@ -199,8 +193,7 @@ struct btp_gatt_disc_all_desc_rp {
 
 #define BTP_GATT_READ            0x11
 struct btp_gatt_read_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
 } __packed;
 struct btp_gatt_read_rp {
@@ -211,8 +204,7 @@ struct btp_gatt_read_rp {
 
 #define BTP_GATT_READ_UUID            0x12
 struct btp_gatt_read_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
     uint8_t uuid_length;
@@ -221,24 +213,21 @@ struct btp_gatt_read_uuid_cmd {
 
 #define BTP_GATT_READ_LONG            0x13
 struct btp_gatt_read_long_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
 } __packed;
 
 #define BTP_GATT_READ_MULTIPLE        0x14
 struct btp_gatt_read_multiple_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t handles_count;
     uint16_t handles[0];
 } __packed;
 
 #define BTP_GATT_WRITE_WITHOUT_RSP        0x15
 struct btp_gatt_write_without_rsp_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -246,8 +235,7 @@ struct btp_gatt_write_without_rsp_cmd {
 
 #define BTP_GATT_SIGNED_WRITE_WITHOUT_RSP    0x16
 struct btp_gatt_signed_write_without_rsp_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -255,8 +243,7 @@ struct btp_gatt_signed_write_without_rsp_cmd {
 
 #define BTP_GATT_WRITE            0x17
 struct btp_gatt_write_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -264,8 +251,7 @@ struct btp_gatt_write_cmd {
 
 #define BTP_GATT_WRITE_LONG            0x18
 struct btp_gatt_write_long_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
     uint16_t data_length;
@@ -274,8 +260,7 @@ struct btp_gatt_write_long_cmd {
 
 #define BTP_GATT_RELIABLE_WRITE        0x19
 struct btp_gatt_reliable_write_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
     uint16_t data_length;
@@ -285,8 +270,7 @@ struct btp_gatt_reliable_write_cmd {
 #define BTP_GATT_CFG_NOTIFY            0x1a
 #define BTP_GATT_CFG_INDICATE        0x1b
 struct btp_gatt_cfg_notify_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t enable;
     uint16_t ccc_handle;
 } __packed;
@@ -311,8 +295,7 @@ struct btp_gatt_attr {
 
 #define BTP_GATT_GET_ATTRIBUTE_VALUE    0x1d
 struct btp_gatt_get_attribute_value_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
 } __packed;
 struct btp_gatt_get_attribute_value_rp {
@@ -331,8 +314,7 @@ struct btp_gatt_change_database {
 /* GATT events */
 #define BTP_GATT_EV_NOTIFICATION        0x80
 struct btp_gatt_notification_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t type;
     uint16_t handle;
     uint16_t data_length;
diff --git a/apps/bttester/src/btp/btp_gattc.h 
b/apps/bttester/src/btp/btp_gattc.h
index 0b946a52b..7c642fdd6 100644
--- a/apps/bttester/src/btp/btp_gattc.h
+++ b/apps/bttester/src/btp/btp_gattc.h
@@ -37,38 +37,33 @@ struct btp_gattc_read_supported_commands_rp {
 
 #define BTP_GATTC_DISC_ALL_PRIM_SVCS    0x03
 struct btp_gattc_disc_all_prim_svcs_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_GATTC_DISC_PRIM_UUID        0x04
 struct btp_gattc_disc_prim_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t uuid_length;
     uint8_t uuid[0];
 } __packed;
 
 #define BTP_GATTC_FIND_INCLUDED        0x05
 struct btp_gattc_find_included_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
 
 #define BTP_GATTC_DISC_ALL_CHRC        0x06
 struct btp_gattc_disc_all_chrc_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
 
 #define BTP_GATTC_DISC_CHRC_UUID        0x07
 struct btp_gattc_disc_chrc_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
     uint8_t uuid_length;
@@ -77,31 +72,27 @@ struct btp_gattc_disc_chrc_uuid_cmd {
 
 #define BTP_GATTC_DISC_ALL_DESC        0x08
 struct btp_gattc_disc_all_desc_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
 } __packed;
 
 #define BTP_GATTC_READ            0x09
 struct btp_gattc_read_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
 } __packed;
 
 #define BTP_GATTC_READ_UUID            0x0a
 struct btp_gattc_read_uuid_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t start_handle;
     uint16_t end_handle;
     uint8_t uuid_length;
     uint8_t uuid[0];
 } __packed;
 struct btp_gattc_read_uuid_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint16_t data_length;
     uint8_t value_length;
@@ -110,24 +101,21 @@ struct btp_gattc_read_uuid_rp {
 
 #define BTP_GATTC_READ_LONG            0x0b
 struct btp_gattc_read_long_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
 } __packed;
 
 #define BTP_GATTC_READ_MULTIPLE        0x0c
 struct btp_gattc_read_multiple_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t handles_count;
     uint16_t handles[0];
 } __packed;
 
 #define BTP_GATTC_WRITE_WITHOUT_RSP        0x0d
 struct btp_gattc_write_without_rsp_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -135,8 +123,7 @@ struct btp_gattc_write_without_rsp_cmd {
 
 #define BTP_GATTC_SIGNED_WRITE_WITHOUT_RSP    0x0e
 struct btp_gattc_signed_write_without_rsp_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -144,8 +131,7 @@ struct btp_gattc_signed_write_without_rsp_cmd {
 
 #define BTP_GATTC_WRITE            0x0f
 struct btp_gattc_write_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t data_length;
     uint8_t data[0];
@@ -153,8 +139,7 @@ struct btp_gattc_write_cmd {
 
 #define BTP_GATTC_WRITE_LONG        0x10
 struct btp_gattc_write_long_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
     uint16_t data_length;
@@ -163,8 +148,7 @@ struct btp_gattc_write_long_cmd {
 
 #define BTP_GATTC_RELIABLE_WRITE        0x11
 struct btp_gattc_reliable_write_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t handle;
     uint16_t offset;
     uint16_t data_length;
@@ -174,8 +158,7 @@ struct btp_gattc_reliable_write_cmd {
 #define BTP_GATTC_CFG_NOTIFY        0x12
 #define BTP_GATTC_CFG_INDICATE        0x13
 struct btp_gattc_cfg_notify_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t enable;
     uint16_t ccc_handle;
 } __packed;
@@ -183,15 +166,13 @@ struct btp_gattc_cfg_notify_cmd {
 /* events */
 #define BTP_GATTC_EV_MTU_EXCHANGED    0x80
 struct btp_gattc_exchange_mtu_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t mtu;
 } __packed;
 
 #define BTP_GATTC_DISC_ALL_PRIM_RP    0x81
 struct btp_gattc_disc_prim_svcs_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint8_t services_count;
     uint8_t data[0];
@@ -201,8 +182,7 @@ struct btp_gattc_disc_prim_svcs_rp {
 
 #define BTP_GATTC_FIND_INCLUDED_RP    0x83
 struct btp_gattc_find_included_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint8_t services_count;
     struct btp_gatt_included included[0];
@@ -211,8 +191,7 @@ struct btp_gattc_find_included_rp {
 #define BTP_GATTC_DISC_ALL_CHRC_RP    0x84
 #define BTP_GATTC_DISC_CHRC_UUID_RP    0x85
 struct btp_gattc_disc_chrc_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint8_t characteristics_count;
     struct btp_gatt_characteristic characteristics[0];
@@ -220,8 +199,7 @@ struct btp_gattc_disc_chrc_rp {
 
 #define BTP_GATTC_DISC_ALL_DESC_RP    0x86
 struct btp_gattc_disc_all_desc_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint8_t descriptors_count;
     struct btp_gatt_descriptor descriptors[0];
@@ -232,8 +210,7 @@ struct btp_gattc_disc_all_desc_rp {
 #define BTP_GATTC_READ_LONG_RP        0x89
 #define BTP_GATTC_READ_MULTIPLE_RP    0x8a
 struct btp_gattc_read_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
     uint16_t data_length;
     uint8_t data[0];
@@ -241,8 +218,7 @@ struct btp_gattc_read_rp {
 
 #define BTP_GATTC_WRITE_RP            0x8b
 struct btp_gattc_write_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
 } __packed;
 #define BTP_GATTC_WRITE_LONG_RP        0x8c
@@ -250,15 +226,13 @@ struct btp_gattc_write_rp {
 #define BTP_GATTC_CFG_NOTIFY_RP        0x8e
 #define BTP_GATTC_CFG_INDICATE_RP    0x8f
 struct btp_subscribe_rp {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t status;
 } __packed;
 
 #define BTP_GATTC_EV_NOTIFICATION_RXED        0x90
 struct btp_gattc_notification_ev {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint8_t type;
     uint16_t handle;
     uint16_t data_length;
diff --git a/apps/bttester/src/btp/btp_l2cap.h 
b/apps/bttester/src/btp/btp_l2cap.h
index 591634553..7d2adcaea 100644
--- a/apps/bttester/src/btp/btp_l2cap.h
+++ b/apps/bttester/src/btp/btp_l2cap.h
@@ -38,8 +38,7 @@ struct btp_l2cap_read_supported_commands_rp {
 
 #define BTP_L2CAP_CONNECT            0x02
 struct btp_l2cap_connect_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t psm;
     uint16_t mtu;
     uint8_t num;
@@ -82,8 +81,7 @@ struct l2cap_accept_connection_cmd {
 
 #define BTP_L2CAP_RECONFIGURE        0x07
 struct btp_l2cap_reconfigure_cmd {
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
     uint16_t mtu;
     uint8_t num;
     uint8_t idxs[];
@@ -99,8 +97,7 @@ struct btp_l2cap_credits_cmd {
 struct btp_l2cap_connection_req_ev {
     uint8_t chan_id;
     uint16_t psm;
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_L2CAP_EV_CONNECTED        0x81
@@ -111,8 +108,7 @@ struct btp_l2cap_connected_ev {
     uint16_t peer_mps;
     uint16_t our_mtu;
     uint16_t our_mps;
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_L2CAP_EV_DISCONNECTED        0x82
@@ -120,8 +116,7 @@ struct btp_l2cap_disconnected_ev {
     uint16_t result;
     uint8_t chan_id;
     uint16_t psm;
-    uint8_t address_type;
-    uint8_t address[6];
+    ble_addr_t address;
 } __packed;
 
 #define BTP_L2CAP_EV_DATA_RECEIVED        0x83
diff --git a/apps/bttester/src/btp_gap.c b/apps/bttester/src/btp_gap.c
index 378e3ae5b..946bda75e 100644
--- a/apps/bttester/src/btp_gap.c
+++ b/apps/bttester/src/btp_gap.c
@@ -210,7 +210,7 @@ controller_info(const void *cmd, uint16_t cmd_len,
         }
         current_settings |= BIT(BTP_GAP_SETTINGS_PRIVACY);
         supported_settings |= BIT(BTP_GAP_SETTINGS_PRIVACY);
-        memcpy(rp->address, addr.val, sizeof(rp->address));
+        memcpy(&rp->address, &addr, sizeof(rp->address));
     } else {
         rc = ble_hs_id_copy_addr(BLE_ADDR_PUBLIC, rp->address, NULL);
         if (rc) {
@@ -595,8 +595,7 @@ store_adv(const ble_addr_t *addr, int8_t rssi,
         return;
     }
 
-    memcpy(ev->address, addr->val, sizeof(ev->address));
-    ev->address_type = addr->type;
+    memcpy(&ev->address, addr, sizeof(ev->address));
     ev->rssi = rssi;
     ev->flags = BTP_GAP_DEVICE_FOUND_FLAG_AD | BTP_GAP_DEVICE_FOUND_FLAG_RSSI;
     ev->eir_data_len = len;
@@ -645,8 +644,7 @@ device_found(ble_addr_t *addr, int8_t rssi, uint8_t evtype,
         }
 
         ev = (void *) adv_buf->om_data;
-        a.type = ev->address_type;
-        memcpy(a.val, ev->address, sizeof(a.val));
+        memcpy(&a, &ev->address, sizeof(a));
 
         /*
          * in general, the Scan Response comes right after the
@@ -818,8 +816,7 @@ le_connected(uint16_t conn_handle, int status)
 
     addr = &desc.peer_id_addr;
 
-    memcpy(connected_ev.address, addr->val, sizeof(connected_ev.address));
-    connected_ev.address_type = addr->type;
+    memcpy(&connected_ev.address, addr, sizeof(connected_ev.address));
     connected_ev.conn_itvl = desc.conn_itvl;
     connected_ev.conn_latency = desc.conn_latency;
     connected_ev.supervision_timeout = desc.supervision_timeout;
@@ -870,8 +867,7 @@ le_disconnected(struct ble_gap_conn_desc *conn, int reason)
     connection_attempts = 0;
     memset(&connected_ev, 0, sizeof(connected_ev));
 
-    memcpy(ev.address, addr->val, sizeof(ev.address));
-    ev.address_type = addr->type;
+    memcpy(&ev.address, addr, sizeof(ev.address));
 
     tester_send(BTP_SERVICE_ID_GAP, BTP_GAP_EV_DEVICE_DISCONNECTED,
                 (uint8_t *) &ev, sizeof(ev));
@@ -925,8 +921,7 @@ auth_passkey_display(uint16_t conn_handle, unsigned int 
passkey)
 
     addr = &desc.peer_ota_addr;
 
-    memcpy(ev.address, addr->val, sizeof(ev.address));
-    ev.address_type = addr->type;
+    memcpy(&ev.address, addr, sizeof(ev.address));
     ev.passkey = htole32(pk.passkey);
 
     tester_send(BTP_SERVICE_ID_GAP, BTP_GAP_EV_PASSKEY_DISPLAY,
@@ -950,8 +945,7 @@ auth_passkey_entry(uint16_t conn_handle)
 
     addr = &desc.peer_ota_addr;
 
-    memcpy(ev.address, addr->val, sizeof(ev.address));
-    ev.address_type = addr->type;
+    memcpy(&ev.address, addr, sizeof(ev.address));
 
     tester_send(BTP_SERVICE_ID_GAP, BTP_GAP_EV_PASSKEY_ENTRY_REQ,
                 (uint8_t *) &ev, sizeof(ev));
@@ -974,8 +968,7 @@ auth_passkey_numcmp(uint16_t conn_handle, unsigned int 
passkey)
 
     addr = &desc.peer_ota_addr;
 
-    memcpy(ev.address, addr->val, sizeof(ev.address));
-    ev.address_type = addr->type;
+    memcpy(&ev.address, addr, sizeof(ev.address));
     ev.passkey = htole32(passkey);
 
     tester_send(BTP_SERVICE_ID_GAP, BTP_GAP_EV_PASSKEY_CONFIRM_REQ,
@@ -1053,11 +1046,9 @@ le_identity_resolved(uint16_t conn_handle)
     peer_id_addr = desc.peer_id_addr;
     peer_ota_addr = desc.peer_ota_addr;
 
-    ev.address_type = desc.peer_ota_addr.type;
-    memcpy(ev.address, desc.peer_ota_addr.val, sizeof(ev.address));
+    memcpy(&ev.address, &desc.peer_ota_addr, sizeof(ev.address));
 
-    ev.identity_address_type = desc.peer_id_addr.type;
-    memcpy(ev.identity_address, desc.peer_id_addr.val,
+    memcpy(&ev.identity_address, &desc.peer_id_addr,
            sizeof(ev.identity_address));
 
     tester_send(BTP_SERVICE_ID_GAP, BTP_GAP_EV_IDENTITY_RESOLVED,
@@ -1081,8 +1072,7 @@ le_pairing_failed(uint16_t conn_handle, int reason)
     peer_id_addr = desc.peer_id_addr;
     peer_ota_addr = desc.peer_ota_addr;
 
-    ev.address_type = desc.peer_ota_addr.type;
-    memcpy(ev.address, desc.peer_ota_addr.val, sizeof(ev.address));
+    memcpy(&ev.address, &desc.peer_ota_addr, sizeof(ev.address));
 
     ev.reason = reason;
 
@@ -1097,8 +1087,7 @@ le_conn_param_update(struct ble_gap_conn_desc *desc)
 
     SYS_LOG_DBG("");
 
-    ev.address_type = desc->peer_ota_addr.type;
-    memcpy(ev.address, desc->peer_ota_addr.val, sizeof(ev.address));
+    memcpy(&ev.address, &desc->peer_ota_addr, sizeof(ev.address));
 
     ev.conn_itvl = desc->conn_itvl;
     ev.conn_latency = desc->conn_latency;
@@ -1117,8 +1106,7 @@ le_encryption_changed(struct ble_gap_conn_desc *desc)
 
     encrypted = (bool) desc->sec_state.encrypted;
 
-    ev.address_type = desc->peer_ota_addr.type;
-    memcpy(ev.address, desc->peer_ota_addr.val, sizeof(ev.address));
+    memcpy(&ev.address, &desc->peer_ota_addr, sizeof(ev.address));
     ev.level = 0;
 
     if (desc->sec_state.encrypted) {
@@ -1147,8 +1135,7 @@ bond_lost(uint16_t conn_handle)
     rc = ble_gap_conn_find(conn_handle, &desc);
     assert(rc == 0);
 
-    memcpy(ev.address, &desc.peer_id_addr, sizeof(ev.address));
-    ev.address_type = desc.peer_id_addr.type;
+    memcpy(&ev.address, &desc.peer_id_addr, sizeof(ev.address));
     tester_send(BTP_SERVICE_ID_GAP,
                 BTP_GAP_EV_BOND_LOST,
                 (uint8_t *) &ev,
@@ -1415,7 +1402,7 @@ connect(const void *cmd, uint16_t cmd_len,
 {
     const struct btp_gap_connect_cmd *cp = cmd;
 
-    ble_addr_t *addr =  (ble_addr_t *)&cp->address_type;
+    ble_addr_t *addr =  (ble_addr_t *)&cp->address;
 
     SYS_LOG_DBG("");
 
@@ -1441,7 +1428,7 @@ disconnect(const void *cmd, uint16_t cmd_len,
 
     SYS_LOG_DBG("");
 
-    rc = gap_conn_find_by_addr((ble_addr_t *)&cp->address_type, &desc);
+    rc = gap_conn_find_by_addr(&cp->address, &desc);
     if (rc) {
         return BTP_STATUS_FAILED;
     }
@@ -1499,7 +1486,7 @@ pair(const void *cmd, uint16_t cmd_len,
 
     SYS_LOG_DBG("");
 
-    rc = gap_conn_find_by_addr((ble_addr_t *)&cp->address_type, &desc);
+    rc = gap_conn_find_by_addr(&cp->address, &desc);
     if (rc) {
         return BTP_STATUS_FAILED;
     }
@@ -1521,7 +1508,7 @@ unpair(const void *cmd, uint16_t cmd_len,
 
     SYS_LOG_DBG("");
 
-    err = ble_gap_unpair((ble_addr_t *)&cp->address_type);
+    err = ble_gap_unpair(&cp->address);
     return err != 0 ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
 }
 
@@ -1536,7 +1523,7 @@ passkey_entry(const void *cmd, uint16_t cmd_len,
 
     SYS_LOG_DBG("");
 
-    rc = gap_conn_find_by_addr((ble_addr_t *)&cp->address_type, &desc);
+    rc = gap_conn_find_by_addr(&cp->address, &desc);
     if (rc) {
         return BTP_STATUS_FAILED;
     }
@@ -1563,7 +1550,7 @@ passkey_confirm(const void *cmd, uint16_t cmd_len,
 
     SYS_LOG_DBG("");
 
-    rc = gap_conn_find_by_addr((ble_addr_t *)&cp->address_type, &desc);
+    rc = gap_conn_find_by_addr(&cp->address, &desc);
     if (rc) {
         return BTP_STATUS_FAILED;
     }
@@ -1595,7 +1582,7 @@ start_direct_adv(const void *cmd, uint16_t cmd_len,
 
     adv_params.high_duty_cycle = cp->high_duty;
 
-    err = ble_gap_adv_start(own_addr_type, (ble_addr_t *)&cp->address_type,
+    err = ble_gap_adv_start(own_addr_type, &cp->address,
                             BLE_HS_FOREVER, &adv_params,
                             gap_event_cb, NULL);
     if (err) {
diff --git a/apps/bttester/src/btp_gatt_cl.c b/apps/bttester/src/btp_gatt_cl.c
index 3f7a09f2f..0ba494a10 100644
--- a/apps/bttester/src/btp_gatt_cl.c
+++ b/apps/bttester/src/btp_gatt_cl.c
@@ -126,7 +126,6 @@ tester_mtu_exchanged_ev(uint16_t conn_handle,
     struct btp_gattc_exchange_mtu_ev *ev;
     struct ble_gap_conn_desc conn;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
 
     SYS_LOG_DBG("");
 
@@ -139,10 +138,7 @@ tester_mtu_exchanged_ev(uint16_t conn_handle,
         return 0;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    ev->address_type = addr->type;
-    memcpy(ev->address, addr->val, sizeof(ev->address));
+    memcpy(&ev->address, &conn.peer_ota_addr, sizeof(ev->address));
 
     ev->mtu = mtu;
 
@@ -189,7 +185,6 @@ disc_prim_svcs_cb(uint16_t conn_handle,
     struct ble_gap_conn_desc conn;
     struct btp_gatt_service *service;
     const ble_uuid_any_t *uuid;
-    const ble_addr_t *addr;
     uint8_t uuid_length;
     struct os_mbuf *buf = os_msys_get(0, 0);
     uint8_t opcode = (uint8_t) (int) arg;
@@ -208,10 +203,7 @@ disc_prim_svcs_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
     if (error->status != 0 && error->status != BLE_HS_EDONE) {
@@ -334,7 +326,6 @@ find_included_cb(uint16_t conn_handle,
     uint8_t uuid_length;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -351,10 +342,7 @@ find_included_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
 
@@ -454,7 +442,6 @@ disc_chrc_cb(uint16_t conn_handle,
     uint8_t opcode = (uint8_t) (int) arg;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -469,10 +456,7 @@ disc_chrc_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
 
@@ -616,7 +600,6 @@ disc_all_desc_cb(uint16_t conn_handle,
     uint8_t uuid_length;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -633,10 +616,7 @@ disc_all_desc_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
 
@@ -732,7 +712,6 @@ read_cb(uint16_t conn_handle,
     struct btp_gattc_read_rp *rp;
     uint8_t opcode = (uint8_t) (int) arg;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -747,10 +726,7 @@ read_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     SYS_LOG_DBG("status=%d", error->status);
 
@@ -821,7 +797,6 @@ read_uuid_cb(uint16_t conn_handle,
     uint8_t opcode = (uint8_t) (int) arg;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
     static uint16_t attr_len;
@@ -839,10 +814,7 @@ read_uuid_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
 
@@ -932,7 +904,6 @@ read_long_cb(uint16_t conn_handle,
     uint8_t opcode = (uint8_t) (int) arg;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -949,10 +920,7 @@ read_long_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
 
@@ -1090,7 +1058,6 @@ write_cb(uint16_t conn_handle, const struct 
ble_gatt_error *error,
     uint8_t err = (uint8_t) error->status;
     uint8_t opcode = (uint8_t) (int) arg;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -1107,10 +1074,7 @@ write_cb(uint16_t conn_handle, const struct 
ble_gatt_error *error,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
     tester_send_buf(BTP_SERVICE_ID_GATTC, opcode,
@@ -1197,7 +1161,6 @@ reliable_write_cb(uint16_t conn_handle,
     struct btp_gattc_write_rp *rp;
     uint8_t err = (uint8_t) error->status;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -1214,10 +1177,7 @@ reliable_write_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
     tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_RELIABLE_WRITE_RP,
@@ -1282,7 +1242,6 @@ subscribe_cb(uint16_t conn_handle,
     uint8_t err = (uint8_t) error->status;
     uint8_t opcode = (uint8_t) (int) arg;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
     struct ble_gap_conn_desc conn;
     int rc = 0;
 
@@ -1299,10 +1258,7 @@ subscribe_cb(uint16_t conn_handle,
         goto free;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    rp->address_type = addr->type;
-    memcpy(rp->address, addr->val, sizeof(rp->address));
+    memcpy(&rp->address, &conn.peer_ota_addr, sizeof(rp->address));
 
     rp->status = err;
     tester_send_buf(BTP_SERVICE_ID_GATTC, opcode,
@@ -1419,7 +1375,6 @@ tester_gattc_notify_rx_ev(uint16_t conn_handle, uint16_t 
attr_handle,
     struct btp_gattc_notification_ev *ev;
     struct ble_gap_conn_desc conn;
     struct os_mbuf *buf = os_msys_get(0, 0);
-    const ble_addr_t *addr;
 
     SYS_LOG_DBG("");
 
@@ -1436,10 +1391,7 @@ tester_gattc_notify_rx_ev(uint16_t conn_handle, uint16_t 
attr_handle,
         return 0;
     }
 
-    addr = &conn.peer_ota_addr;
-
-    ev->address_type = addr->type;
-    memcpy(ev->address, addr->val, sizeof(ev->address));
+    memcpy(&ev->address, &conn.peer_ota_addr, sizeof(ev->address));
     ev->type = (uint8_t) (indication ? 0x02 : 0x01);
     ev->handle = htole16(attr_handle);
     ev->data_length = htole16(os_mbuf_len(om));
diff --git a/apps/bttester/src/btp_l2cap.c b/apps/bttester/src/btp_l2cap.c
index 498d22604..389bb8fd7 100644
--- a/apps/bttester/src/btp_l2cap.c
+++ b/apps/bttester/src/btp_l2cap.c
@@ -201,9 +201,7 @@ connected_cb(uint16_t conn_handle, struct ble_l2cap_chan 
*chan,
     channel->chan = chan;
 
     if (!ble_gap_conn_find(conn_handle, &desc)) {
-        ev.address_type = desc.peer_ota_addr.type;
-        memcpy(ev.address, desc.peer_ota_addr.val,
-               sizeof(ev.address));
+        memcpy(&ev.address, &desc.peer_ota_addr, sizeof(ev.address));
     }
 
     tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_CONNECTED,
@@ -229,9 +227,7 @@ disconnected_cb(uint16_t conn_handle, struct ble_l2cap_chan 
*chan,
     ev.psm = chan_info->psm;
 
     if (!ble_gap_conn_find(conn_handle, &desc)) {
-        ev.address_type = desc.peer_ota_addr.type;
-        memcpy(ev.address, desc.peer_ota_addr.val,
-               sizeof(ev.address));
+        memcpy(&ev.address, &desc.peer_ota_addr, sizeof(ev.address));
     }
 
     tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_DISCONNECTED,


Reply via email to