Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dee60917 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Andre Eisenbach
Browse files

Move all advertising related code into one file

This patch moves btm_ble_adv_raddr_timer_timeout into same file that use
it. It also moves all structures related to multi-advertising into only
source file that uses them, to make sure noone uses them externally
while they undergo further refactoring.

Bug: 30622771
Change-Id: I721d222aa8f5317620c616cc59ee04b7b28a68b3
parent 5fef9ba3
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -3172,14 +3172,6 @@ static void btm_ble_observer_timer_timeout(UNUSED_ATTR void *data)
    btm_ble_stop_observe();
}

void btm_ble_adv_raddr_timer_timeout(void *data)
{
    if ((btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) &&
        (BTM_BleMaxMultiAdvInstanceCount() > 0)) {
        btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST *)data);
    }
}

void btm_ble_refresh_raddr_timer_timeout(UNUSED_ATTR void *data)
{
    if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) {
+0 −2
Original line number Diff line number Diff line
@@ -347,7 +347,6 @@ typedef struct
    uint8_t link_count[2]; /* total link count master and slave*/
} tBTM_BLE_CB;

extern void btm_ble_adv_raddr_timer_timeout(void *data);
extern void btm_ble_refresh_raddr_timer_timeout(void *data);
extern void btm_ble_process_adv_pkt (uint8_t *p);
extern void btm_ble_proc_scan_rsp_rpt (uint8_t *p);
@@ -458,7 +457,6 @@ extern void btm_ble_resolving_list_init(uint8_t max_irk_list_sz);
extern void btm_ble_resolving_list_cleanup(void);
#endif

extern void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
extern void btm_ble_multi_adv_init(void);
extern void* btm_ble_multi_adv_get_ref(uint8_t inst_id);
extern void btm_ble_multi_adv_cleanup(void);
+45 −3
Original line number Diff line number Diff line
@@ -30,6 +30,38 @@
#include "hcidefs.h"
#include "btm_ble_api.h"

typedef struct
{
    uint8_t *p_sub_code; /* dynamic array to store sub code */
    uint8_t *p_inst_id;  /* dynamic array to store instance id */
    uint8_t pending_idx;
    uint8_t next_idx;
}tBTM_BLE_MULTI_ADV_OPQ;

typedef struct
{
    uint8_t                     inst_id;
    bool                        in_use;
    uint8_t                     adv_evt;
    BD_ADDR                     rpa;
    alarm_t                     *adv_raddr_timer;
    tBTM_BLE_MULTI_ADV_CBACK    *p_cback;
    uint8_t                     index;
}tBTM_BLE_MULTI_ADV_INST;

typedef struct
{
    uint8_t inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
    int front;
    int rear;
}tBTM_BLE_MULTI_ADV_INST_IDX_Q;

typedef struct
{
    tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
    tBTM_BLE_MULTI_ADV_OPQ  op_q;
}tBTM_BLE_MULTI_ADV_CB;

/************************************************************************************
**  Constants & Macros
************************************************************************************/
@@ -184,6 +216,16 @@ void btm_ble_multi_adv_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
    return;
}

void btm_ble_multi_adv_configure_rpa(tBTM_BLE_MULTI_ADV_INST *p_inst);

void btm_ble_adv_raddr_timer_timeout(void *data)
{
    if (BTM_BleLocalPrivacyEnabled() &&
        (BTM_BleMaxMultiAdvInstanceCount() > 0)) {
        btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST *)data);
    }
}

/*******************************************************************************
**
** Function         btm_ble_enable_multi_adv
@@ -262,7 +304,7 @@ void btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
    UINT8_TO_STREAM  (pp, p_params->adv_type);

#if (BLE_PRIVACY_SPT == TRUE)
    if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE)
    if (BTM_BleLocalPrivacyEnabled())
    {
        UINT8_TO_STREAM  (pp, BLE_ADDR_RANDOM);
        BDADDR_TO_STREAM (pp, p_inst->rpa);
@@ -305,7 +347,7 @@ void btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
    p_inst->adv_evt = p_params->adv_type;

#if (BLE_PRIVACY_SPT == TRUE)
    if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
    if (BTM_BleLocalPrivacyEnabled()) {
        alarm_set_on_queue(p_inst->adv_raddr_timer,
                           BTM_BLE_PRIVATE_ADDR_INT_MS,
                           btm_ble_adv_raddr_timer_timeout, p_inst,
@@ -747,7 +789,7 @@ void btm_ble_multi_adv_vse_cback(uint8_t len, uint8_t *p)
        if ((idx = btm_handle_to_acl_index(conn_handle)) != MAX_L2CAP_LINKS)
        {
#if (BLE_PRIVACY_SPT == TRUE)
            if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE &&
            if (BTM_BleLocalPrivacyEnabled() &&
                adv_inst <= BTM_BLE_MULTI_ADV_MAX && adv_inst !=  BTM_BLE_MULTI_ADV_DEFAULT_STD)
            {
                memcpy(btm_cb.acl_db[idx].conn_addr, btm_multi_adv_cb.p_adv_inst[adv_inst - 1].rpa,
+0 −32
Original line number Diff line number Diff line
@@ -501,41 +501,9 @@ typedef struct
    tBTM_BLE_ADV_TX_POWER tx_power;
}tBTM_BLE_ADV_PARAMS;

typedef struct
{
    uint8_t *p_sub_code; /* dynamic array to store sub code */
    uint8_t *p_inst_id;  /* dynamic array to store instance id */
    uint8_t pending_idx;
    uint8_t next_idx;
}tBTM_BLE_MULTI_ADV_OPQ;

typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, uint8_t inst_id,
                tBTM_STATUS status);

typedef struct
{
    uint8_t                     inst_id;
    bool                        in_use;
    uint8_t                     adv_evt;
    BD_ADDR                     rpa;
    alarm_t                     *adv_raddr_timer;
    tBTM_BLE_MULTI_ADV_CBACK    *p_cback;
    uint8_t                     index;
}tBTM_BLE_MULTI_ADV_INST;

typedef struct
{
    uint8_t inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
    int front;
    int rear;
}tBTM_BLE_MULTI_ADV_INST_IDX_Q;

typedef struct
{
    tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
    tBTM_BLE_MULTI_ADV_OPQ  op_q;
}tBTM_BLE_MULTI_ADV_CB;

typedef uint8_t tGATT_IF;

typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);