andrzej-kaczmarek commented on a change in pull request #930:
URL: https://github.com/apache/mynewt-nimble/pull/930#discussion_r591407738
##########
File path: nimble/controller/src/ble_ll_sync.c
##########
@@ -996,14 +1006,72 @@ ble_ll_sync_check_failed(struct ble_ll_sync_sm *sm)
ble_ll_sync_est_event_failed(BLE_ERR_CONN_ESTABLISHMENT);
}
+static bool
+ble_ll_sync_check_acad(struct ble_ll_sync_sm *sm,
+ const uint8_t *acad, uint8_t acad_len)
+{
+ struct ble_ll_acad_channel_map_update_ind *chmu;
+ uint8_t ad_len;
+ uint8_t ad_type;
+
+ /* assume no empty fields */
+ while (acad_len > 2) {
+ ad_len = acad[0];
+ ad_type = acad[1];
+
+ acad += 2;
+ acad_len -= 2;
+
+ if (ad_len == 0 || ad_len > acad_len) {
Review comment:
`acad_len` is now without `ad_len` and `ad_type`
`ad_len` is with `ad_type`
so `ad_len - 1` shall be no greater than `acad_len`, thus should be `ad_len
- 1 > acad_len` here
##########
File path: nimble/controller/src/ble_ll_sync.c
##########
@@ -996,14 +1006,72 @@ ble_ll_sync_check_failed(struct ble_ll_sync_sm *sm)
ble_ll_sync_est_event_failed(BLE_ERR_CONN_ESTABLISHMENT);
}
+static bool
+ble_ll_sync_check_acad(struct ble_ll_sync_sm *sm,
+ const uint8_t *acad, uint8_t acad_len)
+{
+ struct ble_ll_acad_channel_map_update_ind *chmu;
+ uint8_t ad_len;
+ uint8_t ad_type;
+
+ /* assume no empty fields */
+ while (acad_len > 2) {
+ ad_len = acad[0];
+ ad_type = acad[1];
+
+ acad += 2;
+ acad_len -= 2;
+
+ if (ad_len == 0 || ad_len > acad_len) {
+ return false;
+ }
+
+ switch (ad_type) {
+ case BLE_LL_ACAD_CHANNEL_MAP_UPDATE_IND:
+ chmu = (void *)acad;
+
+ if (ad_len != sizeof(*chmu) + 1) {
+ return false;
+ }
+
+ /* Channels Mask (37 bits)
+ * TODO should we check this?
+ */
+ sm->chanmap_new[0] = chmu->map[0];
+ sm->chanmap_new[1] = chmu->map[1];
+ sm->chanmap_new[2] = chmu->map[2];
+ sm->chanmap_new[3] = chmu->map[3];
+ sm->chanmap_new[4] = chmu->map[4] & 0x1f;
+ sm->chanmap_new_instant = le16toh(chmu->instant);
+ sm->flags |= BLE_LL_SYNC_SM_FLAG_NEW_CHANMAP;
+ break;
+ default:
+ break;
+ }
+
+ acad += ad_len;
+ acad_len -= ad_len;
Review comment:
`ad_len` includes `ad_type` which was already skipped before, should be
`ad_len - 1` here
##########
File path: nimble/controller/src/ble_ll_sync.c
##########
@@ -1131,6 +1206,18 @@ ble_ll_sync_next_event(struct ble_ll_sync_sm *sm,
uint32_t cur_ww_adjust)
/* Set event counter to the next event */
sm->event_cntr += 1 + skip;
+ /* update channel map if needed */
+ if (sm->flags & BLE_LL_SYNC_SM_FLAG_NEW_CHANMAP) {
+ if (((int16_t)(sm->event_cntr - sm->chanmap_new_instant)) >= 0) {
+ sm->chanmap[0] = sm->chanmap_new[0];
+ sm->chanmap[1] = sm->chanmap_new[1];
+ sm->chanmap[2] = sm->chanmap_new[2];
+ sm->chanmap[3] = sm->chanmap_new[3];
+ sm->chanmap[4] = sm->chanmap_new[4];
+ sm->flags &= ~BLE_LL_SYNC_SM_FLAG_NEW_CHANMAP;
Review comment:
need to recalculate `num_used_channels`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]