use mimimal att db for ancs

This commit is contained in:
matthias.ringwald 2014-06-09 20:33:01 +00:00
parent f8f845275e
commit 5502b46021
3 changed files with 18 additions and 9 deletions

View File

@ -110,8 +110,10 @@ classic_test: ${CORE_OBJ} ${COMMON_OBJ} classic_test.c
# compile .ble description # compile .ble description
profile.h: profile.gatt profile.h: profile.gatt
python ${BTSTACK_ROOT}/ble/compile-gatt.py $< $@ 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 $@ ${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 ble_peripheral: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_REAL_OBJ} ble_peripheral.c profile.h

View File

@ -35,7 +35,6 @@
// //
// ANCS Client Demo // 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: query full text upon notification using control point
// TODO: present notifications in human readable form // TODO: present notifications in human readable form
// //
@ -68,6 +67,9 @@
#include "gatt_client.h" #include "gatt_client.h"
#include "sm.h" #include "sm.h"
// ancs client profile
#include "ancs_client.h"
#ifdef HAVE_UART_CSR #ifdef HAVE_UART_CSR
#include "bt_control_csr.h" #include "bt_control_csr.h"
static hci_uart_config_t hci_uart_config_csr8811 = { static hci_uart_config_t hci_uart_config_csr8811 = {
@ -103,9 +105,6 @@ static todo_t todos = 0;
static uint16_t handle; static uint16_t handle;
// test profile
#include "profile.h"
typedef enum { typedef enum {
TC_IDLE, TC_IDLE,
TC_W4_ENCRYPTED_CONNECTION, TC_W4_ENCRYPTED_CONNECTION,
@ -117,7 +116,6 @@ typedef enum {
TC_W4_DISCONNECT TC_W4_DISCONNECT
} tc_state_t; } tc_state_t;
static gatt_client_t ancs_client_context; static gatt_client_t ancs_client_context;
static int ancs_service_found; static int ancs_service_found;
static le_service_t ancs_service; 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_control_point_characteristic;
static le_characteristic_t ancs_data_source_characteristic; static le_characteristic_t ancs_data_source_characteristic;
static int ancs_characteristcs; static int ancs_characteristcs;
static tc_state_t tc_state = TC_IDLE; static tc_state_t tc_state = TC_IDLE;
void handle_gatt_client_event(le_event_t * event){ void handle_gatt_client_event(le_event_t * event){
le_characteristic_t characteristic; le_characteristic_t characteristic;
le_characteristic_value_event_t * value_event; 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: case HCI_EVENT_ENCRYPTION_CHANGE:
if (handle != READ_BT_16(packet, 3)) break; if (handle != READ_BT_16(packet, 3)) break;
connection_encrypted = packet[5]; 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 (!connection_encrypted) break;
if (tc_state != TC_W4_ENCRYPTED_CONNECTION) break; if (tc_state != TC_W4_ENCRYPTED_CONNECTION) break;
// let's start // let's start
printf("\nANCS Client - CONNECTED, discover ANCS service\n"); printf("\nANCS Client - CONNECTED, discover ANCS service\n");
tc_state = TC_W4_SERVICE_RESULT; tc_state = TC_W4_SERVICE_RESULT;

View File

@ -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,