Skip to content

Commit

Permalink
apps/bttester: Add initial support for PACS autopts tests
Browse files Browse the repository at this point in the history
This commit adds support for Published
Audio Capabilities Service in bttester
application.
  • Loading branch information
szymon-czapracki committed Apr 5, 2024
1 parent 1d809b1 commit 3955688
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/bttester/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pkg.deps:
- "@apache-mynewt-nimble/nimble/host/services/gap"
- "@apache-mynewt-nimble/nimble/host/services/gatt"
- "@apache-mynewt-nimble/nimble/host/services/dis"
- "@apache-mynewt-nimble/nimble/host/audio/services/pacs"
- "@apache-mynewt-nimble/nimble/host/store/config"
- "@apache-mynewt-core/hw/drivers/uart"
- "@apache-mynewt-core/hw/drivers/rtt"

30 changes: 30 additions & 0 deletions apps/bttester/src/btp/btp_pacs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef BTP_PACS_H
#define BTP_PACS_H

#define BTP_PACS_READ_SUPPORTED_COMMANDS 0x01
#define BTP_PACS_UPDATE_CHARACTERISTIC 0x02
#define BTP_PACS_SET_LOCATION 0x03
#define BTP_PACS_SET_AVAILABLE_CONTEXTS 0x04
#define BTP_PACS_SET_SUPPORTED_CONTEXTS 0x05

#endif /* BTP_PACS_H*/

118 changes: 118 additions & 0 deletions apps/bttester/src/btp_pacs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/* btp_pacs.c - Bluetooth Published Audio Capacity Service Tester */

#include "syscfg/syscfg.h"

#if MYNEWT_VAL(BLE_AUDIO)

#include "btp/btp.h"
#include "btp/btp_pacs.h"
#include "console/console.h"

#include "nimble/ble.h"
#include "host/ble_hs.h"
#include "host/util/util.h"

#include "audio/ble_audio.h"
#include "services/pacs/ble_audio_svc_pacs.h"

static uint8_t
pacs_set_available_contexts(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
int rc;
uint16_t conn_handle = 0;
uint16_t sink_contexts = 0;
uint16_t source_contexts = 0;

rc = ble_svc_audio_pacs_avail_contexts_set(conn_handle, sink_contexts,
source_contexts);
if (rc) {
return BTP_STATUS_FAILED;
}

return BTP_STATUS_SUCCESS;
}

static uint8_t
pacs_set_location(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
return BTP_STATUS_SUCCESS;
}

static uint8_t
pacs_update_characteristic(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
return BTP_STATUS_SUCCESS;
}

static uint8_t
pacs_set_supported_contexts(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
return BTP_STATUS_SUCCESS;
}

static const struct btp_handler handlers[] = {
{
.opcode = BTP_PACS_UPDATE_CHARACTERISTIC,
.index = BTP_INDEX_NONE,
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
.func = pacs_update_characteristic,
},
{
.opcode = BTP_PACS_SET_LOCATION,
.index = BTP_INDEX_NONE,
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
.func = pacs_set_location,
},
{
.opcode = BTP_PACS_SET_AVAILABLE_CONTEXTS,
.index = BTP_INDEX_NONE,
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
.func = pacs_set_available_contexts,
},
{
.opcode = BTP_PACS_SET_SUPPORTED_CONTEXTS,
.index = BTP_INDEX_NONE,
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
.func = pacs_set_supported_contexts,
},
};

uint8_t
tester_init_pacs(void)
{
tester_register_command_handlers(BTP_SERVICE_ID_BAP, handlers,
ARRAY_SIZE(handlers));

return BTP_STATUS_SUCCESS;
}

uint8_t
tester_unregister_pacs(void)
{
return BTP_STATUS_SUCCESS;
}

#endif /* MYNEWT_VAL(BLE_AUDIO)*/
10 changes: 9 additions & 1 deletion apps/bttester/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ syscfg.defs:
description: Broadcast name
value: '"test_broadcast"'

BLE_SVC_AUDUI_SINK_PAC: 1
BLE_SVC_AUDUI_SOURCE_PAC: 1

syscfg.vals:
CONSOLE_IMPLEMENTATION: full
LOG_IMPLEMENTATION: full
Expand Down Expand Up @@ -161,5 +164,10 @@ syscfg.vals:
BLE_MESH_TX_SEG_MSG_COUNT: 2
BLE_MAX_CONNECTIONS: 8


syscfg.vals.BSP_NRF5340:
MCU_MPU_ENABLE: 1
MCU_CACHE_ENABLED: 1
BSP_NRF5340_NET_ENABLE: 1
NRF5340_EMBED_NET_CORE: 1
NET_CORE_IMAGE_TARGET_NAME: "@apache-mynewt-nimble/targets/nordic_pca10095_net-blehci_broadcaster"

0 comments on commit 3955688

Please sign in to comment.