Skip to content

Commit d971d4e

Browse files
authored
Merge pull request #13060 from paul-szczepanek-arm/direct-advertising
BLE: fix direct advertising on Cordio
2 parents 12910ea + dd615f7 commit d971d4e

File tree

2 files changed

+323
-19
lines changed

2 files changed

+323
-19
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,59 @@ class Gap : public ::ble::pal::Gap<Gap<EH>, EH> {
414414
}
415415
};
416416

417+
/* Cordio requires the call to DmConnAccept to properly catch direct advertising timeout.
418+
* This call returns a connection ID and expect the peer address and the peer address type.
419+
* This PAL following HCI expectations, these information are not present when the higher
420+
* level calls the function to enable advertising.
421+
* This data structure caches these informations and use them in case of direct advertising.
422+
* Similarly, direct advertising timeout doesn't trigger an advertising timeout instead it
423+
* triggers a disconnection with the status 60. Information on running direct advertising
424+
* is stored here.
425+
*/
426+
struct direct_adv_cb_t {
427+
direct_adv_cb_t() :
428+
peer_address_type(advertising_peer_address_type_t::PUBLIC),
429+
state(free)
430+
{}
431+
432+
address_t peer_address;
433+
advertising_peer_address_type_t peer_address_type;
434+
advertising_handle_t advertising_handle;
435+
connection_handle_t connection_handle;
436+
bool low_duty_cycle;
437+
enum {
438+
free = 0,
439+
pending,
440+
running
441+
} state;
442+
};
443+
444+
/* Predicate expect a const reference to a direct_adv_cb_t
445+
* It must returns true if the criteria are met and false otherwise. */
446+
template<typename Predicate>
447+
direct_adv_cb_t* get_adv_cb(const Predicate& predicate);
448+
449+
direct_adv_cb_t* get_running_direct_adv_cb(advertising_handle_t adv_handle);
450+
451+
direct_adv_cb_t* get_running_conn_direct_adv_cb(connection_handle_t adv_handle);
452+
453+
direct_adv_cb_t* get_pending_direct_adv_cb(advertising_handle_t adv_handle);
454+
455+
direct_adv_cb_t* get_free_direct_adv_cb();
456+
457+
ble_error_t update_direct_advertising_parameters(
458+
advertising_handle_t advertising_handle,
459+
uint8_t advertising_type,
460+
address_t peer_address,
461+
advertising_peer_address_type_t peer_address_type
462+
);
463+
417464
private:
418465
address_t device_random_address;
419466
bool use_active_scanning;
420467
uint8_t extended_scan_type[3];
421468
phy_set_t scanning_phys;
469+
direct_adv_cb_t direct_adv_cb[DM_NUM_ADV_SETS];
422470
};
423471

424472
} // cordio

0 commit comments

Comments
 (0)