add event getters

This commit is contained in:
Milanka Ringwald 2016-04-01 11:34:37 +02:00
parent d15afed991
commit be4bef40bf
3 changed files with 16 additions and 2 deletions

View File

@ -31,7 +31,7 @@ All defines that originate from the Bluetooth Specification are now in *src/blue
## Packet Handlers
We streamlined the use of packet handlers and their types. Most callbacks are now of type *btstack_packet_handler_t* and receive a pointer to an HCI Event packet. Often a void * connection was the first argument - this has been removed.
To facilitate working with HCI Events and get rid of manually calculating offsets into packets, we're providing auto-generated getters for all fields of all elements in *src/hci_event.h*. All functions are defined as static inline, so they are not wasting any program memory if not used. If used, the memory footprint should be identical to accessing the field directly via offsets into the packet. Feel free to start using these getters as needed.
To facilitate working with HCI Events and get rid of manually calculating offsets into packets, we're providing auto-generated getters for all fields of all events in *src/hci_event.h*. All functions are defined as static inline, so they are not wasting any program memory if not used. If used, the memory footprint should be identical to accessing the field directly via offsets into the packet. Feel free to start using these getters as needed.
## Event Forwarding
In the past, events have been forwarded up the stack from layer to layer, with the undesired effect that an app that used both *att_server* and *security_manager* would get each HCI event twice. To fix this and other potential issues, this has been cleaned up by providing a way to register multiple listeners for HCI events. If you need to receive HCI or GAP events, you can now directly register your callback with *hci_add_event_handler*.

View File

@ -77,4 +77,4 @@ various protocol layers. The number of maximum
connections/channels/services can be configured. In addition, the
non-persistent database for remote device names and link keys needs
memory and can be be configured, too. These numbers determine the amount
of static memory allocation.
of static memory allocation.

View File

@ -316,6 +316,7 @@ Bluetooth specification. In particular, this covers:
This is provided by the various *btstack_chipset_t* implementation in the *chipset/* subfolders.
As an example, the *bstack_chipset_cc256x_instance* function returns a pointer to a chipset struct
suitable for the CC256x chipset.
<!-- -->
btstack_chipset_t * chipset = btstack_chipset_cc256x_instance();
@ -433,6 +434,19 @@ services for the HID Control and HID Interrupt PSMs using
*l2cap_register_service*. In this call, youll also specify
a packet handler to accept and receive keyboard data.
All events names have the form MODULE_EVENT_NAME now, e.g., *gap_event_advertising_report*.
To facilitate working with
events and get rid of manually calculating offsets into packets, BTstack provides
auto-generated getters for all fields of all events in *src/hci_event.h*. All
functions are defined as static inline, so they are not wasting any program memory
if not used. If used, the memory footprint should be identical to accessing the
field directly via offsets into the packet. For example, to access fields address_type
and address from the *gap_event_advertising_report* event use following getters:
<!-- -->
uint8_t address type = gap_event_advertising_report_get_address_type(event);
bd_addr_t address;
gap_event_advertising_report_get_address(event, &address);
## Bluetooth HCI Packet Logs {#sec:packetlogsHowTo}