mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-16 16:20:50 +00:00
Windows port for Dialog DA14585 connected via serial port
This commit is contained in:
parent
eb0c105509
commit
3c214e8a16
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
### Added
|
||||
- GAP: Detect Secure Connection -> Legacy Connection Downgrade Attack by remote features and actual encryption type (BIAS)
|
||||
- GAP: Mutual authentication: request authentication after Classic connection got encrypted (BIAS)
|
||||
- Windows port for Dialog DA14585 connected via serial port
|
||||
|
||||
### Changed
|
||||
- CVSD PLC: treat zero frames as good and allow to mark data as bad, e.g. if reported by controller as erroneous
|
||||
|
@ -73,6 +73,7 @@ No build server | [posix-h5-bcm](https://github.com/bluekitchen/btstack/tree/dev
|
||||
No build server | [qt-h4](https://github.com/bluekitchen/btstack/tree/develop/port/qt-h4) | Unix- or Win32-based [Qt application](https://qt.io) connected to Bluetooth module via H4 over serial port
|
||||
No build server | [qt-usb](https://github.com/bluekitchen/btstack/tree/develop/port/qt-usb) | Unix- or Win32-based [Qt application](https://qt.io) with dedicated USB Bluetooth dongle
|
||||
No build server | [windows-h4](https://github.com/bluekitchen/btstack/tree/develop/port/windows-h4) | Win32-based system connected to Bluetooth module via serial port
|
||||
No build server | [windows-h4-da14585](https://github.com/bluekitchen/btstack/tree/develop/port/windows-h4-da14585) | Win32-based system connected to Dialog Semiconductor DA14585 via H4 over serial port
|
||||
No build server | [windows-winusb](https://github.com/bluekitchen/btstack/tree/develop/port/windows-winusb) | Win32-based system with dedicated USB Bluetooth dongle
|
||||
No build server | [windows-winusb-intel](https://github.com/bluekitchen/btstack/tree/develop/port/windows-winusb-intel) | Win32-based system with Intel Wireless 8260/8265 Controller
|
||||
No build server | [raspi](https://github.com/bluekitchen/btstack/tree/develop/port/raspi) | Raspberry Pi 3 or Raspberry Pi Zero W with built-in BCM4343 Bluetooth/Wifi Controller
|
||||
|
39
port/windows-h4-da14585/.gitignore
vendored
Normal file
39
port/windows-h4-da14585/.gitignore
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
ancs_client_demo
|
||||
ancs_client_demo.h
|
||||
ble_central_test
|
||||
ble_peripheral_test
|
||||
bnep_test
|
||||
classic_test
|
||||
gap_dedicated_bonding
|
||||
gap_inquiry
|
||||
gap_inquiry_and_bond
|
||||
gap_le_advertisements
|
||||
gap_le_advertisements
|
||||
gatt_battery_query
|
||||
gatt_browser
|
||||
hfp_ag_demo
|
||||
hfp_hf_demo
|
||||
hsp_ag_demo
|
||||
hsp_hs_demo
|
||||
l2cap_test
|
||||
le_counter
|
||||
le_counter.h
|
||||
le_streamer
|
||||
le_streamer
|
||||
le_streamer.h
|
||||
led_counter
|
||||
panu_demo
|
||||
profile.h
|
||||
sdp_bnep_query
|
||||
sdp_general_query
|
||||
sdp_rfcomm_query
|
||||
sm_pairing_central
|
||||
sm_pairing_peripheral
|
||||
sm_pairing_peripheral.h
|
||||
spp_and_le_counter
|
||||
spp_and_le_counter.h
|
||||
spp_counter
|
||||
spp_streamer
|
||||
spp_streamer
|
||||
sco_input*
|
||||
sco_output*
|
38
port/windows-h4-da14585/Makefile
Normal file
38
port/windows-h4-da14585/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
# Makefile for windows-h4-da14585 examples
|
||||
BTSTACK_ROOT ?= ../..
|
||||
|
||||
CORE += main.c btstack_stdin_windows.c btstack_tlv_posix.c
|
||||
|
||||
COMMON += \
|
||||
btstack_run_loop_windows.c \
|
||||
hci_transport_h4.c \
|
||||
btstack_uart_block_windows.c \
|
||||
le_device_db_tlv.c \
|
||||
hci_585.c \
|
||||
btstack_chipset_da14581.c \
|
||||
rijndael.c \
|
||||
|
||||
# examples
|
||||
include ${BTSTACK_ROOT}/example/Makefile.inc
|
||||
|
||||
# CC = gcc-fsf-4.9
|
||||
CFLAGS += -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Werror
|
||||
# CFLAGS += -Werror
|
||||
|
||||
CFLAGS += -I${BTSTACK_ROOT}/platform/posix \
|
||||
-I${BTSTACK_ROOT}/platform/windows \
|
||||
-I${BTSTACK_ROOT}/platform/embedded \
|
||||
-I$(BTSTACK_ROOT)/chipset/da14581 \
|
||||
-I${BTSTACK_ROOT}/3rd-party/rijndael \
|
||||
-I${BTSTACK_ROOT}/3rd-party/tinydir
|
||||
|
||||
VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
|
||||
|
||||
VPATH += ${BTSTACK_ROOT}/platform/windows
|
||||
VPATH += ${BTSTACK_ROOT}/platform/posix
|
||||
|
||||
VPATH += ${BTSTACK_ROOT}/chipset/da14581
|
||||
|
||||
EXAMPLES = ${EXAMPLES_GENERAL} ${EXAMPLES_LE_ONLY}
|
||||
|
||||
all: ${EXAMPLES}
|
41
port/windows-h4-da14585/README.md
Normal file
41
port/windows-h4-da14585/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
# BTstack Port for Windows Systems with DA14585 Controller connected via Serial Port
|
||||
|
||||
This port allows to use the DA14585 connected via Serial Port with BTstack running on a Win32 host system.
|
||||
|
||||
It first downloads the hci_585.hex firmware from the 6.0.8.509 SDK, before BTstack starts up.
|
||||
|
||||
Please note that it does not detect if the firmware has already been downloaded, so you need to reset the DA14585 before starting an example.
|
||||
|
||||
For production use, the HCI firmware could be flashed into the OTP and the firmware download could be skipped.
|
||||
|
||||
Tested with the official DA14585 Dev Kit Basic on OS X and Windows 10.
|
||||
|
||||
## Toolchain
|
||||
|
||||
The port requires a Unix-like toolchain. We successfully used [mingw-w64](https://mingw-w64.org/doku.php) to compile and run the examples. mingw64-w64 is based on [MinGW](mingw.org), which '...provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs.'
|
||||
|
||||
We've used the Msys2 package available from the [downloads page](https://mingw-w64.org/doku.php/download) on Windows 10, 64-bit and use the MSYS2 MinGW 64-bit start menu item to compile 64-bit binaries.
|
||||
|
||||
In the MSYS2 shell, you can install everything with pacman:
|
||||
|
||||
$ pacman -S git
|
||||
$ pacman -S make
|
||||
$ pacman -S mingw-w64-x86_64-toolchain
|
||||
$ pacman -S python
|
||||
$ pacman -S winpty
|
||||
|
||||
## Compilation
|
||||
|
||||
With mingw64-w64 installed, just go to the port/windows-winusb directory and run make
|
||||
|
||||
$ cd btstack/port/windows-winusb
|
||||
$ make
|
||||
|
||||
Note: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails
|
||||
as `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now.
|
||||
|
||||
## Console Output
|
||||
|
||||
When running the examples in the MSYS2 shell, the console input (via btstack_stdin_support) doesn't work. It works in the older MSYS and also the regular CMD.exe environment. Another option is to install WinPTY and then start the example via WinPTY like this:
|
||||
|
||||
$ winpty ./spp_and_le_counter.exe
|
52
port/windows-h4-da14585/btstack_config.h
Normal file
52
port/windows-h4-da14585/btstack_config.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// btstack_config.h for generic POSIX H4 port
|
||||
//
|
||||
|
||||
#ifndef __BTSTACK_CONFIG
|
||||
#define __BTSTACK_CONFIG
|
||||
|
||||
// Port related features
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_BTSTACK_STDIN
|
||||
#define HAVE_POSIX_TIME
|
||||
|
||||
// BTstack features that can be enabled
|
||||
#define ENABLE_BLE
|
||||
#define ENABLE_CLASSIC
|
||||
#define ENABLE_LE_CENTRAL
|
||||
#define ENABLE_LE_PERIPHERAL
|
||||
#define ENABLE_LE_SECURE_CONNECTIONS
|
||||
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
|
||||
#define ENABLE_LE_DATA_CHANNELS
|
||||
#define ENABLE_LE_DATA_LENGTH_EXTENSION
|
||||
#define ENABLE_LOG_ERROR
|
||||
#define ENABLE_LOG_INFO
|
||||
|
||||
// work around bug in Controller ACL fragmentation
|
||||
#define ENABLE_LE_LIMIT_ACL_FRAGMENT_BY_MAX_OCTETS
|
||||
|
||||
// BTstack configuration. buffers, sizes, ...
|
||||
#define HCI_INCOMING_PRE_BUFFER_SIZE 14 // sizeof benep heade, avoid memcpy
|
||||
#define HCI_ACL_PAYLOAD_SIZE (1691 + 4)
|
||||
|
||||
#define NVM_NUM_DEVICE_DB_ENTRIES 16
|
||||
|
||||
// Mesh Configuration
|
||||
#define ENABLE_MESH
|
||||
#define ENABLE_MESH_ADV_BEARER
|
||||
#define ENABLE_MESH_GATT_BEARER
|
||||
#define ENABLE_MESH_PB_ADV
|
||||
#define ENABLE_MESH_PB_GATT
|
||||
#define ENABLE_MESH_PROXY_SERVER
|
||||
#define ENABLE_MESH_PROVISIONER
|
||||
|
||||
#define MAX_NR_MESH_TRANSPORT_KEYS 16
|
||||
#define MAX_NR_MESH_VIRTUAL_ADDRESSES 16
|
||||
#define MAX_NR_MESH_SUBNETS 2
|
||||
|
||||
// allow for one NetKey update
|
||||
#define MAX_NR_MESH_NETWORK_KEYS (MAX_NR_MESH_SUBNETS+1)
|
||||
|
||||
#endif
|
||||
|
192
port/windows-h4-da14585/main.c
Normal file
192
port/windows-h4-da14585/main.c
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (C) 2014 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
#define __BTSTACK_FILE__ "main.c"
|
||||
|
||||
// *****************************************************************************
|
||||
//
|
||||
// minimal setup for HCI code
|
||||
//
|
||||
// *****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "btstack_config.h"
|
||||
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_event.h"
|
||||
#include "btstack_memory.h"
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_run_loop_windows.h"
|
||||
#include "ble/le_device_db_tlv.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "btstack_stdin.h"
|
||||
#include "btstack_tlv_posix.h"
|
||||
#include "hal_led.h"
|
||||
#include "btstack_chipset_da14581.h"
|
||||
#include "hci_585.h"
|
||||
|
||||
static int main_argc;
|
||||
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 "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 = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
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;
|
||||
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);
|
||||
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sigint_handler(int param){
|
||||
UNUSED(param);
|
||||
|
||||
printf("CTRL-C - SIGINT received, shutting down..\n");
|
||||
log_info("sigint_handler: shutting down");
|
||||
|
||||
// reset anyway
|
||||
btstack_stdin_reset();
|
||||
|
||||
// power down
|
||||
hci_power_control(HCI_POWER_OFF);
|
||||
hci_close();
|
||||
log_info("Good bye, see you.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static int led_state = 0;
|
||||
void hal_led_toggle(void){
|
||||
led_state = 1 - led_state;
|
||||
printf("LED State %u\n", led_state);
|
||||
}
|
||||
|
||||
static void phase2(int status){
|
||||
|
||||
if (status){
|
||||
printf("Download firmware failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Phase 2: Main app\n");
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance(uart_driver);
|
||||
hci_init(transport, (void*) &transport_config);
|
||||
|
||||
// inform about BTstack state
|
||||
hci_event_callback_registration.callback = &packet_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
||||
// setup app
|
||||
btstack_main(main_argc, main_argv);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char * argv[]){
|
||||
|
||||
/// GET STARTED with BTstack ///
|
||||
btstack_memory_init();
|
||||
btstack_run_loop_init(btstack_run_loop_windows_get_instance());
|
||||
|
||||
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
|
||||
const char * pklg_path = "hci_dump.pklg";
|
||||
hci_dump_open(pklg_path, HCI_DUMP_PACKETLOGGER);
|
||||
printf("Packet Log: %s\n", pklg_path);
|
||||
|
||||
// pick serial port and configure uart block driver
|
||||
transport_config.device_name = "\\\\.\\COM19";
|
||||
uart_driver = btstack_uart_block_windows_instance();
|
||||
|
||||
// extract UART config from transport config, but overide initial uart speed
|
||||
uart_config.baudrate = 57600;
|
||||
uart_config.flowcontrol = transport_config.flowcontrol;
|
||||
uart_config.device_name = transport_config.device_name;
|
||||
uart_driver->init(&uart_config);
|
||||
|
||||
main_argc = argc;
|
||||
main_argv = argv;
|
||||
|
||||
// phase #1 download firmware
|
||||
printf("Phase 1: Download firmware\n");
|
||||
|
||||
// phase #2 start main app
|
||||
btstack_chipset_da14581_download_firmware(uart_driver, da14581_fw_data, da14581_fw_size, &phase2);
|
||||
|
||||
// go
|
||||
btstack_run_loop_execute();
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user