mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 13:20:39 +00:00
auto-pts: add btp op and event codes
This commit is contained in:
parent
603cbe0dc8
commit
e0b77f1e04
244
test/auto-pts/btp.h
Normal file
244
test/auto-pts/btp.h
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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_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_COTROLLER_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_OP_SET_DISCOVERABLE 0x08
|
||||
#define BTP_GAP_OP_SET_BONDABLE 0x09
|
||||
#define BTP_GAP_OP_START_ADVERTISING 0x0a
|
||||
#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_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_OP_SERVICE_PRIMARY 0x00
|
||||
#define BTP_GATT_OP_SERVICE_SECONDARY 0x01
|
||||
#define BTP_GATT_OP_ADD_SERVICE 0x02
|
||||
#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_SET_ENC_KEY_SIZE 0x09
|
||||
#define BTP_GATT_OP_EXCHANGE_MTU 0x0a
|
||||
#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_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_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
|
@ -49,6 +49,7 @@
|
||||
#include "hci.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_config.h"
|
||||
#include "btp.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
@ -101,7 +102,7 @@ static void btp_socket_init_statemachine(void){
|
||||
|
||||
static void btp_socket_emit_connection_closed(void){
|
||||
const uint8_t status = BTP_ERROR_NOT_READY;
|
||||
(*btp_socket_packet_callback)(BTP_CORE_SERVICE, BTP_OP_ERROR, BTP_INDEX_NON_CONTROLLER, 1, &status);
|
||||
(*btp_socket_packet_callback)(BTP_SERVICE_ID_CORE, BTP_OP_ERROR, BTP_INDEX_NON_CONTROLLER, 1, &status);
|
||||
}
|
||||
|
||||
void btp_socket_hci_process(btstack_data_source_t *socket_ds, btstack_data_source_callback_type_t callback_type) {
|
||||
|
@ -52,33 +52,6 @@
|
||||
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
|
||||
|
||||
#define BTP_CORE_SERVICE 0
|
||||
#define BTP_GAP_SERVICE 1
|
||||
#define BTP_GATT_SERVICE 2
|
||||
#define BTP_L2CAP_SERVICE 3
|
||||
#define BTP_MESH_NODE_SERVICE 4
|
||||
|
||||
/**
|
||||
* @format 1
|
||||
* @param status
|
||||
*/
|
||||
#define BTP_OP_ERROR 0x00
|
||||
|
||||
#define BTP_OP_CORE_READ_SUPPORTED_COMMANDS 0x01
|
||||
#define BTP_OP_CORE_READ_SUPPORTED_SERVICES 0x02
|
||||
#define BTP_OP_CORE_REGISTER 0x03
|
||||
#define BTP_OP_CORE_UNREGISTER 0x04
|
||||
|
||||
#define BTP_EV_CORE_READY 0x80
|
||||
|
||||
/**
|
||||
* Init socket connection module
|
||||
*/
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "btstack.h"
|
||||
#include "btp.h"
|
||||
#include "btp_socket.h"
|
||||
|
||||
#define AUTOPTS_SOCKET_NAME "/tmp/bt-stack-tester"
|
||||
@ -63,10 +64,16 @@ static void btstack_packet_handler (uint8_t packet_type, uint16_t channel, uint8
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
case BTSTACK_EVENT_STATE:
|
||||
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) return;
|
||||
btp_socket_open_unix(AUTOPTS_SOCKET_NAME);
|
||||
log_info("BTP_CORE_SERVICE/BTP_EV_CORE_READY/BTP_INDEX_NON_CONTROLLER()");
|
||||
btp_socket_send_packet(BTP_CORE_SERVICE, BTP_EV_CORE_READY, BTP_INDEX_NON_CONTROLLER, 0, NULL);
|
||||
switch (btstack_event_state_get_state(packet)){
|
||||
case HCI_STATE_WORKING:
|
||||
btp_socket_open_unix(AUTOPTS_SOCKET_NAME);
|
||||
log_info("BTP_CORE_SERVICE/BTP_EV_CORE_READY/BTP_INDEX_NON_CONTROLLER()");
|
||||
btp_socket_send_packet(BTP_SERVICE_ID_CORE, BTP_CORE_EV_READY, BTP_INDEX_NON_CONTROLLER, 0, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -78,8 +85,11 @@ static void btstack_packet_handler (uint8_t packet_type, uint16_t channel, uint8
|
||||
|
||||
static void btp_packet_handler(uint8_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data){
|
||||
uint8_t status;
|
||||
log_info("service id 0x%02x, opcode 0x%02x, controller_index 0x%0x, len %u", service_id, opcode, controller_index, length);
|
||||
log_info_hexdump(data, length);
|
||||
|
||||
switch (service_id){
|
||||
case BTP_CORE_SERVICE:
|
||||
case BTP_SERVICE_ID_CORE:
|
||||
switch (opcode){
|
||||
case BTP_OP_ERROR:
|
||||
status = data[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user