mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 21:41:13 +00:00
example: gatt_streamer_server and le_streamer_client report DLE and PHY changes
This commit is contained in:
parent
6bbe12ba1f
commit
f4fc15d4ec
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- HCI_ACL_CHUNK_SIZE_ALIGNMENT allows to keep HCI transport writes aligned
|
||||
- HFP: provide SCO packet types and rx/tx packet lengths in HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
|
||||
- Port for Renesas RA6M4 with DA14531
|
||||
- example: gatt_streamer_server and le_streamer_client report DLE and PHY changes
|
||||
|
||||
## Fixed
|
||||
- btstack_stdin_embedded: use timer to poll RTT input, fix for tickless RTOS
|
||||
|
@ -240,10 +240,13 @@ static void hci_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
UNUSED(channel);
|
||||
UNUSED(size);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
|
||||
uint16_t conn_interval;
|
||||
hci_con_handle_t con_handle;
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
static const char * const phy_names[] = {
|
||||
"1 M", "2 M", "Codec"
|
||||
};
|
||||
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
case BTSTACK_EVENT_STATE:
|
||||
@ -276,6 +279,16 @@ static void hci_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
printf("- LE Connection 0x%04x: connection update - connection interval %u.%02u ms, latency %u\n", con_handle, conn_interval * 125 / 100,
|
||||
25 * (conn_interval & 3), hci_subevent_le_connection_update_complete_get_conn_latency(packet));
|
||||
break;
|
||||
case HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE:
|
||||
con_handle = hci_subevent_le_data_length_change_get_connection_handle(packet);
|
||||
printf("- LE Connection 0x%04x: data length change - max %u bytes per packet\n", con_handle,
|
||||
hci_subevent_le_data_length_change_get_max_tx_octets(packet));
|
||||
break;
|
||||
case HCI_SUBEVENT_LE_PHY_UPDATE_COMPLETE:
|
||||
con_handle = hci_subevent_le_phy_update_complete_get_connection_handle(packet);
|
||||
printf("- LE Connection 0x%04x: PHY update - using LE %s PHY now\n", con_handle,
|
||||
phy_names[hci_subevent_le_phy_update_complete_get_tx_phy(packet)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -351,10 +351,15 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
UNUSED(size);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
|
||||
|
||||
static const char * const phy_names[] = {
|
||||
"1 M", "2 M", "Codec"
|
||||
};
|
||||
|
||||
uint16_t conn_interval;
|
||||
uint8_t event = hci_event_packet_get_type(packet);
|
||||
switch (event) {
|
||||
hci_con_handle_t con_handle;
|
||||
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// BTstack activated, get started
|
||||
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING) {
|
||||
@ -378,18 +383,33 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
break;
|
||||
case HCI_EVENT_LE_META:
|
||||
// wait for connection complete
|
||||
if (hci_event_le_meta_get_subevent_code(packet) != HCI_SUBEVENT_LE_CONNECTION_COMPLETE) break;
|
||||
if (state != TC_W4_CONNECT) return;
|
||||
connection_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);
|
||||
// print connection parameters (without using float operations)
|
||||
conn_interval = hci_subevent_le_connection_complete_get_conn_interval(packet);
|
||||
printf("Connection Interval: %u.%02u ms\n", conn_interval * 125 / 100, 25 * (conn_interval & 3));
|
||||
printf("Connection Latency: %u\n", hci_subevent_le_connection_complete_get_conn_latency(packet));
|
||||
// initialize gatt client context with handle, and add it to the list of active clients
|
||||
// query primary services
|
||||
printf("Search for LE Streamer service.\n");
|
||||
state = TC_W4_SERVICE_RESULT;
|
||||
gatt_client_discover_primary_services_by_uuid128(handle_gatt_client_event, connection_handle, le_streamer_service_uuid);
|
||||
switch (hci_event_le_meta_get_subevent_code(packet)){
|
||||
case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
|
||||
if (state != TC_W4_CONNECT) return;
|
||||
connection_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);
|
||||
// print connection parameters (without using float operations)
|
||||
conn_interval = hci_subevent_le_connection_complete_get_conn_interval(packet);
|
||||
printf("Connection Interval: %u.%02u ms\n", conn_interval * 125 / 100, 25 * (conn_interval & 3));
|
||||
printf("Connection Latency: %u\n", hci_subevent_le_connection_complete_get_conn_latency(packet));
|
||||
// initialize gatt client context with handle, and add it to the list of active clients
|
||||
// query primary services
|
||||
printf("Search for LE Streamer service.\n");
|
||||
state = TC_W4_SERVICE_RESULT;
|
||||
gatt_client_discover_primary_services_by_uuid128(handle_gatt_client_event, connection_handle, le_streamer_service_uuid);
|
||||
break;
|
||||
case HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE:
|
||||
con_handle = hci_subevent_le_data_length_change_get_connection_handle(packet);
|
||||
printf("- LE Connection 0x%04x: data length change - max %u bytes per packet\n", con_handle,
|
||||
hci_subevent_le_data_length_change_get_max_tx_octets(packet));
|
||||
break;
|
||||
case HCI_SUBEVENT_LE_PHY_UPDATE_COMPLETE:
|
||||
con_handle = hci_subevent_le_phy_update_complete_get_connection_handle(packet);
|
||||
printf("- LE Connection 0x%04x: PHY update - using LE %s PHY now\n", con_handle,
|
||||
phy_names[hci_subevent_le_phy_update_complete_get_tx_phy(packet)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
// unregister listener
|
||||
|
Loading…
x
Reference in New Issue
Block a user