mirror of
https://github.com/bluekitchen/btstack.git
synced 2024-12-25 15:16:37 +00:00
test/auto-pts: move to extra (remove)
This commit is contained in:
parent
f99c988a5b
commit
18db232f56
2
test/auto-pts/.gitignore
vendored
2
test/auto-pts/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
build
|
||||
xcode
|
@ -1,100 +0,0 @@
|
||||
cmake_minimum_required (VERSION 3.5)
|
||||
project(BTstack-AutoPTS)
|
||||
|
||||
SET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
|
||||
|
||||
# fink pkgconfig
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
# libusb
|
||||
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||
include_directories(${LIBUSB_INCLUDE_DIRS})
|
||||
link_directories(${LIBUSB_LIBRARY_DIRS})
|
||||
link_libraries(${LIBUSB_LIBRARIES})
|
||||
|
||||
# add all directories
|
||||
include_directories((../../chipset/realtek))
|
||||
include_directories(../../3rd-party/micro-ecc)
|
||||
include_directories(../../3rd-party/lc3-google/include)
|
||||
include_directories(../../3rd-party/rijndael)
|
||||
include_directories(../../3rd-party/tinydir)
|
||||
include_directories(../../chipset/bcm)
|
||||
include_directories(../../chipset/csr)
|
||||
include_directories(../../chipset/cc256x)
|
||||
include_directories(../../chipset/csr)
|
||||
include_directories(../../chipset/em9301)
|
||||
include_directories(../../chipset/zephyr)
|
||||
include_directories(../../chipset/realtek)
|
||||
include_directories(../../chipset/tc3566x)
|
||||
include_directories(../../chipset/stlc2500d)
|
||||
include_directories(../../chipset/zephyr)
|
||||
include_directories(../../src)
|
||||
include_directories(../../platform/posix)
|
||||
include_directories(../../platform/embedded)
|
||||
include_directories(../../platform/lwip)
|
||||
include_directories(../../platform/lwip/port)
|
||||
include_directories(.)
|
||||
include_directories(..)
|
||||
|
||||
# find src files
|
||||
file(GLOB SOURCES_BCM "../../chipset/bcm/*.c")
|
||||
file(GLOB SOURCES_CSR "../../chipset/csr/*.c")
|
||||
file(GLOB SOURCES_EM9301 "../../chipset/em9301/*.c")
|
||||
file(GLOB SOURCES_SRC "../../src/*.c" "../../example/sco_demo_util.c")
|
||||
file(GLOB SOURCES_CLASSIC ../../src/classic/btstack_link_key_db_tlv.c
|
||||
../../src/classic/rfcomm.c
|
||||
../../src/classic/sdp_server.c
|
||||
../../src/classic/sdp_util.c)
|
||||
file(GLOB SOURCES_BLE "../../src/ble/*.c")
|
||||
file(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c")
|
||||
file(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c")
|
||||
file(GLOB SOURCES_POSIX "../../platform/posix/*.c")
|
||||
file(GLOB SOURCES_LIBUSB "../../platform/libusb/*.c")
|
||||
file(GLOB SOURCES_REALTEK "../../chipset/realtek/*.c")
|
||||
file(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c")
|
||||
file(GLOB SOURCES_STLC2500D "../../chipset/stlc2500d/*.c")
|
||||
file(GLOB SOURCES_TC2566X "../../chipset/tc3566x/*.c")
|
||||
|
||||
# remove some
|
||||
file(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
|
||||
list(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF})
|
||||
file(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c")
|
||||
list(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
|
||||
|
||||
set(SOURCES
|
||||
${SOURCES_BCM}
|
||||
${SOURCES_CSR}
|
||||
${SOURCES_EM9301}
|
||||
${SOURCES_POSIX}
|
||||
${SOURCES_LIBUSB}
|
||||
${SOURCES_SRC}
|
||||
${SOURCES_CLASSIC}
|
||||
${SOURCES_BLE}
|
||||
${SOURCES_GATT}
|
||||
${SOURCES_UECC}
|
||||
${SOURCES_REALTEK}
|
||||
${SOURCES_ZEPHYR}
|
||||
${SOURCES_REALTEK}
|
||||
${SOURCES_STLC2500D}
|
||||
${SOURCES_TC2566X}
|
||||
"../../3rd-party/rijndael/rijndael.c"
|
||||
)
|
||||
|
||||
# Enable ASAN
|
||||
add_compile_options( -g -fsanitize=address)
|
||||
add_link_options( -fsanitize=address)
|
||||
|
||||
# create static lib
|
||||
add_library(btstack STATIC ${SOURCES})
|
||||
|
||||
# Add CC256x Support and specify init script
|
||||
set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c)
|
||||
include(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake)
|
||||
|
||||
# target btpclient-usb
|
||||
add_executable(btpclient-usb btpclient.c ../../port/libusb/main.c btp_socket.c)
|
||||
target_link_libraries(btpclient-usb btstack)
|
||||
|
||||
# target btpclient-h4
|
||||
add_executable(btpclient-h4 btpclient.c ../../port/posix-h4/main.c btp_socket.c)
|
||||
target_link_libraries(btpclient-h4 btstack)
|
@ -1,273 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* btp.h
|
||||
*/
|
||||
|
||||
#ifndef BTP_H
|
||||
#define BTP_H
|
||||
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_defines.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// BTP Defines
|
||||
#define BTP_INDEX_NON_CONTROLLER 0xff
|
||||
|
||||
#define BTP_ERROR_FAIL 0x01
|
||||
#define BTP_ERROR_UNKNOWN_CMD 0x02
|
||||
#define BTP_ERROR_NOT_READY 0x03
|
||||
#define BTP_ERROR_INVALID_INDEX 0x04
|
||||
|
||||
// Service IDs
|
||||
#define BTP_SERVICE_ID_CORE 0
|
||||
#define BTP_SERVICE_ID_GAP 1
|
||||
#define BTP_SERVICE_ID_GATT 2
|
||||
#define BTP_SERVICE_ID_L2CAP 3
|
||||
#define BTP_SERVICE_ID_MESH 4
|
||||
|
||||
#define BTP_OP_ERROR 0x00
|
||||
|
||||
|
||||
// CORE SERVICE
|
||||
|
||||
#define BTP_CORE_OP_READ_SUPPORTED_COMMANDS 0x01
|
||||
#define BTP_CORE_OP_READ_SUPPORTED_SERVICES 0x02
|
||||
#define BTP_CORE_OP_REGISTER 0x03
|
||||
#define BTP_CORE_OP_UNREGISTER 0x04
|
||||
#define BTP_CORE_OP_LOG_MESSAGE 0x05
|
||||
|
||||
#define BTP_CORE_EV_READY 0x80
|
||||
|
||||
|
||||
// GAP SERVICE
|
||||
|
||||
#define BTP_GAP_OP_READ_SUPPORTED_COMMANDS 0x01
|
||||
#define BTP_GAP_OP_READ_CONTROLLER_INDEX_LIST 0x02
|
||||
|
||||
#define BTP_GAP_SETTING_POWERED 0x00000001
|
||||
#define BTP_GAP_SETTING_CONNECTABLE 0x00000002
|
||||
#define BTP_GAP_SETTING_FAST_CONNECTABLE 0x00000004
|
||||
#define BTP_GAP_SETTING_DISCOVERABLE 0x00000008
|
||||
#define BTP_GAP_SETTING_BONDABLE 0x00000010
|
||||
#define BTP_GAP_SETTING_LL_SECURITY 0x00000020
|
||||
#define BTP_GAP_SETTING_SSP 0x00000040
|
||||
#define BTP_GAP_SETTING_BREDR 0x00000080
|
||||
#define BTP_GAP_SETTING_HS 0x00000100
|
||||
#define BTP_GAP_SETTING_LE 0x00000200
|
||||
#define BTP_GAP_SETTING_ADVERTISING 0x00000400
|
||||
#define BTP_GAP_SETTING_SC 0x00000800
|
||||
#define BTP_GAP_SETTING_DEBUG_KEYS 0x00001000
|
||||
#define BTP_GAP_SETTING_PRIVACY 0x00002000
|
||||
#define BTP_GAP_SETTING_CONTROLLER_CONF 0x00004000
|
||||
#define BTP_GAP_SETTING_STATIC_ADDRESS 0x00008000
|
||||
|
||||
#define BTP_GAP_OP_READ_CONTROLLER_INFO 0x03
|
||||
#define BTP_GAP_OP_RESET 0x04
|
||||
#define BTP_GAP_OP_SET_POWERED 0x05
|
||||
#define BTP_GAP_OP_SET_CONNECTABLE 0x06
|
||||
#define BTP_GAP_OP_SET_FAST_CONNECTABLE 0x07
|
||||
|
||||
#define BTP_GAP_DISCOVERABLE_NON 0x00
|
||||
#define BTP_GAP_DISCOVERABLE_GENERAL 0x01
|
||||
#define BTP_GAP_DISCOVERABLE_LIMITED 0x02
|
||||
|
||||
#define BTP_GAP_OP_SET_DISCOVERABLE 0x08
|
||||
#define BTP_GAP_OP_SET_BONDABLE 0x09
|
||||
#define BTP_GAP_OP_START_ADVERTISING 0x0a
|
||||
|
||||
#define BTP_GAP_OWN_ADDR_TYPE_IDENTITY 0x00
|
||||
#define BTP_GAP_OWN_ADDR_TYPE_RPA 0x01
|
||||
#define BTP_GAP_OWN_ADDR_TYPE_NON_RPA 0x02
|
||||
|
||||
#define BTP_GAP_OP_STOP_ADVERTISING 0x0b
|
||||
#define BTP_GAP_DISCOVERY_FLAG_LE 0x01
|
||||
#define BTP_GAP_DISCOVERY_FLAG_BREDR 0x02
|
||||
#define BTP_GAP_DISCOVERY_FLAG_LIMITED 0x04
|
||||
#define BTP_GAP_DISCOVERY_FLAG_ACTIVE 0x08
|
||||
#define BTP_GAP_DISCOVERY_FLAG_OBSERVATION 0x10
|
||||
#define BTP_GAP_OP_START_DISCOVERY 0x0c
|
||||
#define BTP_GAP_OP_STOP_DISCOVERY 0x0d
|
||||
#define BTP_GAP_ADDR_PUBLIC 0x00
|
||||
#define BTP_GAP_ADDR_RANDOM 0x01
|
||||
#define BTP_GAP_OP_CONNECT 0x0e
|
||||
#define BTP_GAP_OP_DISCONNECT 0x0f
|
||||
#define BTP_GAP_IOCAPA_DISPLAY_ONLY 0x00
|
||||
#define BTP_GAP_IOCAPA_DISPLAY_YESNO 0x01
|
||||
#define BTP_GAP_IOCAPA_KEYBOARD_ONLY 0x02
|
||||
#define BTP_GAP_IOCAPA_NO_INPUT_NO_OUTPUT 0x03
|
||||
#define BTP_GAP_IOCAPA_KEYBOARD_DISPLAY 0x04
|
||||
#define BTP_GAP_OP_SET_IO_CAPA 0x10
|
||||
#define BTP_GAP_OP_PAIR 0x11
|
||||
#define BTP_GAP_OP_UNPAIR 0x12
|
||||
#define BTP_GAP_OP_PASSKEY_ENTRY_RSP 0x13
|
||||
#define BTP_GAP_OP_PASSKEY_CONFIRM_RSP 0x14
|
||||
#define BTP_GAP_OP_START_DIRECTED_ADVERTISING 0x15
|
||||
#define BTP_GAP_OP_CONNECTION_PARAM_UPDATE 0x16
|
||||
#define BTP_GAP_OP_PAIRING_CONSENT_RSP 0x17
|
||||
|
||||
#define BTP_GAP_EV_NEW_SETTINGS 0x80
|
||||
|
||||
#define BTP_GAP_EV_DEVICE_FOUND 0x81
|
||||
#define BTP_GAP_EV_DEVICE_FOUND_FLAG_RSSI 0x01
|
||||
#define BTP_GAP_EV_DEVICE_FOUND_FLAG_AD 0x02
|
||||
#define BTP_GAP_EV_DEVICE_FOUND_FLAG_SR 0x04
|
||||
|
||||
#define BTP_GAP_EV_DEVICE_CONNECTED 0x82
|
||||
#define BTP_GAP_EV_DEVICE_DISCONNECTED 0x83
|
||||
#define BTP_GAP_EV_PASSKEY_DISPLAY 0x84
|
||||
#define BTP_GAP_EV_PASSKEY_REQUEST 0x85
|
||||
#define BTP_GAP_EV_PASSKEY_CONFIRM 0x86
|
||||
#define BTP_GAP_EV_IDENTITY_RESOLVED 0x87
|
||||
|
||||
|
||||
// GATT Service
|
||||
|
||||
#define BTP_GATT_OP_READ_SUPPORTED_COMMANDS 0x01
|
||||
|
||||
#define BTP_GATT_SERVICE_TYPE_PRIMARY 0x00
|
||||
#define BTP_GATT_SERVICE_TYPE_SECONDARY 0x01
|
||||
#define BTP_GATT_OP_ADD_SERVICE 0x02
|
||||
|
||||
#define BTP_GATT_PERM_READ 0x01
|
||||
#define BTP_GATT_PERM_WRITE 0x02
|
||||
#define BTP_GATT_PERM_READ_ENC 0x04
|
||||
#define BTP_GATT_PERM_WRITE_ENC 0x08
|
||||
#define BTP_GATT_PERM_READ_AUTHN 0x10
|
||||
#define BTP_GATT_PERM_WRITE_AUTHN 0x20
|
||||
#define BTP_GATT_PERM_READ_AUTHZ 0x40
|
||||
#define BTP_GATT_PERM_WRITE_AUTHZ 0x80
|
||||
|
||||
#define BTP_GATT_OP_ADD_CHARACTERISTIC 0x03
|
||||
#define BTP_GATT_OP_ADD_DESCRIPTOR 0x04
|
||||
#define BTP_GATT_OP_ADD_INCLUDED_SERVICE 0x05
|
||||
#define BTP_GATT_OP_SET_VALUE 0x06
|
||||
#define BTP_GATT_OP_START_SERVER 0x07
|
||||
#define BTP_GATT_OP_RESET_SERVER 0x08
|
||||
#define BTP_GATT_OP_SET_ENC_KEY_SIZE 0x09
|
||||
#define BTP_GATT_OP_EXCHANGE_MTU 0x0a
|
||||
#define BTP_GATT_OP_DISC_ALL_PRIM 0x0b
|
||||
#define BTP_GATT_OP_DISC_PRIM_UUID 0x0c
|
||||
#define BTP_GATT_OP_FIND_INCLUDED 0x0d
|
||||
#define BTP_GATT_OP_DISC_ALL_CHRC 0x0e
|
||||
#define BTP_GATT_OP_DISC_CHRC_UUID 0x0f
|
||||
#define BTP_GATT_OP_DISC_ALL_DESC 0x10
|
||||
#define BTP_GATT_OP_READ 0x11
|
||||
#define BTP_GATT_OP_READ_UUID 0x12
|
||||
#define BTP_GATT_OP_READ_LONG 0x13
|
||||
#define BTP_GATT_OP_READ_MULTIPLE 0x14
|
||||
#define BTP_GATT_OP_WRITE_WITHOUT_RSP 0x15
|
||||
#define BTP_GATT_OP_SIGNED_WRITE_WITHOUT_RSP 0x16
|
||||
#define BTP_GATT_OP_WRITE 0x17
|
||||
#define BTP_GATT_OP_WRITE_LONG 0x18
|
||||
#define BTP_GATT_OP_WRITE_RELIABLE 0x19
|
||||
#define BTP_GATT_OP_CFG_NOTIFY 0x1a
|
||||
#define BTP_GATT_OP_CFG_INDICATE 0x1b
|
||||
#define BTP_GATT_OP_GET_ATTRIBUTES 0x1c
|
||||
#define BTP_GATT_OP_GET_ATTRIBUTE_VALUE 0x1d
|
||||
|
||||
#define BTP_GATT_EV_NOTIFICATION 0x80
|
||||
#define BTP_GATT_EV_ATTR_VALUE_CHANGED 0x81
|
||||
|
||||
|
||||
// L2CAP Service
|
||||
|
||||
#define BTP_L2CAP_OP_READ_SUPPORTED_COMMANDS 0x01
|
||||
#define BTP_L2CAP_OP_CONNECT 0x02
|
||||
#define BTP_L2CAP_OP_DISCONNECT 0x03
|
||||
#define BTP_L2CAP_OP_SEND_DATA 0x04
|
||||
#define BTP_L2CAP_OP_TRANSPORT_BREDR 0x00
|
||||
#define BTP_L2CAP_OP_TRANSPORT_LE 0x01
|
||||
#define BTP_L2CAP_OP_LISTEN 0x05
|
||||
#define BTP_L2CAP_OP_ACCEPT_CONNECTION 0x06
|
||||
|
||||
#define BTP_L2CAP_EV_CONNECTION_REQ 0x80
|
||||
#define BTP_L2CAP_EV_CONNECTED 0x81
|
||||
#define BTP_L2CAP_EV_DISCONNECTED 0x82
|
||||
#define BTP_L2CAP_EV_DATA_RECEIVED 0x83
|
||||
|
||||
|
||||
// MESH Service
|
||||
|
||||
#define BTP_MESH_OP_READ_SUPPORTED_COMMANDS 0x01
|
||||
#define BTP_MESH_OP_CONFIG_PROVISIONING 0x02
|
||||
#define BTP_MESH_OP_OUT_BLINK (1U <<0)
|
||||
#define BTP_MESH_OP_OUT_BEEP (1U <<1)
|
||||
#define BTP_MESH_OP_OUT_VIBRATE (1U <<2)
|
||||
#define BTP_MESH_OP_OUT_DISPLAY_NUMBER (1U <<3)
|
||||
#define BTP_MESH_OP_OUT_DISPLAY_STRING (1U <<4)
|
||||
#define BTP_MESH_OP_IN_PUSH (1U <<0)
|
||||
#define BTP_MESH_OP_IN_TWIST (1U <<1)
|
||||
#define BTP_MESH_OP_IN_ENTER_NUMBER (1U <<2)
|
||||
#define BTP_MESH_OP_IN_ENTER_STRING (1U <<3)
|
||||
#define BTP_MESH_OP_PROVISION_NODE 0x03
|
||||
#define BTP_MESH_OP_INIT 0x04
|
||||
#define BTP_MESH_OP_RESET 0x05
|
||||
#define BTP_MESH_OP_INPUT_NUMBER 0x06
|
||||
#define BTP_MESH_OP_INPUT_STRING 0x07
|
||||
#define BTP_MESH_OP_IVU_TEST_MODE 0x08
|
||||
#define BTP_MESH_OP_IVU_TOGGLE_STATE 0x09
|
||||
#define BTP_MESH_OP_NET_SEND 0x0a
|
||||
#define BTP_MESH_OP_HEALTH_GENERATE_FAULTS 0x0b
|
||||
#define BTP_MESH_OP_HEALTH_CLEAR_FAULTS 0x0c
|
||||
#define BTP_MESH_OP_LPN 0x0d
|
||||
#define BTP_MESH_OP_LPN_POLL 0x0e
|
||||
#define BTP_MESH_OP_MODEL_SEND 0x0f
|
||||
#define BTP_MESH_OP_LPN_SUBSCRIBE 0x10
|
||||
#define BTP_MESH_OP_LPN_UNSUBSCRIBE 0x11
|
||||
#define BTP_MESH_OP_RPL_CLEAR 0x12
|
||||
#define BTP_MESH_OP_PROXY_IDENTITY 0x13
|
||||
#define BTP_MESH_EV_OUT_NUMBER_ACTION 0x80
|
||||
#define BTP_MESH_EV_OUT_STRING_ACTION 0x81
|
||||
#define BTP_MESH_EV_IN_ACTION 0x82
|
||||
#define BTP_MESH_EV_PROVISIONED 0x83
|
||||
#define BTP_MESH_EV_PROV_LINK_OPEN 0x84
|
||||
#define BTP_MESH_EV_PROV_LINK_OPEN_BEARER_ADV 0x00
|
||||
#define BTP_MESH_EV_PROV_LINK_OPEN_BEARER_GATT 0x01
|
||||
#define BTP_MESH_EV_PROV_LINK_CLOSED 0x85
|
||||
#define BTP_MESH_EV_NET_RECV 0x86
|
||||
#define BTP_MESH_EV_INVALID_BEARER 0x87
|
||||
#define BTP_MESH_EV_INCOMP_TIMER_EXP 0x88
|
||||
|
||||
#endif
|
@ -1,239 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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__ "btp_connection.c"
|
||||
|
||||
/*
|
||||
* btp_connection.c
|
||||
*
|
||||
* Handles btp communication with auto-pts client via unix domain socket
|
||||
*
|
||||
*/
|
||||
|
||||
#include "btp_socket.h"
|
||||
|
||||
#include "hci.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_config.h"
|
||||
#include "btp.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define BTP_PAYLOAD_LEN_MAX 1000
|
||||
#define BTP_HEADER_LEN 5
|
||||
|
||||
#define LOG_BTP
|
||||
|
||||
/** prototypes */
|
||||
|
||||
/** globals */
|
||||
|
||||
typedef enum {
|
||||
SOCKET_W4_HEADER,
|
||||
SOCKET_W4_DATA
|
||||
} SOCKET_STATE;
|
||||
|
||||
static btstack_data_source_t socket_ds;
|
||||
|
||||
static uint8_t buffer[6+BTP_PAYLOAD_LEN_MAX];
|
||||
|
||||
static SOCKET_STATE state;
|
||||
static uint16_t packet_bytes_read;
|
||||
static uint16_t packet_bytes_to_read;
|
||||
|
||||
/** client packet handler */
|
||||
|
||||
static void (*btp_socket_packet_callback)(uint8_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t * data);
|
||||
|
||||
static void btp_socket_free_connection(){
|
||||
// remove from run_loop
|
||||
btstack_run_loop_remove_data_source(&socket_ds);
|
||||
socket_ds.source.fd = 0;
|
||||
}
|
||||
|
||||
static void btp_socket_init_statemachine(void){
|
||||
// wait for next packet
|
||||
state = SOCKET_W4_HEADER;
|
||||
packet_bytes_read = 0;
|
||||
packet_bytes_to_read = BTP_HEADER_LEN;
|
||||
}
|
||||
|
||||
static void btp_socket_emit_connection_closed(void){
|
||||
log_info("Connection closed, emit BTP_ERROR_NOT_READY");
|
||||
const uint8_t status = BTP_ERROR_NOT_READY;
|
||||
(*btp_socket_packet_callback)(BTP_SERVICE_ID_CORE, BTP_OP_ERROR, BTP_INDEX_NON_CONTROLLER, 1, &status);
|
||||
}
|
||||
|
||||
void btp_socket_process(btstack_data_source_t *socket_ds, btstack_data_source_callback_type_t callback_type) {
|
||||
// get socket_fd
|
||||
int socket_fd = socket_ds->source.fd;
|
||||
|
||||
// read from socket
|
||||
int bytes_read = read(socket_fd, &buffer[packet_bytes_read], packet_bytes_to_read);
|
||||
if (bytes_read <= 0){
|
||||
// free connection
|
||||
btp_socket_free_connection();
|
||||
|
||||
// connection broken (no particular channel, no date yet)
|
||||
btp_socket_emit_connection_closed();
|
||||
return;
|
||||
}
|
||||
|
||||
packet_bytes_read += bytes_read;
|
||||
packet_bytes_to_read -= bytes_read;
|
||||
if (packet_bytes_to_read > 0) return;
|
||||
|
||||
bool dispatch = false;
|
||||
switch (state){
|
||||
case SOCKET_W4_HEADER:
|
||||
state = SOCKET_W4_DATA;
|
||||
packet_bytes_to_read = little_endian_read_16( buffer, 3);
|
||||
if (packet_bytes_to_read == 0){
|
||||
dispatch = true;
|
||||
}
|
||||
break;
|
||||
case SOCKET_W4_DATA:
|
||||
dispatch = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (dispatch){
|
||||
// dispatch packet !!! connection, type, channel, data, size
|
||||
(*btp_socket_packet_callback)(buffer[0], buffer[1], buffer[2], little_endian_read_16( buffer, 3), &buffer[BTP_HEADER_LEN]);
|
||||
|
||||
// reset state machine
|
||||
btp_socket_init_statemachine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* send BTP packet
|
||||
*/
|
||||
void btp_socket_send_packet(uint16_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data){
|
||||
#ifdef LOG_BTP
|
||||
log_info("btp_socket_send_packet: service_id %0x, opcode %02x, controller_index 0x%02x, length %u", service_id, opcode, controller_index, length);
|
||||
log_info_hexdump(data, length);
|
||||
#endif
|
||||
|
||||
if (socket_ds.source.fd == 0) return;
|
||||
|
||||
uint8_t header[BTP_HEADER_LEN];
|
||||
header[0] = service_id;
|
||||
header[1] = opcode;
|
||||
header[2] = controller_index;
|
||||
little_endian_store_16(header, 3, length);
|
||||
int res;
|
||||
res = write(socket_ds.source.fd, header, sizeof(header));
|
||||
res = write(socket_ds.source.fd, data, length);
|
||||
UNUSED(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* create socket connection to auto-pts client
|
||||
*/
|
||||
bool btp_socket_open_unix(const char * socket_name){
|
||||
int btp_socket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if(btp_socket == -1){
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sockaddr_un server;
|
||||
memset(&server, 0, sizeof(server));
|
||||
server.sun_family = AF_UNIX;
|
||||
strcpy(server.sun_path, socket_name);
|
||||
if (connect(btp_socket, (struct sockaddr *)&server, sizeof (server)) == -1){
|
||||
return false;
|
||||
};
|
||||
|
||||
btstack_run_loop_set_data_source_handler(&socket_ds, &btp_socket_process);
|
||||
btstack_run_loop_set_data_source_fd(&socket_ds, btp_socket);
|
||||
btstack_run_loop_enable_data_source_callbacks(&socket_ds, DATA_SOURCE_CALLBACK_READ);
|
||||
|
||||
// prepare state machine and
|
||||
btp_socket_init_statemachine();
|
||||
|
||||
// add this socket to the run_loop
|
||||
btstack_run_loop_add_data_source( &socket_ds );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* close socket connection to auto-pts client
|
||||
*/
|
||||
bool btp_socket_close_unix(void){
|
||||
if (socket_ds.source.fd == 0) return false;
|
||||
shutdown(socket_ds.source.fd, SHUT_RDWR);
|
||||
btp_socket_free_connection();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init socket connection module
|
||||
*/
|
||||
void btp_socket_init(void){
|
||||
#if 0
|
||||
// just ignore broken sockets - NO_SO_SIGPIPE
|
||||
sig_t result = signal(SIGPIPE, SIG_IGN);
|
||||
if (result){
|
||||
log_error("btp_socket_init: failed to ignore SIGPIPE, error: %s", strerror(errno));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* set packet handler
|
||||
*/
|
||||
void btp_socket_register_packet_handler( void (*packet_handler)(uint8_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data) ){
|
||||
btp_socket_packet_callback = packet_handler;
|
||||
}
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* btp_socket.h
|
||||
*/
|
||||
|
||||
#ifndef BTP_SOCKET_H
|
||||
#define BTP_SOCKET_H
|
||||
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_defines.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Init socket connection module
|
||||
*/
|
||||
void btp_socket_init(void);
|
||||
|
||||
/**
|
||||
* create unix socket connection to auto-pts client
|
||||
* @returns true if successful
|
||||
*/
|
||||
bool btp_socket_open_unix(const char * socket_name);
|
||||
|
||||
/**
|
||||
* close unix connection to auto-pts client
|
||||
* @returns true if successful
|
||||
*/
|
||||
bool btp_socket_close_unix(void);
|
||||
|
||||
/**
|
||||
* set packet handler
|
||||
*/
|
||||
void btp_socket_register_packet_handler( void (*packet_handler)(uint8_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data) );
|
||||
|
||||
/**
|
||||
* send HCI packet to single connection
|
||||
*/
|
||||
void btp_socket_send_packet(uint16_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t * data);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BTP_CONNECTION_H
|
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
||||
//
|
||||
// btstack_config.h for most tests
|
||||
//
|
||||
|
||||
#ifndef BTSTACK_CONFIG_H
|
||||
#define BTSTACK_CONFIG_H
|
||||
|
||||
// Port related features
|
||||
#define HAVE_BTSTACK_STDIN
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_POSIX_TIME
|
||||
#define HAVE_ASSERT
|
||||
|
||||
// BTstack features that can be enabled
|
||||
#define ENABLE_CLASSIC
|
||||
#define ENABLE_BLE
|
||||
#define ENABLE_BTP
|
||||
#define ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
|
||||
#define ENABLE_LE_CENTRAL
|
||||
#define ENABLE_LE_DATA_LENGTH_EXTENSION
|
||||
#define ENABLE_LE_EXTENDED_ADVERTISING
|
||||
#define ENABLE_LE_ISOCHRONOUS_STREAMS
|
||||
#define ENABLE_LE_PERIODIC_ADVERTISING
|
||||
#define ENABLE_LE_PERIPHERAL
|
||||
#define ENABLE_LE_SECURE_CONNECTIONS
|
||||
#define ENABLE_LE_SIGNED_WRITE
|
||||
#define ENABLE_LOG_ERROR
|
||||
#define ENABLE_LOG_INFO
|
||||
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
|
||||
#define ENABLE_PRINTF_HEXDUMP
|
||||
#define ENABLE_SOFTWARE_AES128
|
||||
|
||||
// BTstack configuration. buffers, sizes, ...
|
||||
#define HCI_ACL_PAYLOAD_SIZE 1024
|
||||
#define HCI_INCOMING_PRE_BUFFER_SIZE 6
|
||||
#define NVM_NUM_DEVICE_DB_ENTRIES 4
|
||||
#define NVM_NUM_LINK_KEYS 2
|
||||
|
||||
#endif
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# collect traces from auto-pts run (exclude chipset/zephyr)
|
||||
lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --exclude "*/chipset/*" --output-file coverage-pts.info
|
||||
|
||||
# optional: download unit tests, merge and filter results like in ../Makefile
|
||||
|
||||
# generate html output
|
||||
genhtml coverage-pts.info --branch-coverage --output-directory coverage-pts
|
Loading…
Reference in New Issue
Block a user