connect att_db_util to BTstack Arduino interface - not working yet

This commit is contained in:
Matthias Ringwald 2015-05-24 00:12:56 +02:00
parent 34498a4937
commit eb449bf72d
4 changed files with 11 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include "ad_parser.h"
#include "att.h"
#include "att_server.h"
#include "att_db_util.h"
#include "le_device_db.h"
#include "sm.h"
#include "debug.h"
@ -512,6 +513,8 @@ BTstackManager::BTstackManager(void){
memcpy(&adv_data[pos], name, strlen(name));
pos += strlen(name);
adv_data_len = pos;
att_db_util_init();
}
void BTstackManager::setBLEAdvertisementCallback(void (*callback)(BLEAdvertisement * bleAdvertisement)){
@ -655,7 +658,7 @@ void BTstackManager::setup(void){
sm_init();
att_server_init(NULL, NULL, NULL);
att_server_init(att_db_util_get_address(), NULL, NULL);
att_server_register_packet_handler(packet_handler);
gatt_client_init();
@ -695,12 +698,16 @@ void BTstackManager::setGATTCharacteristicRead(uint16_t (*)(uint16_t characteris
void BTstackManager::setGATTCharacteristicWrite(int (*)(uint16_t characteristic_id, uint8_t *buffer, uint16_t buffer_size)){
}
void BTstackManager::addGATTService(UUID * uuid){
att_db_util_add_service_uuid128((uint8_t*)uuid->getUuid());
}
void BTstackManager::addGATTCharacteristic(UUID * uuid, uint16_t flags, const char * text){
att_db_util_add_characteristic_uuid128((uint8_t*)uuid->getUuid(), flags, (uint8_t*)text, strlen(text));
}
void BTstackManager::addGATTCharacteristic(UUID * uuid, uint16_t flags, uint8_t * data, uint16_t data_len){
att_db_util_add_characteristic_uuid128((uint8_t*)uuid->getUuid(), flags, data, data_len);
}
void BTstackManager::addGATTCharacteristicDynamic(UUID * uuid, uint16_t flags, uint16_t characteristic_id){
att_db_util_add_characteristic_uuid128((uint8_t*)uuid->getUuid(), flags | ATT_PROPERTY_DYNAMIC, NULL, 0);
}
void BTstackManager::setAdvData(uint16_t size, const uint8_t * data){
memcpy(adv_data, data, size);

View File

@ -11,7 +11,7 @@ ARCHIVE=btstack-arduino-${VERSION}.zip
SRC_FILES =btstack_memory.c linked_list.c memory_pool.c run_loop.c run_loop_embedded.c
SRC_FILES +=hci_dump.c hci.c hci_cmds.c hci_transport_h4_dma.c sdp_util.c utils.c
BLE_FILES = ad_parser.c att.c att_server.c att_dispatch.c le_device_db_memory.c gatt_client.c
BLE_FILES = ad_parser.c att.c att_server.c att_dispatch.c att_db_util.c le_device_db_memory.c gatt_client.c
BLE_FILES += sm.c l2cap_le.c ancs_client_lib.h ancs_client_lib.c
PORT_FILES = btstack-config.h bsp_arduino_em9301.cpp BTstack.cpp BTstack.h

View File

@ -27,3 +27,4 @@
#define MAX_NO_DB_MEM_DEVICE_NAMES 0
#define MAX_NO_DB_MEM_SERVICES 0
#define MAX_NO_GATT_CLIENTS 1
#define MAX_ATT_DB_SIZE 200

View File

@ -31,8 +31,7 @@ void setup(void){
uint8_t * data = NULL;
uint16_t data_len = 0;
BTstack.addGATTService(new UUID("B8E06067-62AD-41BA-9231-206AE80AB550"));
BTstack.addGATTCharacteristic(new UUID("f897177b-aee8-4767-8ecc-cc694fd5fcee"), flags, "string");
BTstack.addGATTCharacteristic(new UUID("f897177b-aee8-4767-8ecc-cc694fd5fcee"), flags, data, data_len);
BTstack.addGATTCharacteristic(new UUID("f897177b-aee8-4767-8ecc-cc694fd5fcee"), flags, "This is a String!");
BTstack.addGATTCharacteristicDynamic(new UUID("f897177b-aee8-4767-8ecc-cc694fd5fcee"), flags, GATT_CHARACTERISTIC_TEMP_ID);
// ..