Hi friends!
I have ARM controller with CC2564 chip, connected by UART.
I'm trying to realize "battery query clinet". I want to receive information about the charge level from the headphones. As example I use file "gatt_battery_query.c" (stack v 1.5.3).
But my exchage is stopped after received message "SM_EVENT_IDENTITY_RESOLVING_STARTED". Could you help me?
Sound transmission (hfp profile) works good.
Thanks.
My init code for battery query:
btstack_memory_init();
// it require to call first!!!
btstack_run_loop_init(btstack_run_loop_freertos_get_instance());
// init HCI btstack_uart_block_t
const btstack_uart_block_t *uart_driver =
btstack_uart_block_freertos_instance();
const hci_transport_t *transport = hci_transport_h4_instance(uart_driver);
hci_init(transport, (void *)&config);
hci_set_chipset(btstack_chipset_cc256x_instance());
hci_set_link_key_db(btstack_link_key_db_memory_instance());
// inform about BTstack state
hci_event_callback_registration.callback = &packet_handler_btTask;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();
// Battery
att_server_init(profile_data, NULL, NULL);
// GATT Client setup
gatt_client_init();
// Device Information Service Client setup
battery_service_client_init();
sm_init();
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
gap_set_local_name(bt_local_name);
gap_discoverable_control(1);
gap_set_class_of_device(0x200408);
gap_set_scan_parameters(0, 0x0030, 0x0030);
hci_power_control(HCI_POWER_ON);
LOGOUT("btstack executing run loop...");
btstack_run_loop_execute();
My logs
BT_TASK: Texas Instruments - CC256x compatible chipset.
BT_TASK: eHCILL disabled.
BT Info: local name:
BT_TASK: Local name:
BT Info: Init script done
BT Info: Command 0x00 supported 2/5
BT Info: Command 0x01 supported 10/4
BT Info: Command 0x02 supported 14/7
BT Info: Command 0x03 supported 18/3
BT Info: Command 0x04 supported 20/4
BT Info: Command 0x06 supported 24/6
BT Info: Local supported commands summary 0000005f
BT Info: controller supports ECDH operation: 0
BT Info: Local Address, Status: 0x00: Addr: A0:E6:F8:61:63:F4
BT Info: hci_read_buffer_size: ACL size module 1021 -> used 1021, count 4 / SCO size 180, count 4
BT Info: ACL Packet types ff1e
BT Info: SCO Packet types 03ff - eSCO 1
BT Info: BR/EDR support 1, LE support 1
BT Info: hci_le_read_buffer_size: acl size 27, acl count 15
BT Info: hci_le_read_white_list_size: size 25
BT Info: hci_init_done -> HCI_STATE_WORKING
BT Info: BTSTACK_EVENT_STATE 2
BT_TASK: BTstack up and running at A0:E6:F8:61:63:F4
BT Info: HCI Working!
BT Err: Persistent IR not set with sm_set_ir. Use of private addresses will cause pairing issues
BT Err: Persistent ER not set with sm_set_er. Legacy Pairing LTK is not secure
BT Err: Please configure btstack_tlv to let BTstack setup ER and IR keys
BT Info: hci_le_set_own_address_type: old 0, new 0
BT Info: DKG_CALC_IRK started
BT Info: irk C7CF41E75979A53FA2FC7B3160EEEAE6
BT Info: DKG_CALC_DHK started
BT Info: dhk B54FC6732A320AA2AA8FB959921729C7
BT_TASK: Start scanning!
BT_TASK: GAP_EVENT_ADVERTISING_REPORT
BT_TASK: adv. event: evt-type 0, addr-type 0, addr 38:5C:76:3E:43:2A, rssi 176, length adv 3, data:
BT Info: gap_connect: no connection exists yet, creating context
BT Info: create_connection_for_addr 38:5C:76:3E:43:2A, type 0
BT Info: gap_connect: send create connection next
BT Info: sending hci_le_create_connection
BT Info: LE Connection_complete (status=0) type 0, 38:5C:76:3E:43:2A
BT Info: New connection: handle 1025, 38:5C:76:3E:43:2A
BT Info: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1
BT_TASK: HCI_EVENT_META_GAP
BT Info: battery_service_run_for_client, state 1
BT Info: GATT client timeout start, handle 0x401
BT_TASK: Battery service connected. Status 0
BT Info: SM_EVENT_IDENTITY_RESOLVING_STARTED
My config:
#define HAVE_EMBEDDED_TIME_MS
#define HAVE_FREERTOS_TASK_NOTIFICATIONS
// BTstack features that can be enabled
#define ENABLE_BLE
#define ENABLE_CLASSIC
#define ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
#define ENABLE_LE_CENTRAL
#define ENABLE_LE_PERIPHERAL
#define ENABLE_LE_SIGNED_WRITE
#define ENABLE_SDP_EXTRA_QUERIES
#define ENABLE_SDP_DES_DUMP
#define ENABLE_SDP_EXTRA_QUERIES
#define ENABLE_SOFTWARE_AES128
#define ENABLE_HFP_AT_MESSAGES
// BTstack configuration. buffers, sizes, ...
#define HCI_ACL_PAYLOAD_SIZE (1024 + 4) //Max official att size + l2cap header size
#define HCI_INCOMING_PRE_BUFFER_SIZE 16
#define MAX_NR_LE_DEVICE_DB_ENTRIES 4
#define MAX_NR_GATT_CLIENTS 3
#define MAX_NR_HCI_CONNECTIONS 4 // for two channels in HFP profile: servise channel and SCO audio channel
#define MAX_NR_L2CAP_SERVICES 4
#define MAX_NR_L2CAP_CHANNELS 4
#define MAX_NR_HFP_CONNECTIONS 2
#define MAX_NR_RFCOMM_MULTIPLEXERS 2
#define MAX_NR_RFCOMM_SERVICES 2
#define MAX_NR_RFCOMM_CHANNELS 2
#define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 10
#define MAX_NR_BNEP_SERVICES 2
#define MAX_NR_BNEP_CHANNELS 2
#define MAX_NR_WHITELIST_ENTRIES 2
#define MAX_NR_SM_LOOKUP_ENTRIES 3
#define MAX_NR_SERVICE_RECORD_ITEMS 2 // for SDP records SPP and HFP
#define MAX_NR_BATTERY_SERVICE_CLIENTS 5
#define MAX_ATT_DB_SIZE 350
// LE Device DB using TLV
#define NVM_NUM_LINK_KEYS 16
#define NVM_NUM_DEVICE_DB_ENTRIES 16