mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-13 20:50:00 +00:00
apps/bttester: split bttester.h and add btp_ prefixes
Splits `bttester.h` into seperate files, one for each BTP service. Adds BTP_ prefix for defines and btp_ prefix for structs.
This commit is contained in:
committed by
Szymon Janc
parent
dc60f90a37
commit
32e39750d6
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp.h - Bluetooth tester btp headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp_core.h"
|
||||
#include "btp_gap.h"
|
||||
#include "btp_gatt.h"
|
||||
#include "btp_gattc.h"
|
||||
#include "btp_l2cap.h"
|
||||
#include "btp_mesh.h"
|
||||
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
#include "mesh/glue.h"
|
||||
#else
|
||||
#include "../glue.h"
|
||||
#endif
|
||||
|
||||
#define BTP_MTU MYNEWT_VAL(BTTESTER_BTP_DATA_SIZE_MAX)
|
||||
#define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))
|
||||
|
||||
#define BTP_INDEX_NONE 0xff
|
||||
|
||||
#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_SERVICE_ID_GATTC 6
|
||||
|
||||
#define BTP_STATUS_SUCCESS 0x00
|
||||
#define BTP_STATUS_FAILED 0x01
|
||||
#define BTP_STATUS_UNKNOWN_CMD 0x02
|
||||
#define BTP_STATUS_NOT_READY 0x03
|
||||
|
||||
#define SYS_LOG_DBG(fmt, ...) \
|
||||
if (MYNEWT_VAL(BTTESTER_DEBUG)) { \
|
||||
console_printf("[DBG] %s: " fmt "\n", \
|
||||
__func__, ## __VA_ARGS__); \
|
||||
}
|
||||
#define SYS_LOG_INF(fmt, ...) console_printf("[INF] %s: " fmt "\n", \
|
||||
__func__, ## __VA_ARGS__);
|
||||
#define SYS_LOG_ERR(fmt, ...) console_printf("[WRN] %s: " fmt "\n", \
|
||||
__func__, ## __VA_ARGS__);
|
||||
|
||||
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
|
||||
#define SYS_LOG_DOMAIN "bttester"
|
||||
|
||||
#define sys_cpu_to_le32 htole32
|
||||
#define sys_le32_to_cpu le32toh
|
||||
#define sys_cpu_to_le16 htole16
|
||||
|
||||
struct btp_hdr {
|
||||
uint8_t service;
|
||||
uint8_t opcode;
|
||||
uint8_t index;
|
||||
uint16_t len;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_STATUS 0x00
|
||||
struct btp_status {
|
||||
uint8_t code;
|
||||
} __packed;
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_core.h - Bluetooth tester Core service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Core Service */
|
||||
#define BTP_CORE_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_core_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_CORE_READ_SUPPORTED_SERVICES 0x02
|
||||
struct btp_core_read_supported_services_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_CORE_REGISTER_SERVICE 0x03
|
||||
struct btp_core_register_service_cmd {
|
||||
uint8_t id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_CORE_UNREGISTER_SERVICE 0x04
|
||||
struct btp_core_unregister_service_cmd {
|
||||
uint8_t id;
|
||||
} __packed;
|
||||
|
||||
/* events */
|
||||
#define BTP_CORE_EV_IUT_READY 0x80
|
||||
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_gap.h - Bluetooth tester GAP service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* GAP Service */
|
||||
/* commands */
|
||||
#define BTP_GAP_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_gap_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_READ_CONTROLLER_INDEX_LIST 0x02
|
||||
struct btp_gap_read_controller_index_list_rp {
|
||||
uint8_t num;
|
||||
uint8_t index[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SETTINGS_POWERED 0
|
||||
#define BTP_GAP_SETTINGS_CONNECTABLE 1
|
||||
#define BTP_GAP_SETTINGS_FAST_CONNECTABLE 2
|
||||
#define BTP_GAP_SETTINGS_DISCOVERABLE 3
|
||||
#define BTP_GAP_SETTINGS_BONDABLE 4
|
||||
#define BTP_GAP_SETTINGS_LINK_SEC_3 5
|
||||
#define BTP_GAP_SETTINGS_SSP 6
|
||||
#define BTP_GAP_SETTINGS_BREDR 7
|
||||
#define BTP_GAP_SETTINGS_HS 8
|
||||
#define BTP_GAP_SETTINGS_LE 9
|
||||
#define BTP_GAP_SETTINGS_ADVERTISING 10
|
||||
#define BTP_GAP_SETTINGS_SC 11
|
||||
#define BTP_GAP_SETTINGS_DEBUG_KEYS 12
|
||||
#define BTP_GAP_SETTINGS_PRIVACY 13
|
||||
#define BTP_GAP_SETTINGS_CONTROLLER_CONFIG 14
|
||||
#define BTP_GAP_SETTINGS_STATIC_ADDRESS 15
|
||||
|
||||
#define BTP_GAP_READ_CONTROLLER_INFO 0x03
|
||||
struct btp_gap_read_controller_info_rp {
|
||||
uint8_t address[6];
|
||||
uint32_t supported_settings;
|
||||
uint32_t current_settings;
|
||||
uint8_t cod[3];
|
||||
uint8_t name[249];
|
||||
uint8_t short_name[11];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_RESET 0x04
|
||||
struct btp_gap_reset_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_POWERED 0x05
|
||||
struct btp_gap_set_powered_cmd {
|
||||
uint8_t powered;
|
||||
} __packed;
|
||||
struct btp_gap_set_powered_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_CONNECTABLE 0x06
|
||||
struct btp_gap_set_connectable_cmd {
|
||||
uint8_t connectable;
|
||||
} __packed;
|
||||
struct btp_gap_set_connectable_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_FAST_CONNECTABLE 0x07
|
||||
struct btp_gap_set_fast_connectable_cmd {
|
||||
uint8_t fast_connectable;
|
||||
} __packed;
|
||||
struct btp_gap_set_fast_connectable_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_NON_DISCOVERABLE 0x00
|
||||
#define BTP_GAP_GENERAL_DISCOVERABLE 0x01
|
||||
#define BTP_GAP_LIMITED_DISCOVERABLE 0x02
|
||||
|
||||
#define BTP_GAP_SET_DISCOVERABLE 0x08
|
||||
struct btp_gap_set_discoverable_cmd {
|
||||
uint8_t discoverable;
|
||||
} __packed;
|
||||
struct btp_gap_set_discoverable_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_BONDABLE 0x09
|
||||
struct btp_gap_set_bondable_cmd {
|
||||
uint8_t bondable;
|
||||
} __packed;
|
||||
struct btp_gap_set_bondable_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_START_ADVERTISING 0x0a
|
||||
struct btp_gap_start_advertising_cmd {
|
||||
uint8_t adv_data_len;
|
||||
uint8_t scan_rsp_len;
|
||||
uint8_t adv_data[0];
|
||||
uint8_t scan_rsp[0];
|
||||
} __packed;
|
||||
struct btp_gap_start_advertising_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_STOP_ADVERTISING 0x0b
|
||||
struct btp_gap_stop_advertising_rp {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#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_LE_ACTIVE_SCAN 0x08
|
||||
#define BTP_GAP_DISCOVERY_FLAG_LE_OBSERVE 0x10
|
||||
|
||||
#define BTP_GAP_START_DISCOVERY 0x0c
|
||||
struct btp_gap_start_discovery_cmd {
|
||||
uint8_t flags;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_STOP_DISCOVERY 0x0d
|
||||
|
||||
#define BTP_GAP_CONNECT 0x0e
|
||||
struct btp_gap_connect_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_DISCONNECT 0x0f
|
||||
struct btp_gap_disconnect_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_IO_CAP_DISPLAY_ONLY 0
|
||||
#define BTP_GAP_IO_CAP_DISPLAY_YESNO 1
|
||||
#define BTP_GAP_IO_CAP_KEYBOARD_ONLY 2
|
||||
#define BTP_GAP_IO_CAP_NO_INPUT_OUTPUT 3
|
||||
#define BTP_GAP_IO_CAP_KEYBOARD_DISPLAY 4
|
||||
|
||||
#define BTP_GAP_SET_IO_CAP 0x10
|
||||
struct btp_gap_set_io_cap_cmd {
|
||||
uint8_t io_cap;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_PAIR 0x11
|
||||
struct btp_gap_pair_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_UNPAIR 0x12
|
||||
struct btp_gap_unpair_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_PASSKEY_ENTRY 0x13
|
||||
struct btp_gap_passkey_entry_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint32_t passkey;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_PASSKEY_CONFIRM 0x14
|
||||
struct btp_gap_passkey_confirm_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t match;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_START_DIRECT_ADV 0x15
|
||||
struct btp_gap_start_direct_adv_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t high_duty;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_CONN_PARAM_UPDATE 0x16
|
||||
struct btp_gap_conn_param_update_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t conn_itvl_min;
|
||||
uint16_t conn_itvl_max;
|
||||
uint16_t conn_latency;
|
||||
uint16_t supervision_timeout;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_PAIRING_CONSENT_RSP 0x17
|
||||
struct btp_gap_pairing_consent_rsp_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t consent;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_OOB_LEGACY_SET_DATA 0x18
|
||||
struct btp_gap_oob_legacy_set_data_cmd {
|
||||
uint8_t oob_data[16];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_OOB_SC_GET_LOCAL_DATA 0x19
|
||||
struct btp_gap_oob_sc_get_local_data_rp {
|
||||
uint8_t r[16];
|
||||
uint8_t c[16];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_OOB_SC_SET_REMOTE_DATA 0x1a
|
||||
struct btp_gap_oob_sc_set_remote_data_cmd {
|
||||
uint8_t r[16];
|
||||
uint8_t c[16];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_MITM 0x1b
|
||||
struct btp_gap_set_mitm_cmd {
|
||||
uint8_t mitm;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_SET_FILTER_ACCEPT_LIST 0x1c
|
||||
struct btp_gap_set_filter_accept_list_cmd {
|
||||
uint8_t list_len;
|
||||
ble_addr_t addrs[];
|
||||
} __packed;
|
||||
/* events */
|
||||
#define BTP_GAP_EV_NEW_SETTINGS 0x80
|
||||
struct btp_gap_new_settings_ev {
|
||||
uint32_t current_settings;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_DEVICE_FOUND_FLAG_RSSI 0x01
|
||||
#define BTP_GAP_DEVICE_FOUND_FLAG_AD 0x02
|
||||
#define BTP_GAP_DEVICE_FOUND_FLAG_SD 0x04
|
||||
|
||||
#define BTP_GAP_EV_DEVICE_FOUND 0x81
|
||||
struct btp_gap_device_found_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
int8_t rssi;
|
||||
uint8_t flags;
|
||||
uint16_t eir_data_len;
|
||||
uint8_t eir_data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_DEVICE_CONNECTED 0x82
|
||||
struct btp_gap_device_connected_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t conn_itvl;
|
||||
uint16_t conn_latency;
|
||||
uint16_t supervision_timeout;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_DEVICE_DISCONNECTED 0x83
|
||||
struct btp_gap_device_disconnected_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_PASSKEY_DISPLAY 0x84
|
||||
struct btp_gap_passkey_display_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint32_t passkey;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_PASSKEY_ENTRY_REQ 0x85
|
||||
struct btp_gap_passkey_entry_req_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_PASSKEY_CONFIRM_REQ 0x86
|
||||
struct btp_gap_passkey_confirm_req_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint32_t passkey;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_IDENTITY_RESOLVED 0x87
|
||||
struct btp_gap_identity_resolved_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t identity_address_type;
|
||||
uint8_t identity_address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_CONN_PARAM_UPDATE 0x88
|
||||
struct btp_gap_conn_param_update_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t conn_itvl;
|
||||
uint16_t conn_latency;
|
||||
uint16_t supervision_timeout;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_SEC_LEVEL_CHANGED 0x89
|
||||
struct btp_gap_sec_level_changed_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t level;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_PAIRING_CONSENT_REQ 0x8a
|
||||
struct btp_gap_pairing_consent_req_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_BOND_LOST 0x8b
|
||||
struct btp_gap_bond_lost_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GAP_EV_SEC_PAIRING_FAILED 0x8c
|
||||
struct btp_gap_sec_pairing_failed_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t reason;
|
||||
} __packed;
|
||||
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_gatt.h - Bluetooth tester GATT service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* GATT Service */
|
||||
/* commands */
|
||||
#define BTP_GATT_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_gatt_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_SERVICE_PRIMARY 0x00
|
||||
#define BTP_GATT_SERVICE_SECONDARY 0x01
|
||||
|
||||
#define BTP_GATT_ADD_SERVICE 0x02
|
||||
struct btp_gatt_add_service_cmd {
|
||||
uint8_t type;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
struct btp_gatt_add_service_rp {
|
||||
uint16_t svc_id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_ADD_CHARACTERISTIC 0x03
|
||||
struct btp_gatt_add_characteristic_cmd {
|
||||
uint16_t svc_id;
|
||||
uint8_t properties;
|
||||
uint8_t permissions;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
struct btp_gatt_add_characteristic_rp {
|
||||
uint16_t char_id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_ADD_DESCRIPTOR 0x04
|
||||
struct btp_gatt_add_descriptor_cmd {
|
||||
uint16_t char_id;
|
||||
uint8_t permissions;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
struct btp_gatt_add_descriptor_rp {
|
||||
uint16_t desc_id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_ADD_INCLUDED_SERVICE 0x05
|
||||
struct btp_gatt_add_included_service_cmd {
|
||||
uint16_t svc_id;
|
||||
} __packed;
|
||||
struct btp_gatt_add_included_service_rp {
|
||||
uint16_t included_service_id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_SET_VALUE 0x06
|
||||
struct btp_gatt_set_value_cmd {
|
||||
uint16_t attr_id;
|
||||
uint16_t len;
|
||||
uint8_t value[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_START_SERVER 0x07
|
||||
struct btp_gatt_start_server_rp {
|
||||
uint16_t db_attr_off;
|
||||
uint8_t db_attr_cnt;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_SET_ENC_KEY_SIZE 0x09
|
||||
struct btp_gatt_set_enc_key_size_cmd {
|
||||
uint16_t attr_id;
|
||||
uint8_t key_size;
|
||||
} __packed;
|
||||
|
||||
struct btp_gatt_service {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
struct btp_gatt_included {
|
||||
uint16_t included_handle;
|
||||
struct btp_gatt_service service;
|
||||
} __packed;
|
||||
|
||||
struct btp_gatt_read_uuid_chr {
|
||||
uint16_t handle;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
struct btp_gatt_characteristic {
|
||||
uint16_t characteristic_handle;
|
||||
uint16_t value_handle;
|
||||
uint8_t properties;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
struct btp_gatt_descriptor {
|
||||
uint16_t descriptor_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_EXCHANGE_MTU 0x0a
|
||||
|
||||
#define BTP_GATT_DISC_ALL_PRIM_SVCS 0x0b
|
||||
struct btp_gatt_disc_all_prim_svcs_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
struct btp_gatt_disc_all_prim_svcs_rp {
|
||||
uint8_t services_count;
|
||||
struct btp_gatt_service services[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_DISC_PRIM_UUID 0x0c
|
||||
struct btp_gatt_disc_prim_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
struct btp_gatt_disc_prim_uuid_rp {
|
||||
uint8_t services_count;
|
||||
struct btp_gatt_service services[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_FIND_INCLUDED 0x0d
|
||||
struct btp_gatt_find_included_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
struct btp_gatt_find_included_rp {
|
||||
uint8_t services_count;
|
||||
struct btp_gatt_included included[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_DISC_ALL_CHRC 0x0e
|
||||
struct btp_gatt_disc_all_chrc_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
struct btp_gatt_disc_chrc_rp {
|
||||
uint8_t characteristics_count;
|
||||
struct btp_gatt_characteristic characteristics[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_DISC_CHRC_UUID 0x0f
|
||||
struct btp_gatt_disc_chrc_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_DISC_ALL_DESC 0x10
|
||||
struct btp_gatt_disc_all_desc_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
struct btp_gatt_disc_all_desc_rp {
|
||||
uint8_t descriptors_count;
|
||||
struct btp_gatt_descriptor descriptors[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_READ 0x11
|
||||
struct btp_gatt_read_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
} __packed;
|
||||
struct btp_gatt_read_rp {
|
||||
uint8_t att_response;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_READ_UUID 0x12
|
||||
struct btp_gatt_read_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_READ_LONG 0x13
|
||||
struct btp_gatt_read_long_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_READ_MULTIPLE 0x14
|
||||
struct btp_gatt_read_multiple_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t handles_count;
|
||||
uint16_t handles[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_WRITE_WITHOUT_RSP 0x15
|
||||
struct btp_gatt_write_without_rsp_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_SIGNED_WRITE_WITHOUT_RSP 0x16
|
||||
struct btp_gatt_signed_write_without_rsp_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_WRITE 0x17
|
||||
struct btp_gatt_write_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_WRITE_LONG 0x18
|
||||
struct btp_gatt_write_long_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_RELIABLE_WRITE 0x19
|
||||
struct btp_gatt_reliable_write_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_CFG_NOTIFY 0x1a
|
||||
#define BTP_GATT_CFG_INDICATE 0x1b
|
||||
struct btp_gatt_cfg_notify_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t enable;
|
||||
uint16_t ccc_handle;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_GET_ATTRIBUTES 0x1c
|
||||
struct btp_gatt_get_attributes_cmd {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t type_length;
|
||||
uint8_t type[0];
|
||||
} __packed;
|
||||
struct btp_gatt_get_attributes_rp {
|
||||
uint8_t attrs_count;
|
||||
uint8_t attrs[0];
|
||||
} __packed;
|
||||
struct btp_gatt_attr {
|
||||
uint16_t handle;
|
||||
uint8_t permission;
|
||||
uint8_t type_length;
|
||||
uint8_t type[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_GET_ATTRIBUTE_VALUE 0x1d
|
||||
struct btp_gatt_get_attribute_value_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
} __packed;
|
||||
struct btp_gatt_get_attribute_value_rp {
|
||||
uint8_t att_response;
|
||||
uint16_t value_length;
|
||||
uint8_t value[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_CHANGE_DATABASE 0x1e
|
||||
struct btp_gatt_change_database {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t visibility;
|
||||
} __packed;
|
||||
|
||||
/* GATT events */
|
||||
#define BTP_GATT_EV_NOTIFICATION 0x80
|
||||
struct btp_gatt_notification_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t type;
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATT_EV_ATTR_VALUE_CHANGED 0x81
|
||||
struct btp_gatt_attr_value_changed_ev {
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_gattc.h - Bluetooth tester GATT Client service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* GATT Client Service */
|
||||
/* commands */
|
||||
#define BTP_GATTC_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_gattc_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_EXCHANGE_MTU 0x02
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_PRIM_SVCS 0x03
|
||||
struct btp_gattc_disc_all_prim_svcs_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_PRIM_UUID 0x04
|
||||
struct btp_gattc_disc_prim_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_FIND_INCLUDED 0x05
|
||||
struct btp_gattc_find_included_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_CHRC 0x06
|
||||
struct btp_gattc_disc_all_chrc_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_CHRC_UUID 0x07
|
||||
struct btp_gattc_disc_chrc_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_DESC 0x08
|
||||
struct btp_gattc_disc_all_desc_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_READ 0x09
|
||||
struct btp_gattc_read_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_READ_UUID 0x0a
|
||||
struct btp_gattc_read_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint8_t uuid_length;
|
||||
uint8_t uuid[0];
|
||||
} __packed;
|
||||
struct btp_gattc_read_uuid_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint16_t data_length;
|
||||
uint8_t value_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_READ_LONG 0x0b
|
||||
struct btp_gattc_read_long_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_READ_MULTIPLE 0x0c
|
||||
struct btp_gattc_read_multiple_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t handles_count;
|
||||
uint16_t handles[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_WRITE_WITHOUT_RSP 0x0d
|
||||
struct btp_gattc_write_without_rsp_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_SIGNED_WRITE_WITHOUT_RSP 0x0e
|
||||
struct btp_gattc_signed_write_without_rsp_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_WRITE 0x0f
|
||||
struct btp_gattc_write_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_WRITE_LONG 0x10
|
||||
struct btp_gattc_write_long_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_RELIABLE_WRITE 0x11
|
||||
struct btp_gattc_reliable_write_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_CFG_NOTIFY 0x12
|
||||
#define BTP_GATTC_CFG_INDICATE 0x13
|
||||
struct btp_gattc_cfg_notify_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t enable;
|
||||
uint16_t ccc_handle;
|
||||
} __packed;
|
||||
|
||||
/* events */
|
||||
#define BTP_GATTC_EV_MTU_EXCHANGED 0x80
|
||||
struct btp_gattc_exchange_mtu_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t mtu;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_PRIM_RP 0x81
|
||||
struct btp_gattc_disc_prim_svcs_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint8_t services_count;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_PRIM_UUID_RP 0x82
|
||||
|
||||
#define BTP_GATTC_FIND_INCLUDED_RP 0x83
|
||||
struct btp_gattc_find_included_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint8_t services_count;
|
||||
struct btp_gatt_included included[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_CHRC_RP 0x84
|
||||
#define BTP_GATTC_DISC_CHRC_UUID_RP 0x85
|
||||
struct btp_gattc_disc_chrc_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint8_t characteristics_count;
|
||||
struct btp_gatt_characteristic characteristics[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_DISC_ALL_DESC_RP 0x86
|
||||
struct btp_gattc_disc_all_desc_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint8_t descriptors_count;
|
||||
struct btp_gatt_descriptor descriptors[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_READ_RP 0x87
|
||||
#define BTP_GATTC_READ_UUID_RP 0x88
|
||||
#define BTP_GATTC_READ_LONG_RP 0x89
|
||||
#define BTP_GATTC_READ_MULTIPLE_RP 0x8a
|
||||
struct btp_gattc_read_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_WRITE_RP 0x8b
|
||||
struct btp_gattc_write_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
#define BTP_GATTC_WRITE_LONG_RP 0x8c
|
||||
#define BTP_GATTC_RELIABLE_WRITE_RP 0x8d
|
||||
#define BTP_GATTC_CFG_NOTIFY_RP 0x8e
|
||||
#define BTP_GATTC_CFG_INDICATE_RP 0x8f
|
||||
struct btp_subscribe_rp {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
|
||||
#define BTP_GATTC_EV_NOTIFICATION_RXED 0x90
|
||||
struct btp_gattc_notification_ev {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint8_t type;
|
||||
uint16_t handle;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_l2cap.h - Bluetooth tester L2CAP service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* L2CAP Service */
|
||||
/* commands */
|
||||
#define BTP_L2CAP_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_l2cap_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_CONNECT_OPT_ECFC 0x01
|
||||
#define BTP_L2CAP_CONNECT_OPT_HOLD_CREDIT 0x02
|
||||
|
||||
#define BTP_L2CAP_CONNECT 0x02
|
||||
struct btp_l2cap_connect_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t psm;
|
||||
uint16_t mtu;
|
||||
uint8_t num;
|
||||
uint8_t options;
|
||||
} __packed;
|
||||
|
||||
struct btp_l2cap_connect_rp {
|
||||
uint8_t num;
|
||||
uint8_t chan_ids[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_DISCONNECT 0x03
|
||||
struct btp_l2cap_disconnect_cmd {
|
||||
uint8_t chan_id;
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_SEND_DATA 0x04
|
||||
struct btp_l2cap_send_data_cmd {
|
||||
uint8_t chan_id;
|
||||
uint16_t data_len;
|
||||
uint8_t data[];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_TRANSPORT_BREDR 0x00
|
||||
#define BTP_L2CAP_TRANSPORT_LE 0x01
|
||||
|
||||
#define BTP_L2CAP_LISTEN 0x05
|
||||
struct btp_l2cap_listen_cmd {
|
||||
uint16_t psm;
|
||||
uint8_t transport;
|
||||
uint16_t mtu;
|
||||
uint16_t response;
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_ACCEPT_CONNECTION 0x06
|
||||
struct l2cap_accept_connection_cmd {
|
||||
uint8_t chan_id;
|
||||
uint16_t result;
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_RECONFIGURE 0x07
|
||||
struct btp_l2cap_reconfigure_cmd {
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
uint16_t mtu;
|
||||
uint8_t num;
|
||||
uint8_t idxs[];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_CREDITS 0x08
|
||||
struct btp_l2cap_credits_cmd {
|
||||
uint8_t chan_id;
|
||||
} __packed;
|
||||
|
||||
/* events */
|
||||
#define BTP_L2CAP_EV_CONNECTION_REQ 0x80
|
||||
struct btp_l2cap_connection_req_ev {
|
||||
uint8_t chan_id;
|
||||
uint16_t psm;
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_EV_CONNECTED 0x81
|
||||
struct btp_l2cap_connected_ev {
|
||||
uint8_t chan_id;
|
||||
uint16_t psm;
|
||||
uint16_t peer_mtu;
|
||||
uint16_t peer_mps;
|
||||
uint16_t our_mtu;
|
||||
uint16_t our_mps;
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_EV_DISCONNECTED 0x82
|
||||
struct btp_l2cap_disconnected_ev {
|
||||
uint16_t result;
|
||||
uint8_t chan_id;
|
||||
uint16_t psm;
|
||||
uint8_t address_type;
|
||||
uint8_t address[6];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_EV_DATA_RECEIVED 0x83
|
||||
struct btp_l2cap_data_received_ev {
|
||||
uint8_t chan_id;
|
||||
uint16_t data_length;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_L2CAP_EV_RECONFIGURED 0x84
|
||||
struct btp_l2cap_reconfigured_ev {
|
||||
uint8_t chan_id;
|
||||
uint16_t peer_mtu;
|
||||
uint16_t peer_mps;
|
||||
uint16_t our_mtu;
|
||||
uint16_t our_mps;
|
||||
} __packed;
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_mesh.h - Bluetooth tester MESH service headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* MESH Service */
|
||||
/* commands */
|
||||
#define BTP_MESH_READ_SUPPORTED_COMMANDS 0x01
|
||||
struct btp_mesh_read_supported_commands_rp {
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_OUT_BLINK BIT(0)
|
||||
#define BTP_MESH_OUT_BEEP BIT(1)
|
||||
#define BTP_MESH_OUT_VIBRATE BIT(2)
|
||||
#define BTP_MESH_OUT_DISPLAY_NUMBER BIT(3)
|
||||
#define BTP_MESH_OUT_DISPLAY_STRING BIT(4)
|
||||
|
||||
#define BTP_MESH_IN_PUSH BIT(0)
|
||||
#define BTP_MESH_IN_TWIST BIT(1)
|
||||
#define BTP_MESH_IN_ENTER_NUMBER BIT(2)
|
||||
#define BTP_MESH_IN_ENTER_STRING BIT(3)
|
||||
|
||||
#define BTP_MESH_CONFIG_PROVISIONING 0x02
|
||||
struct btp_mesh_config_provisioning_cmd {
|
||||
uint8_t uuid[16];
|
||||
uint8_t static_auth[16];
|
||||
uint8_t out_size;
|
||||
uint16_t out_actions;
|
||||
uint8_t in_size;
|
||||
uint16_t in_actions;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_PROVISION_NODE 0x03
|
||||
struct btp_mesh_provision_node_cmd {
|
||||
uint8_t net_key[16];
|
||||
uint16_t net_key_idx;
|
||||
uint8_t flags;
|
||||
uint32_t iv_index;
|
||||
uint32_t seq_num;
|
||||
uint16_t addr;
|
||||
uint8_t dev_key[16];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_INIT 0x04
|
||||
#define BTP_MESH_RESET 0x05
|
||||
#define BTP_MESH_INPUT_NUMBER 0x06
|
||||
struct btp_mesh_input_number_cmd {
|
||||
uint32_t number;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_INPUT_STRING 0x07
|
||||
struct btp_mesh_input_string_cmd {
|
||||
uint8_t string_len;
|
||||
uint8_t string[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_IVU_TEST_MODE 0x08
|
||||
struct btp_mesh_ivu_test_mode_cmd {
|
||||
uint8_t enable;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_IVU_TOGGLE_STATE 0x09
|
||||
|
||||
#define BTP_MESH_NET_SEND 0x0a
|
||||
struct btp_mesh_net_send_cmd {
|
||||
uint8_t ttl;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t payload_len;
|
||||
uint8_t payload[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_HEALTH_GENERATE_FAULTS 0x0b
|
||||
struct btp_mesh_health_generate_faults_rp {
|
||||
uint8_t test_id;
|
||||
uint8_t cur_faults_count;
|
||||
uint8_t reg_faults_count;
|
||||
uint8_t current_faults[0];
|
||||
uint8_t registered_faults[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_HEALTH_CLEAR_FAULTS 0x0c
|
||||
|
||||
#define BTP_MESH_LPN 0x0d
|
||||
struct btp_mesh_lpn_set_cmd {
|
||||
uint8_t enable;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_LPN_POLL 0x0e
|
||||
|
||||
#define BTP_MESH_MODEL_SEND 0x0f
|
||||
struct btp_mesh_model_send_cmd {
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t payload_len;
|
||||
uint8_t payload[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_LPN_SUBSCRIBE 0x10
|
||||
struct btp_mesh_lpn_subscribe_cmd {
|
||||
uint16_t address;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_LPN_UNSUBSCRIBE 0x11
|
||||
struct btp_mesh_lpn_unsubscribe_cmd {
|
||||
uint16_t address;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_RPL_CLEAR 0x12
|
||||
#define BTP_MESH_PROXY_IDENTITY 0x13
|
||||
|
||||
/* events */
|
||||
#define BTP_MESH_EV_OUT_NUMBER_ACTION 0x80
|
||||
struct btp_mesh_out_number_action_ev {
|
||||
uint16_t action;
|
||||
uint32_t number;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_OUT_STRING_ACTION 0x81
|
||||
struct btp_mesh_out_string_action_ev {
|
||||
uint8_t string_len;
|
||||
uint8_t string[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_IN_ACTION 0x82
|
||||
struct btp_mesh_in_action_ev {
|
||||
uint16_t action;
|
||||
uint8_t size;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_PROVISIONED 0x83
|
||||
|
||||
#define BTP_MESH_PROV_BEARER_PB_ADV 0x00
|
||||
#define BTP_MESH_PROV_BEARER_PB_GATT 0x01
|
||||
#define BTP_MESH_EV_PROV_LINK_OPEN 0x84
|
||||
struct btp_mesh_prov_link_open_ev {
|
||||
uint8_t bearer;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_PROV_LINK_CLOSED 0x85
|
||||
struct btp_mesh_prov_link_closed_ev {
|
||||
uint8_t bearer;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_NET_RECV 0x86
|
||||
struct btp_mesh_net_recv_ev {
|
||||
uint8_t ttl;
|
||||
uint8_t ctl;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t payload_len;
|
||||
uint8_t payload[0];
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_INVALID_BEARER 0x87
|
||||
struct btp_mesh_invalid_bearer_ev {
|
||||
uint8_t opcode;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_INCOMP_TIMER_EXP 0x88
|
||||
|
||||
#define BTP_MESH_EV_LPN_ESTABLISHED 0x8b
|
||||
struct btp_mesh_lpn_established_ev {
|
||||
uint16_t net_idx;
|
||||
uint16_t friend_addr;
|
||||
uint8_t queue_size;
|
||||
uint8_t recv_win;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_LPN_TERMINATED 0x8c
|
||||
struct btp_mesh_lpn_terminated_ev {
|
||||
uint16_t net_idx;
|
||||
uint16_t friend_addr;
|
||||
} __packed;
|
||||
|
||||
#define BTP_MESH_EV_LPN_POLLED 0x8d
|
||||
struct btp_mesh_lpn_polled_ev {
|
||||
uint16_t net_idx;
|
||||
uint16_t friend_addr;
|
||||
uint8_t retry;
|
||||
} __packed;
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* bttester.h - Bluetooth tester headers */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __BTTESTER_H__
|
||||
#define __BTTESTER_H__
|
||||
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "host/ble_gatt.h"
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
#include "mesh/glue.h"
|
||||
#else
|
||||
#include "glue.h"
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
tester_set_bit(uint8_t *addr, unsigned int bit)
|
||||
{
|
||||
uint8_t *p = addr + (bit / 8);
|
||||
|
||||
*p |= BIT(bit % 8);
|
||||
}
|
||||
|
||||
static inline uint8_t
|
||||
tester_test_bit(const uint8_t *addr, unsigned int bit)
|
||||
{
|
||||
const uint8_t *p = addr + (bit / 8);
|
||||
|
||||
return *p & BIT(bit % 8);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tester_init(void);
|
||||
void
|
||||
tester_rsp(uint8_t service, uint8_t opcode, uint8_t index, uint8_t status);
|
||||
void
|
||||
tester_send(uint8_t service, uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
size_t len);
|
||||
void
|
||||
tester_send_buf(uint8_t service, uint8_t opcode, uint8_t index,
|
||||
struct os_mbuf *buf);
|
||||
|
||||
uint8_t
|
||||
tester_init_gap(void);
|
||||
uint8_t
|
||||
tester_unregister_gap(void);
|
||||
void
|
||||
tester_handle_gap(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len);
|
||||
void
|
||||
tester_handle_core(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len);
|
||||
uint8_t
|
||||
tester_init_gatt(void);
|
||||
uint8_t
|
||||
tester_unregister_gatt(void);
|
||||
void
|
||||
tester_handle_gatt(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len);
|
||||
void
|
||||
tester_handle_gattc(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len);
|
||||
int
|
||||
tester_gattc_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle,
|
||||
uint8_t indication, struct os_mbuf *om);
|
||||
int
|
||||
tester_gatt_subscribe_ev(uint16_t conn_handle,
|
||||
uint16_t attr_handle,
|
||||
uint8_t reason,
|
||||
uint8_t prev_notify,
|
||||
uint8_t cur_notify,
|
||||
uint8_t prev_indicate,
|
||||
uint8_t cur_indicate);
|
||||
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
uint8_t
|
||||
tester_init_l2cap(void);
|
||||
uint8_t
|
||||
tester_unregister_l2cap(void);
|
||||
void
|
||||
tester_handle_l2cap(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len);
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
uint8_t
|
||||
tester_init_mesh(void);
|
||||
uint8_t
|
||||
tester_unregister_mesh(void);
|
||||
void
|
||||
tester_handle_mesh(uint8_t opcode, uint8_t index, uint8_t *data, uint16_t len);
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
|
||||
void
|
||||
gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg);
|
||||
|
||||
int
|
||||
gatt_svr_init(void);
|
||||
#endif /* __BTTESTER_H__ */
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* btp_core.c - Bluetooth BTP Core service */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Codecoup
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "btp/btp.h"
|
||||
|
||||
static void
|
||||
supported_commands(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buf[1];
|
||||
struct core_read_supported_commands_rp *rp = (void *) buf;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
tester_set_bit(buf, BTP_CORE_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(buf, BTP_CORE_READ_SUPPORTED_SERVICES);
|
||||
tester_set_bit(buf, BTP_CORE_REGISTER_SERVICE);
|
||||
tester_set_bit(buf, BTP_CORE_UNREGISTER_SERVICE);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_CORE, BTP_CORE_READ_SUPPORTED_COMMANDS,
|
||||
BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf));
|
||||
}
|
||||
|
||||
static void
|
||||
supported_services(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buf[1];
|
||||
struct core_read_supported_services_rp *rp = (void *) buf;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_CORE);
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GAP);
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GATT);
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_L2CAP);
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_MESH);
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GATTC);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_CORE, BTP_CORE_READ_SUPPORTED_SERVICES,
|
||||
BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf));
|
||||
}
|
||||
|
||||
static void
|
||||
register_service(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct core_register_service_cmd *cmd = (void *) data;
|
||||
uint8_t status;
|
||||
|
||||
switch (cmd->id) {
|
||||
case BTP_SERVICE_ID_GAP:
|
||||
status = tester_init_gap();
|
||||
/* Rsp with success status will be handled by bt enable cb */
|
||||
if (status == BTP_STATUS_FAILED) {
|
||||
goto rsp;
|
||||
}
|
||||
return;
|
||||
case BTP_SERVICE_ID_GATT:
|
||||
status = tester_init_gatt();
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
case BTP_SERVICE_ID_L2CAP:
|
||||
status = tester_init_l2cap();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
case BTP_SERVICE_ID_MESH:
|
||||
status = tester_init_mesh();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
default:
|
||||
status = BTP_STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, BTP_CORE_REGISTER_SERVICE, BTP_INDEX_NONE,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
unregister_service(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct core_unregister_service_cmd *cmd = (void *) data;
|
||||
uint8_t status;
|
||||
|
||||
switch (cmd->id) {
|
||||
case BTP_SERVICE_ID_GAP:
|
||||
status = tester_unregister_gap();
|
||||
break;
|
||||
case BTP_SERVICE_ID_GATT:
|
||||
status = tester_unregister_gatt();
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
case BTP_SERVICE_ID_L2CAP:
|
||||
status = tester_unregister_l2cap();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
case BTP_SERVICE_ID_MESH:
|
||||
status = tester_unregister_mesh();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
default:
|
||||
status = BTP_STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, BTP_CORE_UNREGISTER_SERVICE, BTP_INDEX_NONE,
|
||||
status);
|
||||
}
|
||||
|
||||
void
|
||||
tester_handle_core(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len)
|
||||
{
|
||||
if (index != BTP_INDEX_NONE) {
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, opcode, index,
|
||||
BTP_STATUS_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case BTP_CORE_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
return;
|
||||
case BTP_CORE_READ_SUPPORTED_SERVICES:
|
||||
supported_services(data, len);
|
||||
return;
|
||||
case BTP_CORE_REGISTER_SERVICE:
|
||||
register_service(data, len);
|
||||
return;
|
||||
case BTP_CORE_UNREGISTER_SERVICE:
|
||||
unregister_service(data, len);
|
||||
return;
|
||||
default:
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, opcode, BTP_INDEX_NONE,
|
||||
BTP_STATUS_UNKNOWN_CMD);
|
||||
return;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@
|
||||
#include "../../../nimble/host/src/ble_att_priv.h"
|
||||
#include "../../../nimble/host/src/ble_gatt_priv.h"
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
#define CONTROLLER_INDEX 0
|
||||
#define MAX_BUFFER_SIZE 2048
|
||||
@@ -255,8 +255,8 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
|
||||
static void
|
||||
attr_value_changed_ev(uint16_t handle, struct os_mbuf *data)
|
||||
{
|
||||
struct gatt_attr_value_changed_ev *ev;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
struct btp_gatt_attr_value_changed_ev *ev;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
@@ -267,7 +267,7 @@ attr_value_changed_ev(uint16_t handle, struct os_mbuf *data)
|
||||
ev->data_length = sys_cpu_to_le16(os_mbuf_len(data));
|
||||
os_mbuf_appendfrom(buf, data, 0, os_mbuf_len(data));
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, GATT_EV_ATTR_VALUE_CHANGED,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, BTP_GATT_EV_ATTR_VALUE_CHANGED,
|
||||
CONTROLLER_INDEX, buf);
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ gatt_svr_rel_write_test(uint16_t conn_handle, uint16_t attr_handle,
|
||||
static void
|
||||
start_server(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct gatt_start_server_rp rp;
|
||||
struct btp_gatt_start_server_rp rp;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
@@ -583,7 +583,7 @@ start_server(uint8_t *data, uint16_t len)
|
||||
rp.db_attr_off = 0;
|
||||
rp.db_attr_cnt = 0;
|
||||
|
||||
tester_send(BTP_SERVICE_ID_GATT, GATT_START_SERVER, CONTROLLER_INDEX,
|
||||
tester_send(BTP_SERVICE_ID_GATT, BTP_GATT_START_SERVER, CONTROLLER_INDEX,
|
||||
(uint8_t *) &rp, sizeof(rp));
|
||||
}
|
||||
|
||||
@@ -672,8 +672,8 @@ read_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gatt_read_rp *rp = (void *) gatt_buf.buf;
|
||||
uint8_t btp_opcode = (uint8_t) (int) arg;
|
||||
struct btp_gatt_read_rp *rp = (void *) gatt_buf.buf;
|
||||
uint8_t btp_opcode = (uint8_t) (int) arg;
|
||||
|
||||
SYS_LOG_DBG("status=%d", error->status);
|
||||
|
||||
@@ -703,8 +703,8 @@ read_cb(uint16_t conn_handle,
|
||||
static void
|
||||
read(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_read_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_read_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
int rc;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
@@ -717,12 +717,12 @@ read(uint8_t *data, uint16_t len)
|
||||
/* Clear buffer */
|
||||
read_destroy();
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_read_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_read(conn.conn_handle, sys_le16_to_cpu(cmd->handle),
|
||||
read_cb, (void *) GATT_READ)) {
|
||||
read_cb, (void *) BTP_GATT_READ)) {
|
||||
read_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -730,7 +730,7 @@ read(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_READ, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -740,8 +740,8 @@ read_long_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gatt_read_rp *rp = (void *) gatt_buf.buf;
|
||||
uint8_t btp_opcode = (uint8_t) (int) arg;
|
||||
struct btp_gatt_read_rp *rp = (void *) gatt_buf.buf;
|
||||
uint8_t btp_opcode = (uint8_t) (int) arg;
|
||||
|
||||
SYS_LOG_DBG("status=%d", error->status);
|
||||
|
||||
@@ -775,8 +775,8 @@ read_long_cb(uint16_t conn_handle,
|
||||
static void
|
||||
read_long(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_read_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_read_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
int rc;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
@@ -789,14 +789,14 @@ read_long(uint8_t *data, uint16_t len)
|
||||
/* Clear buffer */
|
||||
read_destroy();
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_read_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_read_long(conn.conn_handle,
|
||||
sys_le16_to_cpu(cmd->handle),
|
||||
sys_le16_to_cpu(cmd->offset),
|
||||
read_long_cb, (void *) GATT_READ_LONG)) {
|
||||
read_long_cb, (void *) BTP_GATT_READ_LONG)) {
|
||||
read_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -804,15 +804,15 @@ read_long(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_READ_LONG, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
read_multiple(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_read_multiple_cmd *cmd = (void *) data;
|
||||
uint16_t handles[cmd->handles_count];
|
||||
const struct btp_gatt_read_multiple_cmd *cmd = (void *) data;
|
||||
uint16_t handles[cmd->handles_count];
|
||||
struct ble_gap_conn_desc conn;
|
||||
int rc, i;
|
||||
|
||||
@@ -830,13 +830,13 @@ read_multiple(uint8_t *data, uint16_t len)
|
||||
/* Clear buffer */
|
||||
read_destroy();
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_read_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_read_mult(conn.conn_handle, handles,
|
||||
cmd->handles_count, read_cb,
|
||||
(void *) GATT_READ_MULTIPLE)) {
|
||||
(void *) BTP_GATT_READ_MULTIPLE)) {
|
||||
read_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -844,15 +844,15 @@ read_multiple(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ_MULTIPLE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_READ_MULTIPLE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
write_without_rsp(uint8_t *data, uint16_t len, uint8_t op, bool sign)
|
||||
{
|
||||
const struct gatt_write_without_rsp_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_write_without_rsp_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
|
||||
@@ -892,8 +892,8 @@ write_rsp(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||
static void
|
||||
write(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
int rc;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
@@ -905,22 +905,22 @@ write(uint8_t *data, uint16_t len)
|
||||
|
||||
if (ble_gattc_write_flat(conn.conn_handle, sys_le16_to_cpu(cmd->handle),
|
||||
cmd->data, sys_le16_to_cpu(cmd->data_length),
|
||||
write_rsp, (void *) GATT_WRITE)) {
|
||||
write_rsp, (void *) BTP_GATT_WRITE)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_WRITE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_WRITE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
write_long(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_write_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_write_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *om = NULL;
|
||||
int rc = 0;
|
||||
|
||||
@@ -941,7 +941,7 @@ write_long(uint8_t *data, uint16_t len)
|
||||
sys_le16_to_cpu(cmd->handle),
|
||||
sys_le16_to_cpu(cmd->offset),
|
||||
om, write_rsp,
|
||||
(void *) GATT_WRITE_LONG);
|
||||
(void *) BTP_GATT_WRITE_LONG);
|
||||
if (!rc) {
|
||||
return;
|
||||
}
|
||||
@@ -949,7 +949,7 @@ write_long(uint8_t *data, uint16_t len)
|
||||
fail:
|
||||
SYS_LOG_ERR("Failed to send Write Long request, rc=%d", rc);
|
||||
os_mbuf_free_chain(om);
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_WRITE_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_WRITE_LONG, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -964,7 +964,7 @@ reliable_write_rsp(uint16_t conn_handle,
|
||||
|
||||
SYS_LOG_DBG("Reliable write status %d", err);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_GATT, GATT_RELIABLE_WRITE,
|
||||
tester_send(BTP_SERVICE_ID_GATT, BTP_GATT_RELIABLE_WRITE,
|
||||
CONTROLLER_INDEX, &err, sizeof(err));
|
||||
return 0;
|
||||
}
|
||||
@@ -972,8 +972,8 @@ reliable_write_rsp(uint16_t conn_handle,
|
||||
static void
|
||||
reliable_write(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_reliable_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_reliable_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct ble_gatt_attr attr;
|
||||
struct os_mbuf *om = NULL;
|
||||
int rc;
|
||||
@@ -1007,7 +1007,7 @@ reliable_write(uint8_t *data, uint16_t len)
|
||||
fail:
|
||||
os_mbuf_free_chain(om);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_WRITE_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_WRITE_LONG, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -1020,8 +1020,8 @@ static struct bt_gatt_subscribe_params {
|
||||
static void
|
||||
read_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_read_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_read_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
ble_uuid_any_t uuid;
|
||||
int rc;
|
||||
|
||||
@@ -1039,14 +1039,14 @@ read_uuid(uint8_t *data, uint16_t len)
|
||||
/* Clear buffer */
|
||||
read_destroy();
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_read_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_read_by_uuid(conn.conn_handle,
|
||||
sys_le16_to_cpu(cmd->start_handle),
|
||||
sys_le16_to_cpu(cmd->end_handle), &uuid.u,
|
||||
read_long_cb, (void *) GATT_READ_UUID)) {
|
||||
read_long_cb, (void *) BTP_GATT_READ_UUID)) {
|
||||
read_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -1054,7 +1054,7 @@ read_uuid(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_READ, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -1063,9 +1063,9 @@ disc_prim_uuid_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_svc *gatt_svc, void *arg)
|
||||
{
|
||||
struct gatt_disc_prim_uuid_rp *rp = (void *) gatt_buf.buf;
|
||||
struct gatt_service *service;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gatt_disc_prim_uuid_rp *rp = (void *) gatt_buf.buf;
|
||||
struct btp_gatt_service *service;
|
||||
const ble_uuid_any_t *uuid;
|
||||
uint8_t uuid_length;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
|
||||
@@ -1120,22 +1120,22 @@ disc_all_desc_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_dsc *gatt_dsc,
|
||||
void *arg)
|
||||
{
|
||||
struct gatt_disc_all_desc_rp *rp = (void *) gatt_buf.buf;
|
||||
struct gatt_descriptor *dsc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gatt_disc_all_desc_rp *rp = (void *) gatt_buf.buf;
|
||||
struct btp_gatt_descriptor *dsc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
uint8_t uuid_length;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
if (error->status != 0 && error->status != BLE_HS_EDONE) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_DESC,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_DESC,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
discover_destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (error->status == BLE_HS_EDONE) {
|
||||
tester_send(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_DESC,
|
||||
tester_send(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_DESC,
|
||||
CONTROLLER_INDEX, gatt_buf.buf, gatt_buf.len);
|
||||
discover_destroy();
|
||||
return 0;
|
||||
@@ -1146,7 +1146,7 @@ disc_all_desc_cb(uint16_t conn_handle,
|
||||
|
||||
dsc = gatt_buf_reserve(sizeof(*dsc) + uuid_length);
|
||||
if (!dsc) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_DESC,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_DESC,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
discover_destroy();
|
||||
return BLE_HS_ENOMEM;
|
||||
@@ -1180,12 +1180,12 @@ disc_all_prim_svcs(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_disc_all_prim_svcs_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_disc_all_prim_svcs_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_disc_all_svcs(conn.conn_handle, disc_prim_uuid_cb,
|
||||
(void *) GATT_DISC_ALL_PRIM_SVCS)) {
|
||||
(void *) BTP_GATT_DISC_ALL_PRIM_SVCS)) {
|
||||
discover_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -1193,15 +1193,15 @@ disc_all_prim_svcs(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_PRIM_SVCS,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_PRIM_SVCS,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_all_desc(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_disc_all_desc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_disc_all_desc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
int rc;
|
||||
|
||||
@@ -1212,7 +1212,7 @@ disc_all_desc(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_disc_all_desc_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_disc_all_desc_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -1232,7 +1232,7 @@ disc_all_desc(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_DESC, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_DESC, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -1241,23 +1241,23 @@ find_included_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_svc *gatt_svc, void *arg)
|
||||
{
|
||||
struct gatt_find_included_rp *rp = (void *) gatt_buf.buf;
|
||||
struct gatt_included *included;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gatt_find_included_rp *rp = (void *) gatt_buf.buf;
|
||||
struct btp_gatt_included *included;
|
||||
const ble_uuid_any_t *uuid;
|
||||
int service_handle = (int) arg;
|
||||
uint8_t uuid_length;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
if (error->status != 0 && error->status != BLE_HS_EDONE) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_FIND_INCLUDED,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_FIND_INCLUDED,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
discover_destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (error->status == BLE_HS_EDONE) {
|
||||
tester_send(BTP_SERVICE_ID_GATT, GATT_FIND_INCLUDED,
|
||||
tester_send(BTP_SERVICE_ID_GATT, BTP_GATT_FIND_INCLUDED,
|
||||
CONTROLLER_INDEX, gatt_buf.buf, gatt_buf.len);
|
||||
discover_destroy();
|
||||
return 0;
|
||||
@@ -1268,7 +1268,7 @@ find_included_cb(uint16_t conn_handle,
|
||||
|
||||
included = gatt_buf_reserve(sizeof(*included) + uuid_length);
|
||||
if (!included) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_FIND_INCLUDED,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_FIND_INCLUDED,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
discover_destroy();
|
||||
return BLE_HS_ENOMEM;
|
||||
@@ -1299,9 +1299,9 @@ disc_chrc_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_chr *gatt_chr, void *arg)
|
||||
{
|
||||
struct gatt_disc_chrc_rp *rp = (void *) gatt_buf.buf;
|
||||
struct gatt_characteristic *chrc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gatt_disc_chrc_rp *rp = (void *) gatt_buf.buf;
|
||||
struct btp_gatt_characteristic *chrc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
uint8_t btp_opcode = (uint8_t) (int) arg;
|
||||
uint8_t uuid_length;
|
||||
|
||||
@@ -1353,8 +1353,8 @@ disc_chrc_cb(uint16_t conn_handle,
|
||||
static void
|
||||
disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_disc_chrc_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_disc_chrc_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
ble_uuid_any_t uuid;
|
||||
int rc;
|
||||
@@ -1370,7 +1370,7 @@ disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_disc_chrc_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_disc_chrc_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -1379,7 +1379,7 @@ disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
|
||||
if (ble_gattc_disc_chrs_by_uuid(conn.conn_handle, start_handle,
|
||||
end_handle, &uuid.u, disc_chrc_cb,
|
||||
(void *) GATT_DISC_CHRC_UUID)) {
|
||||
(void *) BTP_GATT_DISC_CHRC_UUID)) {
|
||||
discover_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -1387,15 +1387,15 @@ disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_CHRC_UUID, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_CHRC_UUID, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_prim_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_disc_prim_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_disc_prim_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
ble_uuid_any_t uuid;
|
||||
int rc;
|
||||
|
||||
@@ -1410,13 +1410,13 @@ disc_prim_uuid(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_disc_prim_uuid_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_disc_prim_uuid_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ble_gattc_disc_svc_by_uuid(conn.conn_handle,
|
||||
&uuid.u, disc_prim_uuid_cb,
|
||||
(void *) GATT_DISC_PRIM_UUID)) {
|
||||
(void *) BTP_GATT_DISC_PRIM_UUID)) {
|
||||
discover_destroy();
|
||||
goto fail;
|
||||
}
|
||||
@@ -1424,15 +1424,15 @@ disc_prim_uuid(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_PRIM_UUID, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_PRIM_UUID, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_disc_all_chrc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_disc_all_chrc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
int rc;
|
||||
|
||||
@@ -1444,7 +1444,7 @@ disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_disc_chrc_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_disc_chrc_rp))) {
|
||||
SYS_LOG_DBG("Buf reserve failed");
|
||||
goto fail;
|
||||
}
|
||||
@@ -1453,7 +1453,7 @@ disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
end_handle = sys_le16_to_cpu(cmd->end_handle);
|
||||
|
||||
rc = ble_gattc_disc_all_chrs(conn.conn_handle, start_handle, end_handle,
|
||||
disc_chrc_cb, (void *) GATT_DISC_ALL_CHRC);
|
||||
disc_chrc_cb, (void *) BTP_GATT_DISC_ALL_CHRC);
|
||||
if (rc) {
|
||||
discover_destroy();
|
||||
goto fail;
|
||||
@@ -1462,15 +1462,15 @@ disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_DISC_ALL_CHRC, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_DISC_ALL_CHRC, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
find_included(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_find_included_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_find_included_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
int service_handle_arg;
|
||||
int rc;
|
||||
@@ -1482,7 +1482,7 @@ find_included(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_find_included_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct btp_gatt_find_included_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -1500,7 +1500,7 @@ find_included(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_FIND_INCLUDED, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_FIND_INCLUDED, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -1512,13 +1512,13 @@ exchange_func(uint16_t conn_handle,
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
if (error->status) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_EXCHANGE_MTU,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_EXCHANGE_MTU,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_EXCHANGE_MTU, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_EXCHANGE_MTU, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
|
||||
return 0;
|
||||
@@ -1543,7 +1543,7 @@ exchange_mtu(uint8_t *data, uint16_t len)
|
||||
|
||||
return;
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_EXCHANGE_MTU,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_EXCHANGE_MTU,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
@@ -1555,7 +1555,7 @@ enable_subscription(uint16_t conn_handle, uint16_t ccc_handle,
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
op = (uint8_t) (value == 0x0001 ? GATT_CFG_NOTIFY : GATT_CFG_INDICATE);
|
||||
op = (uint8_t) (value == 0x0001 ? BTP_GATT_CFG_NOTIFY : BTP_GATT_CFG_INDICATE);
|
||||
|
||||
if (ble_gattc_write_flat(conn_handle, ccc_handle,
|
||||
&value, sizeof(value), NULL, NULL)) {
|
||||
@@ -1594,8 +1594,8 @@ disable_subscription(uint16_t conn_handle, uint16_t ccc_handle)
|
||||
static void
|
||||
config_subscription(uint8_t *data, uint16_t len, uint8_t op)
|
||||
{
|
||||
const struct gatt_cfg_notify_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_cfg_notify_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t ccc_handle = sys_le16_to_cpu(cmd->ccc_handle);
|
||||
uint8_t status;
|
||||
int rc;
|
||||
@@ -1612,7 +1612,7 @@ config_subscription(uint8_t *data, uint16_t len, uint8_t op)
|
||||
if (cmd->enable) {
|
||||
uint16_t value;
|
||||
|
||||
if (op == GATT_CFG_NOTIFY) {
|
||||
if (op == BTP_GATT_CFG_NOTIFY) {
|
||||
value = 0x0001;
|
||||
} else {
|
||||
value = 0x0002;
|
||||
@@ -1676,10 +1676,10 @@ flags_hs2btp(uint8_t flags)
|
||||
static void
|
||||
get_attrs(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_get_attributes_cmd *cmd = (void *) data;
|
||||
struct gatt_get_attributes_rp *rp;
|
||||
struct gatt_attr *gatt_attr;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const struct btp_gatt_get_attributes_cmd *cmd = (void *) data;
|
||||
struct btp_gatt_get_attributes_rp *rp;
|
||||
struct btp_gatt_attr *gatt_attr;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
uint16_t start_handle, end_handle;
|
||||
struct ble_att_svr_entry *entry = NULL;
|
||||
ble_uuid_any_t uuid;
|
||||
@@ -1742,12 +1742,12 @@ get_attrs(uint8_t *data, uint16_t len)
|
||||
|
||||
rp->attrs_count = count;
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, GATT_GET_ATTRIBUTES,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, BTP_GATT_GET_ATTRIBUTES,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
goto free;
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_GET_ATTRIBUTES, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_GET_ATTRIBUTES, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
free:
|
||||
os_mbuf_free_chain(buf);
|
||||
@@ -1756,9 +1756,9 @@ free:
|
||||
static void
|
||||
get_attr_val(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_get_attribute_value_cmd *cmd = (void *) data;
|
||||
struct gatt_get_attribute_value_rp *rp;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gatt_get_attribute_value_cmd *cmd = (void *) data;
|
||||
struct btp_gatt_get_attribute_value_rp *rp;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
uint16_t handle = sys_cpu_to_le16(cmd->handle);
|
||||
uint8_t out_att_err = 0;
|
||||
@@ -1777,7 +1777,7 @@ get_attr_val(uint8_t *data, uint16_t len)
|
||||
rp->att_response = out_att_err;
|
||||
rp->value_length = os_mbuf_len(buf) - sizeof(*rp);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, GATT_GET_ATTRIBUTE_VALUE,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, BTP_GATT_GET_ATTRIBUTE_VALUE,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
goto free;
|
||||
@@ -1792,7 +1792,7 @@ get_attr_val(uint8_t *data, uint16_t len)
|
||||
rp->att_response = out_att_err;
|
||||
rp->value_length = os_mbuf_len(buf) - sizeof(*rp);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, GATT_GET_ATTRIBUTE_VALUE,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, BTP_GATT_GET_ATTRIBUTE_VALUE,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
goto free;
|
||||
@@ -1805,7 +1805,7 @@ free:
|
||||
static void
|
||||
change_database(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_change_database *cmd = (void *) data;
|
||||
const struct btp_gatt_change_database *cmd = (void *) data;
|
||||
|
||||
SYS_LOG_DBG("")
|
||||
|
||||
@@ -1813,7 +1813,7 @@ change_database(uint8_t *data, uint16_t len)
|
||||
|
||||
ble_svc_gatt_changed(cmd->start_handle, cmd->end_handle);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, GATT_CHANGE_DATABASE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, BTP_GATT_CHANGE_DATABASE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
|
||||
return;
|
||||
@@ -1822,38 +1822,38 @@ change_database(uint8_t *data, uint16_t len)
|
||||
static void
|
||||
supported_commands(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t cmds[4];
|
||||
struct gatt_read_supported_commands_rp *rp = (void *) cmds;
|
||||
uint8_t cmds[4];
|
||||
struct btp_gatt_read_supported_commands_rp *rp = (void *) cmds;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
memset(cmds, 0, sizeof(cmds));
|
||||
|
||||
tester_set_bit(cmds, GATT_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, GATT_START_SERVER);
|
||||
tester_set_bit(cmds, GATT_EXCHANGE_MTU);
|
||||
tester_set_bit(cmds, GATT_DISC_ALL_PRIM_SVCS);
|
||||
tester_set_bit(cmds, GATT_DISC_PRIM_UUID);
|
||||
tester_set_bit(cmds, GATT_FIND_INCLUDED);
|
||||
tester_set_bit(cmds, GATT_DISC_ALL_CHRC);
|
||||
tester_set_bit(cmds, GATT_DISC_CHRC_UUID);
|
||||
tester_set_bit(cmds, GATT_DISC_ALL_DESC);
|
||||
tester_set_bit(cmds, GATT_READ);
|
||||
tester_set_bit(cmds, GATT_READ_LONG);
|
||||
tester_set_bit(cmds, GATT_READ_MULTIPLE);
|
||||
tester_set_bit(cmds, GATT_WRITE_WITHOUT_RSP);
|
||||
tester_set_bit(cmds, BTP_GATT_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, BTP_GATT_START_SERVER);
|
||||
tester_set_bit(cmds, BTP_GATT_EXCHANGE_MTU);
|
||||
tester_set_bit(cmds, BTP_GATT_DISC_ALL_PRIM_SVCS);
|
||||
tester_set_bit(cmds, BTP_GATT_DISC_PRIM_UUID);
|
||||
tester_set_bit(cmds, BTP_GATT_FIND_INCLUDED);
|
||||
tester_set_bit(cmds, BTP_GATT_DISC_ALL_CHRC);
|
||||
tester_set_bit(cmds, BTP_GATT_DISC_CHRC_UUID);
|
||||
tester_set_bit(cmds, BTP_GATT_DISC_ALL_DESC);
|
||||
tester_set_bit(cmds, BTP_GATT_READ);
|
||||
tester_set_bit(cmds, BTP_GATT_READ_LONG);
|
||||
tester_set_bit(cmds, BTP_GATT_READ_MULTIPLE);
|
||||
tester_set_bit(cmds, BTP_GATT_WRITE_WITHOUT_RSP);
|
||||
#if 0
|
||||
tester_set_bit(cmds, GATT_SIGNED_WRITE_WITHOUT_RSP);
|
||||
tester_set_bit(cmds, BTP_GATT_SIGNED_WRITE_WITHOUT_RSP);
|
||||
#endif
|
||||
tester_set_bit(cmds, GATT_WRITE);
|
||||
tester_set_bit(cmds, GATT_WRITE_LONG);
|
||||
tester_set_bit(cmds, GATT_CFG_NOTIFY);
|
||||
tester_set_bit(cmds, GATT_CFG_INDICATE);
|
||||
tester_set_bit(cmds, GATT_GET_ATTRIBUTES);
|
||||
tester_set_bit(cmds, GATT_GET_ATTRIBUTE_VALUE);
|
||||
tester_set_bit(cmds, GATT_CHANGE_DATABASE);
|
||||
tester_set_bit(cmds, BTP_GATT_WRITE);
|
||||
tester_set_bit(cmds, BTP_GATT_WRITE_LONG);
|
||||
tester_set_bit(cmds, BTP_GATT_CFG_NOTIFY);
|
||||
tester_set_bit(cmds, BTP_GATT_CFG_INDICATE);
|
||||
tester_set_bit(cmds, BTP_GATT_GET_ATTRIBUTES);
|
||||
tester_set_bit(cmds, BTP_GATT_GET_ATTRIBUTE_VALUE);
|
||||
tester_set_bit(cmds, BTP_GATT_CHANGE_DATABASE);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_GATT, GATT_READ_SUPPORTED_COMMANDS,
|
||||
tester_send(BTP_SERVICE_ID_GATT, BTP_GATT_READ_SUPPORTED_COMMANDS,
|
||||
CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds));
|
||||
}
|
||||
|
||||
@@ -1868,76 +1868,76 @@ tester_handle_gatt(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len)
|
||||
{
|
||||
switch (opcode) {
|
||||
case GATT_READ_SUPPORTED_COMMANDS:
|
||||
case BTP_GATT_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
return;
|
||||
case GATT_START_SERVER:
|
||||
case BTP_GATT_START_SERVER:
|
||||
start_server(data, len);
|
||||
return;
|
||||
case GATT_EXCHANGE_MTU:
|
||||
case BTP_GATT_EXCHANGE_MTU:
|
||||
exchange_mtu(data, len);
|
||||
return;
|
||||
case GATT_DISC_ALL_PRIM_SVCS:
|
||||
case BTP_GATT_DISC_ALL_PRIM_SVCS:
|
||||
disc_all_prim_svcs(data, len);
|
||||
return;
|
||||
case GATT_DISC_PRIM_UUID:
|
||||
case BTP_GATT_DISC_PRIM_UUID:
|
||||
disc_prim_uuid(data, len);
|
||||
return;
|
||||
case GATT_FIND_INCLUDED:
|
||||
case BTP_GATT_FIND_INCLUDED:
|
||||
find_included(data, len);
|
||||
return;
|
||||
case GATT_DISC_ALL_CHRC:
|
||||
case BTP_GATT_DISC_ALL_CHRC:
|
||||
disc_all_chrc(data, len);
|
||||
return;
|
||||
case GATT_DISC_CHRC_UUID:
|
||||
case BTP_GATT_DISC_CHRC_UUID:
|
||||
disc_chrc_uuid(data, len);
|
||||
return;
|
||||
case GATT_DISC_ALL_DESC:
|
||||
case BTP_GATT_DISC_ALL_DESC:
|
||||
disc_all_desc(data, len);
|
||||
return;
|
||||
case GATT_CHANGE_DATABASE:
|
||||
case BTP_GATT_CHANGE_DATABASE:
|
||||
change_database(data, len);
|
||||
return;
|
||||
case GATT_READ:
|
||||
case BTP_GATT_READ:
|
||||
read(data, len);
|
||||
return;
|
||||
case GATT_READ_UUID:
|
||||
case BTP_GATT_READ_UUID:
|
||||
read_uuid(data, len);
|
||||
return;
|
||||
case GATT_READ_LONG:
|
||||
case BTP_GATT_READ_LONG:
|
||||
read_long(data, len);
|
||||
return;
|
||||
case GATT_READ_MULTIPLE:
|
||||
case BTP_GATT_READ_MULTIPLE:
|
||||
read_multiple(data, len);
|
||||
return;
|
||||
case GATT_WRITE_WITHOUT_RSP:
|
||||
case BTP_GATT_WRITE_WITHOUT_RSP:
|
||||
write_without_rsp(data,
|
||||
len,
|
||||
opcode,
|
||||
false);
|
||||
return;
|
||||
#if 0
|
||||
case GATT_SIGNED_WRITE_WITHOUT_RSP:
|
||||
case BTP_GATT_SIGNED_WRITE_WITHOUT_RSP:
|
||||
write_without_rsp(data, len, opcode, true);
|
||||
return;
|
||||
#endif
|
||||
case GATT_WRITE:
|
||||
case BTP_GATT_WRITE:
|
||||
write(data, len);
|
||||
return;
|
||||
case GATT_WRITE_LONG:
|
||||
case BTP_GATT_WRITE_LONG:
|
||||
write_long(data, len);
|
||||
return;
|
||||
case GATT_RELIABLE_WRITE:
|
||||
case BTP_GATT_RELIABLE_WRITE:
|
||||
reliable_write(data, len);
|
||||
return;
|
||||
case GATT_CFG_NOTIFY:
|
||||
case GATT_CFG_INDICATE:
|
||||
case BTP_GATT_CFG_NOTIFY:
|
||||
case BTP_GATT_CFG_INDICATE:
|
||||
config_subscription(data, len, opcode);
|
||||
return;
|
||||
case GATT_GET_ATTRIBUTES:
|
||||
case BTP_GATT_GET_ATTRIBUTES:
|
||||
get_attrs(data, len);
|
||||
return;
|
||||
case GATT_GET_ATTRIBUTE_VALUE:
|
||||
case BTP_GATT_GET_ATTRIBUTE_VALUE:
|
||||
get_attr_val(data, len);
|
||||
return;
|
||||
default:
|
||||
@@ -1951,8 +1951,8 @@ int
|
||||
tester_gatt_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle,
|
||||
uint8_t indication, struct os_mbuf *om)
|
||||
{
|
||||
struct gatt_notification_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct btp_gatt_notification_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
|
||||
@@ -1978,7 +1978,7 @@ tester_gatt_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle,
|
||||
ev->data_length = sys_cpu_to_le16(os_mbuf_len(om));
|
||||
os_mbuf_appendfrom(buf, om, 0, os_mbuf_len(om));
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, GATT_EV_NOTIFICATION,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATT, BTP_GATT_EV_NOTIFICATION,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
fail:
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "../../../nimble/host/src/ble_att_priv.h"
|
||||
#include "../../../nimble/host/src/ble_gatt_priv.h"
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
#define CONTROLLER_INDEX 0
|
||||
#define MAX_BUFFER_SIZE 2048
|
||||
@@ -123,8 +123,8 @@ tester_mtu_exchanged_ev(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
uint16_t mtu, void *arg)
|
||||
{
|
||||
struct gattc_exchange_mtu_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct btp_gattc_exchange_mtu_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
|
||||
@@ -144,7 +144,7 @@ tester_mtu_exchanged_ev(uint16_t conn_handle,
|
||||
|
||||
ev->mtu = mtu;
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_EV_MTU_EXCHANGED,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_EV_MTU_EXCHANGED,
|
||||
CONTROLLER_INDEX, buf);
|
||||
fail:
|
||||
os_mbuf_free_chain(buf);
|
||||
@@ -174,7 +174,7 @@ exchange_mtu(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_EXCHANGE_MTU,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_EXCHANGE_MTU,
|
||||
CONTROLLER_INDEX, status);
|
||||
}
|
||||
|
||||
@@ -183,10 +183,10 @@ disc_prim_svcs_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_svc *gatt_svc, void *arg)
|
||||
{
|
||||
struct gattc_disc_prim_svcs_rp *rp;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct gatt_service *service;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gattc_disc_prim_svcs_rp *rp;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct btp_gatt_service *service;
|
||||
const ble_uuid_any_t *uuid;
|
||||
const ble_addr_t *addr;
|
||||
uint8_t uuid_length;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
@@ -272,22 +272,22 @@ disc_all_prim_svcs(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
if (ble_gattc_disc_all_svcs(conn.conn_handle, disc_prim_svcs_cb,
|
||||
(void *) GATTC_DISC_ALL_PRIM_RP)) {
|
||||
(void *) BTP_GATTC_DISC_ALL_PRIM_RP)) {
|
||||
discover_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
goto rsp;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_DISC_ALL_PRIM_SVCS,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_ALL_PRIM_SVCS,
|
||||
CONTROLLER_INDEX, status);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_prim_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_disc_prim_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_disc_prim_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
ble_uuid_any_t uuid;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
@@ -307,14 +307,14 @@ disc_prim_uuid(uint8_t *data, uint16_t len)
|
||||
|
||||
if (ble_gattc_disc_svc_by_uuid(conn.conn_handle,
|
||||
&uuid.u, disc_prim_svcs_cb,
|
||||
(void *) GATTC_DISC_PRIM_UUID_RP)) {
|
||||
(void *) BTP_GATTC_DISC_PRIM_UUID_RP)) {
|
||||
discover_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
goto rsp;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_DISC_PRIM_UUID, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_PRIM_UUID, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -323,9 +323,9 @@ find_included_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_svc *gatt_svc, void *arg)
|
||||
{
|
||||
struct gattc_find_included_rp *rp;
|
||||
struct gatt_included *included;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gattc_find_included_rp *rp;
|
||||
struct btp_gatt_included *included;
|
||||
const ble_uuid_any_t *uuid;
|
||||
int service_handle = (int) arg;
|
||||
uint8_t uuid_length;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
@@ -354,7 +354,7 @@ find_included_cb(uint16_t conn_handle,
|
||||
SYS_LOG_DBG("");
|
||||
if (error->status != 0 && error->status != BLE_HS_EDONE) {
|
||||
rp->services_count = 0;
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_FIND_INCLUDED_RP,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_FIND_INCLUDED_RP,
|
||||
CONTROLLER_INDEX, buf);
|
||||
discover_destroy();
|
||||
goto free;
|
||||
@@ -364,7 +364,7 @@ find_included_cb(uint16_t conn_handle,
|
||||
rp->status = 0;
|
||||
rp->services_count = gatt_buf.cnt;
|
||||
os_mbuf_append(buf, gatt_buf.buf, gatt_buf.len);
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_FIND_INCLUDED_RP,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_FIND_INCLUDED_RP,
|
||||
CONTROLLER_INDEX, buf);
|
||||
discover_destroy();
|
||||
goto free;
|
||||
@@ -404,8 +404,8 @@ free:
|
||||
static void
|
||||
find_included(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_find_included_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_find_included_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
int service_handle_arg;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
@@ -432,7 +432,7 @@ find_included(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_FIND_INCLUDED, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_FIND_INCLUDED, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -441,9 +441,9 @@ disc_chrc_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_error *error,
|
||||
const struct ble_gatt_chr *gatt_chr, void *arg)
|
||||
{
|
||||
struct gattc_disc_chrc_rp *rp;
|
||||
struct gatt_characteristic *chrc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gattc_disc_chrc_rp *rp;
|
||||
struct btp_gatt_characteristic *chrc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
uint8_t uuid_length;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
@@ -522,8 +522,8 @@ free:
|
||||
static void
|
||||
disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_disc_all_chrc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_disc_all_chrc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
@@ -544,7 +544,7 @@ disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
start_handle,
|
||||
end_handle,
|
||||
disc_chrc_cb,
|
||||
(void *) GATTC_DISC_ALL_CHRC_RP);
|
||||
(void *) BTP_GATTC_DISC_ALL_CHRC_RP);
|
||||
if (rc) {
|
||||
discover_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
@@ -552,15 +552,15 @@ disc_all_chrc(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_DISC_ALL_CHRC, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_ALL_CHRC, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_disc_chrc_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_disc_chrc_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
ble_uuid_any_t uuid;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
@@ -584,7 +584,7 @@ disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
|
||||
rc = ble_gattc_disc_chrs_by_uuid(conn.conn_handle, start_handle,
|
||||
end_handle, &uuid.u, disc_chrc_cb,
|
||||
(void *) GATTC_DISC_CHRC_UUID_RP);
|
||||
(void *) BTP_GATTC_DISC_CHRC_UUID_RP);
|
||||
if (rc) {
|
||||
discover_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
@@ -592,7 +592,7 @@ disc_chrc_uuid(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_DISC_CHRC_UUID, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_CHRC_UUID, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -603,9 +603,9 @@ disc_all_desc_cb(uint16_t conn_handle,
|
||||
const struct ble_gatt_dsc *gatt_dsc,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_disc_all_desc_rp *rp;
|
||||
struct gatt_descriptor *dsc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
struct btp_gattc_disc_all_desc_rp *rp;
|
||||
struct btp_gatt_descriptor *dsc;
|
||||
const ble_uuid_any_t *uuid;
|
||||
uint8_t uuid_length;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
@@ -632,7 +632,7 @@ disc_all_desc_cb(uint16_t conn_handle,
|
||||
|
||||
if (error->status != 0 && error->status != BLE_HS_EDONE) {
|
||||
rp->descriptors_count = 0;
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_DISC_ALL_DESC_RP,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_ALL_DESC_RP,
|
||||
CONTROLLER_INDEX, buf);
|
||||
discover_destroy();
|
||||
goto free;
|
||||
@@ -642,7 +642,7 @@ disc_all_desc_cb(uint16_t conn_handle,
|
||||
rp->status = 0;
|
||||
rp->descriptors_count = gatt_buf.cnt;
|
||||
os_mbuf_append(buf, gatt_buf.buf, gatt_buf.len);
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_DISC_ALL_DESC_RP,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_ALL_DESC_RP,
|
||||
CONTROLLER_INDEX, buf);
|
||||
discover_destroy();
|
||||
goto free;
|
||||
@@ -678,8 +678,8 @@ free:
|
||||
static void
|
||||
disc_all_desc(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_disc_all_desc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_disc_all_desc_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t start_handle, end_handle;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
@@ -699,7 +699,7 @@ disc_all_desc(uint8_t *data, uint16_t len)
|
||||
start_handle,
|
||||
end_handle,
|
||||
disc_all_desc_cb,
|
||||
(void *) GATTC_DISC_ALL_DESC);
|
||||
(void *) BTP_GATTC_DISC_ALL_DESC);
|
||||
|
||||
SYS_LOG_DBG("rc=%d", rc);
|
||||
|
||||
@@ -710,7 +710,7 @@ disc_all_desc(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_DISC_ALL_DESC, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_DISC_ALL_DESC, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -720,8 +720,8 @@ read_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_read_rp *rp;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
struct btp_gattc_read_rp *rp;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
struct ble_gap_conn_desc conn;
|
||||
@@ -771,8 +771,8 @@ free:
|
||||
static void
|
||||
read(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_read_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_read_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
|
||||
@@ -788,14 +788,14 @@ read(uint8_t *data, uint16_t len)
|
||||
read_destroy();
|
||||
|
||||
if (ble_gattc_read(conn.conn_handle, sys_le16_to_cpu(cmd->handle),
|
||||
read_cb, (void *) GATTC_READ_RP)) {
|
||||
read_cb, (void *) BTP_GATTC_READ_RP)) {
|
||||
read_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
goto rsp;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_READ, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_READ, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -805,9 +805,9 @@ read_uuid_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_read_uuid_rp *rp;
|
||||
struct gatt_read_uuid_chr *chr;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
struct btp_gattc_read_uuid_rp *rp;
|
||||
struct btp_gatt_read_uuid_chr *chr;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
@@ -874,8 +874,8 @@ free:
|
||||
static void
|
||||
read_uuid(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_read_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_read_uuid_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
ble_uuid_any_t uuid;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
@@ -899,13 +899,13 @@ read_uuid(uint8_t *data, uint16_t len)
|
||||
if (ble_gattc_read_by_uuid(conn.conn_handle,
|
||||
sys_le16_to_cpu(cmd->start_handle),
|
||||
sys_le16_to_cpu(cmd->end_handle), &uuid.u,
|
||||
read_uuid_cb, (void *) GATTC_READ_UUID_RP)) {
|
||||
read_uuid_cb, (void *) BTP_GATTC_READ_UUID_RP)) {
|
||||
read_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_READ_UUID, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_READ_UUID, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -915,7 +915,7 @@ read_long_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_read_rp *rp;;
|
||||
struct btp_gattc_read_rp *rp;;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
@@ -974,8 +974,8 @@ free:
|
||||
static void
|
||||
read_long(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_read_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_read_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
|
||||
@@ -993,21 +993,21 @@ read_long(uint8_t *data, uint16_t len)
|
||||
if (ble_gattc_read_long(conn.conn_handle,
|
||||
sys_le16_to_cpu(cmd->handle),
|
||||
sys_le16_to_cpu(cmd->offset),
|
||||
read_long_cb, (void *) GATTC_READ_LONG_RP)) {
|
||||
read_long_cb, (void *) BTP_GATTC_READ_LONG_RP)) {
|
||||
read_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_READ_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_READ_LONG, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
read_multiple(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_read_multiple_cmd *cmd = (void *) data;
|
||||
uint16_t handles[cmd->handles_count];
|
||||
const struct btp_gattc_read_multiple_cmd *cmd = (void *) data;
|
||||
uint16_t handles[cmd->handles_count];
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc, i;
|
||||
@@ -1031,21 +1031,21 @@ read_multiple(uint8_t *data, uint16_t len)
|
||||
handles,
|
||||
cmd->handles_count,
|
||||
read_cb,
|
||||
(void *) GATTC_READ_MULTIPLE_RP)) {
|
||||
(void *) BTP_GATTC_READ_MULTIPLE_RP)) {
|
||||
read_destroy();
|
||||
status = BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_READ_MULTIPLE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_READ_MULTIPLE, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
write_without_rsp(uint8_t *data, uint16_t len, uint8_t op, bool sign)
|
||||
{
|
||||
const struct gattc_write_without_rsp_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_write_without_rsp_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
|
||||
@@ -1072,8 +1072,8 @@ write_cb(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||
struct ble_gatt_attr *attr,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_write_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct btp_gattc_write_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
@@ -1106,8 +1106,8 @@ free:
|
||||
static void
|
||||
write(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
|
||||
@@ -1121,20 +1121,20 @@ write(uint8_t *data, uint16_t len)
|
||||
|
||||
if (ble_gattc_write_flat(conn.conn_handle, sys_le16_to_cpu(cmd->handle),
|
||||
cmd->data, sys_le16_to_cpu(cmd->data_length),
|
||||
write_cb, (void *) GATTC_WRITE_RP)) {
|
||||
write_cb, (void *) BTP_GATTC_WRITE_RP)) {
|
||||
status = BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_WRITE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_WRITE, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
write_long(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_write_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_write_long_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *om = NULL;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc = 0;
|
||||
@@ -1157,7 +1157,7 @@ write_long(uint8_t *data, uint16_t len)
|
||||
sys_le16_to_cpu(cmd->handle),
|
||||
sys_le16_to_cpu(cmd->offset),
|
||||
om, write_cb,
|
||||
(void *) GATTC_WRITE_LONG_RP);
|
||||
(void *) BTP_GATTC_WRITE_LONG_RP);
|
||||
if (rc) {
|
||||
status = BTP_STATUS_FAILED;
|
||||
} else {
|
||||
@@ -1168,7 +1168,7 @@ fail:
|
||||
SYS_LOG_ERR("Failed to send Write Long request, rc=%d", rc);
|
||||
os_mbuf_free_chain(om);
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_WRITE_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_WRITE_LONG, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -1179,8 +1179,8 @@ reliable_write_cb(uint16_t conn_handle,
|
||||
uint8_t num_attrs,
|
||||
void *arg)
|
||||
{
|
||||
struct gattc_write_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct btp_gattc_write_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
struct ble_gap_conn_desc conn;
|
||||
@@ -1202,7 +1202,7 @@ reliable_write_cb(uint16_t conn_handle,
|
||||
memcpy(rp->address, addr->val, sizeof(rp->address));
|
||||
|
||||
rp->status = err;
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_RELIABLE_WRITE_RP,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_RELIABLE_WRITE_RP,
|
||||
CONTROLLER_INDEX, buf);
|
||||
free:
|
||||
os_mbuf_free_chain(buf);
|
||||
@@ -1212,8 +1212,8 @@ free:
|
||||
static void
|
||||
reliable_write(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gattc_reliable_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_reliable_write_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct ble_gatt_attr attr;
|
||||
struct os_mbuf *om = NULL;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
@@ -1251,7 +1251,7 @@ reliable_write(uint8_t *data, uint16_t len)
|
||||
fail:
|
||||
os_mbuf_free_chain(om);
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, GATTC_WRITE_LONG, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_GATTC, BTP_GATTC_WRITE_LONG, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -1261,8 +1261,8 @@ subscribe_cb(uint16_t conn_handle,
|
||||
struct ble_gatt_attr *attrs,
|
||||
void *arg)
|
||||
{
|
||||
struct subscribe_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
struct btp_subscribe_rp *rp;
|
||||
uint8_t err = (uint8_t) error->status;
|
||||
uint8_t opcode = (uint8_t) (int) arg;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
@@ -1300,8 +1300,8 @@ enable_subscription(uint16_t conn_handle, uint16_t ccc_handle,
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
opcode = (uint32_t) (value == 0x0001 ? GATTC_CFG_NOTIFY_RP
|
||||
: GATTC_CFG_INDICATE_RP);
|
||||
opcode = (uint32_t) (value == 0x0001 ? BTP_GATTC_CFG_NOTIFY_RP
|
||||
: BTP_GATTC_CFG_INDICATE_RP);
|
||||
|
||||
if (ble_gattc_write_flat(conn_handle,
|
||||
ccc_handle,
|
||||
@@ -1325,8 +1325,8 @@ disable_subscription(uint16_t conn_handle, uint16_t ccc_handle)
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
opcode = (uint32_t) (value == 0x0001 ? GATTC_CFG_NOTIFY_RP
|
||||
: GATTC_CFG_INDICATE_RP);
|
||||
opcode = (uint32_t) (value == 0x0001 ? BTP_GATTC_CFG_NOTIFY_RP
|
||||
: BTP_GATTC_CFG_INDICATE_RP);
|
||||
|
||||
/* Fail if CCC handle doesn't match */
|
||||
if (ccc_handle != subscribe_params.ccc_handle) {
|
||||
@@ -1350,8 +1350,8 @@ disable_subscription(uint16_t conn_handle, uint16_t ccc_handle)
|
||||
static void
|
||||
config_subscription(uint8_t *data, uint16_t len, uint8_t op)
|
||||
{
|
||||
const struct gattc_cfg_notify_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
const struct btp_gattc_cfg_notify_cmd *cmd = (void *) data;
|
||||
struct ble_gap_conn_desc conn;
|
||||
uint16_t ccc_handle = sys_le16_to_cpu(cmd->ccc_handle);
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
int rc;
|
||||
@@ -1367,7 +1367,7 @@ config_subscription(uint8_t *data, uint16_t len, uint8_t op)
|
||||
if (cmd->enable) {
|
||||
uint16_t value;
|
||||
|
||||
if (op == GATTC_CFG_NOTIFY) {
|
||||
if (op == BTP_GATTC_CFG_NOTIFY) {
|
||||
value = 0x0001;
|
||||
} else {
|
||||
value = 0x0002;
|
||||
@@ -1396,8 +1396,8 @@ int
|
||||
tester_gattc_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle,
|
||||
uint8_t indication, struct os_mbuf *om)
|
||||
{
|
||||
struct gattc_notification_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct btp_gattc_notification_ev *ev;
|
||||
struct ble_gap_conn_desc conn;
|
||||
struct os_mbuf *buf = os_msys_get(0, 0);
|
||||
const ble_addr_t *addr;
|
||||
|
||||
@@ -1423,7 +1423,7 @@ tester_gattc_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle,
|
||||
ev->data_length = sys_cpu_to_le16(os_mbuf_len(om));
|
||||
os_mbuf_appendfrom(buf, om, 0, os_mbuf_len(om));
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, GATTC_EV_NOTIFICATION_RXED,
|
||||
tester_send_buf(BTP_SERVICE_ID_GATTC, BTP_GATTC_EV_NOTIFICATION_RXED,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
fail:
|
||||
@@ -1434,36 +1434,36 @@ fail:
|
||||
static void
|
||||
supported_commands(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t cmds[3];
|
||||
struct gatt_read_supported_commands_rp *rp = (void *) cmds;
|
||||
uint8_t cmds[3];
|
||||
struct btp_gatt_read_supported_commands_rp *rp = (void *) cmds;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
memset(cmds, 0, sizeof(cmds));
|
||||
|
||||
tester_set_bit(cmds, GATTC_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, GATTC_EXCHANGE_MTU);
|
||||
tester_set_bit(cmds, GATTC_DISC_ALL_PRIM_SVCS);
|
||||
tester_set_bit(cmds, GATTC_DISC_PRIM_UUID);
|
||||
tester_set_bit(cmds, GATTC_FIND_INCLUDED);
|
||||
tester_set_bit(cmds, GATTC_DISC_ALL_CHRC);
|
||||
tester_set_bit(cmds, GATTC_DISC_CHRC_UUID);
|
||||
tester_set_bit(cmds, GATTC_DISC_ALL_DESC);
|
||||
tester_set_bit(cmds, GATTC_READ);
|
||||
tester_set_bit(cmds, GATTC_READ_UUID);
|
||||
tester_set_bit(cmds, GATTC_READ_LONG);
|
||||
tester_set_bit(cmds, GATTC_READ_MULTIPLE);
|
||||
tester_set_bit(cmds, GATTC_WRITE_WITHOUT_RSP);
|
||||
tester_set_bit(cmds, BTP_GATTC_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, BTP_GATTC_EXCHANGE_MTU);
|
||||
tester_set_bit(cmds, BTP_GATTC_DISC_ALL_PRIM_SVCS);
|
||||
tester_set_bit(cmds, BTP_GATTC_DISC_PRIM_UUID);
|
||||
tester_set_bit(cmds, BTP_GATTC_FIND_INCLUDED);
|
||||
tester_set_bit(cmds, BTP_GATTC_DISC_ALL_CHRC);
|
||||
tester_set_bit(cmds, BTP_GATTC_DISC_CHRC_UUID);
|
||||
tester_set_bit(cmds, BTP_GATTC_DISC_ALL_DESC);
|
||||
tester_set_bit(cmds, BTP_GATTC_READ);
|
||||
tester_set_bit(cmds, BTP_GATTC_READ_UUID);
|
||||
tester_set_bit(cmds, BTP_GATTC_READ_LONG);
|
||||
tester_set_bit(cmds, BTP_GATTC_READ_MULTIPLE);
|
||||
tester_set_bit(cmds, BTP_GATTC_WRITE_WITHOUT_RSP);
|
||||
#if 0
|
||||
tester_set_bit(cmds, GATTC_SIGNED_WRITE_WITHOUT_RSP);
|
||||
tester_set_bit(cmds, BTP_GATTC_SIGNED_WRITE_WITHOUT_RSP);
|
||||
#endif
|
||||
tester_set_bit(cmds, GATTC_WRITE);
|
||||
tester_set_bit(cmds, GATTC_WRITE_LONG);
|
||||
tester_set_bit(cmds, GATTC_RELIABLE_WRITE);
|
||||
tester_set_bit(cmds, GATTC_CFG_NOTIFY);
|
||||
tester_set_bit(cmds, GATTC_CFG_INDICATE);
|
||||
tester_set_bit(cmds, BTP_GATTC_WRITE);
|
||||
tester_set_bit(cmds, BTP_GATTC_WRITE_LONG);
|
||||
tester_set_bit(cmds, BTP_GATTC_RELIABLE_WRITE);
|
||||
tester_set_bit(cmds, BTP_GATTC_CFG_NOTIFY);
|
||||
tester_set_bit(cmds, BTP_GATTC_CFG_INDICATE);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_GATTC, GATTC_READ_SUPPORTED_COMMANDS,
|
||||
tester_send(BTP_SERVICE_ID_GATTC, BTP_GATTC_READ_SUPPORTED_COMMANDS,
|
||||
CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds));
|
||||
}
|
||||
|
||||
@@ -1472,64 +1472,64 @@ tester_handle_gattc(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len)
|
||||
{
|
||||
switch (opcode) {
|
||||
case GATTC_READ_SUPPORTED_COMMANDS:
|
||||
case BTP_GATTC_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
return;
|
||||
case GATTC_EXCHANGE_MTU:
|
||||
case BTP_GATTC_EXCHANGE_MTU:
|
||||
exchange_mtu(data, len);
|
||||
return;
|
||||
case GATTC_DISC_ALL_PRIM_SVCS:
|
||||
case BTP_GATTC_DISC_ALL_PRIM_SVCS:
|
||||
disc_all_prim_svcs(data, len);
|
||||
return;
|
||||
case GATTC_DISC_PRIM_UUID:
|
||||
case BTP_GATTC_DISC_PRIM_UUID:
|
||||
disc_prim_uuid(data, len);
|
||||
return;
|
||||
case GATTC_FIND_INCLUDED:
|
||||
case BTP_GATTC_FIND_INCLUDED:
|
||||
find_included(data, len);
|
||||
return;
|
||||
case GATTC_DISC_ALL_CHRC:
|
||||
case BTP_GATTC_DISC_ALL_CHRC:
|
||||
disc_all_chrc(data, len);
|
||||
return;
|
||||
case GATTC_DISC_CHRC_UUID:
|
||||
case BTP_GATTC_DISC_CHRC_UUID:
|
||||
disc_chrc_uuid(data, len);
|
||||
return;
|
||||
case GATTC_DISC_ALL_DESC:
|
||||
case BTP_GATTC_DISC_ALL_DESC:
|
||||
disc_all_desc(data, len);
|
||||
return;
|
||||
case GATTC_READ:
|
||||
case BTP_GATTC_READ:
|
||||
read(data, len);
|
||||
return;
|
||||
case GATTC_READ_UUID:
|
||||
case BTP_GATTC_READ_UUID:
|
||||
read_uuid(data, len);
|
||||
return;
|
||||
case GATTC_READ_LONG:
|
||||
case BTP_GATTC_READ_LONG:
|
||||
read_long(data, len);
|
||||
return;
|
||||
case GATTC_READ_MULTIPLE:
|
||||
case BTP_GATTC_READ_MULTIPLE:
|
||||
read_multiple(data, len);
|
||||
return;
|
||||
case GATTC_WRITE_WITHOUT_RSP:
|
||||
case BTP_GATTC_WRITE_WITHOUT_RSP:
|
||||
write_without_rsp(data,
|
||||
len,
|
||||
opcode,
|
||||
false);
|
||||
return;
|
||||
#if 0
|
||||
case GATTC_SIGNED_WRITE_WITHOUT_RSP:
|
||||
case BTP_GATTC_SIGNED_WRITE_WITHOUT_RSP:
|
||||
write_without_rsp(data, len, opcode, true);
|
||||
return;
|
||||
#endif
|
||||
case GATTC_WRITE:
|
||||
case BTP_GATTC_WRITE:
|
||||
write(data, len);
|
||||
return;
|
||||
case GATTC_WRITE_LONG:
|
||||
case BTP_GATTC_WRITE_LONG:
|
||||
write_long(data, len);
|
||||
return;
|
||||
case GATTC_RELIABLE_WRITE:
|
||||
case BTP_GATTC_RELIABLE_WRITE:
|
||||
reliable_write(data, len);
|
||||
return;
|
||||
case GATTC_CFG_NOTIFY:
|
||||
case GATTC_CFG_INDICATE:
|
||||
case BTP_GATTC_CFG_NOTIFY:
|
||||
case BTP_GATTC_CFG_INDICATE:
|
||||
config_subscription(data, len, opcode);
|
||||
return;
|
||||
default:
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "../../../nimble/host/src/ble_l2cap_priv.h"
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
#define CONTROLLER_INDEX 0
|
||||
#define CHANNELS MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
@@ -57,7 +57,7 @@ static struct channel {
|
||||
} channels[CHANNELS];
|
||||
|
||||
static uint8_t
|
||||
recv_cb_buf[TESTER_COC_MTU + sizeof(struct l2cap_data_received_ev)];
|
||||
recv_cb_buf[TESTER_COC_MTU + sizeof(struct btp_l2cap_data_received_ev)];
|
||||
|
||||
static struct channel *
|
||||
get_free_channel(void)
|
||||
@@ -122,8 +122,8 @@ static void
|
||||
recv_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
struct os_mbuf *buf, void *arg)
|
||||
{
|
||||
struct l2cap_data_received_ev *ev = (void *) recv_cb_buf;
|
||||
struct channel *channel = find_channel(chan);
|
||||
struct btp_l2cap_data_received_ev *ev = (void *) recv_cb_buf;
|
||||
struct channel *channel = find_channel(chan);
|
||||
assert(channel != NULL);
|
||||
|
||||
ev->chan_id = channel->chan_id;
|
||||
@@ -135,7 +135,7 @@ recv_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
}
|
||||
os_mbuf_copydata(buf, 0, ev->data_length, ev->data);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_DATA_RECEIVED,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_DATA_RECEIVED,
|
||||
CONTROLLER_INDEX, recv_cb_buf, sizeof(*ev) + ev->data_length);
|
||||
|
||||
tester_l2cap_coc_recv(chan, buf);
|
||||
@@ -146,10 +146,10 @@ unstalled_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
int status, void *arg)
|
||||
{
|
||||
if (status) {
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_SEND_DATA,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_SEND_DATA,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
} else {
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_SEND_DATA,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_SEND_DATA,
|
||||
CONTROLLER_INDEX, BTP_STATUS_SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -159,8 +159,8 @@ reconfigured_ev(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
struct ble_l2cap_chan_info *chan_info,
|
||||
int status)
|
||||
{
|
||||
struct l2cap_reconfigured_ev ev;
|
||||
struct channel *channel;
|
||||
struct btp_l2cap_reconfigured_ev ev;
|
||||
struct channel *channel;
|
||||
|
||||
if (status != 0) {
|
||||
return;
|
||||
@@ -175,7 +175,7 @@ reconfigured_ev(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
ev.our_mtu = chan_info->our_coc_mtu;
|
||||
ev.our_mps = chan_info->our_l2cap_mtu;
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_RECONFIGURED,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_RECONFIGURED,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
@@ -183,8 +183,8 @@ static void
|
||||
connected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
struct ble_l2cap_chan_info *chan_info, void *arg)
|
||||
{
|
||||
struct l2cap_connected_ev ev;
|
||||
struct ble_gap_conn_desc desc;
|
||||
struct btp_l2cap_connected_ev ev;
|
||||
struct ble_gap_conn_desc desc;
|
||||
struct channel *channel = find_channel(chan);
|
||||
|
||||
if (channel == NULL) {
|
||||
@@ -206,7 +206,7 @@ connected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
sizeof(ev.address));
|
||||
}
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_CONNECTED, CONTROLLER_INDEX,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_CONNECTED, CONTROLLER_INDEX,
|
||||
(uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
@@ -214,11 +214,11 @@ static void
|
||||
disconnected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
struct ble_l2cap_chan_info *chan_info, void *arg)
|
||||
{
|
||||
struct l2cap_disconnected_ev ev;
|
||||
struct ble_gap_conn_desc desc;
|
||||
struct btp_l2cap_disconnected_ev ev;
|
||||
struct ble_gap_conn_desc desc;
|
||||
struct channel *channel;
|
||||
|
||||
memset(&ev, 0, sizeof(struct l2cap_disconnected_ev));
|
||||
memset(&ev, 0, sizeof(struct btp_l2cap_disconnected_ev));
|
||||
|
||||
channel = find_channel(chan);
|
||||
assert(channel != NULL);
|
||||
@@ -234,7 +234,7 @@ disconnected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan,
|
||||
sizeof(ev.address));
|
||||
}
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_DISCONNECTED,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_DISCONNECTED,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
@@ -406,18 +406,18 @@ tester_l2cap_event(struct ble_l2cap_event *event, void *arg)
|
||||
static void
|
||||
connect(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_connect_cmd *cmd = (void *) data;
|
||||
uint8_t rp_buf[sizeof(struct l2cap_connect_rp) + cmd->num];
|
||||
struct l2cap_connect_rp *rp = (void *) rp_buf;
|
||||
struct ble_gap_conn_desc desc;
|
||||
const struct btp_l2cap_connect_cmd *cmd = (void *) data;
|
||||
uint8_t rp_buf[sizeof(struct btp_l2cap_connect_rp) + cmd->num];
|
||||
struct btp_l2cap_connect_rp *rp = (void *) rp_buf;
|
||||
struct ble_gap_conn_desc desc;
|
||||
struct channel *chan;
|
||||
struct os_mbuf *sdu_rx[cmd->num];
|
||||
ble_addr_t *addr = (void *) data;
|
||||
uint16_t mtu = htole16(cmd->mtu);
|
||||
int rc;
|
||||
int i, j;
|
||||
bool ecfc = cmd->options & L2CAP_CONNECT_OPT_ECFC;
|
||||
hold_credit = cmd->options & L2CAP_CONNECT_OPT_HOLD_CREDIT;
|
||||
bool ecfc = cmd->options & BTP_L2CAP_CONNECT_OPT_ECFC;
|
||||
hold_credit = cmd->options & BTP_L2CAP_CONNECT_OPT_HOLD_CREDIT;
|
||||
|
||||
SYS_LOG_DBG("connect: type: %d addr: %s",
|
||||
addr->type,
|
||||
@@ -481,21 +481,21 @@ connect(uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_CONNECT, CONTROLLER_INDEX,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_CONNECT, CONTROLLER_INDEX,
|
||||
(uint8_t *) rp, sizeof(rp_buf));
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_CONNECT, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_CONNECT, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_disconnect_cmd *cmd = (void *) data;
|
||||
struct channel *chan;
|
||||
const struct btp_l2cap_disconnect_cmd *cmd = (void *) data;
|
||||
struct channel *chan;
|
||||
uint8_t status;
|
||||
int err;
|
||||
|
||||
@@ -513,15 +513,15 @@ disconnect(const uint8_t *data, uint16_t len)
|
||||
status = BTP_STATUS_SUCCESS;
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_DISCONNECT, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_DISCONNECT, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
send_data(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_send_data_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *sdu_tx = NULL;
|
||||
const struct btp_l2cap_send_data_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *sdu_tx = NULL;
|
||||
int rc;
|
||||
uint16_t data_len = sys_le16_to_cpu(cmd->data_len);
|
||||
struct channel *chan = get_channel(cmd->chan_id);
|
||||
@@ -550,7 +550,7 @@ send_data(const uint8_t *data, uint16_t len)
|
||||
/* ble_l2cap_send takes ownership of the sdu */
|
||||
rc = ble_l2cap_send(chan->chan, sdu_tx);
|
||||
if (rc == 0 || rc == BLE_HS_ESTALLED) {
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_SEND_DATA, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_SEND_DATA, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
return;
|
||||
}
|
||||
@@ -559,15 +559,15 @@ send_data(const uint8_t *data, uint16_t len)
|
||||
os_mbuf_free_chain(sdu_tx);
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_SEND_DATA, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_SEND_DATA, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
listen(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_listen_cmd *cmd = (void *) data;
|
||||
uint16_t mtu = htole16(cmd->mtu);
|
||||
const struct btp_l2cap_listen_cmd *cmd = (void *) data;
|
||||
uint16_t mtu = htole16(cmd->mtu);
|
||||
int rc;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
@@ -582,20 +582,20 @@ listen(const uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_LISTEN, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_LISTEN, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_LISTEN, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_LISTEN, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
credits(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_credits_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *sdu;
|
||||
const struct btp_l2cap_credits_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *sdu;
|
||||
int rc;
|
||||
|
||||
struct channel *channel = get_channel(cmd->chan_id);
|
||||
@@ -613,19 +613,19 @@ credits(uint8_t *data, uint16_t len)
|
||||
if (rc != 0) {
|
||||
goto fail;
|
||||
}
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_CREDITS, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_CREDITS, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
return;
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_CREDITS, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_CREDITS, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
reconfigure(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct l2cap_reconfigure_cmd *cmd = (void *) data;
|
||||
uint16_t mtu = htole16(cmd->mtu);
|
||||
const struct btp_l2cap_reconfigure_cmd *cmd = (void *) data;
|
||||
uint16_t mtu = htole16(cmd->mtu);
|
||||
struct ble_gap_conn_desc desc;
|
||||
ble_addr_t *addr = (void *) data;
|
||||
struct ble_l2cap_chan *chans[cmd->num];
|
||||
@@ -658,31 +658,31 @@ reconfigure(const uint8_t *data, uint16_t len)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_RECONFIGURE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_RECONFIGURE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
return;
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, L2CAP_RECONFIGURE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_RECONFIGURE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
supported_commands(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t cmds[1];
|
||||
struct l2cap_read_supported_commands_rp *rp = (void *) cmds;
|
||||
uint8_t cmds[1];
|
||||
struct btp_l2cap_read_supported_commands_rp *rp = (void *) cmds;
|
||||
|
||||
memset(cmds, 0, sizeof(cmds));
|
||||
|
||||
tester_set_bit(cmds, L2CAP_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, L2CAP_CONNECT);
|
||||
tester_set_bit(cmds, L2CAP_DISCONNECT);
|
||||
tester_set_bit(cmds, L2CAP_LISTEN);
|
||||
tester_set_bit(cmds, L2CAP_SEND_DATA);
|
||||
tester_set_bit(cmds, L2CAP_RECONFIGURE);
|
||||
tester_set_bit(cmds, BTP_L2CAP_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(cmds, BTP_L2CAP_CONNECT);
|
||||
tester_set_bit(cmds, BTP_L2CAP_DISCONNECT);
|
||||
tester_set_bit(cmds, BTP_L2CAP_LISTEN);
|
||||
tester_set_bit(cmds, BTP_L2CAP_SEND_DATA);
|
||||
tester_set_bit(cmds, BTP_L2CAP_RECONFIGURE);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_READ_SUPPORTED_COMMANDS,
|
||||
tester_send(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_READ_SUPPORTED_COMMANDS,
|
||||
CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds));
|
||||
}
|
||||
|
||||
@@ -691,25 +691,25 @@ tester_handle_l2cap(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len)
|
||||
{
|
||||
switch (opcode) {
|
||||
case L2CAP_READ_SUPPORTED_COMMANDS:
|
||||
case BTP_L2CAP_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
return;
|
||||
case L2CAP_CONNECT:
|
||||
case BTP_L2CAP_CONNECT:
|
||||
connect(data, len);
|
||||
return;
|
||||
case L2CAP_DISCONNECT:
|
||||
case BTP_L2CAP_DISCONNECT:
|
||||
disconnect(data, len);
|
||||
return;
|
||||
case L2CAP_SEND_DATA:
|
||||
case BTP_L2CAP_SEND_DATA:
|
||||
send_data(data, len);
|
||||
return;
|
||||
case L2CAP_LISTEN:
|
||||
case BTP_L2CAP_LISTEN:
|
||||
listen(data, len);
|
||||
return;
|
||||
case L2CAP_RECONFIGURE:
|
||||
case BTP_L2CAP_RECONFIGURE:
|
||||
reconfigure(data, len);
|
||||
return;
|
||||
case L2CAP_CREDITS:
|
||||
case BTP_L2CAP_CREDITS:
|
||||
credits(data, len);
|
||||
return;
|
||||
default:
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "mesh/testing.h"
|
||||
#include "console/console.h"
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
extern uint8_t own_addr_type;
|
||||
|
||||
@@ -93,32 +93,32 @@ supported_commands(uint8_t *data, uint16_t len)
|
||||
|
||||
/* 1st octet */
|
||||
memset(net_buf_simple_add(buf, 1), 0, 1);
|
||||
tester_set_bit(buf->om_data, MESH_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(buf->om_data, MESH_CONFIG_PROVISIONING);
|
||||
tester_set_bit(buf->om_data, MESH_PROVISION_NODE);
|
||||
tester_set_bit(buf->om_data, MESH_INIT);
|
||||
tester_set_bit(buf->om_data, MESH_RESET);
|
||||
tester_set_bit(buf->om_data, MESH_INPUT_NUMBER);
|
||||
tester_set_bit(buf->om_data, MESH_INPUT_STRING);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_CONFIG_PROVISIONING);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_PROVISION_NODE);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_INIT);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_RESET);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_INPUT_NUMBER);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_INPUT_STRING);
|
||||
/* 2nd octet */
|
||||
tester_set_bit(buf->om_data, MESH_IVU_TEST_MODE);
|
||||
tester_set_bit(buf->om_data, MESH_IVU_TOGGLE_STATE);
|
||||
tester_set_bit(buf->om_data, MESH_NET_SEND);
|
||||
tester_set_bit(buf->om_data, MESH_HEALTH_GENERATE_FAULTS);
|
||||
tester_set_bit(buf->om_data, MESH_HEALTH_CLEAR_FAULTS);
|
||||
tester_set_bit(buf->om_data, MESH_LPN);
|
||||
tester_set_bit(buf->om_data, MESH_LPN_POLL);
|
||||
tester_set_bit(buf->om_data, MESH_MODEL_SEND);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_IVU_TEST_MODE);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_IVU_TOGGLE_STATE);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_NET_SEND);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_HEALTH_GENERATE_FAULTS);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_HEALTH_CLEAR_FAULTS);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_LPN);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_LPN_POLL);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_MODEL_SEND);
|
||||
/* 3rd octet */
|
||||
memset(net_buf_simple_add(buf, 1), 0, 1);
|
||||
#if MYNEWT_VAL(BLE_MESH_TESTING)
|
||||
tester_set_bit(buf->om_data, MESH_LPN_SUBSCRIBE);
|
||||
tester_set_bit(buf->om_data, MESH_LPN_UNSUBSCRIBE);
|
||||
tester_set_bit(buf->om_data, MESH_RPL_CLEAR);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_LPN_SUBSCRIBE);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_LPN_UNSUBSCRIBE);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_RPL_CLEAR);
|
||||
#endif /* CONFIG_BT_TESTING */
|
||||
tester_set_bit(buf->om_data, MESH_PROXY_IDENTITY);
|
||||
tester_set_bit(buf->om_data, BTP_MESH_PROXY_IDENTITY);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, MESH_READ_SUPPORTED_COMMANDS,
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, BTP_MESH_READ_SUPPORTED_COMMANDS,
|
||||
CONTROLLER_INDEX, buf);
|
||||
}
|
||||
|
||||
@@ -266,16 +266,16 @@ static struct bt_mesh_elem elements[] = {
|
||||
static void
|
||||
link_open(bt_mesh_prov_bearer_t bearer)
|
||||
{
|
||||
struct mesh_prov_link_open_ev ev;
|
||||
struct btp_mesh_prov_link_open_ev ev;
|
||||
|
||||
SYS_LOG_DBG("bearer 0x%02x", bearer);
|
||||
|
||||
switch (bearer) {
|
||||
case BT_MESH_PROV_ADV:
|
||||
ev.bearer = MESH_PROV_BEARER_PB_ADV;
|
||||
ev.bearer = BTP_MESH_PROV_BEARER_PB_ADV;
|
||||
break;
|
||||
case BT_MESH_PROV_GATT:
|
||||
ev.bearer = MESH_PROV_BEARER_PB_GATT;
|
||||
ev.bearer = BTP_MESH_PROV_BEARER_PB_GATT;
|
||||
break;
|
||||
default:
|
||||
SYS_LOG_ERR("Invalid bearer");
|
||||
@@ -283,23 +283,23 @@ link_open(bt_mesh_prov_bearer_t bearer)
|
||||
return;
|
||||
}
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_PROV_LINK_OPEN,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_PROV_LINK_OPEN,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
static void
|
||||
link_close(bt_mesh_prov_bearer_t bearer)
|
||||
{
|
||||
struct mesh_prov_link_closed_ev ev;
|
||||
struct btp_mesh_prov_link_closed_ev ev;
|
||||
|
||||
SYS_LOG_DBG("bearer 0x%02x", bearer);
|
||||
|
||||
switch (bearer) {
|
||||
case BT_MESH_PROV_ADV:
|
||||
ev.bearer = MESH_PROV_BEARER_PB_ADV;
|
||||
ev.bearer = BTP_MESH_PROV_BEARER_PB_ADV;
|
||||
break;
|
||||
case BT_MESH_PROV_GATT:
|
||||
ev.bearer = MESH_PROV_BEARER_PB_GATT;
|
||||
ev.bearer = BTP_MESH_PROV_BEARER_PB_GATT;
|
||||
break;
|
||||
default:
|
||||
SYS_LOG_ERR("Invalid bearer");
|
||||
@@ -307,21 +307,21 @@ link_close(bt_mesh_prov_bearer_t bearer)
|
||||
return;
|
||||
}
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_PROV_LINK_CLOSED,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_PROV_LINK_CLOSED,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
static int
|
||||
output_number(bt_mesh_output_action_t action, uint32_t number)
|
||||
{
|
||||
struct mesh_out_number_action_ev ev;
|
||||
struct btp_mesh_out_number_action_ev ev;
|
||||
|
||||
SYS_LOG_DBG("action 0x%04x number 0x%08lx", action, number);
|
||||
|
||||
ev.action = sys_cpu_to_le16(action);
|
||||
ev.number = sys_cpu_to_le32(number);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_OUT_NUMBER_ACTION,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_OUT_NUMBER_ACTION,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
|
||||
return 0;
|
||||
@@ -330,8 +330,8 @@ output_number(bt_mesh_output_action_t action, uint32_t number)
|
||||
static int
|
||||
output_string(const char *str)
|
||||
{
|
||||
struct mesh_out_string_action_ev *ev;
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(BTP_DATA_MAX_SIZE);
|
||||
struct btp_mesh_out_string_action_ev *ev;
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(BTP_DATA_MAX_SIZE);
|
||||
|
||||
SYS_LOG_DBG("str %s", str);
|
||||
|
||||
@@ -342,7 +342,7 @@ output_string(const char *str)
|
||||
|
||||
net_buf_simple_add_mem(buf, str, ev->string_len);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, MESH_EV_OUT_STRING_ACTION,
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, BTP_MESH_EV_OUT_STRING_ACTION,
|
||||
CONTROLLER_INDEX, buf);
|
||||
|
||||
os_mbuf_free_chain(buf);
|
||||
@@ -352,7 +352,7 @@ output_string(const char *str)
|
||||
static int
|
||||
input(bt_mesh_input_action_t action, uint8_t size)
|
||||
{
|
||||
struct mesh_in_action_ev ev;
|
||||
struct btp_mesh_in_action_ev ev;
|
||||
|
||||
SYS_LOG_DBG("action 0x%04x number 0x%02x", action, size);
|
||||
|
||||
@@ -361,7 +361,7 @@ input(bt_mesh_input_action_t action, uint8_t size)
|
||||
ev.action = sys_cpu_to_le16(action);
|
||||
ev.size = size;
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_IN_ACTION, CONTROLLER_INDEX,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_IN_ACTION, CONTROLLER_INDEX,
|
||||
(uint8_t *) &ev, sizeof(ev));
|
||||
|
||||
return 0;
|
||||
@@ -379,7 +379,7 @@ prov_complete(uint16_t net_idx, uint16_t addr)
|
||||
net.local = addr;
|
||||
net.dst = addr;
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_PROVISIONED, CONTROLLER_INDEX,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_PROVISIONED, CONTROLLER_INDEX,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ static struct bt_mesh_prov prov = {
|
||||
static void
|
||||
config_prov(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct mesh_config_provisioning_cmd *cmd = (void *) data;
|
||||
const struct btp_mesh_config_provisioning_cmd *cmd = (void *) data;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
@@ -425,14 +425,14 @@ config_prov(uint8_t *data, uint16_t len)
|
||||
prov.input_size = cmd->in_size;
|
||||
prov.input_actions = sys_le16_to_cpu(cmd->in_actions);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_CONFIG_PROVISIONING,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_CONFIG_PROVISIONING,
|
||||
CONTROLLER_INDEX, BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
provision_node(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct mesh_provision_node_cmd *cmd = (void *) data;
|
||||
const struct btp_mesh_provision_node_cmd *cmd = (void *) data;
|
||||
|
||||
SYS_LOG_DBG("");
|
||||
|
||||
@@ -444,7 +444,7 @@ provision_node(uint8_t *data, uint16_t len)
|
||||
iv_index = sys_le32_to_cpu(cmd->iv_index);
|
||||
net_key_idx = sys_le16_to_cpu(cmd->net_key_idx);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_PROVISION_NODE,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_PROVISION_NODE,
|
||||
CONTROLLER_INDEX, BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ init(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_INIT, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_INIT, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -488,15 +488,15 @@ reset(uint8_t *data, uint16_t len)
|
||||
|
||||
bt_mesh_reset();
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_RESET, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_RESET, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
input_number(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct mesh_input_number_cmd *cmd = (void *) data;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
const struct btp_mesh_input_number_cmd *cmd = (void *) data;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
uint32_t number;
|
||||
int err;
|
||||
|
||||
@@ -509,15 +509,15 @@ input_number(uint8_t *data, uint16_t len)
|
||||
status = BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_INPUT_NUMBER, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_INPUT_NUMBER, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
input_string(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct mesh_input_string_cmd *cmd = (void *) data;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
const struct btp_mesh_input_string_cmd *cmd = (void *) data;
|
||||
uint8_t status = BTP_STATUS_SUCCESS;
|
||||
uint8_t str_auth[16];
|
||||
int err;
|
||||
|
||||
@@ -541,20 +541,20 @@ input_string(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_INPUT_STRING, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_INPUT_STRING, CONTROLLER_INDEX,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
ivu_test_mode(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct mesh_ivu_test_mode_cmd *cmd = (void *) data;
|
||||
const struct btp_mesh_ivu_test_mode_cmd *cmd = (void *) data;
|
||||
|
||||
SYS_LOG_DBG("enable 0x%02x", cmd->enable);
|
||||
|
||||
bt_mesh_iv_update_test(cmd->enable ? true : false);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_IVU_TEST_MODE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_IVU_TEST_MODE, CONTROLLER_INDEX,
|
||||
BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -570,14 +570,14 @@ ivu_toggle_state(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to toggle the IV Update state");
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_IVU_TOGGLE_STATE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_IVU_TOGGLE_STATE, CONTROLLER_INDEX,
|
||||
result ? BTP_STATUS_SUCCESS : BTP_STATUS_FAILED);
|
||||
}
|
||||
|
||||
static void
|
||||
lpn(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_lpn_set_cmd *cmd = (void *) data;
|
||||
struct btp_mesh_lpn_set_cmd *cmd = (void *) data;
|
||||
bool enable;
|
||||
int err;
|
||||
|
||||
@@ -589,7 +589,7 @@ lpn(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to toggle LPN (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_LPN, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_LPN, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -605,15 +605,15 @@ lpn_poll(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to send poll msg (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_LPN_POLL, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_LPN_POLL, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
net_send(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_net_send_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct btp_mesh_net_send_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
.net_idx = net.net_idx,
|
||||
.app_idx = vnd_app_key_idx,
|
||||
@@ -638,7 +638,7 @@ net_send(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to send (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_NET_SEND, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_NET_SEND, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
|
||||
os_mbuf_free_chain(msg);
|
||||
@@ -647,8 +647,8 @@ net_send(uint8_t *data, uint16_t len)
|
||||
static void
|
||||
health_generate_faults(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_health_generate_faults_rp *rp;
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(sizeof(*rp) + sizeof(cur_faults) +
|
||||
struct btp_mesh_health_generate_faults_rp *rp;
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(sizeof(*rp) + sizeof(cur_faults) +
|
||||
sizeof(reg_faults));
|
||||
uint8_t some_faults[] = {0x01, 0x02, 0x03, 0xff, 0x06};
|
||||
uint8_t cur_faults_count, reg_faults_count;
|
||||
@@ -667,7 +667,7 @@ health_generate_faults(uint8_t *data, uint16_t len)
|
||||
|
||||
bt_mesh_fault_update(&elements[0]);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, MESH_HEALTH_GENERATE_FAULTS,
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, BTP_MESH_HEALTH_GENERATE_FAULTS,
|
||||
CONTROLLER_INDEX, buf);
|
||||
}
|
||||
|
||||
@@ -681,15 +681,15 @@ health_clear_faults(uint8_t *data, uint16_t len)
|
||||
|
||||
bt_mesh_fault_update(&elements[0]);
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_HEALTH_CLEAR_FAULTS,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_HEALTH_CLEAR_FAULTS,
|
||||
CONTROLLER_INDEX, BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
model_send(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_model_send_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct btp_mesh_model_send_cmd *cmd = (void *) data;
|
||||
struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
.net_idx = net.net_idx,
|
||||
.app_idx = BT_MESH_KEY_DEV,
|
||||
@@ -728,7 +728,7 @@ model_send(uint8_t *data, uint16_t len)
|
||||
}
|
||||
|
||||
fail:
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_MODEL_SEND, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_MODEL_SEND, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
|
||||
os_mbuf_free_chain(msg);
|
||||
@@ -739,8 +739,8 @@ fail:
|
||||
static void
|
||||
lpn_subscribe(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_lpn_subscribe_cmd *cmd = (void *) data;
|
||||
uint16_t address = sys_le16_to_cpu(cmd->address);
|
||||
struct btp_mesh_lpn_subscribe_cmd *cmd = (void *) data;
|
||||
uint16_t address = sys_le16_to_cpu(cmd->address);
|
||||
int err;
|
||||
|
||||
SYS_LOG_DBG("address 0x%04x", address);
|
||||
@@ -750,15 +750,15 @@ lpn_subscribe(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to subscribe (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_LPN_SUBSCRIBE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_LPN_SUBSCRIBE, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
lpn_unsubscribe(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct mesh_lpn_unsubscribe_cmd *cmd = (void *) data;
|
||||
uint16_t address = sys_le16_to_cpu(cmd->address);
|
||||
struct btp_mesh_lpn_unsubscribe_cmd *cmd = (void *) data;
|
||||
uint16_t address = sys_le16_to_cpu(cmd->address);
|
||||
int err;
|
||||
|
||||
SYS_LOG_DBG("address 0x%04x", address);
|
||||
@@ -768,7 +768,7 @@ lpn_unsubscribe(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to unsubscribe (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_LPN_UNSUBSCRIBE, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_LPN_UNSUBSCRIBE, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ rpl_clear(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to clear RPL (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_RPL_CLEAR, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_RPL_CLEAR, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -802,7 +802,7 @@ proxy_identity_enable(uint8_t *data, uint16_t len)
|
||||
SYS_LOG_ERR("Failed to enable proxy identity (err %d)", err);
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, MESH_PROXY_IDENTITY, CONTROLLER_INDEX,
|
||||
tester_rsp(BTP_SERVICE_ID_MESH, BTP_MESH_PROXY_IDENTITY, CONTROLLER_INDEX,
|
||||
err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -810,63 +810,63 @@ void
|
||||
tester_handle_mesh(uint8_t opcode, uint8_t index, uint8_t *data, uint16_t len)
|
||||
{
|
||||
switch (opcode) {
|
||||
case MESH_READ_SUPPORTED_COMMANDS:
|
||||
case BTP_MESH_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
break;
|
||||
case MESH_CONFIG_PROVISIONING:
|
||||
case BTP_MESH_CONFIG_PROVISIONING:
|
||||
config_prov(data, len);
|
||||
break;
|
||||
case MESH_PROVISION_NODE:
|
||||
case BTP_MESH_PROVISION_NODE:
|
||||
provision_node(data, len);
|
||||
break;
|
||||
case MESH_INIT:
|
||||
case BTP_MESH_INIT:
|
||||
init(data, len);
|
||||
break;
|
||||
case MESH_RESET:
|
||||
case BTP_MESH_RESET:
|
||||
reset(data, len);
|
||||
break;
|
||||
case MESH_INPUT_NUMBER:
|
||||
case BTP_MESH_INPUT_NUMBER:
|
||||
input_number(data, len);
|
||||
break;
|
||||
case MESH_INPUT_STRING:
|
||||
case BTP_MESH_INPUT_STRING:
|
||||
input_string(data, len);
|
||||
break;
|
||||
case MESH_IVU_TEST_MODE:
|
||||
case BTP_MESH_IVU_TEST_MODE:
|
||||
ivu_test_mode(data, len);
|
||||
break;
|
||||
case MESH_IVU_TOGGLE_STATE:
|
||||
case BTP_MESH_IVU_TOGGLE_STATE:
|
||||
ivu_toggle_state(data, len);
|
||||
break;
|
||||
case MESH_LPN:
|
||||
case BTP_MESH_LPN:
|
||||
lpn(data, len);
|
||||
break;
|
||||
case MESH_LPN_POLL:
|
||||
case BTP_MESH_LPN_POLL:
|
||||
lpn_poll(data, len);
|
||||
break;
|
||||
case MESH_NET_SEND:
|
||||
case BTP_MESH_NET_SEND:
|
||||
net_send(data, len);
|
||||
break;
|
||||
case MESH_HEALTH_GENERATE_FAULTS:
|
||||
case BTP_MESH_HEALTH_GENERATE_FAULTS:
|
||||
health_generate_faults(data, len);
|
||||
break;
|
||||
case MESH_HEALTH_CLEAR_FAULTS:
|
||||
case BTP_MESH_HEALTH_CLEAR_FAULTS:
|
||||
health_clear_faults(data, len);
|
||||
break;
|
||||
case MESH_MODEL_SEND:
|
||||
case BTP_MESH_MODEL_SEND:
|
||||
model_send(data, len);
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_MESH_TESTING)
|
||||
case MESH_LPN_SUBSCRIBE:
|
||||
case BTP_MESH_LPN_SUBSCRIBE:
|
||||
lpn_subscribe(data, len);
|
||||
break;
|
||||
case MESH_LPN_UNSUBSCRIBE:
|
||||
case BTP_MESH_LPN_UNSUBSCRIBE:
|
||||
lpn_unsubscribe(data, len);
|
||||
break;
|
||||
case MESH_RPL_CLEAR:
|
||||
case BTP_MESH_RPL_CLEAR:
|
||||
rpl_clear(data, len);
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_MESH_TESTING) */
|
||||
case MESH_PROXY_IDENTITY:
|
||||
case BTP_MESH_PROXY_IDENTITY:
|
||||
proxy_identity_enable(data, len);
|
||||
break;
|
||||
default:
|
||||
@@ -884,8 +884,8 @@ net_recv_ev(uint8_t ttl,
|
||||
const void *payload,
|
||||
size_t payload_len)
|
||||
{
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct mesh_net_recv_ev *ev;
|
||||
struct os_mbuf *buf = NET_BUF_SIMPLE(UINT8_MAX);
|
||||
struct btp_mesh_net_recv_ev *ev;
|
||||
|
||||
SYS_LOG_DBG("ttl 0x%02x ctl 0x%02x src 0x%04x dst 0x%04x "
|
||||
"payload_len %d", ttl, ctl, src, dst, payload_len);
|
||||
@@ -904,7 +904,7 @@ net_recv_ev(uint8_t ttl,
|
||||
ev->payload_len = payload_len;
|
||||
net_buf_simple_add_mem(buf, payload, payload_len);
|
||||
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, MESH_EV_NET_RECV, CONTROLLER_INDEX,
|
||||
tester_send_buf(BTP_SERVICE_ID_MESH, BTP_MESH_EV_NET_RECV, CONTROLLER_INDEX,
|
||||
buf);
|
||||
done:
|
||||
os_mbuf_free_chain(buf);
|
||||
@@ -957,20 +957,20 @@ model_unbound_cb(uint16_t addr, struct bt_mesh_model *model,
|
||||
static void
|
||||
invalid_bearer_cb(uint8_t opcode)
|
||||
{
|
||||
struct mesh_invalid_bearer_ev ev = {
|
||||
struct btp_mesh_invalid_bearer_ev ev = {
|
||||
.opcode = opcode,
|
||||
};
|
||||
|
||||
SYS_LOG_DBG("opcode 0x%02x", opcode);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_INVALID_BEARER,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_INVALID_BEARER,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
static void
|
||||
incomp_timer_exp_cb(void)
|
||||
{
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_INCOMP_TIMER_EXP,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_INCOMP_TIMER_EXP,
|
||||
CONTROLLER_INDEX, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -987,7 +987,7 @@ lpn_established(uint16_t friend_addr)
|
||||
{
|
||||
|
||||
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
|
||||
struct mesh_lpn_established_ev
|
||||
struct btp_mesh_lpn_established_ev
|
||||
ev = {lpn->sub->net_idx, friend_addr, lpn->queue_size,
|
||||
lpn->recv_win};
|
||||
|
||||
@@ -995,20 +995,20 @@ lpn_established(uint16_t friend_addr)
|
||||
"Friend 0x%04x Queue Size %d Receive Window %d",
|
||||
friend_addr, lpn->queue_size, lpn->recv_win);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_LPN_ESTABLISHED,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_LPN_ESTABLISHED,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
static void
|
||||
lpn_terminated(uint16_t friend_addr)
|
||||
{
|
||||
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
|
||||
struct mesh_lpn_terminated_ev ev = {lpn->sub->net_idx, friend_addr};
|
||||
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
|
||||
struct btp_mesh_lpn_terminated_ev ev = {lpn->sub->net_idx, friend_addr};
|
||||
|
||||
SYS_LOG_DBG("Friendship (as LPN) lost with Friend "
|
||||
"0x%04x", friend_addr);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_MESH, MESH_EV_LPN_TERMINATED,
|
||||
tester_send(BTP_SERVICE_ID_MESH, BTP_MESH_EV_LPN_TERMINATED,
|
||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "console/console.h"
|
||||
|
||||
#include "bttester_pipe.h"
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
#define CMD_QUEUED 2
|
||||
|
||||
@@ -51,145 +51,6 @@ struct btp_buf {
|
||||
|
||||
static struct btp_buf cmd_buf[CMD_QUEUED];
|
||||
|
||||
static void
|
||||
supported_commands(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buf[1];
|
||||
struct core_read_supported_commands_rp *rp = (void *) buf;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
tester_set_bit(buf, CORE_READ_SUPPORTED_COMMANDS);
|
||||
tester_set_bit(buf, CORE_READ_SUPPORTED_SERVICES);
|
||||
tester_set_bit(buf, CORE_REGISTER_SERVICE);
|
||||
tester_set_bit(buf, CORE_UNREGISTER_SERVICE);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_CORE, CORE_READ_SUPPORTED_COMMANDS,
|
||||
BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf));
|
||||
}
|
||||
|
||||
static void
|
||||
supported_services(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buf[1];
|
||||
struct core_read_supported_services_rp *rp = (void *) buf;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_CORE);
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GAP);
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GATT);
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_L2CAP);
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_MESH);
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
tester_set_bit(buf, BTP_SERVICE_ID_GATTC);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_CORE, CORE_READ_SUPPORTED_SERVICES,
|
||||
BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf));
|
||||
}
|
||||
|
||||
static void
|
||||
register_service(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct core_register_service_cmd *cmd = (void *) data;
|
||||
uint8_t status;
|
||||
|
||||
switch (cmd->id) {
|
||||
case BTP_SERVICE_ID_GAP:
|
||||
status = tester_init_gap();
|
||||
/* Rsp with success status will be handled by bt enable cb */
|
||||
if (status == BTP_STATUS_FAILED) {
|
||||
goto rsp;
|
||||
}
|
||||
return;
|
||||
case BTP_SERVICE_ID_GATT:
|
||||
status = tester_init_gatt();
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
case BTP_SERVICE_ID_L2CAP:
|
||||
status = tester_init_l2cap();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
case BTP_SERVICE_ID_MESH:
|
||||
status = tester_init_mesh();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
default:
|
||||
status = BTP_STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
rsp:
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, CORE_REGISTER_SERVICE, BTP_INDEX_NONE,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
unregister_service(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct core_unregister_service_cmd *cmd = (void *) data;
|
||||
uint8_t status;
|
||||
|
||||
switch (cmd->id) {
|
||||
case BTP_SERVICE_ID_GAP:
|
||||
status = tester_unregister_gap();
|
||||
break;
|
||||
case BTP_SERVICE_ID_GATT:
|
||||
status = tester_unregister_gatt();
|
||||
break;
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||
case BTP_SERVICE_ID_L2CAP:
|
||||
status = tester_unregister_l2cap();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) */
|
||||
#if MYNEWT_VAL(BLE_MESH)
|
||||
case BTP_SERVICE_ID_MESH:
|
||||
status = tester_unregister_mesh();
|
||||
break;
|
||||
#endif /* MYNEWT_VAL(BLE_MESH) */
|
||||
default:
|
||||
status = BTP_STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, CORE_UNREGISTER_SERVICE, BTP_INDEX_NONE,
|
||||
status);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_core(uint8_t opcode, uint8_t index, uint8_t *data,
|
||||
uint16_t len)
|
||||
{
|
||||
if (index != BTP_INDEX_NONE) {
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, opcode, index,
|
||||
BTP_STATUS_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case CORE_READ_SUPPORTED_COMMANDS:
|
||||
supported_commands(data, len);
|
||||
return;
|
||||
case CORE_READ_SUPPORTED_SERVICES:
|
||||
supported_services(data, len);
|
||||
return;
|
||||
case CORE_REGISTER_SERVICE:
|
||||
register_service(data, len);
|
||||
return;
|
||||
case CORE_UNREGISTER_SERVICE:
|
||||
unregister_service(data, len);
|
||||
return;
|
||||
default:
|
||||
tester_rsp(BTP_SERVICE_ID_CORE, opcode, BTP_INDEX_NONE,
|
||||
BTP_STATUS_UNKNOWN_CMD);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_handler(struct os_event *ev)
|
||||
{
|
||||
@@ -216,7 +77,7 @@ cmd_handler(struct os_event *ev)
|
||||
|
||||
switch (cmd->hdr.service) {
|
||||
case BTP_SERVICE_ID_CORE:
|
||||
handle_core(cmd->hdr.opcode, cmd->hdr.index,
|
||||
tester_handle_core(cmd->hdr.opcode, cmd->hdr.index,
|
||||
cmd->hdr.data, len);
|
||||
break;
|
||||
case BTP_SERVICE_ID_GAP:
|
||||
@@ -330,7 +191,7 @@ tester_init(void)
|
||||
|
||||
bttester_pipe_register(buf->data, BTP_MTU, recv_cb);
|
||||
|
||||
tester_send(BTP_SERVICE_ID_CORE, CORE_EV_IUT_READY, BTP_INDEX_NONE,
|
||||
tester_send(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, BTP_INDEX_NONE,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@
|
||||
#define __BTTESTER_PIPE_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "bttester.h"
|
||||
#include "btp/bttester.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "host/ble_uuid.h"
|
||||
#include "host/ble_hs.h"
|
||||
|
||||
#include "bttester.h"
|
||||
#include "btp/btp.h"
|
||||
|
||||
static void
|
||||
on_reset(int reason)
|
||||
|
||||
Reference in New Issue
Block a user