Bluetooth: tests: Add edtt_ble_test_app

Added application for testing the bluetooth stack
from the EDTTool

Signed-off-by: Henrik Eriksen <heri@oticon.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2019-06-25 14:48:54 +02:00 committed by Carles Cufí
commit c256d06aee
73 changed files with 8996 additions and 0 deletions

View file

@ -0,0 +1,63 @@
Intro
#####
This is the embedded side of the BLE conformance tests which are part of the
EDTT (Embedded Device Test Tool).
Much more info about the tool can be found in https://github.com/EDTTool/EDTT
and in its `doc/` folder.
In very short, there is 2 applications in this folder:
1.) A controller only build of the BLE stack, where the HCI, and a few extra
interfaces are exposed to the EDTT.
2.) An application which implements the test GATT services specified by BT SIG
in GATT_Test_Databases.xlsm, with an EDTT interface which allows the EDTT
tests to switch between theses.
The first application is used for LL and HCI conformance tests of the
controller.
The second application for GATT tests.
These 2 particular applications are meant to be used in a simulated environment,
for regression, either as part of a CI system, or in workstation during
development.
This is due to this particular application only containing an EDTT transport
driver for simulated targets, meant to connect to the `bsim` EDTT transport
driver thru the EDTT bridge.
How to use it
#############
Assuming you have already
`installed BabbleSim <https://babblesim.github.io/fetching.html>`_.
Add to your environment the variable EDTT_PATH poitining to the
EDTT folder. You can do this by adding it to your `~/.bashrc`, `~/.zephyrrc`,
or similar something like:
```
export EDTT_PATH=${ZEPHYR_BASE}/../tools/edtt/
```
(if you add it to your .bashrc you probably won't be able to refer to
ZEPHYR_BASE)
To run these sets of tests you need to compile both of these applications as any
other Zephyr app, targeting the nrf52_bsim.
To compile both in an automated way you can just use the `compile.sh` (see
below).
To run the tests you can either run one of the provided scripts, or run by
hand the BabbleSim 2G4 Phy, EDTT bridge, EDTT and needed simulated devices.
The shortest path is to use the provided scripts.
In short the whole process being:
```
cd ${ZEPHYR_BASE} && source zephyr-env.sh
#Compile all apps:
WORK_DIR=${ZEPHYR_BASE}/bsim_bt_out tests/bluetooth/bsim_bt/compile.sh
#run all tests
RESULTS_FILE=${ZEPHYR_BASE}/banana.xml SEARCH_PATH=tests/bluetooth/bsim_bt/edtt_ble_test_app/ tests/bluetooth/bsim_bt/run_parallel.sh
#or just run one set:
tests/bluetooth/bsim_bt/edtt_ble_test_app/tests_scripts/hci.sh
```

View file

@ -0,0 +1,241 @@
/*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef EDDT_APP_COMMANDS_H
#define EDDT_APP_COMMANDS_H
enum commands_t {
CMD_NOTHING = 0,
CMD_ECHO_REQ,
CMD_ECHO_RSP,
CMD_INQUIRE_REQ,
CMD_INQUIRE_RSP,
CMD_DISCONNECT_REQ,
CMD_DISCONNECT_RSP,
CMD_READ_REMOTE_VERSION_INFORMATION_REQ,
CMD_READ_REMOTE_VERSION_INFORMATION_RSP,
CMD_SET_EVENT_MASK_REQ,
CMD_SET_EVENT_MASK_RSP,
CMD_RESET_REQ,
CMD_RESET_RSP,
CMD_READ_TRANSMIT_POWER_LEVEL_REQ,
CMD_READ_TRANSMIT_POWER_LEVEL_RSP,
CMD_SET_CONTROLLER_TO_HOST_FLOW_CONTROL_REQ,
CMD_SET_CONTROLLER_TO_HOST_FLOW_CONTROL_RSP,
CMD_HOST_BUFFER_SIZE_REQ,
CMD_HOST_BUFFER_SIZE_RSP,
CMD_HOST_NUMBER_OF_COMPLETED_PACKETS_REQ,
CMD_HOST_NUMBER_OF_COMPLETED_PACKETS_RSP,
CMD_SET_EVENT_MASK_PAGE_2_REQ,
CMD_SET_EVENT_MASK_PAGE_2_RSP,
CMD_WRITE_LE_HOST_SUPPORT_REQ,
CMD_WRITE_LE_HOST_SUPPORT_RSP,
CMD_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ,
CMD_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_RSP,
CMD_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ,
CMD_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_RSP,
CMD_READ_LOCAL_VERSION_INFORMATION_REQ,
CMD_READ_LOCAL_VERSION_INFORMATION_RSP,
CMD_READ_LOCAL_SUPPORTED_COMMANDS_REQ,
CMD_READ_LOCAL_SUPPORTED_COMMANDS_RSP,
CMD_READ_LOCAL_SUPPORTED_FEATURES_REQ,
CMD_READ_LOCAL_SUPPORTED_FEATURES_RSP,
CMD_READ_BUFFER_SIZE_REQ,
CMD_READ_BUFFER_SIZE_RSP,
CMD_READ_BD_ADDR_REQ,
CMD_READ_BD_ADDR_RSP,
CMD_READ_RSSI_REQ,
CMD_READ_RSSI_RSP,
CMD_LE_SET_EVENT_MASK_REQ,
CMD_LE_SET_EVENT_MASK_RSP,
CMD_LE_READ_BUFFER_SIZE_REQ,
CMD_LE_READ_BUFFER_SIZE_RSP,
CMD_LE_READ_LOCAL_SUPPORTED_FEATURES_REQ,
CMD_LE_READ_LOCAL_SUPPORTED_FEATURES_RSP,
CMD_LE_SET_RANDOM_ADDRESS_REQ,
CMD_LE_SET_RANDOM_ADDRESS_RSP,
CMD_LE_SET_ADVERTISING_PARAMETERS_REQ,
CMD_LE_SET_ADVERTISING_PARAMETERS_RSP,
CMD_LE_READ_ADVERTISING_CHANNEL_TX_POWER_REQ,
CMD_LE_READ_ADVERTISING_CHANNEL_TX_POWER_RSP,
CMD_LE_SET_ADVERTISING_DATA_REQ,
CMD_LE_SET_ADVERTISING_DATA_RSP,
CMD_LE_SET_SCAN_RESPONSE_DATA_REQ,
CMD_LE_SET_SCAN_RESPONSE_DATA_RSP,
CMD_LE_SET_ADVERTISING_ENABLE_REQ,
CMD_LE_SET_ADVERTISING_ENABLE_RSP,
CMD_LE_SET_SCAN_PARAMETERS_REQ,
CMD_LE_SET_SCAN_PARAMETERS_RSP,
CMD_LE_SET_SCAN_ENABLE_REQ,
CMD_LE_SET_SCAN_ENABLE_RSP,
CMD_LE_CREATE_CONNECTION_REQ,
CMD_LE_CREATE_CONNECTION_RSP,
CMD_LE_CREATE_CONNECTION_CANCEL_REQ,
CMD_LE_CREATE_CONNECTION_CANCEL_RSP,
CMD_LE_READ_WHITE_LIST_SIZE_REQ,
CMD_LE_READ_WHITE_LIST_SIZE_RSP,
CMD_LE_CLEAR_WHITE_LIST_REQ,
CMD_LE_CLEAR_WHITE_LIST_RSP,
CMD_LE_ADD_DEVICE_TO_WHITE_LIST_REQ,
CMD_LE_ADD_DEVICE_TO_WHITE_LIST_RSP,
CMD_LE_REMOVE_DEVICE_FROM_WHITE_LIST_REQ,
CMD_LE_REMOVE_DEVICE_FROM_WHITE_LIST_RSP,
CMD_LE_CONNECTION_UPDATE_REQ,
CMD_LE_CONNECTION_UPDATE_RSP,
CMD_LE_SET_HOST_CHANNEL_CLASSIFICATION_REQ,
CMD_LE_SET_HOST_CHANNEL_CLASSIFICATION_RSP,
CMD_LE_READ_CHANNEL_MAP_REQ,
CMD_LE_READ_CHANNEL_MAP_RSP,
CMD_LE_READ_REMOTE_FEATURES_REQ,
CMD_LE_READ_REMOTE_FEATURES_RSP,
CMD_LE_ENCRYPT_REQ,
CMD_LE_ENCRYPT_RSP,
CMD_LE_RAND_REQ,
CMD_LE_RAND_RSP,
CMD_LE_START_ENCRYPTION_REQ,
CMD_LE_START_ENCRYPTION_RSP,
CMD_LE_LONG_TERM_KEY_REQUEST_REPLY_REQ,
CMD_LE_LONG_TERM_KEY_REQUEST_REPLY_RSP,
CMD_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_REQ,
CMD_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_RSP,
CMD_LE_READ_SUPPORTED_STATES_REQ,
CMD_LE_READ_SUPPORTED_STATES_RSP,
CMD_LE_RECEIVER_TEST_REQ,
CMD_LE_RECEIVER_TEST_RSP,
CMD_LE_TRANSMITTER_TEST_REQ,
CMD_LE_TRANSMITTER_TEST_RSP,
CMD_LE_TEST_END_REQ,
CMD_LE_TEST_END_RSP,
CMD_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY_REQ,
CMD_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY_RSP,
CMD_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY_REQ,
CMD_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY_RSP,
CMD_LE_SET_DATA_LENGTH_REQ,
CMD_LE_SET_DATA_LENGTH_RSP,
CMD_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_REQ,
CMD_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_RSP,
CMD_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_REQ,
CMD_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_RSP,
CMD_LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND_REQ,
CMD_LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND_RSP,
CMD_LE_GENERATE_DHKEY_COMMAND_REQ,
CMD_LE_GENERATE_DHKEY_COMMAND_RSP,
CMD_LE_ADD_DEVICE_TO_RESOLVING_LIST_REQ,
CMD_LE_ADD_DEVICE_TO_RESOLVING_LIST_RSP,
CMD_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_REQ,
CMD_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_RSP,
CMD_LE_CLEAR_RESOLVING_LIST_REQ,
CMD_LE_CLEAR_RESOLVING_LIST_RSP,
CMD_LE_READ_RESOLVING_LIST_SIZE_REQ,
CMD_LE_READ_RESOLVING_LIST_SIZE_RSP,
CMD_LE_READ_PEER_RESOLVABLE_ADDRESS_REQ,
CMD_LE_READ_PEER_RESOLVABLE_ADDRESS_RSP,
CMD_LE_READ_LOCAL_RESOLVABLE_ADDRESS_REQ,
CMD_LE_READ_LOCAL_RESOLVABLE_ADDRESS_RSP,
CMD_LE_SET_ADDRESS_RESOLUTION_ENABLE_REQ,
CMD_LE_SET_ADDRESS_RESOLUTION_ENABLE_RSP,
CMD_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_REQ,
CMD_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_RSP,
CMD_LE_READ_MAXIMUM_DATA_LENGTH_REQ,
CMD_LE_READ_MAXIMUM_DATA_LENGTH_RSP,
CMD_LE_READ_PHY_REQ,
CMD_LE_READ_PHY_RSP,
CMD_LE_SET_DEFAULT_PHY_REQ,
CMD_LE_SET_DEFAULT_PHY_RSP,
CMD_LE_SET_PHY_REQ,
CMD_LE_SET_PHY_RSP,
CMD_LE_ENHANCED_RECEIVER_TEST_REQ,
CMD_LE_ENHANCED_RECEIVER_TEST_RSP,
CMD_LE_ENHANCED_TRANSMITTER_TEST_REQ,
CMD_LE_ENHANCED_TRANSMITTER_TEST_RSP,
CMD_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_REQ,
CMD_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_RSP,
CMD_LE_SET_EXTENDED_ADVERTISING_DATA_REQ,
CMD_LE_SET_EXTENDED_ADVERTISING_DATA_RSP,
CMD_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_REQ,
CMD_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_RSP,
CMD_LE_SET_EXTENDED_ADVERTISING_ENABLE_REQ,
CMD_LE_SET_EXTENDED_ADVERTISING_ENABLE_RSP,
CMD_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_REQ,
CMD_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_RSP,
CMD_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_REQ,
CMD_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_RSP,
CMD_LE_REMOVE_ADVERTISING_SET_REQ,
CMD_LE_REMOVE_ADVERTISING_SET_RSP,
CMD_LE_CLEAR_ADVERTISING_SETS_REQ,
CMD_LE_CLEAR_ADVERTISING_SETS_RSP,
CMD_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_REQ,
CMD_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_RSP,
CMD_LE_SET_PERIODIC_ADVERTISING_DATA_REQ,
CMD_LE_SET_PERIODIC_ADVERTISING_DATA_RSP,
CMD_LE_SET_PERIODIC_ADVERTISING_ENABLE_REQ,
CMD_LE_SET_PERIODIC_ADVERTISING_ENABLE_RSP,
CMD_LE_SET_EXTENDED_SCAN_PARAMETERS_REQ,
CMD_LE_SET_EXTENDED_SCAN_PARAMETERS_RSP,
CMD_LE_SET_EXTENDED_SCAN_ENABLE_REQ,
CMD_LE_SET_EXTENDED_SCAN_ENABLE_RSP,
CMD_LE_EXTENDED_CREATE_CONNECTION_REQ,
CMD_LE_EXTENDED_CREATE_CONNECTION_RSP,
CMD_LE_PERIODIC_ADVERTISING_CREATE_SYNC_REQ,
CMD_LE_PERIODIC_ADVERTISING_CREATE_SYNC_RSP,
CMD_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_REQ,
CMD_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_RSP,
CMD_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_REQ,
CMD_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_RSP,
CMD_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_REQ,
CMD_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_RSP,
CMD_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_REQ,
CMD_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_RSP,
CMD_LE_CLEAR_PERIODIC_ADVERTISER_LIST_REQ,
CMD_LE_CLEAR_PERIODIC_ADVERTISER_LIST_RSP,
CMD_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_REQ,
CMD_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_RSP,
CMD_LE_READ_TRANSMIT_POWER_REQ,
CMD_LE_READ_TRANSMIT_POWER_RSP,
CMD_LE_READ_RF_PATH_COMPENSATION_REQ,
CMD_LE_READ_RF_PATH_COMPENSATION_RSP,
CMD_LE_WRITE_RF_PATH_COMPENSATION_REQ,
CMD_LE_WRITE_RF_PATH_COMPENSATION_RSP,
CMD_LE_SET_PRIVACY_MODE_REQ,
CMD_LE_SET_PRIVACY_MODE_RSP,
CMD_WRITE_BD_ADDR_REQ,
CMD_WRITE_BD_ADDR_RSP,
CMD_FLUSH_EVENTS_REQ,
CMD_FLUSH_EVENTS_RSP,
CMD_HAS_EVENT_REQ,
CMD_HAS_EVENT_RSP,
CMD_GET_EVENT_REQ,
CMD_GET_EVENT_RSP,
CMD_LE_FLUSH_DATA_REQ,
CMD_LE_FLUSH_DATA_RSP,
CMD_LE_DATA_READY_REQ,
CMD_LE_DATA_READY_RSP,
CMD_LE_DATA_WRITE_REQ,
CMD_LE_DATA_WRITE_RSP,
CMD_LE_DATA_READ_REQ,
CMD_LE_DATA_READ_RSP,
CMD_GATT_SERVICE_SET_REQ,
CMD_GATT_SERVICE_SET_RSP,
CMD_GATT_SERVICE_NOTIFY_REQ,
CMD_GATT_SERVICE_NOTIFY_RSP,
CMD_GATT_SERVICE_INDICATE_REQ,
CMD_GATT_SERVICE_INDICATE_RSP,
CMD_GAP_ADVERTISING_MODE_REQ,
CMD_GAP_ADVERTISING_MODE_RSP,
CMD_GAP_ADVERTISING_DATA_REQ,
CMD_GAP_ADVERTISING_DATA_RSP,
CMD_GAP_SCANNING_MODE_REQ,
CMD_GAP_SCANNING_MODE_RSP,
CMD_READ_STATIC_ADDRESSES_REQ,
CMD_READ_STATIC_ADDRESSES_RSP,
CMD_READ_KEY_HIERARCHY_ROOTS_REQ,
CMD_READ_KEY_HIERARCHY_ROOTS_RSP,
CMD_GAP_READ_IRK_REQ,
CMD_GAP_READ_IRK_RSP,
CMD_GAP_ROLE_REQ,
CMD_GAP_ROLE_RSP
};
#endif /* EDDT_APP_COMMANDS_H */

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef EDTT_DRIVER_H
#define EDTT_DRIVER_H
#include <stdlib.h>
#include <stdbool.h>
#include "zephyr/types.h"
#define EDTTT_NONBLOCK 0
#define EDTTT_BLOCK 1
#ifdef __cplusplus
extern "C" {
#endif
/**
* Generic EDTT interface
*/
bool edtt_start(void);
bool edtt_stop(void);
int edtt_read(u8_t *ptr, size_t size, int flags);
int edtt_write(u8_t *ptr, size_t size, int flags);
#if defined(CONFIG_ARCH_POSIX)
/**
* Exclusive functions for the BabbleSim driver
*/
void enable_edtt_mode(void);
void set_edtt_autoshutdown(bool mode);
#endif /* CONFIG_POSIX_ARCH */
#ifdef __cplusplus
}
#endif
#endif /* EDTT_DRIVER_H */

View file

@ -0,0 +1,269 @@
/*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "edtt_driver.h"
#include "kernel.h"
#include "soc.h"
#include "bs_tracing.h"
#include "bs_utils.h"
#include "bs_oswrap.h"
#include "bs_pc_base_fifo_user.h"
/* Recheck if something arrived from the EDTT every 5ms */
#define EDTT_IF_RECHECK_DELTA 5 /*ms*/
/* We want the runs to be deterministic => we want to resync with the Phy
* before we retry any read so the bridge device may also run
*/
#define EDTT_SIMU_RESYNC_TIME_WITH_EDTT (EDTT_IF_RECHECK_DELTA*1e3-1)
int edtt_mode_enabled;
/* In this mode, when the EDTTool closes the FIFO we automatically terminate
* this simulated device. If false, we just continue running
*/
static int edtt_autoshutdown;
#define TO_DEVICE 0
#define TO_BRIDGE 1
static int fifo[2] = { -1, -1 };
static char *fifo_path[2] = {NULL, NULL};
extern unsigned int global_device_nbr;
static void edttd_clean_up(void);
static void edptd_create_fifo_if(void);
static int fifo_low_level_read(u8_t *bufptr, int size);
bool edtt_start(void)
{
if (edtt_mode_enabled == false) {
/* otherwise we don't try to open the EDTT interface */
return true;
}
edptd_create_fifo_if();
extern void tm_set_phy_max_resync_offset(u64_t offset_in_us);
tm_set_phy_max_resync_offset(EDTT_SIMU_RESYNC_TIME_WITH_EDTT);
return true;
}
bool edtt_stop(void)
{
if (edtt_mode_enabled == false) {
/* otherwise we don't try to open the EDTT interface */
return true;
}
bs_trace_raw(9, "EDTTT: %s called\n", __func__);
edttd_clean_up();
edtt_mode_enabled = false;
return true;
}
#if defined(NATIVE_TASK)
NATIVE_TASK(edtt_stop, ON_EXIT, 1);
#endif
/**
* Attempt to read size bytes thru the EDTT IF into the buffer <*ptr>
* <flags> can be set to EDTTT_BLOCK or EDTTT_NONBLOCK
*
* If set to EDTTT_BLOCK it will block the calling thread until <size>
* bytes have been read or the interface has been closed.
* If set to EDTTT_NONBLOCK it returns as soon as there is no more data to be
* read
*
* Returns the amount of read bytes, or -1 on error
*/
int edtt_read(u8_t *ptr, size_t size, int flags)
{
if (edtt_mode_enabled == false) {
return -1;
}
bs_trace_raw_time(8, "EDTT: Asked to read %i bytes\n", size);
int read = 0;
while (size > 0) {
int received_bytes;
received_bytes = fifo_low_level_read(ptr, size);
if (received_bytes < 0) {
return -1;
} else if (received_bytes > 0) {
size -= received_bytes;
ptr += received_bytes;
read += received_bytes;
} else {
if (flags & EDTTT_BLOCK) {
bs_trace_raw_time(9, "EDTT: No enough data yet,"
"sleeping for %i ms\n",
EDTT_IF_RECHECK_DELTA);
k_sleep(EDTT_IF_RECHECK_DELTA);
} else {
bs_trace_raw_time(9, "EDTT: No enough data yet,"
"returning\n");
break;
}
}
}
return read;
}
/**
* Write <size> bytes from <ptr> toward the EDTTool
*
* <flags> is ignored in this driver, all writes to the tool are
* instantaneous
*/
int edtt_write(u8_t *ptr, size_t size, int flags)
{
if (edtt_mode_enabled == false) {
return -1;
}
bs_trace_raw_time(9, "EDTT: Asked to write %i bytes\n", size);
if (write(fifo[TO_BRIDGE], ptr, size) != size) {
if (errno == EPIPE) {
bs_trace_error_line("EDTT IF suddenly closed by other "
"end\n");
}
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
bs_trace_error_line("EDTT IF to bridge filled up (FIFO "
"size needs to be increased)\n");
}
bs_trace_error_line("EDTT IF: Unexpected error on write\n");
}
return size;
}
/*
* Applications may want to enable the EDTT interface only in some
* cases. By default it is not enabled in this driver. This function
* must be called once before starting it to do so
*/
void enable_edtt_mode(void)
{
edtt_mode_enabled = true;
}
/**
* Automatically terminate this device execution once the EDTTool disconnects
*/
void set_edtt_autoshutdown(bool Mode)
{
edtt_autoshutdown = Mode;
}
static void edptd_create_fifo_if(void)
{
int flags;
bs_trace_raw_time(9, "Bringing EDTT IF up (waiting for other side)\n");
if (pb_com_path == NULL) {
bs_trace_error_line("Not connected to Phy."
"EDTT IF cannot be brough up\n");
}
/* At this point we have connected to the Phy so the COM folder does
* already exist
* also SIGPIPE is already ignored
*/
fifo_path[TO_DEVICE] = (char *)bs_calloc(pb_com_path_length + 30,
sizeof(char));
fifo_path[TO_BRIDGE] = (char *)bs_calloc(pb_com_path_length + 30,
sizeof(char));
sprintf(fifo_path[TO_DEVICE], "%s/Device%i.PTTin",
pb_com_path, global_device_nbr);
sprintf(fifo_path[TO_BRIDGE], "%s/Device%i.PTTout",
pb_com_path, global_device_nbr);
if ((pb_create_fifo_if_not_there(fifo_path[TO_DEVICE]) != 0)
|| (pb_create_fifo_if_not_there(fifo_path[TO_BRIDGE]) != 0)) {
bs_trace_error_line("Couldnt create FIFOs for EDTT IF\n");
}
/* we block here until the bridge opens its end */
fifo[TO_BRIDGE] = open(fifo_path[TO_BRIDGE], O_WRONLY);
if (fifo[TO_BRIDGE] == -1) {
bs_trace_error_line("Couldn't create FIFOs for EDTT IF\n");
}
flags = fcntl(fifo[TO_BRIDGE], F_GETFL);
flags |= O_NONBLOCK;
fcntl(fifo[TO_BRIDGE], F_SETFL, flags);
/* we will block here until the bridge opens its end */
fifo[TO_DEVICE] = open(fifo_path[TO_DEVICE], O_RDONLY);
if (fifo[TO_DEVICE] == -1) {
bs_trace_error_line("Couldn't create FIFOs for EDTT IF\n");
}
flags = fcntl(fifo[TO_DEVICE], F_GETFL);
flags |= O_NONBLOCK;
fcntl(fifo[TO_DEVICE], F_SETFL, flags);
}
static void edttd_clean_up(void)
{
for (int dir = TO_DEVICE ; dir <= TO_BRIDGE ; dir++) {
if (fifo_path[dir]) {
if (fifo[dir] != -1) {
close(fifo[dir]);
remove(fifo_path[dir]);
fifo[dir] = -1;
}
free(fifo_path[dir]);
fifo_path[dir] = NULL;
}
}
if (pb_com_path != NULL) {
rmdir(pb_com_path);
}
}
static int fifo_low_level_read(u8_t *bufptr, int size)
{
int received_bytes = read(fifo[TO_DEVICE], bufptr, size);
if ((received_bytes == -1) && (errno == EAGAIN)) {
return 0;
} else if (received_bytes == EOF || received_bytes == 0) {
/*The FIFO was closed by the bridge*/
if (edtt_autoshutdown) {
bs_trace_raw_time(3, "EDTT: FIFO closed "
"(ptt_autoshutdown==true) =>"
" Terminate\n");
edttd_clean_up();
bs_trace_exit_line("\n");
} else {
bs_trace_raw_time(3, "EDTT: FIFO closed "
"(ptt_autoshutdown==false) => We close "
"the FIFOs and move on\n");
edttd_clean_up();
edtt_mode_enabled = false;
return -1;
}
} else if (received_bytes == -1) {
bs_trace_error_line("EDTT: Unexpected error\n");
}
return received_bytes;
}

View file

@ -0,0 +1,29 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Oticon A/S
cmake_minimum_required(VERSION 3.13.1)
if (NOT DEFINED ENV{BSIM_COMPONENTS_PATH})
message(FATAL_ERROR "This test requires the BabbleSim simulator. Please set\
the environment variable BSIM_COMPONENTS_PATH to point to its components \
folder. More information can be found in\
https://babblesim.github.io/folder_structure_and_env.html")
endif()
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(peripheral_test)
FILE(GLOB app_sources src/*.c)
FILE(GLOB gatt_sources src/gatt/*.c)
target_sources(app PRIVATE
${app_sources}
../common/edtt_driver_bsim.c
${gatt_sources}
)
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth
../common/
src/
$ENV{BSIM_COMPONENTS_PATH}/libUtilv1/src/
$ENV{BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)

View file

@ -0,0 +1,33 @@
# Copyright (c) 2019 Oticon A/S
# SPDX-License-Identifier: Apache-2.0
CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_ATT_TX_MAX=3
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Test Database"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_GATT_DYNAMIC_DB=y
CONFIG_BT_CTLR=y
# CONFIG_BT_LL_SW_LEGACY=y
CONFIG_BT_LL_SW_SPLIT=y
#
# NOTE: In order to get ACL_FLOW_CONTROL to work it is imperative that BT_CTRL_RX_BUFFERS is increased from its default value of 1.
#
CONFIG_BT_HCI_ACL_FLOW_CONTROL=y
CONFIG_BT_L2CAP_RX_MTU=512
CONFIG_BT_L2CAP_TX_MTU=512
CONFIG_BT_CTLR_RX_BUFFERS=3
CONFIG_BT_DEBUG=y
CONFIG_BT_DEBUG_LOG=y
#
# To make DEVICE Name writable...
#
CONFIG_BT_CONN=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_LOG_MAX_LEVEL=2

View file

@ -0,0 +1,238 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief GATT Macros
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Qualification_Test_Databases.xlsm' Sheet: 'Large Database 1'
*
* Feel free to change it - but be aware that your changes might be
* overwritten at the next generation...
*/
#ifndef GATT_MACS_H
#define GATT_MACS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bluetooth/gatt.h>
/** @def BT_GATT_H_ATTRIBUTE
* @brief Attribute Declaration Macro.
*
* Helper macro to declare an attribute.
*
* @param _uuid Attribute uuid.
* @param _perm Attribute access permissions.
* @param _read Attribute read callback.
* @param _write Attribute write callback.
* @param _value Attribute value.
* @param _handle Attribute handle.
*/
#define BT_GATT_H_ATTRIBUTE(_uuid, _perm, _read, _write, _value, _handle) \
{ \
.uuid = _uuid, \
.perm = _perm, \
.read = _read, \
.write = _write, \
.user_data = _value, \
.handle = _handle \
}
/** @def BT_GATT_H_CHARACTERISTIC
* @brief Characteristic and Value Declaration Macro.
*
* Helper macro to declare a characteristic attribute along with its attribute
* value.
*
* @param _uuid Characteristic attribute uuid.
* @param _props Characteristic attribute properties.
* @param _perm Characteristic attribute access permissions.
* @param _read Characteristic attribute read callback.
* @param _write Characteristic attribute write callback.
* @param _value Characteristic attribute value.
* @param _handle Characteristic attribute handle.
*/
#define BT_GATT_H_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _value,\
_handle) \
BT_GATT_H_ATTRIBUTE(BT_UUID_GATT_CHRC, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_chrc, \
NULL, \
(&(struct bt_gatt_chrc) {.uuid = _uuid, \
.properties = _props \
}), \
_handle), \
BT_GATT_H_ATTRIBUTE(_uuid, _perm, _read, _write, _value, _handle + 1)
/** @def BT_GATT_H_PRIMARY_SERVICE
* @brief Primary Service Declaration Macro.
*
* Helper macro to declare a primary service attribute.
*
* @param _service Service attribute value.
* @param _handle Service attribute handle.
*/
#define BT_GATT_H_PRIMARY_SERVICE(_service, _handle) \
BT_GATT_H_ATTRIBUTE(BT_UUID_GATT_PRIMARY, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_service, \
NULL, \
_service, \
_handle)
/** @def BT_GATT_H_SECONDARY_SERVICE
* @brief Secondary Service Declaration Macro.
*
* Helper macro to declare a secondary service attribute.
*
* @param _service Service attribute value.
* @param _handle Service attribute handle.
*/
#define BT_GATT_H_SECONDARY_SERVICE(_service, _handle) \
BT_GATT_H_ATTRIBUTE(BT_UUID_GATT_SECONDARY, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_service, \
NULL, \
_service, \
_handle)
/** @def BT_GATT_H_INCLUDE_SERVICE
* @brief Include Service Declaration Macro.
*
* Helper macro to declare database internal include service attribute.
*
* @param _service_incl The first service attribute of service to include.
* @param _handle Service attribute handle.
*/
#define BT_GATT_H_INCLUDE_SERVICE(_service_incl, _handle) \
BT_GATT_H_ATTRIBUTE(BT_UUID_GATT_INCLUDE, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_included, \
NULL, \
_service_incl, \
_handle)
/** @def BT_GATT_H_DESCRIPTOR
* @brief Descriptor Declaration Macro.
*
* Helper macro to declare a descriptor attribute.
*
* @param _uuid Descriptor attribute uuid.
* @param _perm Descriptor attribute access permissions.
* @param _read Descriptor attribute read callback.
* @param _write Descriptor attribute write callback.
* @param _value Descriptor attribute value.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_DESCRIPTOR(_uuid, _perm, _read, _write, _value, _handle) \
BT_GATT_H_ATTRIBUTE(_uuid, _perm, _read, _write, _value, _handle)
/** @def BT_GATT_H_MANAGED
* @brief Managed Client Characteristic Configuration Declaration Macro.
*
* Helper macro to declare a Managed CCC attribute.
*
* @param _ccc CCC attribute user data, shall point to a _bt_gatt_ccc.
* @param _perm CCC access permissions.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_MANAGED(_ccc, _perm, _handle) \
BT_GATT_H_ATTRIBUTE(BT_UUID_GATT_CCC, _perm,\
bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, _ccc, _handle)
/** @def BT_GATT_H_CCC
* @brief Client Characteristic Configuration Change Declaration Macro.
*
* Helper macro to declare a CCC attribute.
*
* @param _cfg Initial configuration.
* @param _cfg_changed Configuration changed callback.
* @param _handle Descriptor attribute handle.
*/
/* #undef BT_GATT_H_CCC
* #define BT_GATT_H_CCC(_cfg, _cfg_changed, _handle) \
* BT_GATT_H_DESCRIPTOR(BT_UUID_GATT_CCC, \
* BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, \
* bt_gatt_attr_read_ccc, \
* bt_gatt_attr_write_ccc, \
* (&(struct _bt_gatt_ccc) { \
* .cfg = _cfg, \
* .cfg_len = ARRAY_SIZE(_cfg), \
* .cfg_changed = _cfg_changed \
* } ), \
* _handle)
*/
/** @def BT_GATT_H_CCC
* @brief Client Characteristic Configuration Change Declaration Macro.
*
* Helper macro to declare a CCC attribute.
*
* @param _cfg Initial configuration.
* @param _cfg_changed Configuration changed callback.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_CCC(_cfg, _cfg_changed, _handle) \
BT_GATT_H_MANAGED((&(struct _bt_gatt_ccc) \
BT_GATT_CCC_INITIALIZER(_cfg_changed, NULL, NULL)),\
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, _handle)
/** @def BT_GATT_H_CEP
* @brief Characteristic Extended Properties Declaration Macro.
*
* Helper macro to declare a CEP attribute.
*
* @param _value Descriptor attribute value.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_CEP(_value, _handle) \
BT_GATT_H_DESCRIPTOR(BT_UUID_GATT_CEP, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_cep, \
NULL, \
(void *)_value, \
_handle)
/** @def BT_GATT_H_CUD
* @brief Characteristic User Format Descriptor Declaration Macro.
*
* Helper macro to declare a CUD attribute.
*
* @param _value User description NULL-terminated C string.
* @param _perm Descriptor attribute access permissions.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_CUD(_value, _perm, _handle) \
BT_GATT_H_DESCRIPTOR(BT_UUID_GATT_CUD, \
_perm, \
bt_gatt_attr_read_cud, \
NULL, \
(void *)_value, \
_handle)
/** @def BT_GATT_H_CPF
* @brief Characteristic Presentation Format Descriptor Declaration Macro.
*
* Helper macro to declare a CPF attribute.
*
* @param _value Descriptor attribute value.
* @param _handle Descriptor attribute handle.
*/
#define BT_GATT_H_CPF(_value, _handle) \
BT_GATT_H_DESCRIPTOR(BT_UUID_GATT_CPF, \
BT_GATT_PERM_READ, \
bt_gatt_attr_read_cpf, \
NULL, \
(void *)_value, \
_handle)
#ifdef __cplusplus
}
#endif
#endif /* GATT_MACS_H */

View file

@ -0,0 +1,262 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_d_1_attrs[];
/** @def BT_UUID_SERVICE_A
* @brief UUID for the Service A
*/
#define BT_UUID_SERVICE_A BT_UUID_DECLARE_16(0xa00a)
/** @def BT_UUID_VALUE_V1
* @brief UUID for the Value V1 Characteristic
*/
#define BT_UUID_VALUE_V1 BT_UUID_DECLARE_16(0xb001)
/** @def BT_UUID_VALUE_V2
* @brief UUID for the Value V2 Characteristic
*/
#define BT_UUID_VALUE_V2 BT_UUID_DECLARE_16(0xb002)
/** @def BT_UUID_VALUE_V3
* @brief UUID for the Value V3 Characteristic
*/
#define BT_UUID_VALUE_V3 BT_UUID_DECLARE_16(0xb003)
static u8_t value_v1_value = 0x01;
static u8_t value_v2_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '1', '1',
'1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3',
'4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6', '6', '6',
'6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '9',
'9', '9', '9', '9', '0', '0', '0', '0', '0', '1', '1', '1', '1',
'1', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4',
'4', '4', '4', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6',
'7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '9', '9', '9',
'9', '9', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '2',
'2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4', '4',
'4', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '7', '7',
'7', '7', '7', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9',
'0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '2', '2', '2',
'2', '2', '3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5',
'5', '5', '5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '7',
'7', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9', '0', '0',
'0', '0', '0', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2',
'3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '8',
'8', '8', '8', '8', '9', '9', '9', '9', '9', '0', '0', '0', '0',
'0', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3',
'3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5',
'6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8',
'8', '8', '9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '1',
'1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3', '3',
'3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6', '6',
'6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8',
'9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '1', '1', '1',
'1', '1', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4',
'4', '4', '4', '4', '5', '5', '5', '5', '5', '6', '6', '6', '6',
'6', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '9', '9',
'9', '9', '9', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1',
'2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4',
'4', '4', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '7',
'7', '7', '7', '7', '8', '8', '8', '8', '8', '9', '9', '9', '9',
'9', '0', '0', '0', '0', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '0', '1', '2', '\0'
};
static u8_t value_v2_1_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '\0'
};
static u8_t value_v3_value = 0x03;
/**
* @brief Attribute read call back for the Value V1 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v1_value));
}
/**
* @brief Attribute read call back for the Value V2 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V3 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_a_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_A, 0x20),
BT_GATT_H_INCLUDE_SERVICE(service_d_1_attrs, 0x21),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V1,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ_ENCRYPT,
read_value_v1, NULL, &value_v1_value, 0x22),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2, &value_v2_value, 0x24),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v2_1, &value_v2_1_value, 0x26),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V3,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v3, &value_v3_value, 0x28)
};
static struct bt_gatt_service service_a_1_svc =
BT_GATT_SERVICE(service_a_1_attrs);
/**
* @brief Register the Service A and all its Characteristics...
*/
void service_a_1_init(void)
{
bt_gatt_service_register(&service_a_1_svc);
}
/**
* @brief Un-Register the Service A and all its Characteristics...
*/
void service_a_1_remove(void)
{
bt_gatt_service_unregister(&service_a_1_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_A_1_H
#define SERVICE_A_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_a_1_init(void);
void service_a_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_A_1_H */

View file

@ -0,0 +1,188 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_d_2_attrs[];
extern struct bt_gatt_attr service_c_1_2_attrs[];
/** @def BT_UUID_SERVICE_A
* @brief UUID for the Service A
*/
#define BT_UUID_SERVICE_A BT_UUID_DECLARE_16(0xa00a)
/** @def BT_UUID_VALUE_V1
* @brief UUID for the Value V1 Characteristic
*/
#define BT_UUID_VALUE_V1 BT_UUID_DECLARE_16(0xb001)
/** @def BT_UUID_VALUE_V2
* @brief UUID for the Value V2 Characteristic
*/
#define BT_UUID_VALUE_V2 BT_UUID_DECLARE_16(0xb002)
/** @def BT_UUID_VALUE_V3
* @brief UUID for the Value V3 Characteristic
*/
#define BT_UUID_VALUE_V3 BT_UUID_DECLARE_16(0xb003)
static u8_t value_v1_value = 0x01;
static u8_t value_v2_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '\0'
};
static u8_t value_v3_value = 0x03;
/**
* @brief Attribute read call back for the Value V1 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v1_value));
}
/**
* @brief Attribute read call back for the Value V2 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V3 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_a_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_A, 0x60),
BT_GATT_H_INCLUDE_SERVICE(service_d_2_attrs, 0x61),
BT_GATT_H_INCLUDE_SERVICE(service_c_1_2_attrs, 0x62),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V1,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v1, NULL, &value_v1_value, 0x63),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2, &value_v2_value, 0x65),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V3,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v3, &value_v3_value, 0x67)
};
static struct bt_gatt_service service_a_2_svc =
BT_GATT_SERVICE(service_a_2_attrs);
/**
* @brief Register the Service A and all its Characteristics...
*/
void service_a_2_init(void)
{
bt_gatt_service_register(&service_a_2_svc);
}
/**
* @brief Un-Register the Service A and all its Characteristics...
*/
void service_a_2_remove(void)
{
bt_gatt_service_unregister(&service_a_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_A_2_H
#define SERVICE_A_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_a_2_init(void);
void service_a_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_A_2_H */

View file

@ -0,0 +1,188 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_d_3_attrs[];
extern struct bt_gatt_attr service_c_1_3_attrs[];
/** @def BT_UUID_SERVICE_A
* @brief UUID for the Service A
*/
#define BT_UUID_SERVICE_A BT_UUID_DECLARE_16(0xa00a)
/** @def BT_UUID_VALUE_V1
* @brief UUID for the Value V1 Characteristic
*/
#define BT_UUID_VALUE_V1 BT_UUID_DECLARE_16(0xb001)
/** @def BT_UUID_VALUE_V2
* @brief UUID for the Value V2 Characteristic
*/
#define BT_UUID_VALUE_V2 BT_UUID_DECLARE_16(0xb002)
/** @def BT_UUID_VALUE_V3
* @brief UUID for the Value V3 Characteristic
*/
#define BT_UUID_VALUE_V3 BT_UUID_DECLARE_16(0xb003)
static u8_t value_v1_value = 0x01;
static u8_t value_v2_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '9', '9', '0', '0', '0', '0', '0', '\0'
};
static u8_t value_v3_value = 0x03;
/**
* @brief Attribute read call back for the Value V1 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v1_value));
}
/**
* @brief Attribute read call back for the Value V2 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V3 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_a_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_A, 0x70),
BT_GATT_H_INCLUDE_SERVICE(service_d_3_attrs, 0x71),
BT_GATT_H_INCLUDE_SERVICE(service_c_1_3_attrs, 0x72),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V1,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v1, NULL, &value_v1_value, 0x73),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2, &value_v2_value, 0x75),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V3,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v3, &value_v3_value, 0x77)
};
static struct bt_gatt_service service_a_3_svc =
BT_GATT_SERVICE(service_a_3_attrs);
/**
* @brief Register the Service A and all its Characteristics...
*/
void service_a_3_init(void)
{
bt_gatt_service_register(&service_a_3_svc);
}
/**
* @brief Un-Register the Service A and all its Characteristics...
*/
void service_a_3_remove(void)
{
bt_gatt_service_unregister(&service_a_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service A
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_A_3_H
#define SERVICE_A_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_a_3_init(void);
void service_a_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_A_3_H */

View file

@ -0,0 +1,312 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_1
* @brief UUID for the Service B.1
*/
#define BT_UUID_SERVICE_B_1 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V4
* @brief UUID for the Value V4 Characteristic
*/
#define BT_UUID_VALUE_V4 BT_UUID_DECLARE_16(0xb004)
/** @def BT_UUID_LONG_DES_V2D1
* @brief UUID for the Long descriptor V2D1 Characteristic
*/
#define BT_UUID_LONG_DES_V2D1 BT_UUID_DECLARE_16(0xb012)
static u8_t value_v4_value = 0x04;
static u8_t value_v4_1_value = 0x04;
static u16_t server_cha_con_value;
static u8_t value_v4_2_value = 0x04;
static u8_t long_des_v2d1_value[] = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12,
0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22, 0x33,
0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33
};
static u8_t value_v4_3_value[] = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12,
0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22, 0x33,
0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33
};
static u8_t long_des_v2d1_1_value[] = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12,
0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22, 0x33,
0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33
};
/**
* @brief Attribute read call back for the Value V4 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v4_value));
}
/**
* @brief Attribute write call back for the Value V4 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Value V4 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v4_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v4_1_value));
}
/**
* @brief Attribute write call back for the Value V4 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v4_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v4_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v4_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Server Characteristic Configuration
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_server_cha_con(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u16_t *value = attr->user_data;
u16_t server_cha_con_conv = sys_cpu_to_le16(*value);
return bt_gatt_attr_read(conn, attr, buf, len, offset,
&server_cha_con_conv,
sizeof(server_cha_con_conv));
}
/**
* @brief Attribute write call back for the Server Characteristic Configuration
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_server_cha_con(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
u16_t *value = attr->user_data;
u16_t server_cha_con_conv = sys_cpu_to_le16(*value);
if (offset >= sizeof(server_cha_con_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(server_cha_con_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy((u8_t *)&server_cha_con_conv + offset, buf, len);
*value = sys_le16_to_cpu(server_cha_con_conv);
return len;
}
/**
* @brief Attribute read call back for the Value V4 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v4_3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v4_3_value));
}
/**
* @brief Attribute read call back for the Long descriptor V2D1 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_long_des_v2d1_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(long_des_v2d1_1_value));
}
#define BT_GATT_CHRC_NONE 0
static struct bt_gatt_attr service_b_1_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_1, 0x60),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE_AUTHEN,
read_value_v4, write_value_v4, &value_v4_value, 0x61),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v4_1, write_value_v4_1, &value_v4_1_value, 0x63),
BT_GATT_H_DESCRIPTOR(BT_UUID_GATT_SCC,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_server_cha_con, write_server_cha_con,
&server_cha_con_value, 0x65),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_NONE,
BT_GATT_PERM_NONE,
NULL, NULL, &value_v4_2_value, 0x66),
BT_GATT_H_DESCRIPTOR(BT_UUID_LONG_DES_V2D1,
BT_GATT_PERM_NONE,
NULL, NULL, &long_des_v2d1_value, 0x68),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v4_3, NULL, &value_v4_3_value, 0x69),
BT_GATT_H_DESCRIPTOR(BT_UUID_LONG_DES_V2D1,
BT_GATT_PERM_READ,
read_long_des_v2d1_1, NULL, &long_des_v2d1_1_value, 0x6B)
};
static struct bt_gatt_service service_b_1_1_svc =
BT_GATT_SERVICE(service_b_1_1_attrs);
/**
* @brief Register the Service B.1 and all its Characteristics...
*/
void service_b_1_1_init(void)
{
bt_gatt_service_register(&service_b_1_1_svc);
}
/**
* @brief Un-Register the Service B.1 and all its Characteristics...
*/
void service_b_1_1_remove(void)
{
bt_gatt_service_unregister(&service_b_1_1_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_B_1_1_H
#define SERVICE_B_1_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_1_1_init(void);
void service_b_1_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_1_1_H */

View file

@ -0,0 +1,107 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_1
* @brief UUID for the Service B.1
*/
#define BT_UUID_SERVICE_B_1 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V4
* @brief UUID for the Value V4 Characteristic
*/
#define BT_UUID_VALUE_V4 BT_UUID_DECLARE_16(0xb004)
static u8_t value_v4_value = 0x04;
/**
* @brief Attribute read call back for the Value V4 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v4_value));
}
/**
* @brief Attribute write call back for the Value V4 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
struct bt_gatt_attr service_b_1_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_1, 0x50),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v4, write_value_v4, &value_v4_value, 0x51)
};
static struct bt_gatt_service service_b_1_2_svc =
BT_GATT_SERVICE(service_b_1_2_attrs);
/**
* @brief Register the Service B.1 and all its Characteristics...
*/
void service_b_1_2_init(void)
{
bt_gatt_service_register(&service_b_1_2_svc);
}
/**
* @brief Un-Register the Service B.1 and all its Characteristics...
*/
void service_b_1_2_remove(void)
{
bt_gatt_service_unregister(&service_b_1_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_B_1_2_H
#define SERVICE_B_1_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_1_2_init(void);
void service_b_1_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_1_2_H */

View file

@ -0,0 +1,107 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_1
* @brief UUID for the Service B.1
*/
#define BT_UUID_SERVICE_B_1 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V4
* @brief UUID for the Value V4 Characteristic
*/
#define BT_UUID_VALUE_V4 BT_UUID_DECLARE_16(0xb004)
static u8_t value_v4_value = 0x04;
/**
* @brief Attribute read call back for the Value V4 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v4_value));
}
/**
* @brief Attribute write call back for the Value V4 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v4(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_b_1_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_1, 0x10),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V4,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v4, write_value_v4, &value_v4_value, 0x11)
};
static struct bt_gatt_service service_b_1_3_svc =
BT_GATT_SERVICE(service_b_1_3_attrs);
/**
* @brief Register the Service B.1 and all its Characteristics...
*/
void service_b_1_3_init(void)
{
bt_gatt_service_register(&service_b_1_3_svc);
}
/**
* @brief Un-Register the Service B.1 and all its Characteristics...
*/
void service_b_1_3_remove(void)
{
bt_gatt_service_unregister(&service_b_1_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_B_1_3_H
#define SERVICE_B_1_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_1_3_init(void);
void service_b_1_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_1_3_H */

View file

@ -0,0 +1,165 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_2
* @brief UUID for the Service B.2
*/
#define BT_UUID_SERVICE_B_2 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V5
* @brief UUID for the Value V5 Characteristic
*/
#define BT_UUID_VALUE_V5 BT_UUID_DECLARE_16(0xb005)
/** @def BT_UUID_DES_V5D4__128_BIT_UUID
* @brief UUID for the Descriptor V5D4 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V5D4__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0x00, 0x00)
static u8_t value_v5_value = 0x05;
static struct bt_gatt_cep cha_ext_pro_value = { 0x0003 };
static u8_t cha_user_des_value[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'\0'
};
static const struct bt_gatt_cpf cha_format_value = {
0x04, 0x00, 0x3001, 0x01, 0x3111
};
static u8_t des_v5d4__128_bit_uuid_value = 0x44;
static bool bAuthorized;
/**
* @brief Attribute read call back for the Value V5 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v5_value));
}
/**
* @brief Attribute write call back for the Value V5 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
if (!bAuthorized)
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V5D4 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v5d4__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v5d4__128_bit_uuid_value));
}
static struct bt_gatt_attr service_b_2_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_2, 0x70),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V5,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v5, write_value_v5, &value_v5_value, 0x71),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x73),
BT_GATT_H_CUD(cha_user_des_value, BT_GATT_PERM_READ, 0x74),
BT_GATT_H_CPF(&cha_format_value, 0x75),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V5D4__128_BIT_UUID,
BT_GATT_PERM_READ,
read_des_v5d4__128_bit_uuid, NULL,
&des_v5d4__128_bit_uuid_value, 0x76)
};
static struct bt_gatt_service service_b_2_1_svc =
BT_GATT_SERVICE(service_b_2_1_attrs);
/**
* @brief Register the Service B.2 and all its Characteristics...
*/
void service_b_2_1_init(void)
{
bt_gatt_service_register(&service_b_2_1_svc);
}
/**
* @brief Un-Register the Service B.2 and all its Characteristics...
*/
void service_b_2_1_remove(void)
{
bt_gatt_service_unregister(&service_b_2_1_svc);
}
/**
* @brief Set authorization for Characteristics and Descriptors in Service B.2.
*/
void service_b_2_1_authorize(bool authorized)
{
bAuthorized = authorized;
}

View file

@ -0,0 +1,26 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_B_2_1_H
#define SERVICE_B_2_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_2_1_authorize(bool);
void service_b_2_1_init(void);
void service_b_2_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_2_1_H */

View file

@ -0,0 +1,154 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_2
* @brief UUID for the Service B.2
*/
#define BT_UUID_SERVICE_B_2 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V5
* @brief UUID for the Value V5 Characteristic
*/
#define BT_UUID_VALUE_V5 BT_UUID_DECLARE_16(0xb005)
/** @def BT_UUID_DES_V5D4__128_BIT_UUID
* @brief UUID for the Descriptor V5D4 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V5D4__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0x00, 0x00)
static u8_t value_v5_value = 0x05;
static u8_t des_v5d4__128_bit_uuid_value = 0x44;
static struct bt_gatt_cep cha_ext_pro_value = { 0x0003 };
static u8_t cha_user_des_value[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'\0'
};
static const struct bt_gatt_cpf cha_format_value = {
0x04, 0x00, 0x3001, 0x01, 0x3111
};
/**
* @brief Attribute read call back for the Value V5 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v5_value));
}
/**
* @brief Attribute write call back for the Value V5 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V5D4 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v5d4__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v5d4__128_bit_uuid_value));
}
static struct bt_gatt_attr service_b_2_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_2, 0x90),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V5,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v5, write_value_v5, &value_v5_value, 0x91),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V5D4__128_BIT_UUID,
BT_GATT_PERM_READ,
read_des_v5d4__128_bit_uuid, NULL,
&des_v5d4__128_bit_uuid_value, 0x93),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x94),
BT_GATT_H_CUD(cha_user_des_value, BT_GATT_PERM_READ, 0x95),
BT_GATT_H_CPF(&cha_format_value, 0x96)
};
static struct bt_gatt_service service_b_2_2_svc =
BT_GATT_SERVICE(service_b_2_2_attrs);
/**
* @brief Register the Service B.2 and all its Characteristics...
*/
void service_b_2_2_init(void)
{
bt_gatt_service_register(&service_b_2_2_svc);
}
/**
* @brief Un-Register the Service B.2 and all its Characteristics...
*/
void service_b_2_2_remove(void)
{
bt_gatt_service_unregister(&service_b_2_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_B_2_2_H
#define SERVICE_B_2_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_2_2_init(void);
void service_b_2_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_2_2_H */

View file

@ -0,0 +1,154 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_2
* @brief UUID for the Service B.2
*/
#define BT_UUID_SERVICE_B_2 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V5
* @brief UUID for the Value V5 Characteristic
*/
#define BT_UUID_VALUE_V5 BT_UUID_DECLARE_16(0xb005)
/** @def BT_UUID_DES_V5D4__128_BIT_UUID
* @brief UUID for the Descriptor V5D4 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V5D4__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd4, 0xd5, 0x00, 0x00)
static u8_t value_v5_value = 0x05;
static u8_t cha_user_des_value[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'\0'
};
static struct bt_gatt_cep cha_ext_pro_value = { 0x0003 };
static u8_t des_v5d4__128_bit_uuid_value = 0x44;
static const struct bt_gatt_cpf cha_format_value = {
0x04, 0x00, 0x3001, 0x01, 0x3111
};
/**
* @brief Attribute read call back for the Value V5 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v5_value));
}
/**
* @brief Attribute write call back for the Value V5 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v5(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V5D4 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v5d4__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v5d4__128_bit_uuid_value));
}
static struct bt_gatt_attr service_b_2_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_2, 0x90),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V5,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v5, write_value_v5, &value_v5_value, 0x91),
BT_GATT_H_CUD(cha_user_des_value, BT_GATT_PERM_READ, 0x93),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x94),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V5D4__128_BIT_UUID,
BT_GATT_PERM_READ,
read_des_v5d4__128_bit_uuid, NULL,
&des_v5d4__128_bit_uuid_value, 0x95),
BT_GATT_H_CPF(&cha_format_value, 0x96)
};
static struct bt_gatt_service service_b_2_3_svc =
BT_GATT_SERVICE(service_b_2_3_attrs);
/**
* @brief Register the Service B.2 and all its Characteristics...
*/
void service_b_2_3_init(void)
{
bt_gatt_service_register(&service_b_2_3_svc);
}
/**
* @brief Un-Register the Service B.2 and all its Characteristics...
*/
void service_b_2_3_remove(void)
{
bt_gatt_service_unregister(&service_b_2_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_B_2_3_H
#define SERVICE_B_2_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_2_3_init(void);
void service_b_2_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_2_3_H */

View file

@ -0,0 +1,135 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_3
* @brief UUID for the Service B.3
*/
#define BT_UUID_SERVICE_B_3 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V6
* @brief UUID for the Value V6 Characteristic
*/
#define BT_UUID_VALUE_V6 BT_UUID_DECLARE_16(0xb006)
static u8_t value_v6_value = 0x06;
static bool value_v6_ntf_active;
/**
* @brief Attribute read call back for the Value V6 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v6_value));
}
/**
* @brief Attribute write call back for the Value V6 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Descriptor configuration change call back for the Value V6 attribute
*
* @param attr The attribute whose descriptor configuration has changed
* @param value The new value of the descriptor configuration
*/
static void value_v6_ccc_cfg_changed(const struct bt_gatt_attr *attr,
u16_t value)
{
value_v6_ntf_active = value == BT_GATT_CCC_NOTIFY;
}
static struct bt_gatt_attr service_b_3_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_3, 0x50),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V6,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE_WITHOUT_RESP |
BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v6, write_value_v6, &value_v6_value, 0x51),
BT_GATT_H_CCC(value_v6_ccc_cfg, value_v6_ccc_cfg_changed, 0x53)
};
static struct bt_gatt_service service_b_3_1_svc =
BT_GATT_SERVICE(service_b_3_1_attrs);
/**
* @brief Register the Service B.3 and all its Characteristics...
*/
void service_b_3_1_init(void)
{
bt_gatt_service_register(&service_b_3_1_svc);
}
/**
* @brief Un-Register the Service B.3 and all its Characteristics...
*/
void service_b_3_1_remove(void)
{
bt_gatt_service_unregister(&service_b_3_1_svc);
}
/**
* @brief Generate notification for 'Value V6' attribute, if notifications are
* enabled.
*/
void service_b_3_1_value_v6_notify(void)
{
if (!value_v6_ntf_active)
return;
bt_gatt_notify(NULL, &service_b_3_1_attrs[1], &value_v6_value,
sizeof(value_v6_value));
}

View file

@ -0,0 +1,26 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_B_3_1_H
#define SERVICE_B_3_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_3_1_init(void);
void service_b_3_1_remove(void);
void service_b_3_1_value_v6_notify(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_3_1_H */

View file

@ -0,0 +1,174 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_3
* @brief UUID for the Service B.3
*/
#define BT_UUID_SERVICE_B_3 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V6
* @brief UUID for the Value V6 Characteristic
*/
#define BT_UUID_VALUE_V6 BT_UUID_DECLARE_16(0xb006)
static u8_t value_v6_value = 0x06;
static struct bt_gatt_indicate_params ind_params;
static bool value_v6_ntf_active;
static bool value_v6_ind_active;
/**
* @brief Attribute read call back for the Value V6 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v6_value));
}
/**
* @brief Attribute write call back for the Value V6 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Descriptor configuration change call back for the Value V6 attribute
*
* @param attr The attribute whose descriptor configuration has changed
* @param value The new value of the descriptor configuration
*/
static void value_v6_ccc_cfg_changed(const struct bt_gatt_attr *attr,
u16_t value)
{
value_v6_ntf_active = value == BT_GATT_CCC_NOTIFY;
value_v6_ind_active = value == BT_GATT_CCC_INDICATE;
}
static struct bt_gatt_attr service_b_3_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_3, 0x70),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V6,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE_WITHOUT_RESP |
BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY |
BT_GATT_CHRC_INDICATE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v6, write_value_v6, &value_v6_value, 0x71),
BT_GATT_H_CCC(value_v6_ccc_cfg, value_v6_ccc_cfg_changed, 0x73)
};
static struct bt_gatt_service service_b_3_2_svc =
BT_GATT_SERVICE(service_b_3_2_attrs);
/**
* @brief Register the Service B.3 and all its Characteristics...
*/
void service_b_3_2_init(void)
{
bt_gatt_service_register(&service_b_3_2_svc);
}
/**
* @brief Un-Register the Service B.3 and all its Characteristics...
*/
void service_b_3_2_remove(void)
{
bt_gatt_service_unregister(&service_b_3_2_svc);
}
/**
* @brief Generate notification for 'Value V6' attribute, if notifications are
* enabled.
*/
void service_b_3_2_value_v6_notify(void)
{
if (!value_v6_ntf_active)
return;
bt_gatt_notify(NULL, &service_b_3_2_attrs[1], &value_v6_value,
sizeof(value_v6_value));
}
/**
* @brief Indication call back for 'Value V6' attribute
*
* @param conn The connection for which the indication was generated
* @param attr The attribute that generated the indication
* @param err The error code from the indicate attempt, 0 if no error or
* BT_GATT_ERR() with a specific ATT error code.
*/
static void value_v6_indicate_cb(struct bt_conn *conn,
const struct bt_gatt_attr *attr, u8_t err)
{
printk("Indication for attribute 'Value V6' %s\n",
(err) ? "failed" : "succeded");
}
/**
* @brief Generate indication for 'Value V6' attribute, if indications are
* enabled.
*/
void service_b_3_2_value_v6_indicate(void)
{
if (!value_v6_ind_active)
return;
/*
* NOTE: Zephyr doesn't automatically bump up the attribute pointer for
* indications as it does for notifications.
*/
ind_params.attr = &service_b_3_2_attrs[2];
ind_params.func = value_v6_indicate_cb;
ind_params.data = &value_v6_value;
ind_params.len = sizeof(value_v6_value);
bt_gatt_indicate(NULL, &ind_params);
}

View file

@ -0,0 +1,27 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_B_3_2_H
#define SERVICE_B_3_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_3_2_init(void);
void service_b_3_2_remove(void);
void service_b_3_2_value_v6_notify(void);
void service_b_3_2_value_v6_indicate(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_3_2_H */

View file

@ -0,0 +1,174 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_3
* @brief UUID for the Service B.3
*/
#define BT_UUID_SERVICE_B_3 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V6
* @brief UUID for the Value V6 Characteristic
*/
#define BT_UUID_VALUE_V6 BT_UUID_DECLARE_16(0xb006)
static u8_t value_v6_value = 0x06;
static struct bt_gatt_indicate_params ind_params;
static bool value_v6_ntf_active;
static bool value_v6_ind_active;
/**
* @brief Attribute read call back for the Value V6 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v6_value));
}
/**
* @brief Attribute write call back for the Value V6 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Descriptor configuration change call back for the Value V6 attribute
*
* @param attr The attribute whose descriptor configuration has changed
* @param value The new value of the descriptor configuration
*/
static void value_v6_ccc_cfg_changed(const struct bt_gatt_attr *attr,
u16_t value)
{
value_v6_ntf_active = value == BT_GATT_CCC_NOTIFY;
value_v6_ind_active = value == BT_GATT_CCC_INDICATE;
}
static struct bt_gatt_attr service_b_3_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_3, 0x50),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V6,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE_WITHOUT_RESP |
BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY |
BT_GATT_CHRC_INDICATE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v6, write_value_v6, &value_v6_value, 0x51),
BT_GATT_H_CCC(value_v6_ccc_cfg, value_v6_ccc_cfg_changed, 0x53)
};
static struct bt_gatt_service service_b_3_3_svc =
BT_GATT_SERVICE(service_b_3_3_attrs);
/**
* @brief Register the Service B.3 and all its Characteristics...
*/
void service_b_3_3_init(void)
{
bt_gatt_service_register(&service_b_3_3_svc);
}
/**
* @brief Un-Register the Service B.3 and all its Characteristics...
*/
void service_b_3_3_remove(void)
{
bt_gatt_service_unregister(&service_b_3_3_svc);
}
/**
* @brief Generate notification for 'Value V6' attribute, if notifications are
* enabled.
*/
void service_b_3_3_value_v6_notify(void)
{
if (!value_v6_ntf_active)
return;
bt_gatt_notify(NULL, &service_b_3_3_attrs[1], &value_v6_value,
sizeof(value_v6_value));
}
/**
* @brief Indication call back for 'Value V6' attribute
*
* @param conn The connection for which the indication was generated
* @param attr The attribute that generated the indication
* @param err The error code from the indicate attempt, 0 if no error or
* BT_GATT_ERR() with a specific ATT error code.
*/
static void value_v6_indicate_cb(struct bt_conn *conn,
const struct bt_gatt_attr *attr, u8_t err)
{
printk("Indication for attribute 'Value V6' %s\n",
(err) ? "failed" : "succeded");
}
/**
* @brief Generate indication for 'Value V6' attribute, if indications are
* enabled.
*/
void service_b_3_3_value_v6_indicate(void)
{
if (!value_v6_ind_active)
return;
/*
* NOTE: Zephyr doesn't automatically bump up the attribute pointer for
* indications as it does for notifications.
*/
ind_params.attr = &service_b_3_3_attrs[2];
ind_params.func = value_v6_indicate_cb;
ind_params.data = &value_v6_value;
ind_params.len = sizeof(value_v6_value);
bt_gatt_indicate(NULL, &ind_params);
}

View file

@ -0,0 +1,27 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.3
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_B_3_3_H
#define SERVICE_B_3_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_3_3_init(void);
void service_b_3_3_remove(void);
void service_b_3_3_value_v6_notify(void);
void service_b_3_3_value_v6_indicate(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_3_3_H */

View file

@ -0,0 +1,85 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_4
* @brief UUID for the Service B.4
*/
#define BT_UUID_SERVICE_B_4 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V7
* @brief UUID for the Value V7 Characteristic
*/
#define BT_UUID_VALUE_V7 BT_UUID_DECLARE_16(0xb007)
static u8_t value_v7_value = 0x07;
/**
* @brief Attribute write call back for the Value V7 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v7(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_b_4_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_4, 0x30),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V7,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v7, &value_v7_value, 0x31)
};
static struct bt_gatt_service service_b_4_1_svc =
BT_GATT_SERVICE(service_b_4_1_attrs);
/**
* @brief Register the Service B.4 and all its Characteristics...
*/
void service_b_4_1_init(void)
{
bt_gatt_service_register(&service_b_4_1_svc);
}
/**
* @brief Un-Register the Service B.4 and all its Characteristics...
*/
void service_b_4_1_remove(void)
{
bt_gatt_service_unregister(&service_b_4_1_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_B_4_1_H
#define SERVICE_B_4_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_4_1_init(void);
void service_b_4_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_4_1_H */

View file

@ -0,0 +1,85 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_4
* @brief UUID for the Service B.4
*/
#define BT_UUID_SERVICE_B_4 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V7
* @brief UUID for the Value V7 Characteristic
*/
#define BT_UUID_VALUE_V7 BT_UUID_DECLARE_16(0xb007)
static u8_t value_v7_value = 0x07;
/**
* @brief Attribute write call back for the Value V7 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v7(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_b_4_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_4, 0x30),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V7,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v7, &value_v7_value, 0x31)
};
static struct bt_gatt_service service_b_4_2_svc =
BT_GATT_SERVICE(service_b_4_2_attrs);
/**
* @brief Register the Service B.4 and all its Characteristics...
*/
void service_b_4_2_init(void)
{
bt_gatt_service_register(&service_b_4_2_svc);
}
/**
* @brief Un-Register the Service B.4 and all its Characteristics...
*/
void service_b_4_2_remove(void)
{
bt_gatt_service_unregister(&service_b_4_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_B_4_2_H
#define SERVICE_B_4_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_4_2_init(void);
void service_b_4_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_4_2_H */

View file

@ -0,0 +1,85 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_4
* @brief UUID for the Service B.4
*/
#define BT_UUID_SERVICE_B_4 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V7
* @brief UUID for the Value V7 Characteristic
*/
#define BT_UUID_VALUE_V7 BT_UUID_DECLARE_16(0xb007)
static u8_t value_v7_value = 0x07;
/**
* @brief Attribute write call back for the Value V7 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v7(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_b_4_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_4, 0x40),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V7,
BT_GATT_CHRC_WRITE,
BT_GATT_PERM_WRITE,
NULL, write_value_v7, &value_v7_value, 0x41)
};
static struct bt_gatt_service service_b_4_3_svc =
BT_GATT_SERVICE(service_b_4_3_attrs);
/**
* @brief Register the Service B.4 and all its Characteristics...
*/
void service_b_4_3_init(void)
{
bt_gatt_service_register(&service_b_4_3_svc);
}
/**
* @brief Un-Register the Service B.4 and all its Characteristics...
*/
void service_b_4_3_remove(void)
{
bt_gatt_service_unregister(&service_b_4_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.4
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_B_4_3_H
#define SERVICE_B_4_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_4_3_init(void);
void service_b_4_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_4_3_H */

View file

@ -0,0 +1,301 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_5
* @brief UUID for the Service B.5
*/
#define BT_UUID_SERVICE_B_5 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V8
* @brief UUID for the Value V8 Characteristic
*/
#define BT_UUID_VALUE_V8 BT_UUID_DECLARE_16(0xb008)
/** @def BT_UUID_DES_V8D1
* @brief UUID for the Descriptor V8D1 Characteristic
*/
#define BT_UUID_DES_V8D1 BT_UUID_DECLARE_16(0xb015)
/** @def BT_UUID_DES_V8D2
* @brief UUID for the Descriptor V8D2 Characteristic
*/
#define BT_UUID_DES_V8D2 BT_UUID_DECLARE_16(0xb016)
/** @def BT_UUID_DES_V8D3
* @brief UUID for the Descriptor V8D3 Characteristic
*/
#define BT_UUID_DES_V8D3 BT_UUID_DECLARE_16(0xb017)
static u8_t value_v8_value = 0x08;
static u8_t des_v8d1_value = 0x01;
static u8_t des_v8d2_value = 0x02;
static u8_t des_v8d3_value = 0x03;
static bool bAuthorized;
/**
* @brief Attribute read call back for the Value V8 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v8(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v8_value));
}
/**
* @brief Attribute write call back for the Value V8 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v8(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v8_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v8_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V8D1 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v8d1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v8d1_value));
}
/**
* @brief Attribute write call back for the Descriptor V8D1 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v8d1(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v8d1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v8d1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V8D2 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v8d2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
if (!bAuthorized)
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v8d2_value));
}
/**
* @brief Attribute write call back for the Descriptor V8D2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v8d2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v8d2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v8d2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
if (!bAuthorized)
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V8D3 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v8d3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v8d3_value));
}
/**
* @brief Attribute write call back for the Descriptor V8D3 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v8d3(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v8d3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v8d3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
struct bt_gatt_attr service_b_5_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_5, 0x80),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V8,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE_ENCRYPT,
read_value_v8, write_value_v8, &value_v8_value, 0x81),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V8D1,
BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN,
read_des_v8d1, write_des_v8d1, &des_v8d1_value, 0x83),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V8D2,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_des_v8d2, write_des_v8d2, &des_v8d2_value, 0x84),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V8D3,
BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT,
read_des_v8d3, write_des_v8d3, &des_v8d3_value, 0x85)
};
static struct bt_gatt_service service_b_5_1_svc =
BT_GATT_SERVICE(service_b_5_1_attrs);
/**
* @brief Register the Service B.5 and all its Characteristics...
*/
void service_b_5_1_init(void)
{
bt_gatt_service_register(&service_b_5_1_svc);
}
/**
* @brief Un-Register the Service B.5 and all its Characteristics...
*/
void service_b_5_1_remove(void)
{
bt_gatt_service_unregister(&service_b_5_1_svc);
}
/**
* @brief Set authorization for Characteristics and Descriptors in Service B.5.
*/
void service_b_5_1_authorize(bool authorized)
{
bAuthorized = authorized;
}

View file

@ -0,0 +1,26 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_B_5_1_H
#define SERVICE_B_5_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_5_1_authorize(bool);
void service_b_5_1_init(void);
void service_b_5_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_5_1_H */

View file

@ -0,0 +1,78 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_5
* @brief UUID for the Service B.5
*/
#define BT_UUID_SERVICE_B_5 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V8
* @brief UUID for the Value V8 Characteristic
*/
#define BT_UUID_VALUE_V8 BT_UUID_DECLARE_16(0xb008)
static u8_t value_v8_value = 0x08;
/**
* @brief Attribute read call back for the Value V8 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v8(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v8_value));
}
static struct bt_gatt_attr service_b_5_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_5, 0xA0),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V8,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v8, NULL, &value_v8_value, 0xA1)
};
static struct bt_gatt_service service_b_5_2_svc =
BT_GATT_SERVICE(service_b_5_2_attrs);
/**
* @brief Register the Service B.5 and all its Characteristics...
*/
void service_b_5_2_init(void)
{
bt_gatt_service_register(&service_b_5_2_svc);
}
/**
* @brief Un-Register the Service B.5 and all its Characteristics...
*/
void service_b_5_2_remove(void)
{
bt_gatt_service_unregister(&service_b_5_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_B_5_2_H
#define SERVICE_B_5_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_5_2_init(void);
void service_b_5_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_5_2_H */

View file

@ -0,0 +1,78 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_B_5
* @brief UUID for the Service B.5
*/
#define BT_UUID_SERVICE_B_5 BT_UUID_DECLARE_16(0xa00b)
/** @def BT_UUID_VALUE_V8
* @brief UUID for the Value V8 Characteristic
*/
#define BT_UUID_VALUE_V8 BT_UUID_DECLARE_16(0xb008)
static u8_t value_v8_value = 0x08;
/**
* @brief Attribute read call back for the Value V8 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v8(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v8_value));
}
static struct bt_gatt_attr service_b_5_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_5, 0x30),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V8,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v8, NULL, &value_v8_value, 0x31)
};
static struct bt_gatt_service service_b_5_3_svc =
BT_GATT_SERVICE(service_b_5_3_attrs);
/**
* @brief Register the Service B.5 and all its Characteristics...
*/
void service_b_5_3_init(void)
{
bt_gatt_service_register(&service_b_5_3_svc);
}
/**
* @brief Un-Register the Service B.5 and all its Characteristics...
*/
void service_b_5_3_remove(void)
{
bt_gatt_service_unregister(&service_b_5_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service B.5
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_B_5_3_H
#define SERVICE_B_5_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_b_5_3_init(void);
void service_b_5_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_B_5_3_H */

View file

@ -0,0 +1,227 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_d_1_attrs[];
/** @def BT_UUID_SERVICE_C_1
* @brief UUID for the Service C.1
*/
#define BT_UUID_SERVICE_C_1 BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V9__128_BIT_UUID
* @brief UUID for the Value V9 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V9__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x09, 0xb0, 0x00, 0x00)
/** @def BT_UUID_DES_V9D2__128_BIT_UUID
* @brief UUID for the Descriptor V9D2 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D2__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd2, 0xd9, 0x00, 0x00)
/** @def BT_UUID_DES_V9D3__128_BIT_UUID
* @brief UUID for the Descriptor V9D3 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D3__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd3, 0xd9, 0x00, 0x00)
static u8_t value_v9__128_bit_uuid_value = 0x09;
static struct bt_gatt_cep cha_ext_pro_value = { 0x0001 };
static u8_t des_v9d2__128_bit_uuid_value = 0x22;
static u8_t des_v9d3__128_bit_uuid_value = 0x33;
/**
* @brief Attribute read call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v9__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v9d2__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Descriptor V9D3 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_c_1_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_C_1, 0x90),
BT_GATT_H_INCLUDE_SERVICE(service_d_1_attrs, 0x91),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V9__128_BIT_UUID,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v9__128_bit_uuid, write_value_v9__128_bit_uuid,
&value_v9__128_bit_uuid_value, 0x92),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x94),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D2__128_BIT_UUID,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_des_v9d2__128_bit_uuid, write_des_v9d2__128_bit_uuid,
&des_v9d2__128_bit_uuid_value, 0x95),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D3__128_BIT_UUID,
BT_GATT_PERM_WRITE,
NULL, write_des_v9d3__128_bit_uuid,
&des_v9d3__128_bit_uuid_value, 0x96)
};
static struct bt_gatt_service service_c_1_1_svc =
BT_GATT_SERVICE(service_c_1_1_attrs);
/**
* @brief Register the Service C.1 and all its Characteristics...
*/
void service_c_1_1_init(void)
{
bt_gatt_service_register(&service_c_1_1_svc);
}
/**
* @brief Un-Register the Service C.1 and all its Characteristics...
*/
void service_c_1_1_remove(void)
{
bt_gatt_service_unregister(&service_c_1_1_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_C_1_1_H
#define SERVICE_C_1_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_1_1_init(void);
void service_c_1_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_1_1_H */

View file

@ -0,0 +1,227 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_d_2_attrs[];
/** @def BT_UUID_SERVICE_C_1
* @brief UUID for the Service C.1
*/
#define BT_UUID_SERVICE_C_1 BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V9__128_BIT_UUID
* @brief UUID for the Value V9 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V9__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x09, 0xb0, 0x00, 0x00)
/** @def BT_UUID_DES_V9D2__128_BIT_UUID
* @brief UUID for the Descriptor V9D2 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D2__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd2, 0xd9, 0x00, 0x00)
/** @def BT_UUID_DES_V9D3__128_BIT_UUID
* @brief UUID for the Descriptor V9D3 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D3__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd3, 0xd9, 0x00, 0x00)
static u8_t value_v9__128_bit_uuid_value = 0x09;
static u8_t des_v9d2__128_bit_uuid_value = 0x22;
static u8_t des_v9d3__128_bit_uuid_value = 0x33;
static struct bt_gatt_cep cha_ext_pro_value = { 0x0001 };
/**
* @brief Attribute read call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v9__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v9d2__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Descriptor V9D3 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
struct bt_gatt_attr service_c_1_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_C_1, 0x20),
BT_GATT_H_INCLUDE_SERVICE(service_d_2_attrs, 0x21),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V9__128_BIT_UUID,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v9__128_bit_uuid, write_value_v9__128_bit_uuid,
&value_v9__128_bit_uuid_value, 0x22),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D2__128_BIT_UUID,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_des_v9d2__128_bit_uuid, write_des_v9d2__128_bit_uuid,
&des_v9d2__128_bit_uuid_value, 0x24),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D3__128_BIT_UUID,
BT_GATT_PERM_WRITE,
NULL, write_des_v9d3__128_bit_uuid,
&des_v9d3__128_bit_uuid_value, 0x25),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x26)
};
static struct bt_gatt_service service_c_1_2_svc =
BT_GATT_SERVICE(service_c_1_2_attrs);
/**
* @brief Register the Service C.1 and all its Characteristics...
*/
void service_c_1_2_init(void)
{
bt_gatt_service_register(&service_c_1_2_svc);
}
/**
* @brief Un-Register the Service C.1 and all its Characteristics...
*/
void service_c_1_2_remove(void)
{
bt_gatt_service_unregister(&service_c_1_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_C_1_2_H
#define SERVICE_C_1_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_1_2_init(void);
void service_c_1_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_1_2_H */

View file

@ -0,0 +1,224 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_C_1
* @brief UUID for the Service C.1
*/
#define BT_UUID_SERVICE_C_1 BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V9__128_BIT_UUID
* @brief UUID for the Value V9 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V9__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x09, 0xb0, 0x00, 0x00)
/** @def BT_UUID_DES_V9D2__128_BIT_UUID
* @brief UUID for the Descriptor V9D2 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D2__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd2, 0xd9, 0x00, 0x00)
/** @def BT_UUID_DES_V9D3__128_BIT_UUID
* @brief UUID for the Descriptor V9D3 (128-bit UUID) Characteristic
*/
#define BT_UUID_DES_V9D3__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0xd3, 0xd9, 0x00, 0x00)
static u8_t value_v9__128_bit_uuid_value = 0x09;
static u8_t des_v9d2__128_bit_uuid_value = 0x22;
static struct bt_gatt_cep cha_ext_pro_value = { 0x0001 };
static u8_t des_v9d3__128_bit_uuid_value = 0x33;
/**
* @brief Attribute read call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v9__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Value V9 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v9__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(des_v9d2__128_bit_uuid_value));
}
/**
* @brief Attribute write call back for the Descriptor V9D2 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d2__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Descriptor V9D3 (128-bit UUID)
* attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(des_v9d3__128_bit_uuid_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
struct bt_gatt_attr service_c_1_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_C_1, 0x80),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V9__128_BIT_UUID,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v9__128_bit_uuid, write_value_v9__128_bit_uuid,
&value_v9__128_bit_uuid_value, 0x81),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D2__128_BIT_UUID,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_des_v9d2__128_bit_uuid, write_des_v9d2__128_bit_uuid,
&des_v9d2__128_bit_uuid_value, 0x83),
BT_GATT_H_CEP(&cha_ext_pro_value, 0x84),
BT_GATT_H_DESCRIPTOR(BT_UUID_DES_V9D3__128_BIT_UUID,
BT_GATT_PERM_WRITE,
NULL, write_des_v9d3__128_bit_uuid,
&des_v9d3__128_bit_uuid_value, 0x85)
};
static struct bt_gatt_service service_c_1_3_svc =
BT_GATT_SERVICE(service_c_1_3_attrs);
/**
* @brief Register the Service C.1 and all its Characteristics...
*/
void service_c_1_3_init(void)
{
bt_gatt_service_register(&service_c_1_3_svc);
}
/**
* @brief Un-Register the Service C.1 and all its Characteristics...
*/
void service_c_1_3_remove(void)
{
bt_gatt_service_unregister(&service_c_1_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.1
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_C_1_3_H
#define SERVICE_C_1_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_1_3_init(void);
void service_c_1_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_1_3_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_C_2_1_H
#define SERVICE_C_2_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_2_1_authorize(bool);
void service_c_2_1_init(void);
void service_c_2_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_2_1_H */

View file

@ -0,0 +1,340 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_C_2
* @brief UUID for the Service C.2
*/
#define BT_UUID_SERVICE_C_2 BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V10
* @brief UUID for the Value V10 Characteristic
*/
#define BT_UUID_VALUE_V10 BT_UUID_DECLARE_16(0xb00a)
/** @def BT_UUID_VALUE_V2
* @brief UUID for the Value V2 Characteristic
*/
#define BT_UUID_VALUE_V2 BT_UUID_DECLARE_16(0xb002)
static u8_t value_v10_value = 0x0A;
static u8_t value_v2_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '\0'
};
static u8_t value_v2_1_value[] = {
'2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4',
'4', '4', '5', '5', '5', '5', '5', '6', '6', '\0'
};
static u8_t value_v2_2_value[] = {
'3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '\0'
};
static u8_t value_v2_3_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '\0'
};
static u8_t value_v2_4_value[] = {
'2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4',
'4', '4', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '7',
'7', '7', '7', '7', '8', '8', '8', '8', '8', '9', '9', '9', '9',
'9', '0', '0', '0', '0', '\0'
};
static u8_t value_v2_5_value[] = {
'3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '8',
'8', '8', '8', '8', '9', '9', '9', '9', '9', '0', '0', '0', '0',
'0', '1', '1', '1', '1', '1', '\0'
};
/**
* @brief Attribute read call back for the Value V10 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v10(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v10_value));
}
/**
* @brief Attribute read call back for the Value V2 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_2(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_3(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_4(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_5(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_c_2_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_C_2, 0x10),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V10,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v10, NULL, &value_v10_value, 0x11),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2, &value_v2_value, 0x13),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_1, &value_v2_1_value, 0x15),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_2, &value_v2_2_value, 0x17),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_3, &value_v2_3_value, 0x19),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_4, &value_v2_4_value, 0x1B),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_5, &value_v2_5_value, 0x1D)
};
static struct bt_gatt_service service_c_2_2_svc =
BT_GATT_SERVICE(service_c_2_2_attrs);
/**
* @brief Register the Service C.2 and all its Characteristics...
*/
void service_c_2_2_init(void)
{
bt_gatt_service_register(&service_c_2_2_svc);
}
/**
* @brief Un-Register the Service C.2 and all its Characteristics...
*/
void service_c_2_2_remove(void)
{
bt_gatt_service_unregister(&service_c_2_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_C_2_2_H
#define SERVICE_C_2_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_2_2_init(void);
void service_c_2_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_2_2_H */

View file

@ -0,0 +1,340 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_C_2
* @brief UUID for the Service C.2
*/
#define BT_UUID_SERVICE_C_2 BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V10
* @brief UUID for the Value V10 Characteristic
*/
#define BT_UUID_VALUE_V10 BT_UUID_DECLARE_16(0xb00a)
/** @def BT_UUID_VALUE_V2
* @brief UUID for the Value V2 Characteristic
*/
#define BT_UUID_VALUE_V2 BT_UUID_DECLARE_16(0xb002)
static u8_t value_v10_value = 0x0A;
static u8_t value_v2_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '\0'
};
static u8_t value_v2_1_value[] = {
'2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4',
'4', '4', '5', '5', '5', '5', '5', '6', '6', '\0'
};
static u8_t value_v2_2_value[] = {
'3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '\0'
};
static u8_t value_v2_3_value[] = {
'1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '6',
'6', '6', '6', '6', '7', '7', '7', '7', '7', '8', '8', '8', '8',
'8', '9', '9', '9', '\0'
};
static u8_t value_v2_4_value[] = {
'2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '4', '4', '4',
'4', '4', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '7',
'7', '7', '7', '7', '8', '8', '8', '8', '8', '9', '9', '9', '9',
'9', '0', '0', '0', '0', '\0'
};
static u8_t value_v2_5_value[] = {
'3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '8',
'8', '8', '8', '8', '9', '9', '9', '9', '9', '0', '0', '0', '0',
'0', '1', '1', '1', '1', '1', '\0'
};
/**
* @brief Attribute read call back for the Value V10 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v10(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v10_value));
}
/**
* @brief Attribute read call back for the Value V2 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_1(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_2(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_2_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_3(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_3_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_4(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute write call back for the Value V2 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v2_5(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset,
u8_t flags)
{
char *value = attr->user_data;
if (offset >= sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
static struct bt_gatt_attr service_c_2_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_C_2, 0xA0),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V10,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v10, NULL, &value_v10_value, 0xA1),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2, &value_v2_value, 0xA3),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_1, &value_v2_1_value, 0xA5),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_2, &value_v2_2_value, 0xA7),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_3, &value_v2_3_value, 0xA9),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_4, &value_v2_4_value, 0xAB),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V2,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_str_value, write_value_v2_5, &value_v2_5_value, 0xAD)
};
static struct bt_gatt_service service_c_2_3_svc =
BT_GATT_SERVICE(service_c_2_3_attrs);
/**
* @brief Register the Service C.2 and all its Characteristics...
*/
void service_c_2_3_init(void)
{
bt_gatt_service_register(&service_c_2_3_svc);
}
/**
* @brief Un-Register the Service C.2 and all its Characteristics...
*/
void service_c_2_3_remove(void)
{
bt_gatt_service_unregister(&service_c_2_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service C.2
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_C_2_3_H
#define SERVICE_C_2_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_c_2_3_init(void);
void service_c_2_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_C_2_3_H */

View file

@ -0,0 +1,128 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_b_5_1_attrs[];
/** @def BT_UUID_SERVICE_D
* @brief UUID for the Service D
*/
#define BT_UUID_SERVICE_D BT_UUID_DECLARE_16(0xa00d)
/** @def BT_UUID_VALUE_V12
* @brief UUID for the Value V12 Characteristic
*/
#define BT_UUID_VALUE_V12 BT_UUID_DECLARE_16(0xb00c)
/** @def BT_UUID_VALUE_V11__128_BIT_UUID
* @brief UUID for the Value V11 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V11__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0b, 0xb0, 0x00, 0x00)
static u8_t value_v12_value = 0x0C;
static u8_t value_v11__128_bit_uuid_value = 0x0B;
static bool bAuthorized;
/**
* @brief Attribute read call back for the Value V12 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v12(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v12_value));
}
/**
* @brief Attribute read call back for the Value V11 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v11__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
if (!bAuthorized)
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v11__128_bit_uuid_value));
}
struct bt_gatt_attr service_d_1_attrs[] = {
BT_GATT_H_SECONDARY_SERVICE(BT_UUID_SERVICE_D, 0x10),
BT_GATT_H_INCLUDE_SERVICE(service_b_5_1_attrs, 0x11),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V12,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ_AUTHEN,
read_value_v12, NULL, &value_v12_value, 0x12),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V11__128_BIT_UUID,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v11__128_bit_uuid, NULL,
&value_v11__128_bit_uuid_value, 0x14)
};
static struct bt_gatt_service service_d_1_svc =
BT_GATT_SERVICE(service_d_1_attrs);
/**
* @brief Register the Service D and all its Characteristics...
*/
void service_d_1_init(void)
{
bt_gatt_service_register(&service_d_1_svc);
}
/**
* @brief Un-Register the Service D and all its Characteristics...
*/
void service_d_1_remove(void)
{
bt_gatt_service_unregister(&service_d_1_svc);
}
/**
* @brief Set authorization for Characteristics and Descriptors in Service D.
*/
void service_d_1_authorize(bool authorized)
{
bAuthorized = authorized;
}

View file

@ -0,0 +1,26 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_D_1_H
#define SERVICE_D_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_d_1_authorize(bool);
void service_d_1_init(void);
void service_d_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_D_1_H */

View file

@ -0,0 +1,116 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_b_1_2_attrs[];
/** @def BT_UUID_SERVICE_D
* @brief UUID for the Service D
*/
#define BT_UUID_SERVICE_D BT_UUID_DECLARE_16(0xa00d)
/** @def BT_UUID_VALUE_V11__128_BIT_UUID
* @brief UUID for the Value V11 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V11__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0b, 0xb0, 0x00, 0x00)
/** @def BT_UUID_VALUE_V12
* @brief UUID for the Value V12 Characteristic
*/
#define BT_UUID_VALUE_V12 BT_UUID_DECLARE_16(0xb00c)
static u8_t value_v11__128_bit_uuid_value = 0x0B;
static u8_t value_v12_value = 0x0C;
/**
* @brief Attribute read call back for the Value V11 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v11__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v11__128_bit_uuid_value));
}
/**
* @brief Attribute read call back for the Value V12 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v12(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v12_value));
}
struct bt_gatt_attr service_d_2_attrs[] = {
BT_GATT_H_SECONDARY_SERVICE(BT_UUID_SERVICE_D, 0x40),
BT_GATT_H_INCLUDE_SERVICE(service_b_1_2_attrs, 0x41),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V11__128_BIT_UUID,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v11__128_bit_uuid, NULL,
&value_v11__128_bit_uuid_value, 0x42),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V12,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v12, NULL, &value_v12_value, 0x44)
};
static struct bt_gatt_service service_d_2_svc =
BT_GATT_SERVICE(service_d_2_attrs);
/**
* @brief Register the Service D and all its Characteristics...
*/
void service_d_2_init(void)
{
bt_gatt_service_register(&service_d_2_svc);
}
/**
* @brief Un-Register the Service D and all its Characteristics...
*/
void service_d_2_remove(void)
{
bt_gatt_service_unregister(&service_d_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_D_2_H
#define SERVICE_D_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_d_2_init(void);
void service_d_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_D_2_H */

View file

@ -0,0 +1,116 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
extern struct bt_gatt_attr service_c_1_3_attrs[];
/** @def BT_UUID_SERVICE_D
* @brief UUID for the Service D
*/
#define BT_UUID_SERVICE_D BT_UUID_DECLARE_16(0xa00d)
/** @def BT_UUID_VALUE_V12
* @brief UUID for the Value V12 Characteristic
*/
#define BT_UUID_VALUE_V12 BT_UUID_DECLARE_16(0xb00c)
/** @def BT_UUID_VALUE_V11__128_BIT_UUID
* @brief UUID for the Value V11 (128-bit UUID) Characteristic
*/
#define BT_UUID_VALUE_V11__128_BIT_UUID BT_UUID_DECLARE_128( \
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x0b, 0xb0, 0x00, 0x00)
static u8_t value_v12_value = 0x0C;
static u8_t value_v11__128_bit_uuid_value = 0x0B;
/**
* @brief Attribute read call back for the Value V12 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v12(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v12_value));
}
/**
* @brief Attribute read call back for the Value V11 (128-bit UUID) attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v11__128_bit_uuid(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v11__128_bit_uuid_value));
}
struct bt_gatt_attr service_d_3_attrs[] = {
BT_GATT_H_SECONDARY_SERVICE(BT_UUID_SERVICE_D, 0x20),
BT_GATT_H_INCLUDE_SERVICE(service_c_1_3_attrs, 0x21),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V12,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v12, NULL, &value_v12_value, 0x22),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V11__128_BIT_UUID,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v11__128_bit_uuid, NULL,
&value_v11__128_bit_uuid_value, 0x24)
};
static struct bt_gatt_service service_d_3_svc =
BT_GATT_SERVICE(service_d_3_attrs);
/**
* @brief Register the Service D and all its Characteristics...
*/
void service_d_3_init(void)
{
bt_gatt_service_register(&service_d_3_svc);
}
/**
* @brief Un-Register the Service D and all its Characteristics...
*/
void service_d_3_remove(void)
{
bt_gatt_service_unregister(&service_d_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service D
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_D_3_H
#define SERVICE_D_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_d_3_init(void);
void service_d_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_D_3_H */

View file

@ -0,0 +1,78 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service E
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_E
* @brief UUID for the Service E
*/
#define BT_UUID_SERVICE_E BT_UUID_DECLARE_16(0xa00e)
/** @def BT_UUID_VALUE_V13
* @brief UUID for the Value V13 Characteristic
*/
#define BT_UUID_VALUE_V13 BT_UUID_DECLARE_16(0xb00d)
static u8_t value_v13_value = 0x0D;
/**
* @brief Attribute read call back for the Value V13 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v13(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v13_value));
}
static struct bt_gatt_attr service_e_2_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_E, 0xFFFD),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V13,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v13, NULL, &value_v13_value, 0xFFFE)
};
static struct bt_gatt_service service_e_2_svc =
BT_GATT_SERVICE(service_e_2_attrs);
/**
* @brief Register the Service E and all its Characteristics...
*/
void service_e_2_init(void)
{
bt_gatt_service_register(&service_e_2_svc);
}
/**
* @brief Un-Register the Service E and all its Characteristics...
*/
void service_e_2_remove(void)
{
bt_gatt_service_unregister(&service_e_2_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service E
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
*/
#ifndef SERVICE_E_2_H
#define SERVICE_E_2_H
#ifdef __cplusplus
extern "C" {
#endif
void service_e_2_init(void);
void service_e_2_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_E_2_H */

View file

@ -0,0 +1,45 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service E
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_E
* @brief UUID for the Service E
*/
#define BT_UUID_SERVICE_E BT_UUID_DECLARE_16(0xa00e)
static struct bt_gatt_attr service_e_3_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_E, 0xFFFF)
};
static struct bt_gatt_service service_e_3_svc =
BT_GATT_SERVICE(service_e_3_attrs);
/**
* @brief Register the Service E and all its Characteristics...
*/
void service_e_3_init(void)
{
bt_gatt_service_register(&service_e_3_svc);
}
/**
* @brief Un-Register the Service E and all its Characteristics...
*/
void service_e_3_remove(void)
{
bt_gatt_service_unregister(&service_e_3_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service E
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
*/
#ifndef SERVICE_E_3_H
#define SERVICE_E_3_H
#ifdef __cplusplus
extern "C" {
#endif
void service_e_3_init(void);
void service_e_3_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_E_3_H */

View file

@ -0,0 +1,400 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service F
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#include <sys/byteorder.h>
#include <sys/printk.h>
#include <bluetooth/gatt.h>
#include "gatt_macs.h"
/** @def BT_UUID_SERVICE_F
* @brief UUID for the Service F
*/
#define BT_UUID_SERVICE_F BT_UUID_DECLARE_16(0xa00f)
/** @def BT_UUID_VALUE_V14
* @brief UUID for the Value V14 Characteristic
*/
#define BT_UUID_VALUE_V14 BT_UUID_DECLARE_16(0xb00e)
/** @def BT_UUID_VALUE_V15
* @brief UUID for the Value V15 Characteristic
*/
#define BT_UUID_VALUE_V15 BT_UUID_DECLARE_16(0xb00f)
/** @def BT_UUID_VALUE_V6
* @brief UUID for the Value V6 Characteristic
*/
#define BT_UUID_VALUE_V6 BT_UUID_DECLARE_16(0xb006)
/** @def BT_UUID_VALUE_V7
* @brief UUID for the Value V7 Characteristic
*/
#define BT_UUID_VALUE_V7 BT_UUID_DECLARE_16(0xb007)
/** @def BT_UUID_VALUE_V16
* @brief UUID for the Value V16 Characteristic
*/
#define BT_UUID_VALUE_V16 BT_UUID_DECLARE_16(0xb010)
/** @def BT_UUID_AGG_FORMAT
* @brief UUID for the Aggregate Format Characteristic
*/
#define BT_UUID_AGG_FORMAT BT_UUID_DECLARE_16(0x2905)
/** @def BT_UUID_VALUE_V17
* @brief UUID for the Value V17 Characteristic
*/
#define BT_UUID_VALUE_V17 BT_UUID_DECLARE_16(0xb011)
static u8_t value_v14_value[] = {
'L', 'e', 'n', 'g', 't', 'h', ' ', 'i', 's', ' ', '\0'
};
static const struct bt_gatt_cpf cha_format_value = {
0x19, 0x00, 0x3000, 0x01, 0x0000
};
static u8_t value_v15_value = 0x65;
static const struct bt_gatt_cpf cha_format_1_value = {
0x04, 0x00, 0x2701, 0x01, 0x0001
};
static u16_t value_v6_value = 0x1234;
static const struct bt_gatt_cpf cha_format_2_value = {
0x06, 0x00, 0x2710, 0x01, 0x0002
};
static u32_t value_v7_value = 0x01020304;
static const struct bt_gatt_cpf cha_format_3_value = {
0x08, 0x00, 0x2717, 0x01, 0x0003
};
static struct __packed value_v16_t {
u8_t field_a;
u16_t field_b;
u32_t field_c;
} value_v16_value = { 0x65, 0x1234, 0x01020304 };
static struct __packed agg_format_t {
u16_t field_a;
u16_t field_b;
u16_t field_c;
} agg_format_value = { 0x00A6, 0x00A9, 0x00AC };
static u8_t value_v17_value = 0x12;
/**
* @brief Attribute read call back for the Value V14 string attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_str_value(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const char *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/**
* @brief Attribute read call back for the Value V15 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v15(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v15_value));
}
/**
* @brief Attribute write call back for the Value V15 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v15(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u8_t *value = attr->user_data;
if (offset >= sizeof(value_v15_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v15_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
/**
* @brief Attribute read call back for the Value V6 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u16_t *value = attr->user_data;
u16_t value_v6_conv = sys_cpu_to_le16(*value);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &value_v6_conv,
sizeof(value_v6_conv));
}
/**
* @brief Attribute write call back for the Value V6 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v6(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u16_t *value = attr->user_data;
u16_t value_v6_conv = sys_cpu_to_le16(*value);
if (offset >= sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v6_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy((u8_t *)&value_v6_conv + offset, buf, len);
*value = sys_le16_to_cpu(value_v6_conv);
return len;
}
/**
* @brief Attribute read call back for the Value V7 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v7(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u32_t *value = attr->user_data;
u32_t value_v7_conv = sys_cpu_to_le32(*value);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &value_v7_conv,
sizeof(value_v7_conv));
}
/**
* @brief Attribute write call back for the Value V7 attribute
*
* @param conn The connection that is requesting to write
* @param attr The attribute that's being written
* @param buf Buffer with the data to write
* @param len Number of bytes in the buffer
* @param offset Offset to start writing from
* @param flags Flags (BT_GATT_WRITE_*)
*
* @return Number of bytes written, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t write_value_v7(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
u32_t *value = attr->user_data;
u32_t value_v7_conv = sys_cpu_to_le32(*value);
if (offset >= sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v7_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy((u8_t *)&value_v7_conv + offset, buf, len);
*value = sys_le32_to_cpu(value_v7_conv);
return len;
}
/**
* @brief Attribute read call back for the Value V16 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v16(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const struct value_v16_t *value = attr->user_data;
struct value_v16_t value_v16_conv;
value_v16_conv.field_a = value->field_a;
value_v16_conv.field_b = sys_cpu_to_le16(value->field_b);
value_v16_conv.field_c = sys_cpu_to_le32(value->field_c);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &value_v16_conv,
sizeof(value_v16_conv));
}
/**
* @brief Attribute read call back for the Aggregate Format attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_agg_format(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const struct agg_format_t *value = attr->user_data;
struct agg_format_t agg_format_conv;
agg_format_conv.field_a = sys_cpu_to_le16(value->field_a);
agg_format_conv.field_b = sys_cpu_to_le16(value->field_b);
agg_format_conv.field_c = sys_cpu_to_le16(value->field_c);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &agg_format_conv,
sizeof(agg_format_conv));
}
/**
* @brief Attribute read call back for the Value V17 attribute
*
* @param conn The connection that is requesting to read
* @param attr The attribute that's being read
* @param buf Buffer to place the read result in
* @param len Length of data to read
* @param offset Offset to start reading from
*
* @return Number of bytes read, or in case of an error - BT_GATT_ERR()
* with a specific ATT error code.
*/
static ssize_t read_value_v17(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
const u8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v17_value));
}
static struct bt_gatt_attr service_f_1_attrs[] = {
BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_F, 0xA0),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V14,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_str_value, NULL, &value_v14_value, 0xA1),
BT_GATT_H_CPF(&cha_format_value, 0xA3),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V15,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v15, write_value_v15, &value_v15_value, 0xA4),
BT_GATT_H_CPF(&cha_format_1_value, 0xA6),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V6,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v6, write_value_v6, &value_v6_value, 0xA7),
BT_GATT_H_CPF(&cha_format_2_value, 0xA9),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V7,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v7, write_value_v7, &value_v7_value, 0xAA),
BT_GATT_H_CPF(&cha_format_3_value, 0xAC),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V16,
BT_GATT_CHRC_READ,
BT_GATT_PERM_READ,
read_value_v16, NULL, &value_v16_value, 0xAD),
BT_GATT_H_DESCRIPTOR(BT_UUID_AGG_FORMAT,
BT_GATT_PERM_READ,
read_agg_format, NULL, &agg_format_value, 0xAF),
BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V17,
BT_GATT_CHRC_READ | BT_GATT_CHRC_AUTH,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
read_value_v17, NULL, &value_v17_value, 0xB0)
};
static struct bt_gatt_service service_f_1_svc =
BT_GATT_SERVICE(service_f_1_attrs);
/**
* @brief Register the Service F and all its Characteristics...
*/
void service_f_1_init(void)
{
bt_gatt_service_register(&service_f_1_svc);
}
/**
* @brief Un-Register the Service F and all its Characteristics...
*/
void service_f_1_remove(void)
{
bt_gatt_service_unregister(&service_f_1_svc);
}

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Service F
*
* This code is auto-generated from the Excel Workbook
* 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 1'
*/
#ifndef SERVICE_F_1_H
#define SERVICE_F_1_H
#ifdef __cplusplus
extern "C" {
#endif
void service_f_1_init(void);
void service_f_1_remove(void);
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_F_1_H */

View file

@ -0,0 +1,40 @@
/**
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef GATT_TEST_APP_GATT_SERVICES_H
#define GATT_TEST_APP_GATT_SERVICES_H
#include "service_a_1.h"
#include "service_a_2.h"
#include "service_a_3.h"
#include "service_b_1_1.h"
#include "service_b_1_2.h"
#include "service_b_1_3.h"
#include "service_b_2_1.h"
#include "service_b_2_2.h"
#include "service_b_2_3.h"
#include "service_b_3_1.h"
#include "service_b_3_2.h"
#include "service_b_3_3.h"
#include "service_b_4_1.h"
#include "service_b_4_2.h"
#include "service_b_4_3.h"
#include "service_b_5_1.h"
#include "service_b_5_2.h"
#include "service_b_5_3.h"
#include "service_c_1_1.h"
#include "service_c_1_2.h"
#include "service_c_1_3.h"
#include "service_c_2_1.h"
#include "service_c_2_2.h"
#include "service_c_2_3.h"
#include "service_d_1.h"
#include "service_d_2.h"
#include "service_d_3.h"
#include "service_e_2.h"
#include "service_e_3.h"
#include "service_f_1.h"
#endif /* GATT_TEST_APP_GATT_SERVICES_H */

View file

@ -0,0 +1,376 @@
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/types.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <sys/printk.h>
#include <sys/byteorder.h>
#include <zephyr.h>
#include <settings/settings.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/conn.h>
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>
#include <gatt/services.h>
#include "edtt_driver.h"
#include "bs_tracing.h"
#include "commands.h"
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID16_ALL,
0x0d, 0x18, 0x0f, 0x18, 0x05, 0x18),
BT_DATA_BYTES(BT_DATA_UUID128_ALL,
0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12),
};
static const struct bt_data sd[] = {
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};
static int service_set;
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
} else {
printk("Connected\n");
}
}
static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
}
static void security_changed(struct bt_conn *conn, bt_security_t level,
enum bt_security_err err)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
printk("Security changed: %s level %u\n", addr, level);
}
static struct bt_conn_cb conn_callbacks = {
.connected = connected,
.disconnected = disconnected,
.security_changed = security_changed,
};
static void service_setup(int set)
{
if (set == service_set) {
printk("Ignored request to change GATT services set to #%d - "
"already selected!\n", set);
return;
}
switch (service_set) {
case 0:
break;
case 1:
service_c_2_1_remove();
service_f_1_remove();
service_c_1_1_remove();
service_b_5_1_remove();
service_b_2_1_remove();
service_b_1_1_remove();
service_b_3_1_remove();
service_b_4_1_remove();
service_a_1_remove();
service_d_1_remove();
break;
case 2:
service_e_2_remove();
service_b_5_2_remove();
service_b_2_2_remove();
service_b_3_2_remove();
service_a_2_remove();
service_b_1_2_remove();
service_d_2_remove();
service_b_4_2_remove();
service_c_1_2_remove();
service_c_2_2_remove();
break;
case 3:
service_e_3_remove();
service_c_2_3_remove();
service_b_2_3_remove();
service_c_1_3_remove();
service_a_3_remove();
service_b_3_3_remove();
service_b_4_3_remove();
service_b_5_3_remove();
service_d_3_remove();
service_b_1_3_remove();
break;
default:
break;
}
switch (set) {
case 0:
break;
case 1:
service_d_1_init();
service_a_1_init();
service_b_4_1_init();
service_b_3_1_init();
service_b_1_1_init();
service_b_2_1_init();
service_b_5_1_init();
service_c_1_1_init();
service_f_1_init();
service_c_2_1_init();
break;
case 2:
service_c_2_2_init();
service_c_1_2_init();
service_b_4_2_init();
service_d_2_init();
service_b_1_2_init();
service_a_2_init();
service_b_3_2_init();
service_b_2_2_init();
service_b_5_2_init();
service_e_2_init();
break;
case 3:
service_b_1_3_init();
service_d_3_init();
service_b_5_3_init();
service_b_4_3_init();
service_b_3_3_init();
service_a_3_init();
service_c_1_3_init();
service_b_2_3_init();
service_c_2_3_init();
service_e_3_init();
break;
default:
break;
}
service_set = set;
printk("Switched to GATT services set to #%d\n", set);
}
static void service_notify(void)
{
switch (service_set) {
case 0:
break;
case 1:
service_b_3_1_value_v6_notify();
break;
case 2:
service_b_3_2_value_v6_notify();
break;
case 3:
service_b_3_3_value_v6_notify();
break;
default:
break;
}
}
static void service_indicate(void)
{
switch (service_set) {
case 0:
break;
case 1:
break;
case 2:
service_b_3_2_value_v6_indicate();
break;
case 3:
service_b_3_3_value_v6_indicate();
break;
default:
break;
}
}
static void bt_ready(int err)
{
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
printk("Bluetooth initialized\n");
service_setup(1);
printk("GATT Services initialized\n");
if (IS_ENABLED(CONFIG_SETTINGS)) {
settings_load();
}
err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd,
ARRAY_SIZE(sd));
if (err) {
printk("Advertising failed to start (err %d)\n", err);
return;
}
printk("Advertising successfully started\n");
}
static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
printk("Passkey for %s: %06u\n", addr, passkey);
}
static void auth_cancel(struct bt_conn *conn)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
printk("Pairing cancelled: %s\n", addr);
}
static struct bt_conn_auth_cb auth_cb_display = {
.passkey_display = auth_passkey_display,
.passkey_entry = NULL,
.cancel = auth_cancel,
};
/**
* @brief Clean out excess bytes from the input buffer
*/
static void read_excess_bytes(u16_t size)
{
if (size > 0) {
u8_t buffer[size];
edtt_read((u8_t *)buffer, size, EDTTT_BLOCK);
printk("command size wrong! (%u extra bytes removed)", size);
}
}
/**
* @brief Switch GATT Service Set
*/
static void switch_service_set(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_GATT_SERVICE_SET_RSP);
u8_t set;
if (size > 0) {
edtt_read((u8_t *)&set, sizeof(set), EDTTT_BLOCK);
service_setup((int)set);
size -= sizeof(set);
}
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
/**
* @brief Send Notifications from GATT Service Set
*/
static void handle_service_notify(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_GATT_SERVICE_NOTIFY_RSP);
service_notify();
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
/**
* @brief Send Indications from GATT Service Set
*/
static void handle_service_indicate(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_GATT_SERVICE_INDICATE_RSP);
service_indicate();
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
void main(void)
{
int err;
u16_t command;
u16_t size;
err = bt_enable(bt_ready);
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
bt_conn_cb_register(&conn_callbacks);
bt_conn_auth_cb_register(&auth_cb_display);
/**
* Initialize and start EDTT system
*/
#if defined(CONFIG_ARCH_POSIX)
enable_edtt_mode();
set_edtt_autoshutdown(true);
#endif
edtt_start();
/* Implement notification. At the moment there is no suitable way
* of starting delayed work so we do it here
*/
while (1) {
/**
* Wait for a command to arrive - then read and execute command
*/
edtt_read((u8_t *)&command, sizeof(command), EDTTT_BLOCK);
command = sys_le16_to_cpu(command);
edtt_read((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
size = sys_le16_to_cpu(size);
bs_trace_raw_time(4, "command 0x%04X received (size %u)\n",
command, size);
switch (command) {
case CMD_GATT_SERVICE_SET_REQ:
switch_service_set(size);
break;
case CMD_GATT_SERVICE_NOTIFY_REQ:
handle_service_notify(size);
break;
case CMD_GATT_SERVICE_INDICATE_REQ:
handle_service_indicate(size);
break;
default:
break;
}
}
}

View file

@ -0,0 +1,27 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Oticon A/S
cmake_minimum_required(VERSION 3.13.1)
if (NOT DEFINED ENV{BSIM_COMPONENTS_PATH})
message(FATAL_ERROR "This test requires the BabbleSim simulator. Please set\
the environment variable BSIM_COMPONENTS_PATH to point to its components \
folder. More information can be found in\
https://babblesim.github.io/folder_structure_and_env.html")
endif()
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(hci_test_app)
target_sources(app PRIVATE
src/main.c
../common/edtt_driver_bsim.c
)
zephyr_library_include_directories(
$ENV{ZEPHYR_BASE}/samples/bluetooth
$ENV{ZEPHYR_BASE}/subsys/bluetooth
../common/
$ENV{BSIM_COMPONENTS_PATH}/libUtilv1/src/
$ENV{BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)

View file

@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_DEBUG_LOG=y
# CONFIG_SYS_LOG=y
# CONFIG_SYS_LOG_DEFAULT_LEVEL=4
# CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_DEBUG=y
CONFIG_BT_DEBUG_RPA=y
CONFIG_BT_DEBUG_CONN=y
CONFIG_BT_ECC=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_RPA=y
# CONFIG_BT_PRIVACY=y
# CONFIG_BT_SIGNING=y
# CONFIG_BT_L2CAP_TX_BUF_COUNT=6
# CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
##
## Enabling BT_CTRL_DTM_HCI requires BT_LL_SW which requires BT_CTRL
##
CONFIG_BT_CTLR=y
# CONFIG_BT_LL_SW_LEGACY=y
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_CTLR_CRYPTO=y
CONFIG_BT_CTLR_LE_ENC=y
CONFIG_BT_CTLR_PRIVACY=y
CONFIG_BT_CTLR_FILTER=y
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_TX_BUFFER_SIZE=60
CONFIG_BT_CTLR_DATA_LENGTH_MAX=60
CONFIG_SYS_POWER_MANAGEMENT=y
CONFIG_TICKLESS_IDLE=y
CONFIG_TICKLESS_KERNEL=y
CONFIG_LOG_MAX_LEVEL=2

View file

@ -0,0 +1,33 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_DEBUG_LOG=y
# CONFIG_SYS_LOG=y
# CONFIG_SYS_LOG_DEFAULT_LEVEL=4
# CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_ECC=y
CONFIG_BT_TINYCRYPT_ECC=y
# CONFIG_BT_SMP=y
# CONFIG_BT_PRIVACY=y
# CONFIG_BT_SIGNING=y
# CONFIG_BT_L2CAP_TX_BUF_COUNT=6
# CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
##
## Enabling BT_CTRL_DTM_HCI requires BT_LL_SW which requires BT_CTRL
##
CONFIG_BT_CTLR=y
CONFIG_BT_LL_SW_LEGACY=y
CONFIG_BT_CTLR_CRYPTO=y
CONFIG_BT_CTLR_LE_ENC=y
CONFIG_BT_CTLR_PRIVACY=y
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_TX_BUFFER_SIZE=60
CONFIG_BT_CTLR_DATA_LENGTH_MAX=60
CONFIG_SYS_POWER_MANAGEMENT=y
CONFIG_TICKLESS_IDLE=y
CONFIG_TICKLESS_KERNEL=y
CONFIG_LOG_MAX_LEVEL=2

View file

@ -0,0 +1,598 @@
/*
* Copyright (c) 2019 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief HCI interface application
*/
#include <zephyr.h>
#include <settings/settings.h>
#include <sys/byteorder.h>
#include <debug/stack.h>
#include <net/buf.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/hci_vs.h>
#include <bluetooth/hci_raw.h>
#include "edtt_driver.h"
#include "bs_tracing.h"
#include "commands.h"
static u16_t waiting_opcode;
static enum commands_t waiting_response;
static u8_t m_events;
/**
* @brief Clean out excess bytes from the input buffer
*/
static void read_excess_bytes(u16_t size)
{
if (size > 0) {
u8_t buffer[size];
edtt_read((u8_t *)buffer, size, EDTTT_BLOCK);
printk("command size wrong! (%u extra bytes removed)", size);
}
}
/**
* @brief Provide an error response when an HCI command send failed
*/
static void error_response(int error)
{
u16_t response = sys_cpu_to_le16(waiting_response);
int le_error = sys_cpu_to_le32(error);
u16_t size = sys_cpu_to_le16(sizeof(le_error));
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)&le_error, sizeof(le_error), EDTTT_BLOCK);
waiting_response = CMD_NOTHING;
waiting_opcode = 0;
}
#if defined(CONFIG_BT_CTLR_DATA_LENGTH_MAX)
#define BT_BUF_ACL_SIZE BT_L2CAP_BUF_SIZE(CONFIG_BT_CTLR_DATA_LENGTH_MAX)
#else
#define BT_BUF_ACL_SIZE BT_L2CAP_BUF_SIZE(60)
#endif
NET_BUF_POOL_DEFINE(hci_cmd_pool, CONFIG_BT_HCI_CMD_COUNT,
BT_BUF_RX_SIZE, BT_BUF_USER_DATA_MIN, NULL);
NET_BUF_POOL_DEFINE(hci_data_pool, CONFIG_BT_CTLR_TX_BUFFERS+4,
BT_BUF_ACL_SIZE, BT_BUF_USER_DATA_MIN, NULL);
/**
* @brief Allocate buffer for HCI command and fill in opCode for the command
*/
static struct net_buf *hci_cmd_create(u16_t opcode, u8_t param_len)
{
struct bt_hci_cmd_hdr *hdr;
struct net_buf *buf;
buf = net_buf_alloc(&hci_cmd_pool, K_FOREVER);
__ASSERT_NO_MSG(buf);
net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE);
bt_buf_set_type(buf, BT_BUF_CMD);
hdr = net_buf_add(buf, sizeof(*hdr));
hdr->opcode = sys_cpu_to_le16(opcode);
hdr->param_len = param_len;
return buf;
}
/**
* @brief Allocate buffer for ACL Data Package and fill in Header
*/
static struct net_buf *acl_data_create(struct bt_hci_acl_hdr *le_hdr)
{
struct net_buf *buf;
struct bt_hci_acl_hdr *hdr;
buf = net_buf_alloc(&hci_data_pool, K_FOREVER);
__ASSERT_NO_MSG(buf);
net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE);
bt_buf_set_type(buf, BT_BUF_ACL_OUT);
hdr = net_buf_add(buf, sizeof(*hdr));
*hdr = *le_hdr;
return buf;
}
/**
* @brief Allocate buffer for HCI command, fill in parameters and send the
* command...
*/
static int send_hci_command(u16_t opcode, u8_t param_len, u16_t response)
{
struct net_buf *buf;
void *cp;
int err = 0;
waiting_response = response;
buf = hci_cmd_create(waiting_opcode = opcode, param_len);
if (buf) {
if (param_len) {
cp = net_buf_add(buf, param_len);
edtt_read((u8_t *)cp, param_len, EDTTT_BLOCK);
}
err = bt_send(buf);
if (err) {
printk("Failed to send HCI command %d (err %d)\n",
opcode, err);
error_response(err);
}
} else {
printk("Failed to create buffer for HCI command %u\n", opcode);
error_response(-1);
}
return err;
}
/**
* @brief Echo function - echo input received...
*/
static void echo(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_ECHO_RSP);
u16_t le_size = sys_cpu_to_le16(size);
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&le_size, sizeof(le_size), EDTTT_BLOCK);
if (size > 0) {
u8_t buff[size];
edtt_read(buff, size, EDTTT_BLOCK);
edtt_write(buff, size, EDTTT_BLOCK);
}
}
NET_BUF_POOL_DEFINE(event_pool, 32, BT_BUF_RX_SIZE + 4,
BT_BUF_USER_DATA_MIN, NULL);
static K_FIFO_DEFINE(event_queue);
static K_FIFO_DEFINE(rx_queue);
NET_BUF_POOL_DEFINE(data_pool, CONFIG_BT_CTLR_RX_BUFFERS + 14,
BT_BUF_ACL_SIZE + 4, BT_BUF_USER_DATA_MIN, NULL);
static K_FIFO_DEFINE(data_queue);
/**
* @brief Handle Command Complete HCI event...
*/
static void command_complete(struct net_buf *buf)
{
struct bt_hci_evt_cmd_complete *evt = (void *)buf->data;
u16_t opcode = sys_le16_to_cpu(evt->opcode);
u16_t response = sys_cpu_to_le16(waiting_response);
net_buf_pull(buf, sizeof(*evt));
u16_t size = sys_cpu_to_le16(buf->len);
if (opcode == waiting_opcode) {
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
waiting_opcode = 0;
}
}
/**
* @brief Handle Command Status HCI event...
*/
static void command_status(struct net_buf *buf)
{
struct bt_hci_evt_cmd_status *evt = (void *)buf->data;
u16_t opcode = sys_le16_to_cpu(evt->opcode);
u16_t response = sys_cpu_to_le16(waiting_response);
u16_t size = sys_cpu_to_le16(buf->len);
if (opcode == waiting_opcode) {
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
waiting_opcode = 0;
}
}
/**
* @brief Remove an event from the event queue
*/
static void discard_event(void)
{
struct net_buf *buf = net_buf_get(&event_queue, K_FOREVER);
net_buf_unref(buf);
m_events--;
}
/**
* @brief Allocate and store an event in the event queue
*/
static struct net_buf *queue_event(struct net_buf *buf)
{
struct net_buf *evt;
evt = net_buf_alloc(&event_pool, K_NO_WAIT);
if (evt) {
bt_buf_set_type(evt, BT_BUF_EVT);
net_buf_add_le32(evt, sys_cpu_to_le32(k_uptime_get()));
net_buf_add_mem(evt, buf->data, buf->len);
net_buf_put(&event_queue, evt);
m_events++;
}
return evt;
}
/**
* @brief Thread to service events and ACL data packets from the HCI input queue
*/
static void service_events(void *p1, void *p2, void *p3)
{
struct net_buf *buf, *evt;
while (1) {
buf = net_buf_get(&rx_queue, K_FOREVER);
if (bt_buf_get_type(buf) == BT_BUF_EVT) {
evt = queue_event(buf);
if (!evt) {
bs_trace_raw_time(4,
"Failed to allocated buffer "
"for event!\n");
}
struct bt_hci_evt_hdr *hdr = (void *)buf->data;
net_buf_pull(buf, sizeof(*hdr));
switch (hdr->evt) {
case BT_HCI_EVT_CMD_COMPLETE:
if (!evt) {
discard_event();
evt = queue_event(buf);
}
command_complete(buf);
break;
case BT_HCI_EVT_CMD_STATUS:
if (!evt) {
discard_event();
evt = queue_event(buf);
}
command_status(buf);
break;
default:
break;
}
} else if (bt_buf_get_type(buf) == BT_BUF_ACL_IN) {
struct net_buf *data;
data = net_buf_alloc(&data_pool, K_NO_WAIT);
if (data) {
bt_buf_set_type(data, BT_BUF_ACL_IN);
net_buf_add_le32(data,
sys_cpu_to_le32(k_uptime_get()));
net_buf_add_mem(data, buf->data, buf->len);
net_buf_put(&data_queue, data);
}
}
net_buf_unref(buf);
k_yield();
}
}
/**
* @brief Flush all HCI events from the input-copy queue
*/
static void flush_events(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_FLUSH_EVENTS_RSP);
struct net_buf *buf;
while ((buf = net_buf_get(&event_queue, K_NO_WAIT))) {
net_buf_unref(buf);
m_events--;
}
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
/**
* @brief Get next available HCI event from the input-copy queue
*/
static void get_event(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_GET_EVENT_RSP);
struct net_buf *buf;
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
buf = net_buf_get(&event_queue, K_FOREVER);
if (buf) {
size = sys_cpu_to_le16(buf->len);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
net_buf_unref(buf);
m_events--;
} else {
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
}
/**
* @brief Get next available HCI events from the input-copy queue
*/
static void get_events(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_GET_EVENT_RSP);
struct net_buf *buf;
u8_t count = m_events;
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&count, sizeof(count), EDTTT_BLOCK);
while (count--) {
buf = net_buf_get(&event_queue, K_FOREVER);
size = sys_cpu_to_le16(buf->len);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
net_buf_unref(buf);
m_events--;
}
}
/**
* @brief Check whether an HCI event is available in the input-copy queue
*/
static void has_event(u16_t size)
{
struct has_event_resp {
u16_t response;
u16_t size;
u8_t count;
} __packed;
struct has_event_resp le_response = {
.response = sys_cpu_to_le16(CMD_HAS_EVENT_RSP),
.size = sys_cpu_to_le16(1),
.count = m_events
};
if (size > 0) {
read_excess_bytes(size);
}
edtt_write((u8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK);
}
/**
* @brief Flush all ACL Data Packages from the input-copy queue
*/
static void le_flush_data(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_DATA_RSP);
struct net_buf *buf;
while ((buf = net_buf_get(&data_queue, K_NO_WAIT))) {
net_buf_unref(buf);
}
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
/**
* @brief Check whether an ACL Data Package is available in the input-copy queue
*/
static void le_data_ready(u16_t size)
{
struct has_data_resp {
u16_t response;
u16_t size;
u8_t empty;
} __packed;
struct has_data_resp le_response = {
.response = sys_cpu_to_le16(CMD_LE_DATA_READY_RSP),
.size = sys_cpu_to_le16(1),
.empty = 0
};
if (size > 0) {
read_excess_bytes(size);
}
if (k_fifo_is_empty(&data_queue)) {
le_response.empty = 1;
}
edtt_write((u8_t *)&le_response, sizeof(le_response), EDTTT_BLOCK);
}
/**
* @brief Get next available HCI Data Package from the input-copy queue
*/
static void le_data_read(u16_t size)
{
u16_t response = sys_cpu_to_le16(CMD_LE_DATA_READ_RSP);
struct net_buf *buf;
read_excess_bytes(size);
size = 0;
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
buf = net_buf_get(&data_queue, K_FOREVER);
if (buf) {
size = sys_cpu_to_le16(buf->len);
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
edtt_write((u8_t *)buf->data, buf->len, EDTTT_BLOCK);
net_buf_unref(buf);
} else {
edtt_write((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
}
}
/**
* @brief Write ACL Data Package to the Controller...
*/
static void le_data_write(u16_t size)
{
struct data_write_resp {
u16_t code;
u16_t size;
u8_t status;
} __packed;
struct data_write_resp response = {
.code = sys_cpu_to_le16(CMD_LE_DATA_WRITE_RSP),
.size = sys_cpu_to_le16(1),
.status = 0
};
struct net_buf *buf;
struct bt_hci_acl_hdr hdr;
int err;
if (size >= sizeof(hdr)) {
edtt_read((u8_t *)&hdr, sizeof(hdr), EDTTT_BLOCK);
size -= sizeof(hdr);
buf = acl_data_create(&hdr);
if (buf) {
u16_t hdr_length = sys_le16_to_cpu(hdr.len);
u8_t *pdata = net_buf_add(buf, hdr_length);
if (size >= hdr_length) {
edtt_read(pdata, hdr_length, EDTTT_BLOCK);
size -= hdr_length;
}
err = bt_send(buf);
if (err) {
printk("Failed to send ACL Data (err %d)\n",
err);
}
} else {
err = -2; /* Failed to allocate data buffer */
printk("Failed to create buffer for ACL Data.\n");
}
} else {
/* Size too small for header (handle and data length) */
err = -3;
}
read_excess_bytes(size);
response.status = sys_cpu_to_le32(err);
edtt_write((u8_t *)&response, sizeof(response), EDTTT_BLOCK);
}
static K_THREAD_STACK_DEFINE(service_events_stack,
CONFIG_BT_HCI_TX_STACK_SIZE);
static struct k_thread service_events_data;
/**
* @brief Zephyr application main entry...
*/
void main(void)
{
int err;
u16_t command;
u16_t size;
u16_t opcode;
/**
* Initialize HCI command opcode and response variables...
*/
waiting_opcode = 0;
waiting_response = CMD_NOTHING;
m_events = 0;
/**
* Initialize Bluetooth stack in raw mode...
*/
err = bt_enable_raw(&rx_queue);
if (err) {
printk("Bluetooth initialization failed (err %d)\n", err);
return;
}
/**
* Initialize and start EDTT system...
*/
#if defined(CONFIG_ARCH_POSIX)
enable_edtt_mode();
set_edtt_autoshutdown(true);
#endif
edtt_start();
/**
* Initialize and start thread to service HCI events and ACL data...
*/
k_thread_create(&service_events_data, service_events_stack,
K_THREAD_STACK_SIZEOF(service_events_stack),
service_events, NULL, NULL, NULL, K_PRIO_COOP(7),
0, K_NO_WAIT);
while (1) {
/**
* Wait for a command to arrive - then read and execute command
*/
edtt_read((u8_t *)&command, sizeof(command), EDTTT_BLOCK);
command = sys_le16_to_cpu(command);
edtt_read((u8_t *)&size, sizeof(size), EDTTT_BLOCK);
size = sys_le16_to_cpu(size);
bs_trace_raw_time(4, "command 0x%04X received (size %u) "
"events=%u\n",
command, size, m_events);
switch (command) {
case CMD_ECHO_REQ:
echo(size);
break;
case CMD_FLUSH_EVENTS_REQ:
flush_events(size);
break;
case CMD_HAS_EVENT_REQ:
has_event(size);
break;
case CMD_GET_EVENT_REQ:
{
u8_t multiple;
edtt_read((u8_t *)&multiple, sizeof(multiple),
EDTTT_BLOCK);
if (multiple)
get_events(--size);
else
get_event(--size);
}
break;
case CMD_LE_FLUSH_DATA_REQ:
le_flush_data(size);
break;
case CMD_LE_DATA_READY_REQ:
le_data_ready(size);
break;
case CMD_LE_DATA_WRITE_REQ:
le_data_write(size);
break;
case CMD_LE_DATA_READ_REQ:
le_data_read(size);
break;
default:
if (size >= 2) {
edtt_read((u8_t *)&opcode, sizeof(opcode),
EDTTT_BLOCK);
send_hci_command(sys_le16_to_cpu(opcode),
size-2, command+1);
}
}
}
}