Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BIGInfo reports to controller and host #1507

Merged
merged 2 commits into from May 31, 2023

Conversation

m-gorecki
Copy link
Contributor

No description provided.

sm->flags |= BLE_LE_SYNC_SM_FLAG_BIGINFO;
} else {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just pass pointer and length to function, no need to check for encryption here

if ((sm->flags & BLE_LE_SYNC_SM_FLAG_BIGINFO) &&
!(sm->flags & BLE_LL_SYNC_SM_FLAG_HCI_NO_DATA_SENT)) {
ble_ll_sync_send_biginfo_adv_rpt(sm);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just send biginfo report if it's present in current PDU, no need to use additional flags


hci_ev = ble_transport_alloc_evt(1);
if (!hci_ev) {
assert(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to assert here, we'll just skip that event


#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_BIGINFO_REPORTS)
struct ble_ll_acad_biginfo biginfo;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to keep this huge structure in sm all the time. all you need is likely to check if biginfo is present in acad, store the offset and then parse it directly to hci event.

for now I think it will be enough to return that offset from ble_ll_sync_check_acad and use it in ble_ll_sync_rx_pkt_in to check whether to send biginfo report

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to keep offset in sm, ble_ll_sync_check_acad is called from ble_ll_sync_rx_pkt_in so it can just return pointer to biginfo and biginfo length

uint16_t max_sdu;

/** Advertising PHY */
uint8_t phy;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is big phy, not advertising phy

uint16_t max_pdu;

/** Service Data Unit Interval */
uint8_t sdu_interval[3];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint32_t will be easier to handle by app
also move below max_sdu so we don't waste space on alignment unnecessarily

uint8_t framing;

/** Encryption */
uint8_t encryption;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use bitfield for both

if (version >= BLE_HCI_VER_BCS_5_2) {
/**
* Enable the following LE events:
* 0x0000000200000000 LE Periodic Advertising Sync Transfer Received event
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the proper event (at least according to description)

@@ -128,6 +131,9 @@ static ble_hs_hci_evt_le_fn * const ble_hs_hci_evt_le_dispatch[] = {
[BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED] = ble_hs_hci_evt_le_adv_set_terminated,
[BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD] = ble_hs_hci_evt_le_scan_req_rcvd,
[BLE_HCI_LE_SUBEV_PERIODIC_ADV_SYNC_TRANSFER] = ble_hs_hci_evt_le_periodic_adv_sync_transfer,
#if MYNEWT_VAL(BLE_BIGINFO_REPORTS)
[BLE_HCI_LE_SUBEV_BIGINFO_ADV_REPORT] = ble_hs_hci_evt_le_biginfo_adv_rpt,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...adv_report

}
ble_hs_unlock();

if (!psync || !cb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not make sense to return if !cb since the same condition is checked below

#define BLE_LL_SYNC_SM_FLAG_NEW_CHANMAP 0x0200
#define BLE_LL_SYNC_SM_FLAG_CHAIN 0x0400

#define BLE_LL_SYNC_ITVL_USECS 1250
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not reformat code unnecesarilly

@@ -661,6 +669,72 @@ ble_ll_sync_send_truncated_per_adv_rpt(struct ble_ll_sync_sm *sm, uint8_t *evbuf
ble_ll_hci_event_send(hci_ev);
}

#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_BIGINFO_REPORTS)
static void
ble_ll_sync_parse_biginfo_adv_data_to_ev(struct ble_hci_ev_le_subev_biginfo_adv_report *ev, const uint8_t *acad, uint8_t biginfo_acad_offset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ble_ll_sync_parse_biginfo_to_ev

also parameters should be biginfo pointer and length, it does not make sense to pass acad and offset and calculate biginfo pointer over and over again

event.biginfo_report.pto = ev->pto;
event.biginfo_report.irc = ev->irc;
event.biginfo_report.max_pdu = ev->max_pdu;
event.biginfo_report.sdu_interval = get_le32(&ev->sdu_interval[0]) & 0x00FFFFFF;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_le24

uint8_t framing;
uint8_t giv[8];
uint8_t gskd[16];
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used anywhere


#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_BIGINFO_REPORTS)
struct ble_ll_acad_biginfo biginfo;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to keep offset in sm, ble_ll_sync_check_acad is called from ble_ll_sync_rx_pkt_in so it can just return pointer to biginfo and biginfo length

}

static void
ble_ll_sync_send_biginfo_adv_rpt(struct ble_ll_sync_sm *sm, const uint8_t *acad)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

biginfo and biginfo_len instead of acad

@@ -323,6 +323,12 @@ syscfg.defs:
Advertising Sync Transfer Feature.
value: MYNEWT_VAL(BLE_PERIODIC_ADV_SYNC_TRANSFER)

BLE_LL_CFG_FEAT_LL_BIGINFO_REPORTS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLE_LL_PERIODIC_ADV_SYNC_BIGINFO_REPORTS

@m-gorecki m-gorecki force-pushed the biginfo branch 2 times, most recently from ac0cecd to ae70df0 Compare May 31, 2023 07:10
This allows to receive BIGInfo reports in periodic advertisement
sync callback function
@andrzej-kaczmarek andrzej-kaczmarek merged commit 8d6cc49 into apache:master May 31, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants