mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 01:21:28 +00:00
example/le_streamer: print connection interval and connection latency on connect
This commit is contained in:
parent
e67b545f69
commit
8e46c84798
@ -166,6 +166,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
UNUSED(size);
|
||||
|
||||
int mtu;
|
||||
uint16_t conn_interval;
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
@ -177,6 +178,10 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
|
||||
test_data_len = ATT_DEFAULT_MTU - 3;
|
||||
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)); break;
|
||||
// min con interval 20 ms
|
||||
// gap_request_connection_parameter_update(connection_handle, 0x10, 0x18, 0, 0x0048);
|
||||
// printf("Connected, requesting conn param update for handle 0x%04x\n", connection_handle);
|
||||
|
@ -185,6 +185,7 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
|
||||
uint16_t conn_interval;
|
||||
uint8_t event = hci_event_packet_get_type(packet);
|
||||
switch (event) {
|
||||
case BTSTACK_EVENT_STATE:
|
||||
@ -219,6 +220,10 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
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)); break;
|
||||
// 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");
|
||||
|
@ -194,7 +194,8 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
|
||||
uint16_t conn_interval;
|
||||
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
@ -226,7 +227,10 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
|
||||
le_test_data_len = ATT_DEFAULT_MTU - 3;
|
||||
le_connection_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);
|
||||
break;
|
||||
// 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)); break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user