Skip to content

Commit 77695ef

Browse files
committed
pbio/drv/bluetooth_btstack: Add hook for packet handler.
The POSIX variant needs to handle specific packets that are not relevant to the other platforms.
1 parent 709b9ee commit 77695ef

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

lib/pbio/drv/bluetooth/bluetooth_btstack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ static void parse_hci_local_version_information(pbdrv_bluetooth_btstack_local_ve
245245
// currently, this function just handles the Powered Up handset control.
246246
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
247247

248+
// Platform-specific platform handler has priority.
249+
pbdrv_bluetooth_btstack_platform_packet_handler(packet_type, channel, packet, size);
250+
248251
#if PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
249252
pbdrv_bluetooth_peripheral_t *peri = &peripheral_singleton;
250253
#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE

lib/pbio/drv/bluetooth/bluetooth_btstack.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ pbio_error_t pbdrv_bluetooth_btstack_platform_init(void);
2727
*/
2828
void pbdrv_bluetooth_btstack_platform_poll(void);
2929

30+
/**
31+
* Optional platform packet handler, called on HCI packets before common handler.
32+
*
33+
* @param [in] packet_type The HCI packet type.
34+
* @param [in] channel The HCI channel.
35+
* @param [in] packet Pointer to the raw packet data.
36+
* @param [in] size Size of the packet data.
37+
*/
38+
void pbdrv_bluetooth_btstack_platform_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
39+
3040
/** Chipset info */
3141
typedef struct {
3242
/** Version */

lib/pbio/drv/bluetooth/bluetooth_btstack_ev3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ pbio_error_t pbdrv_bluetooth_btstack_platform_init(void) {
7373
void pbdrv_bluetooth_btstack_platform_poll(void) {
7474
}
7575

76+
void pbdrv_bluetooth_btstack_platform_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
77+
}
78+
7679
void pbdrv_bluetooth_btstack_set_chipset(pbdrv_bluetooth_btstack_local_version_info_t *device_info) {
7780
const pbdrv_bluetooth_btstack_chipset_info_t *info = device_info->lmp_pal_subversion == cc2560_info.lmp_version ?
7881
&cc2560_info : &cc2560a_info;

lib/pbio/drv/bluetooth/bluetooth_btstack_stm32_hal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pbio_error_t pbdrv_bluetooth_btstack_platform_init(void) {
3333
void pbdrv_bluetooth_btstack_platform_poll(void) {
3434
}
3535

36+
void pbdrv_bluetooth_btstack_platform_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
37+
}
38+
3639
void pbdrv_bluetooth_btstack_set_chipset(pbdrv_bluetooth_btstack_local_version_info_t *device_info) {
3740

3841
const pbdrv_bluetooth_btstack_platform_data_t *pdata =

lib/pbio/test/drv/test_bluetooth_btstack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ pbio_error_t pbdrv_bluetooth_btstack_platform_init(void) {
780780
void pbdrv_bluetooth_btstack_platform_poll(void) {
781781
}
782782

783+
void pbdrv_bluetooth_btstack_platform_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
784+
}
785+
783786
static pbio_error_t test_btstack_run_loop_contiki_poll(pbio_os_state_t *state, void *context) {
784787
static btstack_data_source_t data_source;
785788
static uint32_t callback_count;

0 commit comments

Comments
 (0)