mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 02:37:41 +00:00
posix-h4: reworked all ports for btstack_main_config
posix-h4: use btstack_main_config posix-h4: use btstack_main_config
This commit is contained in:
parent
b546af5496
commit
2bb8df9f92
@ -43,8 +43,6 @@
|
|||||||
//
|
//
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
#include <btstack_signal.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -60,10 +58,12 @@
|
|||||||
#include "btstack_chipset_bcm.h"
|
#include "btstack_chipset_bcm.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
#include "btstack_run_loop_posix.h"
|
#include "btstack_run_loop_posix.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
|
#include "btstack_signal.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
#include "btstack_uart.h"
|
#include "btstack_uart.h"
|
||||||
#include "classic/btstack_link_key_db_tlv.h"
|
#include "classic/btstack_link_key_db_tlv.h"
|
||||||
@ -81,16 +81,15 @@ static char tlv_db_path[100];
|
|||||||
static const btstack_tlv_t * tlv_impl;
|
static const btstack_tlv_t * tlv_impl;
|
||||||
static btstack_tlv_posix_t tlv_context;
|
static btstack_tlv_posix_t tlv_context;
|
||||||
static bool tlv_reset;
|
static bool tlv_reset;
|
||||||
static bd_addr_t custom_address;
|
static bd_addr_t custom_address = {0,0,0,0,0,0};
|
||||||
static bool custom_address_set;
|
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
921600,
|
.device_name = "/dev/ttyACM0",
|
||||||
921600, // main baudrate
|
.baudrate_init = 921600,
|
||||||
1, // flow control
|
.baudrate_main = 921600,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
BTSTACK_UART_PARITY_OFF, // parity
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
static btstack_uart_config_t uart_config;
|
static btstack_uart_config_t uart_config;
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ static void sigint_handler(void){
|
|||||||
// power down
|
// power down
|
||||||
hci_power_control(HCI_POWER_OFF);
|
hci_power_control(HCI_POWER_OFF);
|
||||||
hci_close();
|
hci_close();
|
||||||
log_info("Good bye, see you.\n");
|
log_info("Good bye, see you.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +182,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
btstack_tlv_set_instance(tlv_impl, &tlv_context);
|
btstack_tlv_set_instance(tlv_impl, &tlv_context);
|
||||||
#ifdef ENABLE_CLASSIC
|
#ifdef ENABLE_CLASSIC
|
||||||
hci_set_link_key_db(btstack_link_key_db_tlv_get_instance(tlv_impl, &tlv_context));
|
hci_set_link_key_db(btstack_link_key_db_tlv_get_instance(tlv_impl, &tlv_context));
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_BLE
|
#ifdef ENABLE_BLE
|
||||||
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
||||||
#endif
|
#endif
|
||||||
@ -211,98 +210,9 @@ static void enter_download_mode(const btstack_uart_t * the_uart_driver){
|
|||||||
printf("Firmware download started\n");
|
printf("Firmware download started\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char short_options[] = "+hu:l:rb:";
|
|
||||||
|
|
||||||
static struct option long_options[] = {
|
|
||||||
{"help", no_argument, NULL, 'h'},
|
|
||||||
{"logfile", required_argument, NULL, 'l'},
|
|
||||||
{"reset-tlv", no_argument, NULL, 'r'},
|
|
||||||
{"tty", required_argument, NULL, 'u'},
|
|
||||||
{"bd-addr", required_argument, NULL, 'b'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *help_options[] = {
|
|
||||||
"print (this) help.",
|
|
||||||
"set file to store debug output and HCI trace.",
|
|
||||||
"reset bonding information stored in TLV.",
|
|
||||||
"set path to Bluetooth Controller.",
|
|
||||||
"set Bluetooth address.",
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *option_arg_name[] = {
|
|
||||||
"",
|
|
||||||
"LOGFILE",
|
|
||||||
"",
|
|
||||||
"TTY",
|
|
||||||
"BD_ADDR",
|
|
||||||
};
|
|
||||||
|
|
||||||
static void usage(const char *name){
|
|
||||||
unsigned int i;
|
|
||||||
printf( "usage:\n\t%s [options]\n", name );
|
|
||||||
printf("valid options:\n");
|
|
||||||
for( i=0; long_options[i].name != 0; i++) {
|
|
||||||
printf("--%-10s| -%c %-10s\t\t%s\n", long_options[i].name, long_options[i].val, option_arg_name[i], help_options[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
const char * log_file_path = NULL;
|
btstack_main_config( argc, argv, &transport_config, custom_address, &tlv_reset );
|
||||||
|
|
||||||
// set default device path
|
|
||||||
transport_config.device_name = "/dev/tty.usbserial-FT1XBIL9"; // murata m.2 adapter
|
|
||||||
|
|
||||||
int oldopterr = opterr;
|
|
||||||
opterr = 0;
|
|
||||||
// parse command line parameters
|
|
||||||
while(true){
|
|
||||||
int c = getopt_long( argc, (char* const *)argv, short_options, long_options, NULL );
|
|
||||||
if (c < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (c == '?'){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (c) {
|
|
||||||
case 'u':
|
|
||||||
transport_config.device_name = optarg;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
log_file_path = optarg;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
tlv_reset = true;
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
sscanf_bd_addr(optarg, custom_address);
|
|
||||||
custom_address_set = true;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
default:
|
|
||||||
usage(argv[0]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// reset getopt parsing, so it works as intended from btstack_main
|
|
||||||
optind = 1;
|
|
||||||
opterr = oldopterr;
|
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
if (log_file_path == NULL){
|
|
||||||
log_file_path = "/tmp/hci_dump.pklg";
|
|
||||||
}
|
|
||||||
hci_dump_posix_fs_open(log_file_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", log_file_path);
|
|
||||||
|
|
||||||
printf("tty: %s\n", transport_config.device_name);
|
|
||||||
|
|
||||||
// get BCM chipset driver
|
// get BCM chipset driver
|
||||||
const btstack_chipset_t * chipset = btstack_chipset_bcm_instance();
|
const btstack_chipset_t * chipset = btstack_chipset_bcm_instance();
|
||||||
@ -323,7 +233,7 @@ int main(int argc, const char * argv[]){
|
|||||||
hci_init(transport, (void*) &transport_config);
|
hci_init(transport, (void*) &transport_config);
|
||||||
hci_set_chipset(btstack_chipset_bcm_instance());
|
hci_set_chipset(btstack_chipset_bcm_instance());
|
||||||
|
|
||||||
if (custom_address_set) {
|
if (!btstack_is_null_bd_addr(custom_address)) {
|
||||||
hci_set_bd_addr(custom_address);
|
hci_set_bd_addr(custom_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +256,6 @@ int main(int argc, const char * argv[]){
|
|||||||
btstack_main(argc, argv);
|
btstack_main(argc, argv);
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,9 @@ CORE += \
|
|||||||
hci_transport_h4.c \
|
hci_transport_h4.c \
|
||||||
le_device_db_tlv.c \
|
le_device_db_tlv.c \
|
||||||
main.c \
|
main.c \
|
||||||
wav_util.c \
|
wav_util.c \
|
||||||
btstack_stdin_posix.c \
|
btstack_stdin_posix.c \
|
||||||
|
btstack_main_config.c \
|
||||||
btstack_signal.c \
|
btstack_signal.c \
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
|
@ -54,9 +54,7 @@
|
|||||||
#include "ble/le_device_db_tlv.h"
|
#include "ble/le_device_db_tlv.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -89,11 +87,12 @@ static bool shutdown_triggered;
|
|||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
921600,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 921600,
|
||||||
1, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -124,7 +123,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -158,7 +157,7 @@ static void phase2(int status){
|
|||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &transport_config);
|
hci_init(transport, (void*) &transport_config);
|
||||||
hci_set_chipset(btstack_chipset_atwilc3000_instance());
|
hci_set_chipset(btstack_chipset_atwilc3000_instance());
|
||||||
|
|
||||||
// inform about BTstack state
|
// inform about BTstack state
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
@ -173,24 +172,13 @@ static void phase2(int status){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &transport_config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port and configure uart block driver
|
|
||||||
transport_config.device_name = "/dev/tty.usbserial-A96PXBJ7";
|
|
||||||
uart_driver = btstack_uart_posix_instance();
|
uart_driver = btstack_uart_posix_instance();
|
||||||
|
|
||||||
// extract UART config from transport config, but disable flow control and use default baudrate
|
// extract UART config from transport config, but disable flow control and use default baudrate
|
||||||
uart_config.baudrate = HCI_DEFAULT_BAUDRATE;
|
uart_config.baudrate = HCI_DEFAULT_BAUDRATE;
|
||||||
uart_config.flowcontrol = 0;
|
uart_config.flowcontrol = BTSTACK_UART_FLOWCONTROL_OFF;
|
||||||
uart_config.device_name = transport_config.device_name;
|
uart_config.device_name = transport_config.device_name;
|
||||||
uart_driver->init(&uart_config);
|
uart_driver->init(&uart_config);
|
||||||
|
|
||||||
@ -204,6 +192,6 @@ int main(int argc, const char * argv[]){
|
|||||||
btstack_chipset_atwilc3000_download_firmware_with_uart(uart_driver, transport_config.baudrate_init, transport_config.flowcontrol, (const uint8_t *) firmware_ble, sizeof(firmware_ble), &phase2);
|
btstack_chipset_atwilc3000_download_firmware_with_uart(uart_driver, transport_config.baudrate_init, transport_config.flowcontrol, (const uint8_t *) firmware_ble, sizeof(firmware_ble), &phase2);
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ CORE += \
|
|||||||
le_device_db_tlv.c \
|
le_device_db_tlv.c \
|
||||||
main.c \
|
main.c \
|
||||||
btstack_stdin_posix.c \
|
btstack_stdin_posix.c \
|
||||||
|
btstack_main_config.c \
|
||||||
btstack_signal.c \
|
btstack_signal.c \
|
||||||
hci_531_active_uart_460800.c \
|
hci_531_active_uart_460800.c \
|
||||||
|
|
||||||
|
@ -55,9 +55,7 @@
|
|||||||
#include "btstack_chipset_da145xx.h"
|
#include "btstack_chipset_da145xx.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -85,11 +83,12 @@ static bool shutdown_triggered;
|
|||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
460800,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 460800,
|
||||||
0, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_OFF,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -152,7 +151,7 @@ static void phase2(int status){
|
|||||||
// init HCI
|
// init HCI
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &transport_config);
|
hci_init(transport, (void*) &transport_config);
|
||||||
|
|
||||||
// inform about BTstack state
|
// inform about BTstack state
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
@ -167,19 +166,7 @@ static void phase2(int status){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &transport_config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port and configure uart block driver
|
|
||||||
transport_config.device_name = "/dev/tty.usbserial-143342200";
|
|
||||||
uart_driver = btstack_uart_posix_instance();
|
uart_driver = btstack_uart_posix_instance();
|
||||||
|
|
||||||
// extract UART config from transport config, but overide initial uart speed
|
// extract UART config from transport config, but overide initial uart speed
|
||||||
@ -198,6 +185,6 @@ int main(int argc, const char * argv[]){
|
|||||||
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,7 @@
|
|||||||
#include "btstack_chipset_da145xx.h"
|
#include "btstack_chipset_da145xx.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -87,11 +85,12 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
|||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
115200,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 115200,
|
||||||
1, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
@ -118,8 +117,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ static void phase2(int status){
|
|||||||
// init HCI
|
// init HCI
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &transport_config);
|
hci_init(transport, (void*) &transport_config);
|
||||||
|
|
||||||
// inform about BTstack state
|
// inform about BTstack state
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
@ -165,19 +165,7 @@ static void phase2(int status){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &transport_config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port and configure uart block driver
|
|
||||||
transport_config.device_name = "/dev/tty.usbmodem1442311";
|
|
||||||
uart_driver = btstack_uart_posix_instance();
|
uart_driver = btstack_uart_posix_instance();
|
||||||
|
|
||||||
// extract UART config from transport config, but overide initial uart speed
|
// extract UART config from transport config, but overide initial uart speed
|
||||||
@ -196,6 +184,6 @@ int main(int argc, const char * argv[]){
|
|||||||
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,7 @@
|
|||||||
#include "btstack_chipset_da145xx.h"
|
#include "btstack_chipset_da145xx.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -85,11 +83,12 @@ static bool shutdown_triggered;
|
|||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
115200,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 115200,
|
||||||
1, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -152,7 +151,7 @@ static void phase2(int status){
|
|||||||
// init HCI
|
// init HCI
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &transport_config);
|
hci_init(transport, (void*) &transport_config);
|
||||||
|
|
||||||
// inform about BTstack state
|
// inform about BTstack state
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
@ -167,19 +166,7 @@ static void phase2(int status){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &transport_config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port and configure uart block driver
|
|
||||||
transport_config.device_name = "/dev/tty.usbmodem1461";
|
|
||||||
uart_driver = btstack_uart_posix_instance();
|
uart_driver = btstack_uart_posix_instance();
|
||||||
|
|
||||||
// extract UART config from transport config, but overide initial uart speed
|
// extract UART config from transport config, but overide initial uart speed
|
||||||
@ -198,6 +185,6 @@ int main(int argc, const char * argv[]){
|
|||||||
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
btstack_chipset_da145xx_download_firmware_with_uart(uart_driver, da145xx_fw_data, da145xx_fw_size, &phase2);
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ include_directories(${BTSTACK_ROOT}/platform/lwip)
|
|||||||
include_directories(${BTSTACK_ROOT}/platform/lwip/port)
|
include_directories(${BTSTACK_ROOT}/platform/lwip/port)
|
||||||
include_directories(${BTSTACK_ROOT}/platform/posix)
|
include_directories(${BTSTACK_ROOT}/platform/posix)
|
||||||
|
|
||||||
file(GLOB SOURCES_SRC "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/*demo_util*.c")
|
file(GLOB SOURCES_SRC "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util*.c")
|
||||||
file(GLOB SOURCES_BLE "${BTSTACK_ROOT}/src/ble/*.c")
|
file(GLOB SOURCES_BLE "${BTSTACK_ROOT}/src/ble/*.c")
|
||||||
file(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c")
|
file(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c")
|
||||||
file(GLOB SOURCES_CLASSIC "${BTSTACK_ROOT}/src/classic/*.c")
|
file(GLOB SOURCES_CLASSIC "${BTSTACK_ROOT}/src/classic/*.c")
|
||||||
|
@ -57,8 +57,7 @@
|
|||||||
#include "btstack_audio.h"
|
#include "btstack_audio.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -90,11 +89,12 @@ int btstack_main(int argc, const char * argv[]);
|
|||||||
static void local_version_information_handler(uint8_t * packet);
|
static void local_version_information_handler(uint8_t * packet);
|
||||||
|
|
||||||
static hci_transport_config_uart_t transport_config = {
|
static hci_transport_config_uart_t transport_config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
115200,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 115200,
|
||||||
1, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -114,7 +114,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
btstack_tlv_set_instance(tlv_impl, &tlv_context);
|
btstack_tlv_set_instance(tlv_impl, &tlv_context);
|
||||||
#ifdef ENABLE_CLASSIC
|
#ifdef ENABLE_CLASSIC
|
||||||
hci_set_link_key_db(btstack_link_key_db_tlv_get_instance(tlv_impl, &tlv_context));
|
hci_set_link_key_db(btstack_link_key_db_tlv_get_instance(tlv_impl, &tlv_context));
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_BLE
|
#ifdef ENABLE_BLE
|
||||||
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
||||||
#endif
|
#endif
|
||||||
@ -128,7 +128,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -188,28 +188,7 @@ static void nxp_phase2(uint8_t status){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &transport_config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port
|
|
||||||
transport_config.device_name = "/dev/tty.usbserial-A506WORJ"; // DVK-ST60-2230C / 88W8997
|
|
||||||
// transport_config.device_name = "/dev/tty.usbserial-FT1XBGIM"; // murata m.2 adapter
|
|
||||||
|
|
||||||
// accept path from command line
|
|
||||||
if (argc >= 3 && strcmp(argv[1], "-u") == 0){
|
|
||||||
transport_config.device_name = argv[2];
|
|
||||||
argc -= 2;
|
|
||||||
memmove((void *) &argv[1], &argv[3], (argc-1) * sizeof(char *));
|
|
||||||
}
|
|
||||||
printf("H4 device: %s\n", transport_config.device_name);
|
|
||||||
|
|
||||||
uart_driver = btstack_uart_posix_instance();
|
uart_driver = btstack_uart_posix_instance();
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT})
|
|||||||
# get list of examples
|
# get list of examples
|
||||||
include(../../example/CMakeLists.txt)
|
include(../../example/CMakeLists.txt)
|
||||||
set (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
|
set (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
|
||||||
|
list(REMOVE_ITEM EXAMPLES "mesh_node_demo")
|
||||||
|
|
||||||
# create targets
|
# create targets
|
||||||
foreach(EXAMPLE ${EXAMPLES})
|
foreach(EXAMPLE ${EXAMPLES})
|
||||||
|
@ -50,15 +50,13 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack_config.h"
|
||||||
|
#include "btstack.h"
|
||||||
#include "ble/le_device_db_tlv.h"
|
#include "ble/le_device_db_tlv.h"
|
||||||
#include "bluetooth_company_id.h"
|
#include "bluetooth_company_id.h"
|
||||||
#include "btstack_chipset_zephyr.h"
|
#include "btstack_chipset_zephyr.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
@ -79,11 +77,12 @@ static btstack_tlv_posix_t tlv_context;
|
|||||||
static bool shutdown_triggered;
|
static bool shutdown_triggered;
|
||||||
|
|
||||||
static hci_transport_config_uart_t config = {
|
static hci_transport_config_uart_t config = {
|
||||||
HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
1000000,
|
.device_name = "/dev/ttyACM0",
|
||||||
0, // main baudrate
|
.baudrate_init = 1000000,
|
||||||
1, // flow control
|
.baudrate_main = 0,
|
||||||
NULL,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_ON,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -154,34 +153,13 @@ void hal_led_toggle(void){
|
|||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
btstack_main_config( argc, argv, &config, NULL, NULL );
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
const char * pklg_path = "/tmp/hci_dump.pklg";
|
|
||||||
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", pklg_path);
|
|
||||||
|
|
||||||
// pick serial port
|
|
||||||
config.device_name = "/dev/tty.usbmodem0006830491191"; // PCA10056 nRF52840
|
|
||||||
|
|
||||||
// accept path from command line
|
|
||||||
if (argc >= 3 && strcmp(argv[1], "-u") == 0){
|
|
||||||
config.device_name = argv[2];
|
|
||||||
argc -= 2;
|
|
||||||
memmove((void *) &argv[1], &argv[3], (argc-1) * sizeof(char *));
|
|
||||||
}
|
|
||||||
printf("H4 device: %s\n", config.device_name);
|
|
||||||
|
|
||||||
// init HCI
|
// init HCI
|
||||||
const btstack_uart_t * uart_driver = btstack_uart_posix_instance();
|
const btstack_uart_t * uart_driver = btstack_uart_posix_instance();
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &config);
|
hci_init(transport, (void*) &config);
|
||||||
hci_set_chipset(btstack_chipset_zephyr_instance());
|
hci_set_chipset(btstack_chipset_zephyr_instance());
|
||||||
|
|
||||||
// inform about BTstack state
|
// inform about BTstack state
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
@ -196,7 +174,7 @@ int main(int argc, const char * argv[]){
|
|||||||
sm_init();
|
sm_init();
|
||||||
|
|
||||||
// go
|
// go
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
|
|
||||||
#include "ble/le_device_db_tlv.h"
|
#include "ble/le_device_db_tlv.h"
|
||||||
#include "bluetooth_company_id.h"
|
#include "bluetooth_company_id.h"
|
||||||
#include "btstack_audio.h"
|
|
||||||
#include "btstack_chipset_bcm.h"
|
#include "btstack_chipset_bcm.h"
|
||||||
#include "btstack_chipset_cc256x.h"
|
#include "btstack_chipset_cc256x.h"
|
||||||
#include "btstack_chipset_csr.h"
|
#include "btstack_chipset_csr.h"
|
||||||
@ -65,25 +64,19 @@
|
|||||||
#include "btstack_chipset_zephyr.h"
|
#include "btstack_chipset_zephyr.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_event.h"
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_main_config.h"
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_run_loop_posix.h"
|
|
||||||
#include "btstack_signal.h"
|
#include "btstack_signal.h"
|
||||||
#include "btstack_stdin.h"
|
#include "btstack_stdin.h"
|
||||||
#include "btstack_tlv_posix.h"
|
#include "btstack_tlv_posix.h"
|
||||||
#include "btstack_uart.h"
|
#include "btstack_uart.h"
|
||||||
#include "classic/btstack_link_key_db_tlv.h"
|
#include "classic/btstack_link_key_db_tlv.h"
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
#include "hci_dump_posix_fs.h"
|
|
||||||
#include "hci_transport.h"
|
|
||||||
#include "hci_transport_h4.h"
|
#include "hci_transport_h4.h"
|
||||||
|
#include "hci.h"
|
||||||
|
|
||||||
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
|
#define TLV_DB_PATH_PREFIX "/tmp/btstack_"
|
||||||
#define TLV_DB_PATH_POSTFIX ".tlv"
|
#define TLV_DB_PATH_POSTFIX ".tlv"
|
||||||
static char tlv_db_path[100];
|
static char tlv_db_path[100];
|
||||||
static bool tlv_reset;
|
static bool tlv_reset=false;
|
||||||
static const btstack_tlv_t * tlv_impl;
|
static const btstack_tlv_t * tlv_impl;
|
||||||
static btstack_tlv_posix_t tlv_context;
|
static btstack_tlv_posix_t tlv_context;
|
||||||
static bd_addr_t static_address;
|
static bd_addr_t static_address;
|
||||||
@ -100,9 +93,11 @@ static void local_version_information_handler(uint8_t * packet);
|
|||||||
|
|
||||||
static hci_transport_config_uart_t config = {
|
static hci_transport_config_uart_t config = {
|
||||||
.type = HCI_TRANSPORT_CONFIG_UART,
|
.type = HCI_TRANSPORT_CONFIG_UART,
|
||||||
|
.device_name = "/dev/ttyACM0",
|
||||||
.baudrate_init = 115200,
|
.baudrate_init = 115200,
|
||||||
.baudrate_main = 0,
|
.baudrate_main = 0,
|
||||||
.flowcontrol = 1,
|
.flowcontrol = BTSTACK_UART_FLOWCONTROL_OFF,
|
||||||
|
.parity = BTSTACK_UART_PARITY_OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
@ -195,19 +190,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void trigger_shutdown(void){
|
|
||||||
printf("CTRL-C - SIGINT received, shutting down..\n");
|
|
||||||
log_info("sigint_handler: shutting down");
|
|
||||||
shutdown_triggered = true;
|
|
||||||
hci_power_control(HCI_POWER_OFF);
|
|
||||||
btstack_stdin_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int led_state = 0;
|
static int led_state = 0;
|
||||||
void hal_led_toggle(void){
|
void hal_led_toggle(void){
|
||||||
led_state = 1 - led_state;
|
led_state = 1 - led_state;
|
||||||
printf("LED State %u\n", led_state);
|
printf("LED State %u\n", led_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void use_fast_uart(void){
|
static void use_fast_uart(void){
|
||||||
printf("Using 921600 baud.\n");
|
printf("Using 921600 baud.\n");
|
||||||
config.baudrate_main = 921600;
|
config.baudrate_main = 921600;
|
||||||
@ -287,107 +275,26 @@ static void local_version_information_handler(uint8_t * packet){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char short_options[] = "+hu:l:rb:";
|
static void trigger_shutdown(void){
|
||||||
|
printf("CTRL-C - SIGINT received, shutting down..\n");
|
||||||
static struct option long_options[] = {
|
log_info("sigint_handler: shutting down");
|
||||||
{"help", no_argument, NULL, 'h'},
|
shutdown_triggered = true;
|
||||||
{"logfile", required_argument, NULL, 'l'},
|
hci_power_control(HCI_POWER_OFF);
|
||||||
{"reset-tlv", no_argument, NULL, 'r'},
|
btstack_stdin_reset();
|
||||||
{"tty", required_argument, NULL, 'u'},
|
|
||||||
{"bd-addr", required_argument, NULL, 'b'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *help_options[] = {
|
|
||||||
"print (this) help.",
|
|
||||||
"set file to store debug output and HCI trace.",
|
|
||||||
"reset bonding information stored in TLV.",
|
|
||||||
"set path to Bluetooth Controller.",
|
|
||||||
"set random static Bluetooth address for nRF5340 with PacketCraft Controller.",
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *option_arg_name[] = {
|
|
||||||
"",
|
|
||||||
"LOGFILE",
|
|
||||||
"",
|
|
||||||
"TTY",
|
|
||||||
"BD_ADDR",
|
|
||||||
};
|
|
||||||
|
|
||||||
static void usage(const char *name){
|
|
||||||
unsigned int i;
|
|
||||||
printf( "usage:\n\t%s [options]\n", name );
|
|
||||||
printf("valid options:\n");
|
|
||||||
for( i=0; long_options[i].name != 0; i++) {
|
|
||||||
printf("--%-10s| -%c %-10s\t\t%s\n", long_options[i].name, long_options[i].val, option_arg_name[i], help_options[i] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char * argv[]){
|
int main(int argc, const char * argv[]){
|
||||||
|
|
||||||
const char * log_file_path = NULL;
|
btstack_main_config( argc, argv, &config, random_address, &tlv_reset );
|
||||||
|
|
||||||
// set default device path
|
// register callback for CTRL-c
|
||||||
config.device_name = "/dev/tty.usbmodemEF437DF524C51";
|
btstack_signal_register_callback(SIGINT, &trigger_shutdown);
|
||||||
int oldopterr = opterr;
|
|
||||||
opterr = 0;
|
|
||||||
// parse command line parameters
|
|
||||||
while(true){
|
|
||||||
int c = getopt_long( argc, (char* const *)argv, short_options, long_options, NULL );
|
|
||||||
if (c < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (c == '?'){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (c) {
|
|
||||||
case 'u':
|
|
||||||
config.device_name = optarg;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
log_file_path = optarg;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
tlv_reset = true;
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
sscanf_bd_addr(optarg, random_address);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
default:
|
|
||||||
usage(argv[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// reset getopt parsing, so it works as intended from btstack_main
|
|
||||||
optind = 1;
|
|
||||||
opterr = oldopterr;
|
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
|
||||||
btstack_memory_init();
|
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
|
||||||
|
|
||||||
// log into file using HCI_DUMP_PACKETLOGGER format
|
|
||||||
if (log_file_path == NULL){
|
|
||||||
log_file_path = "/tmp/hci_dump.pklg";
|
|
||||||
}
|
|
||||||
hci_dump_posix_fs_open(log_file_path, HCI_DUMP_PACKETLOGGER);
|
|
||||||
const hci_dump_t * hci_dump_impl = hci_dump_posix_fs_get_instance();
|
|
||||||
hci_dump_init(hci_dump_impl);
|
|
||||||
printf("Packet Log: %s\n", log_file_path);
|
|
||||||
|
|
||||||
printf("H4 device: %s\n", config.device_name);
|
|
||||||
|
|
||||||
// init HCI
|
// init HCI
|
||||||
const btstack_uart_t * uart_driver = btstack_uart_posix_instance();
|
const btstack_uart_t * uart_driver = btstack_uart_posix_instance();
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
const hci_transport_t * transport = hci_transport_h4_instance_for_uart(uart_driver);
|
||||||
hci_init(transport, (void*) &config);
|
hci_init(transport, (void*) &config);
|
||||||
|
|
||||||
#ifdef HAVE_PORTAUDIO
|
|
||||||
btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance());
|
|
||||||
btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set BD_ADDR for CSR without Flash/unique address
|
// set BD_ADDR for CSR without Flash/unique address
|
||||||
// bd_addr_t own_address = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
|
// bd_addr_t own_address = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
|
||||||
// btstack_chipset_csr_set_bd_addr(own_address);
|
// btstack_chipset_csr_set_bd_addr(own_address);
|
||||||
@ -396,9 +303,6 @@ int main(int argc, const char * argv[]){
|
|||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
|
|
||||||
// register callback for CTRL-c
|
|
||||||
btstack_signal_register_callback(SIGINT, &trigger_shutdown);
|
|
||||||
|
|
||||||
// setup app
|
// setup app
|
||||||
btstack_main(argc, argv);
|
btstack_main(argc, argv);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user