posix: use TLV with btstack_tlv_posix

This commit is contained in:
Matthias Ringwald 2018-07-29 11:06:23 +02:00
parent d3849e4c96
commit 7daa8bd9ce
8 changed files with 101 additions and 3 deletions

View File

@ -19,6 +19,8 @@ include ${BTSTACK_ROOT}/example/Makefile.inc
# firmware
include ${BTSTACK_ROOT}/chipset/atwilc3000/Makefile.inc
all: wilc3000_ble_firmware.h
CFLAGS += -g -Wall -Werror \
-I$(BTSTACK_ROOT)/platform/posix \
-I$(BTSTACK_ROOT)/chipset/atwilc3000 \

View File

@ -60,6 +60,7 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_atwilc3000.h"
// #include "wilc3000_bt_firmware.h"
@ -70,6 +71,12 @@ static const char ** main_argv;
static const btstack_uart_block_t * uart_driver;
static btstack_uart_config_t uart_config;
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
int btstack_main(int argc, const char * argv[]);
static hci_transport_config_uart_t transport_config = {
@ -83,11 +90,19 @@ static hci_transport_config_uart_t transport_config = {
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t addr;
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
printf("BTstack up and running.\n");
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
default:
break;

View File

@ -60,6 +60,7 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_da14581.h"
#include "hci_581_active_uart.h"
@ -69,6 +70,12 @@ static const char ** main_argv;
static const btstack_uart_block_t * uart_driver;
static btstack_uart_config_t uart_config;
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
int btstack_main(int argc, const char * argv[]);
static hci_transport_config_uart_t transport_config = {
@ -82,11 +89,19 @@ static hci_transport_config_uart_t transport_config = {
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t addr;
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
printf("BTstack up and running.\n");
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
default:
break;

View File

@ -60,6 +60,7 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_da14581.h"
#include "hci_581_active_uart.h"
@ -69,6 +70,12 @@ static const char ** main_argv;
static const btstack_uart_block_t * uart_driver;
static btstack_uart_config_t uart_config;
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
int btstack_main(int argc, const char * argv[]);
static hci_transport_config_uart_t transport_config = {
@ -82,17 +89,26 @@ static hci_transport_config_uart_t transport_config = {
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t addr;
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
printf("BTstack up and running.\n");
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
default:
break;
}
}
static void sigint_handler(int param){
UNUSED(param);

View File

@ -62,9 +62,16 @@
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_chipset_zephyr.h"
#include "btstack_tlv_posix.h"
int btstack_main(int argc, const char * argv[]);
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
static hci_transport_config_uart_t config = {
HCI_TRANSPORT_CONFIG_UART,
1000000,
@ -85,6 +92,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
printf("BTstack up and running as %s\n", bd_addr_to_str(static_address));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
case HCI_EVENT_COMMAND_COMPLETE:
if (memcmp(packet, read_static_address_command_complete_prefix, sizeof(read_static_address_command_complete_prefix)) == 0){

View File

@ -61,6 +61,7 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_bcm.h"
#include "btstack_chipset_csr.h"
@ -71,6 +72,12 @@
int is_bcm;
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
int btstack_main(int argc, const char * argv[]);
static void local_version_information_handler(uint8_t * packet);
@ -92,6 +99,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
case HCI_EVENT_COMMAND_COMPLETE:
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_name)){

View File

@ -61,12 +61,18 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_bcm.h"
#include "btstack_chipset_bcm_download_firmware.h"
int btstack_main(int argc, const char * argv[]);
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
static hci_transport_config_uart_t transport_config = {
HCI_TRANSPORT_CONFIG_UART,
@ -112,6 +118,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
default:
break;

View File

@ -61,6 +61,7 @@
#include "hci.h"
#include "hci_dump.h"
#include "btstack_stdin.h"
#include "btstack_tlv_posix.h"
#include "btstack_chipset_csr.h"
#include "btstack_chipset_cc256x.h"
@ -70,6 +71,11 @@
int btstack_main(int argc, const char * argv[]);
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
#define TLV_DB_PATH_POSTFIX ".tlv"
static char tlv_db_path[100];
static const btstack_tlv_t * tlv_impl;
static btstack_tlv_posix_t tlv_context;
static hci_transport_config_uart_t config = {
HCI_TRANSPORT_CONFIG_UART,
@ -158,6 +164,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
gap_local_bd_addr(addr);
printf("BTstack up and running at %s\n", bd_addr_to_str(addr));
// setup TLV
strcpy(tlv_db_path, TLV_DB_PATH_PREFIX);
strcat(tlv_db_path, bd_addr_to_str(addr));
strcat(tlv_db_path, TLV_DB_PATH_POSTFIX);
tlv_impl = btstack_tlv_posix_init_instance(&tlv_context, tlv_db_path);
btstack_tlv_set_instance(tlv_impl, &tlv_context);
break;
case HCI_EVENT_COMMAND_COMPLETE:
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_name)){