diff --git a/example/libusb/Makefile b/example/libusb/Makefile index 18408a663..8991fb7ad 100644 --- a/example/libusb/Makefile +++ b/example/libusb/Makefile @@ -110,8 +110,10 @@ classic_test: ${CORE_OBJ} ${COMMON_OBJ} classic_test.c # compile .ble description profile.h: profile.gatt python ${BTSTACK_ROOT}/ble/compile-gatt.py $< $@ +ancs_client.h: ancs_client.gatt + python ${BTSTACK_ROOT}/ble/compile-gatt.py $< $@ -ancs_client: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ${SM_REAL_OBJ} ancs_client.c profile.h +ancs_client: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ${SM_REAL_OBJ} ancs_client.c ancs_client.h ${CC} ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ${SM_REAL_OBJ} ancs_client.c ${CFLAGS} ${LDFLAGS} -o $@ ble_peripheral: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_REAL_OBJ} ble_peripheral.c profile.h diff --git a/example/libusb/ancs_client.c b/example/libusb/ancs_client.c index ef66d9365..8e65b379d 100644 --- a/example/libusb/ancs_client.c +++ b/example/libusb/ancs_client.c @@ -35,7 +35,6 @@ // // ANCS Client Demo // -// TODO: figure out why pairing/connecting from iOS Settings doesn't work // TODO: query full text upon notification using control point // TODO: present notifications in human readable form // @@ -68,6 +67,9 @@ #include "gatt_client.h" #include "sm.h" +// ancs client profile +#include "ancs_client.h" + #ifdef HAVE_UART_CSR #include "bt_control_csr.h" static hci_uart_config_t hci_uart_config_csr8811 = { @@ -103,9 +105,6 @@ static todo_t todos = 0; static uint16_t handle; -// test profile -#include "profile.h" - typedef enum { TC_IDLE, TC_W4_ENCRYPTED_CONNECTION, @@ -117,7 +116,6 @@ typedef enum { TC_W4_DISCONNECT } tc_state_t; - static gatt_client_t ancs_client_context; static int ancs_service_found; static le_service_t ancs_service; @@ -125,10 +123,8 @@ static le_characteristic_t ancs_notification_source_characteristic; static le_characteristic_t ancs_control_point_characteristic; static le_characteristic_t ancs_data_source_characteristic; static int ancs_characteristcs; - static tc_state_t tc_state = TC_IDLE; - void handle_gatt_client_event(le_event_t * event){ le_characteristic_t characteristic; le_characteristic_value_event_t * value_event; @@ -293,9 +289,10 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t * case HCI_EVENT_ENCRYPTION_CHANGE: if (handle != READ_BT_16(packet, 3)) break; connection_encrypted = packet[5]; - log_info("Eencryption state change: %u", connection_encrypted); + log_info("Encryption state change: %u", connection_encrypted); if (!connection_encrypted) break; if (tc_state != TC_W4_ENCRYPTED_CONNECTION) break; + // let's start printf("\nANCS Client - CONNECTED, discover ANCS service\n"); tc_state = TC_W4_SERVICE_RESULT; diff --git a/example/libusb/ancs_client.gatt b/example/libusb/ancs_client.gatt new file mode 100644 index 000000000..1f323af59 --- /dev/null +++ b/example/libusb/ancs_client.gatt @@ -0,0 +1,10 @@ +PRIMARY_SERVICE, GAP_SERVICE +CHARACTERISTIC, GAP_DEVICE_NAME, READ, "ANCS Demo" +CHARACTERISTIC, GAP_APPEARANCE, READ | WRITE | DYNAMIC, +// GAP Peripheral Privacy Flag +CHARACTERISTIC, 2A02, READ | WRITE | DYNAMIC, 00 +PRIMARY_SERVICE, GATT_SERVICE +CHARACTERISTIC, GATT_SERVICE_CHANGED, READ, + + +