OSDN Git Service

Remove duplicate local bdaddr management functions
authorZach Johnson <zachoverflow@google.com>
Mon, 6 Oct 2014 20:15:00 +0000 (13:15 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 16 Mar 2015 23:51:36 +0000 (16:51 -0700)
21 files changed:
bta/dm/bta_dm_act.c
bta/include/bta_api.h
bta/include/bta_jv_api.h
bta/jv/bta_jv_act.c
bta/jv/bta_jv_api.c
bta/jv/bta_jv_int.h
bta/jv/bta_jv_main.c
btif/include/btif_common.h
btif/src/btif_core.c
btif/src/btif_dm.c
btif/src/btif_pan.c
stack/bnep/bnep_api.c
stack/bnep/bnep_int.h
stack/bnep/bnep_main.c
stack/bnep/bnep_utils.c
stack/btm/btm_acl.c
stack/btm/btm_devctl.c
stack/include/bnep_api.h
stack/include/btm_api.h
stack/pan/pan_int.h
stack/smp/smp_utils.c

index 0c0c222..7079147 100644 (file)
@@ -3198,7 +3198,6 @@ static void bta_dm_local_name_cback(UINT8 *p_name)
     tBTA_DM_SEC sec_event;
     UNUSED(p_name);
 
-    BTM_GetLocalDeviceAddr(sec_event.enable.bd_addr);
     sec_event.enable.status = BTA_SUCCESS;
 
     if(bta_dm_cb.p_sec_cback)
index 42bc744..7b6f094 100644 (file)
@@ -643,7 +643,6 @@ typedef UINT8 tBTA_DM_SEC_EVT;
 /* Structure associated with BTA_DM_ENABLE_EVT */
 typedef struct
 {
-    BD_ADDR         bd_addr;            /* BD address of local device. */
     tBTA_STATUS    status;
 } tBTA_DM_ENABLE;
 
index 66eb16a..dea47f9 100644 (file)
@@ -137,7 +137,7 @@ typedef UINT8 tBTA_JV_CONN_STATE;
 /* events received by tBTA_JV_DM_CBACK */
 #define BTA_JV_ENABLE_EVT           0  /* JV enabled */
 #define BTA_JV_SET_DISCOVER_EVT     1  /* the result for BTA_JvSetDiscoverability */
-#define BTA_JV_LOCAL_ADDR_EVT       2  /* Local device address */
+// (zachoverflow): removed 2 because it's obsolete now
 #define BTA_JV_LOCAL_NAME_EVT       3  /* Local device name */
 #define BTA_JV_REMOTE_NAME_EVT      4  /* Remote device name */
 #define BTA_JV_SET_ENCRYPTION_EVT   5  /* Set Encryption */
@@ -415,7 +415,6 @@ typedef union
     tBTA_JV_DISCOVERY_COMP  disc_comp;      /* BTA_JV_DISCOVERY_COMP_EVT */
     tBTA_JV_SET_DISCOVER    set_discover;   /* BTA_JV_SET_DISCOVER_EVT */
     tBTA_JV_SET_ENCRYPTION  set_encrypt;    /* BTA_JV_SET_ENCRYPTION_EVT */
-    BD_ADDR                 bd_addr;        /* BTA_JV_LOCAL_ADDR_EVT */
     UINT8                   *p_name;        /* BTA_JV_LOCAL_NAME_EVT,
                                                BTA_JV_REMOTE_NAME_EVT */
     UINT8                   scn;            /* BTA_JV_GET_SCN_EVT */
@@ -540,20 +539,6 @@ extern tBTA_JV_DISC BTA_JvGetDiscoverability(void);
 
 /*******************************************************************************
 **
-** Function         BTA_JvGetLocalDeviceAddr
-**
-** Description      This function obtains the local Bluetooth device address.
-**                  The local Bluetooth device address is reported by the
-**                  tBTA_JV_DM_CBACK callback with a BTA_JV_LOCAL_ADDR_EVT.
-**
-** Returns          BTA_JV_SUCCESS if successful.
-**                  BTA_JV_FAIL if internal failure.
-**
-*******************************************************************************/
-extern tBTA_JV_STATUS BTA_JvGetLocalDeviceAddr(void);
-
-/*******************************************************************************
-**
 ** Function         BTA_JvGetLocalDeviceName
 **
 ** Description      This function obtains the name of the local device
index 3419089..a0eebe4 100644 (file)
@@ -70,21 +70,6 @@ tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_
 
 /*******************************************************************************
 **
-** Function     bta_jv_get_local_device_addr_cback
-**
-** Description  Callback from btm after local bdaddr is read
-**
-** Returns      void
-**
-*******************************************************************************/
-static void bta_jv_get_local_device_addr_cback(BD_ADDR bd_addr)
-{
-    if(bta_jv_cb.p_dm_cback)
-        bta_jv_cb.p_dm_cback(BTA_JV_LOCAL_ADDR_EVT, (tBTA_JV *)bd_addr, 0);
-}
-
-/*******************************************************************************
-**
 ** Function     bta_jv_get_remote_device_name_cback
 **
 ** Description  Callback from btm after remote name is read
@@ -838,22 +823,6 @@ void bta_jv_set_discoverability (tBTA_JV_MSG *p_data)
 
 /*******************************************************************************
 **
-** Function     bta_jv_get_local_device_addr
-**
-** Description  Reads the local Bluetooth device address
-**
-** Returns      void
-**
-*******************************************************************************/
-void bta_jv_get_local_device_addr(tBTA_JV_MSG *p_data)
-{
-    UNUSED(p_data);
-
-    BTM_ReadLocalDeviceAddr((tBTM_CMPL_CB *)bta_jv_get_local_device_addr_cback);
-}
-
-/*******************************************************************************
-**
 ** Function     bta_jv_get_local_device_name
 **
 ** Description  Reads the local Bluetooth device name
index e0d100d..a5f0e07 100644 (file)
@@ -177,34 +177,6 @@ tBTA_JV_DISC BTA_JvGetDiscoverability(void)
 
 /*******************************************************************************
 **
-** Function         BTA_JvGetLocalDeviceAddr
-**
-** Description      This function obtains the local Bluetooth device address.
-**                  The local Bluetooth device address is reported by the
-**                  tBTA_JV_DM_CBACK callback with a BTA_JV_LOCAL_ADDR_EVT.
-**
-** Returns          BTA_JV_SUCCESS if successful.
-**                  BTA_JV_FAIL if internal failure.
-**
-*******************************************************************************/
-tBTA_JV_STATUS BTA_JvGetLocalDeviceAddr(void)
-{
-    tBTA_JV_STATUS ret = BTA_JV_FAILURE;
-    BT_HDR *p_msg;
-
-    APPL_TRACE_API( "BTA_JvGetLocalDeviceAddr");
-    if ((p_msg = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
-    {
-        p_msg->event = BTA_JV_API_GET_LOCAL_DEVICE_ADDR_EVT;
-        bta_sys_sendmsg(p_msg);
-        ret = BTA_JV_SUCCESS;
-    }
-
-    return(ret);
-}
-
-/*******************************************************************************
-**
 ** Function         BTA_JvGetLocalDeviceName
 **
 ** Description      This function obtains the name of the local device
index 436c0a5..b1b41cb 100644 (file)
@@ -478,7 +478,6 @@ extern UINT32 bta_jv_get_sdp_handle(UINT32 sdp_id);
 extern void bta_jv_enable (tBTA_JV_MSG *p_data);
 extern void bta_jv_disable (tBTA_JV_MSG *p_data);
 extern void bta_jv_set_discoverability (tBTA_JV_MSG *p_data);
-extern void bta_jv_get_local_device_addr (tBTA_JV_MSG *p_data);
 extern void bta_jv_get_local_device_name (tBTA_JV_MSG *p_data);
 extern void bta_jv_get_remote_device_name (tBTA_JV_MSG *p_data);
 extern void bta_jv_set_service_class (tBTA_JV_MSG *p_data);
index 686ff17..e4b7663 100644 (file)
@@ -47,7 +47,7 @@ const tBTA_JV_ACTION bta_jv_action[] =
     bta_jv_enable,                  /* BTA_JV_API_ENABLE_EVT */
     bta_jv_disable,                 /* BTA_JV_API_DISABLE_EVT */
     bta_jv_set_discoverability,     /* BTA_JV_API_SET_DISCOVERABILITY_EVT */
-    bta_jv_get_local_device_addr,   /* BTA_JV_API_GET_LOCAL_DEVICE_ADDR_EVT */
+    NULL,   /* BTA_JV_API_GET_LOCAL_DEVICE_ADDR_EVT is obsolete */
     bta_jv_get_local_device_name,   /* BTA_JV_API_GET_LOCAL_DEVICE_NAME_EVT */
     bta_jv_get_remote_device_name,  /* BTA_JV_API_GET_REMOTE_DEVICE_NAME_EVT */
     bta_jv_set_service_class,       /* BTA_JV_API_SET_SERVICE_CLASS_EVT */
index bfa7243..a5d0997 100644 (file)
@@ -186,7 +186,7 @@ int btif_is_enabled(void);
 /**
  * BTIF_Events
  */
-void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd);
+void btif_enable_bluetooth_evt(tBTA_STATUS status);
 void btif_disable_bluetooth_evt(void);
 void btif_adapter_properties_evt(bt_status_t status, uint32_t num_props, bt_property_t *p_props);
 void btif_remote_properties_evt(bt_status_t status, bt_bdaddr_t *remote_addr,
index 529f54e..53e7dd1 100644 (file)
@@ -53,6 +53,7 @@
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "btu.h"
+#include "controller.h"
 #include "fixed_queue.h"
 #include "future.h"
 #include "gki.h"
@@ -454,47 +455,43 @@ error_exit:;
 **
 *******************************************************************************/
 
-void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd)
+void btif_enable_bluetooth_evt(tBTA_STATUS status)
 {
-    bt_bdaddr_t bd_addr;
+    const controller_t *controller = controller_get_interface();
     bdstr_t bdstr;
+    bdaddr_to_string(controller->get_address(), bdstr, sizeof(bdstr));
 
-    bdcpy(bd_addr.address, local_bd);
-    BTIF_TRACE_DEBUG("%s: status %d, local bd [%s]", __FUNCTION__, status,
-                                                     bdaddr_to_string(&bd_addr, bdstr, sizeof(bdstr)));
+    BTIF_TRACE_DEBUG("%s: status %d, local bd [%s]", __FUNCTION__, status, bdstr);
 
-    if (bdcmp(btif_local_bd_addr.address,local_bd))
+    if (bdcmp(btif_local_bd_addr.address, controller->get_address()->address))
     {
-        bdstr_t buf;
+        // TODO(zachoverflow): this whole code path seems like a bad time waiting to happen
+        // We open the vendor library using the old address.
+        bdstr_t old_address;
         bt_property_t prop;
 
+        bdaddr_to_string(&btif_local_bd_addr, old_address, sizeof(old_address));
+
         /**
          * The Controller's BDADDR does not match to the BTIF's initial BDADDR!
-         * This could be because the factory BDADDR was stored separatley in
+         * This could be because the factory BDADDR was stored separately in
          * the Controller's non-volatile memory rather than in device's file
          * system.
          **/
         BTIF_TRACE_WARNING("***********************************************");
-        BTIF_TRACE_WARNING("BTIF init BDA was %02X:%02X:%02X:%02X:%02X:%02X",
-            btif_local_bd_addr.address[0], btif_local_bd_addr.address[1],
-            btif_local_bd_addr.address[2], btif_local_bd_addr.address[3],
-            btif_local_bd_addr.address[4], btif_local_bd_addr.address[5]);
-        BTIF_TRACE_WARNING("Controller BDA is %02X:%02X:%02X:%02X:%02X:%02X",
-            local_bd[0], local_bd[1], local_bd[2],
-            local_bd[3], local_bd[4], local_bd[5]);
+        BTIF_TRACE_WARNING("BTIF init BDA was %s", old_address);
+        BTIF_TRACE_WARNING("Controller BDA is %s", bdstr);
         BTIF_TRACE_WARNING("***********************************************");
 
-        bdcpy(btif_local_bd_addr.address, local_bd);
+        btif_local_bd_addr = *controller->get_address();
 
         //save the bd address to config file
-        bdaddr_to_string(&btif_local_bd_addr, buf, sizeof(buf));
-        btif_config_set_str("Adapter", "Address", buf);
+        btif_config_set_str("Adapter", "Address", bdstr);
         btif_config_save();
 
         //fire HAL callback for property change
-        memcpy(buf, &btif_local_bd_addr, sizeof(bt_bdaddr_t));
         prop.type = BT_PROPERTY_BDADDR;
-        prop.val = (void*)buf;
+        prop.val = (void*)&btif_local_bd_addr;
         prop.len = sizeof(bt_bdaddr_t);
         HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, BT_STATUS_SUCCESS, 1, &prop);
     }
index 57d712d..51d5e5a 100644 (file)
@@ -1615,7 +1615,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
 
              btif_storage_load_autopair_device_list();
 
-             btif_enable_bluetooth_evt(p_data->enable.status, p_data->enable.bd_addr);
+             btif_enable_bluetooth_evt(p_data->enable.status);
         }
         break;
 
index 1ad0442..3b7df1e 100644 (file)
@@ -52,6 +52,7 @@
 #include "btm_api.h"
 #include "bd.h"
 #include "bdaddr.h"
+#include "controller.h"
 
 #include "bta_api.h"
 #include "bta_pan_api.h"
@@ -83,7 +84,6 @@
 
 btpan_cb_t btpan_cb;
 
-BD_ADDR local_addr;
 static int jni_initialized, stack_initialized;
 static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks);
 static void btpan_jni_cleanup();
@@ -306,7 +306,7 @@ void destroy_tap_read_thread(void)
     }
 }
 
-static int tap_if_up(const char *devname, BD_ADDR addr)
+static int tap_if_up(const char *devname, const bt_bdaddr_t *addr)
 {
     struct ifreq ifr;
     int sk, err;
@@ -323,14 +323,9 @@ static int tap_if_up(const char *devname, BD_ADDR addr)
         close(sk);
         return -1;
     }
-    /* debug("found mac address for interface:%s = %02x:%02x:%02x:%02x:%02x:%02x", devname, */
-    /*         ifr.ifr_hwaddr.sa_data[0], ifr.ifr_hwaddr.sa_data[1], ifr.ifr_hwaddr.sa_data[2], */
-    /*         ifr.ifr_hwaddr.sa_data[3], ifr.ifr_hwaddr.sa_data[4], ifr.ifr_hwaddr.sa_data[5]); */
+
     strncpy(ifr.ifr_name, devname, IFNAMSIZ - 1);
-    memcpy(ifr.ifr_hwaddr.sa_data, addr, 6);
-    /* debug("setting bt address for interface:%s = %02x:%02x:%02x:%02x:%02x:%02x", devname, */
-    /*         ifr.ifr_hwaddr.sa_data[0], ifr.ifr_hwaddr.sa_data[1], ifr.ifr_hwaddr.sa_data[2], */
-    /*         ifr.ifr_hwaddr.sa_data[3], ifr.ifr_hwaddr.sa_data[4], ifr.ifr_hwaddr.sa_data[5]); */
+    memcpy(ifr.ifr_hwaddr.sa_data, addr->address, 6);
 
     /* The IEEE has specified that the most significant bit of the most significant byte is used to
      * determine a multicast address. If its a 1, that means multicast, 0 means unicast.
@@ -408,7 +403,6 @@ int btpan_tap_open()
 
     /* open the clone device */
 
-    //system("insmod /system/lib/modules/tun.ko");
     if( (fd = open(clonedev, O_RDWR)) < 0 ) {
 
         BTIF_TRACE_DEBUG("could not open %s, err:%d", clonedev, errno);
@@ -421,14 +415,13 @@ int btpan_tap_open()
     strncpy(ifr.ifr_name, TAP_IF_NAME, IFNAMSIZ);
 
     /* try to create the device */
-    if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 )//|| tap_setup_ip(TAP_IF_NAME) == FALSE)
+    if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 )
     {
         BTIF_TRACE_DEBUG("ioctl error:%d, errno:%s", err, strerror(errno));
         close(fd);
         return err;
     }
-    BTM_GetLocalDeviceAddr (local_addr);
-    if(tap_if_up(TAP_IF_NAME, local_addr) == 0)
+    if(tap_if_up(TAP_IF_NAME, controller_get_interface()->get_address()) == 0)
     {
         int flags = fcntl(fd, F_GETFL, 0);
         fcntl(fd, F_SETFL, flags | O_NONBLOCK);
@@ -447,9 +440,6 @@ int btpan_tap_send(int tap_fd, const BD_ADDR src, const BD_ADDR dst, UINT16 prot
     if(tap_fd != -1)
     {
         tETH_HDR eth_hdr;
-        //if(is_empty_eth_addr(dst))
-        //    memcpy(&eth_hdr.h_dest, local_addr, ETH_ADDR_LEN);
-        //else
         memcpy(&eth_hdr.h_dest, dst, ETH_ADDR_LEN);
         memcpy(&eth_hdr.h_src, src, ETH_ADDR_LEN);
         eth_hdr.h_proto = htons(proto);
@@ -463,8 +453,6 @@ int btpan_tap_send(int tap_fd, const BD_ADDR src, const BD_ADDR dst, UINT16 prot
         memcpy(packet + sizeof(tETH_HDR), buf, len);
 
         /* Send data to network interface */
-        //btnet_send(btpan_cb.conn[i].sock.sock, &buffer, (len + sizeof(tETH_HDR)));
-        //dump_bin("packet to network", packet, len + sizeof(tETH_HDR));
         int ret = write(tap_fd, packet, len + sizeof(tETH_HDR));
         BTIF_TRACE_DEBUG("ret:%d", ret);
         return ret;
@@ -615,10 +603,6 @@ static void bta_pan_callback_transfer(UINT16 event, char *p_param)
             }
         case BTA_PAN_OPEN_EVT:
             {
-                /* debug("BTA_PAN_OPEN_EVT, open status:%d, bd_addr = [%02X:%02X:%02X:%02X:%02X:%02X]", */
-                /*         p_data->open.status, */
-                /*         p_data->open.bd_addr[0], p_data->open.bd_addr[1], p_data->open.bd_addr[2], */
-                /*         p_data->open.bd_addr[3], p_data->open.bd_addr[4], p_data->open.bd_addr[5]); */
                 btpan_connection_state_t state;
                 bt_status_t status;
                 btpan_conn_t *conn = btpan_find_conn_handle(p_data->open.handle);
@@ -638,7 +622,6 @@ static void bta_pan_callback_transfer(UINT16 event, char *p_param)
                 /* debug("BTA_PAN_OPEN_EVT handle:%d, conn:%p",  p_data->open.handle, conn); */
                 /* debug("conn bta local_role:%d, bta remote role:%d", conn->local_role, conn->remote_role); */
                 int btpan_conn_local_role = bta_role_to_btpan(p_data->open.local_role);
-                /* debug("bta local_role:%d, bta remote role:%d", p_data->open.local_role, p_data->open.peer_role); */
                 int btpan_remote_role = bta_role_to_btpan(p_data->open.peer_role);
                 callback.connection_state_cb(state, status, (const bt_bdaddr_t*)p_data->open.bd_addr,
                         btpan_conn_local_role, btpan_remote_role);
@@ -652,7 +635,6 @@ static void bta_pan_callback_transfer(UINT16 event, char *p_param)
 
                 if(conn && conn->handle >= 0)
                 {
-                    /* debug("BTA_PAN_CLOSE_EVT, conn local_role:%d, remote_role:%d", conn->local_role, conn->remote_role); */
                     int btpan_conn_local_role = bta_role_to_btpan(conn->local_role);
                     int btpan_remote_role = bta_role_to_btpan(conn->remote_role);
                     callback.connection_state_cb(BTPAN_STATE_DISCONNECTED, 0, (const bt_bdaddr_t*)conn->peer,
index 87b2cb5..c9987cb 100644 (file)
@@ -83,7 +83,6 @@ tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info)
         return BNEP_SECURITY_FAIL;
 
     bnep_cb.profile_registered  = TRUE;
-    BTM_GetLocalDeviceAddr (bnep_cb.my_bda);
     return BNEP_SUCCESS;
 }
 
@@ -690,25 +689,6 @@ tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
 #endif
 }
 
-
-/*******************************************************************************
-**
-** Function         BNEP_GetMyBdAddr
-**
-** Description      This function returns a pointer to the local device BD address.
-**                  If the BD address has not been read yet, it returns NULL.
-**
-** Returns          the BD address
-**
-*******************************************************************************/
-UINT8 *BNEP_GetMyBdAddr (void)
-{
-    if (bnep_cb.got_my_bd_addr)
-        return (bnep_cb.my_bda);
-    else
-        return (NULL);
-}
-
 /*******************************************************************************
 **
 ** Function         BNEP_SetTraceLevel
index 948201c..9d641b5 100644 (file)
@@ -183,8 +183,6 @@ typedef struct
     TIMER_LIST_ENT          bnep_tle;
     BOOLEAN                 profile_registered;             /* TRUE when we got our BD addr */
     UINT8                   trace_level;
-    BOOLEAN                 got_my_bd_addr;         /* TRUE when we got our BD addr */
-    BD_ADDR                 my_bda;                 /* BD Address of this device    */
 
 } tBNEP_CB;
 
index 62fa316..2e3d959 100644 (file)
@@ -43,6 +43,8 @@
 #include "bnep_int.h"
 #include "bt_utils.h"
 
+#include "controller.h"
+
 
 /********************************************************************************/
 /*                       G L O B A L    B N E P       D A T A                   */
@@ -65,8 +67,6 @@ static void bnep_disconnect_cfm (UINT16 l2cap_cid, UINT16 result);
 static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg);
 static void bnep_congestion_ind (UINT16 lcid, BOOLEAN is_congested);
 
-static void bnep_read_addr_cb (void *p_bda);
-
 
 /*******************************************************************************
 **
@@ -639,7 +639,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
         p_src_addr = (UINT8 *) p_bcb->rem_bda;
 
     if (!p_dst_addr)
-        p_dst_addr = (UINT8 *) bnep_cb.my_bda;
+        p_dst_addr = (UINT8 *) controller_get_interface()->get_address();
 
     /* check whether there are any extensions to be forwarded */
     if (ext_type)
@@ -677,13 +677,6 @@ void bnep_process_timeout (TIMER_LIST_ENT  *p_tle)
 
     if (!p_tle->param)
     {
-        if (!bnep_cb.got_my_bd_addr)
-        {
-            if (BTM_IsDeviceUp())
-                BTM_ReadLocalDeviceAddr (bnep_read_addr_cb);
-
-            btu_start_timer (&bnep_cb.bnep_tle, BTU_TTYPE_BNEP, 2);
-        }
         return;
     }
 
@@ -810,31 +803,3 @@ void bnep_connected (tBNEP_CONN *p_bcb)
     if (bnep_cb.p_conn_state_cb)
         (*bnep_cb.p_conn_state_cb) (p_bcb->handle, p_bcb->rem_bda, BNEP_SUCCESS, is_role_change);
 }
-
-
-/*******************************************************************************
-**
-** Function         bnep_read_addr_cb
-**
-** Description      This function is called by BTM when the local BD address
-**                  is read. It saves the BD address, and flags it as read.
-**
-** Returns          void
-**
-*******************************************************************************/
-static void bnep_read_addr_cb (void *p_bda)
-{
-    UINT8 *bda = (UINT8 *)p_bda;
-    if (p_bda &&
-            (bda[0] | bda[1] | bda[2] | bda[3] | bda[4] | bda[5]) != 0)
-    {
-        /* Save my BD address */
-        memcpy (bnep_cb.my_bda, p_bda, BD_ADDR_LEN);
-
-        bnep_cb.got_my_bd_addr = TRUE;
-    }
-    else
-        /* Retry after a couple seconds */
-        btu_start_timer (&bnep_cb.bnep_tle, BTU_TTYPE_BNEP, 2);
-}
-
index 89c471c..4369f0a 100644 (file)
@@ -30,6 +30,7 @@
 #include "btu.h"
 #include "btm_int.h"
 #include "bt_utils.h"
+#include "controller.h"
 
 
 /********************************************************************************/
@@ -487,19 +488,20 @@ void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf)
 void bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol,
                            UINT8 *p_src_addr, UINT8 *p_dest_addr, BOOLEAN fw_ext_present)
 {
+    const controller_t *controller = controller_get_interface();
     UINT8    ext_bit, *p = (UINT8 *)NULL;
     UINT8    type = BNEP_FRAME_COMPRESSED_ETHERNET;
 
     ext_bit = fw_ext_present ? 0x80 : 0x00;
 
-    if ((p_src_addr) && (memcmp (p_src_addr, bnep_cb.my_bda, BD_ADDR_LEN)))
+    if ((p_src_addr) && (memcmp (p_src_addr, &controller->get_address()->address, BD_ADDR_LEN)))
         type = BNEP_FRAME_COMPRESSED_ETHERNET_SRC_ONLY;
 
     if (memcmp (p_dest_addr, p_bcb->rem_bda, BD_ADDR_LEN))
         type = (type == BNEP_FRAME_COMPRESSED_ETHERNET) ? BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY : BNEP_FRAME_GENERAL_ETHERNET;
 
     if (!p_src_addr)
-        p_src_addr = (UINT8 *)bnep_cb.my_bda;
+        p_src_addr = (UINT8 *)controller->get_address();
 
     switch (type)
     {
@@ -1444,11 +1446,7 @@ void bnep_dump_status (void)
     char            buff[200];
     tBNEP_CONN     *p_bcb;
 
-    BNEP_TRACE_DEBUG ("BNEP my BD Addr %x.%x.%x.%x.%x.%x",
-        bnep_cb.my_bda[0], bnep_cb.my_bda[1], bnep_cb.my_bda[2],
-        bnep_cb.my_bda[3], bnep_cb.my_bda[4], bnep_cb.my_bda[5]);
-    BNEP_TRACE_DEBUG ("profile registered %d, trace %d, got_my_bd_addr %d",
-        bnep_cb.profile_registered, bnep_cb.trace_level, bnep_cb.got_my_bd_addr);
+    BNEP_TRACE_DEBUG ("profile registered %d, trace %d", bnep_cb.profile_registered, bnep_cb.trace_level);
 
     for (i = 0, p_bcb = bnep_cb.bcb; i < BNEP_MAX_CONNECTIONS; i++, p_bcb++)
     {
index a7d4a52..a3aa33c 100644 (file)
@@ -256,7 +256,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
 #endif
                 {
                     p->conn_addr_type = BLE_ADDR_PUBLIC;
-                    BTM_GetLocalDeviceAddr(p->conn_addr);
+                    memcpy(p->conn_addr, controller_get_interface()->get_address()->address, BD_ADDR_LEN);
                 }
             }
 #endif
index 963a2af..e7f2113 100644 (file)
@@ -620,40 +620,6 @@ void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len)
     }
 }
 
-// TODO(zachoverflow):
-// These two functions do pretty much the same thing...just what is this I can't even whyyy
-/*******************************************************************************
-**
-** Function         BTM_GetLocalDeviceAddr
-**
-** Description      This function is called to read the local device address
-**
-** Returns          void
-**                  the local device address is copied into bd_addr
-**
-*******************************************************************************/
-void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr)
-{
-    memcpy (bd_addr, controller_get_interface()->get_address(), BD_ADDR_LEN);
-}
-
-/*******************************************************************************
-**
-** Function         BTM_ReadLocalDeviceAddr
-**
-** Description      This function is called to read the local device address
-**
-** Returns          status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb)
-{
-    if(p_cb)
-        (*p_cb)((void *)controller_get_interface()->get_address());
-
-    return (BTM_SUCCESS);
-}
-
 /*******************************************************************************
 **
 ** Function         BTM_SetDeviceClass
index b8a3e96..3ca31d5 100644 (file)
@@ -418,18 +418,6 @@ extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
 
 /*******************************************************************************
 **
-** Function         BNEP_GetMyBdAddr
-**
-** Description      This function returns a pointer to the local device BD address.
-**                  If the BD address has not been read yet, it returns NULL.
-**
-** Returns          the BD address
-**
-*******************************************************************************/
-extern UINT8 *BNEP_GetMyBdAddr (void);
-
-/*******************************************************************************
-**
 ** Function         BNEP_SetTraceLevel
 **
 ** Description      This function sets the trace level for BNEP. If called with
index b4c5305..8a908a1 100644 (file)
@@ -2064,32 +2064,6 @@ extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cm
 
 /*******************************************************************************
 **
-** Function         BTM_ReadLocalDeviceAddr
-**
-** Description      This function is called to read the local device address
-**
-** Returns          BTM_SUCCESS
-**                  Callback returns the local device address
-**
-*******************************************************************************/
-extern tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb);
-
-
-/*******************************************************************************
-**
-** Function         BTM_GetLocalDeviceAddr
-**
-** Description      This function is called to read the local device address
-**
-** Returns          void
-**                  the local device address is copied into bd_addr
-**
-*******************************************************************************/
-extern void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr);
-
-
-/*******************************************************************************
-**
 ** Function         BTM_ReadDeviceClass
 **
 ** Description      This function is called to read the local device class
index 2d6fb8b..4e463e6 100644 (file)
@@ -82,7 +82,6 @@ typedef struct
     tPAN_MFILTER_IND_CB         *pan_mfilt_ind_cb;      /* multicast filter indication callback */
     tPAN_TX_DATA_FLOW_CB        *pan_tx_data_flow_cb;
 
-    BD_ADDR                     my_bda;                 /* BD Address of this device    */
     char                        *user_service_name;
     char                        *gn_service_name;
     char                        *nap_service_name;
index 21d93f8..0014940 100644 (file)
@@ -34,6 +34,7 @@
 #include "l2c_api.h"
 #include "l2c_int.h"
 #include "smp_int.h"
+#include "controller.h"
 
 
 #define SMP_PAIRING_REQ_SIZE    7
@@ -349,7 +350,6 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
 {
     BT_HDR      *p_buf = NULL ;
     UINT8       *p;
-    BD_ADDR     static_addr;
     UNUSED(cmd_code);
     UNUSED(p_cb);
 
@@ -360,8 +360,7 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
 
         UINT8_TO_STREAM (p, SMP_OPCODE_ID_ADDR);
         UINT8_TO_STREAM (p, 0);     /* TODO: update with local address type */
-        BTM_GetLocalDeviceAddr(static_addr);
-        BDADDR_TO_STREAM (p, static_addr);
+        BDADDR_TO_STREAM (p, controller_get_interface()->get_address()->address);
 
         p_buf->offset = L2CAP_MIN_OFFSET;
         p_buf->len = SMP_ID_ADDR_SIZE;