diff --git a/.gdb_out b/.gdb_out new file mode 100644 index 0000000000..079f1e514f --- /dev/null +++ b/.gdb_out @@ -0,0 +1,156 @@ +GNU gdb (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.1.90.20221210-git +Copyright (C) 2022 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +Type "show copying" and "show warranty" for details. +This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi". +Type "show configuration" for configuration details. +For bug reporting instructions, please see: +. +Find the GDB manual and other documentation resources online at: + . + +For help, type "help". +Type "apropos word" to search for commands related to "word". +SEGGER J-Link GDB Server V7.96 Command Line Version + +JLinkARM.dll V7.96 (DLL compiled Mar 7 2024 16:49:04) + +Command line: -device nrf52840_xxaa -speed 1000 -if SWD -port 3333 -singlerun +-----GDB Server start settings----- +GDBInit file: none +GDB Server Listening port: 3333 +SWO raw output listening port: 2332 +Terminal I/O port: 2333 +Accept remote connection: localhost only +Generate logfile: off +Verify download: off +Init regs on start: off +Silent mode: off +Single run mode: on +Target connection timeout: 0 ms +------J-Link related settings------ +J-Link Host interface: USB +J-Link script: none +J-Link settings file: none +------Target related settings------ +Target device: nrf52840_xxaa +Target device parameters: none +Target interface: SWD +Target interface speed: 1000kHz +Target endian: little + +Connecting to J-Link... +J-Link is connected. +Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Oct 30 2023 12:12:17 +Hardware: V1.00 +S/N: 683403725 +Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB +Checking target voltage... +Target voltage: 3.30 V +Listening on TCP/IP port 3333 +Connecting to target... +Halting core... +Connected to target +Waiting for GDB connection...Connected to 0000:0000:0000:0000:0000:0000:0000:0001 +GDB client (conn. 888) requested target.xml from GDB Server +warning: No executable has been specified and target does not support +determining executable automatically. Try using the "file" command. +Reading common registers: Read register 'r0' (4 bytes) from hardware: 0xFF7F0000 +Read register 'r1' (4 bytes) from hardware: 0x01010600 +Read register 'r2' (4 bytes) from hardware: 0x00010600 +Read register 'r3' (4 bytes) from hardware: 0x00100140 +Read register 'r4' (4 bytes) from hardware: 0x80000000 +Read register 'r5' (4 bytes) from hardware: 0x80000000 +Read register 'r6' (4 bytes) from hardware: 0x00000000 +Read register 'r7' (4 bytes) from hardware: 0x01060000 +Read register 'r8' (4 bytes) from hardware: 0x00000000 +Read register 'r9' (4 bytes) from hardware: 0x40000000 +Read register 'r10' (4 bytes) from hardware: 0x00000000 +Read register 'r11' (4 bytes) from hardware: 0x00000000 +Read register 'r12' (4 bytes) from hardware: 0x00000000 +Read register 'sp' (4 bytes) from hardware: 0x00DA0020 +Read register 'lr' (4 bytes) from hardware: 0x19FE0400 +Read register 'pc' (4 bytes) from hardware: 0xA0FE0400 +Read register 'xpsr' (4 bytes) from hardware: 0x00000021 +Read 4 bytes @ address 0x0004FEA0 (Data = 0xBD38B954) +Read 2 bytes @ address 0x0004FEA0 (Data = 0xB954) +0x0004fea0 in ?? () +Received monitor command: reset +Resetting target +Resetting target +Downloading 16000 bytes @ address 0x0000C000 +Downloading 15968 bytes @ address 0x0000FE80 +Downloading 16000 bytes @ address 0x00013CE0 +Downloading 16096 bytes @ address 0x00017B60 +Downloading 16048 bytes @ address 0x0001BA40 +Downloading 15824 bytes @ address 0x0001F8F0 +Downloading 16160 bytes @ address 0x000236C0 +Downloading 16064 bytes @ address 0x000275E0 +Downloading 16096 bytes @ address 0x0002B4A0 +Downloading 16048 bytes @ address 0x0002F380 +Downloading 16096 bytes @ address 0x00033230 +Downloading 16048 bytes @ address 0x00037110 +Downloading 16016 bytes @ address 0x0003AFC0 +Downloading 16016 bytes @ address 0x0003EE50 +Downloading 16064 bytes @ address 0x00042CE0 +Downloading 15936 bytes @ address 0x00046BA0 +Downloading 15952 bytes @ address 0x0004A9E0 +Downloading 16128 bytes @ address 0x0004E830 +Downloading 11416 bytes @ address 0x00052730 +Restoring binary file ..\..\bin\targets\bttester\app\@apache-mynewt-nimble\apps\bttester\bttester.img into memory (0xc000 to 0x553c8) +Reading register 'msp' = 0x20040000 +Reading register 'psp' = 0x00000000 +Reading register 'primask' = 0x00000000 +Reading register 'basepri' = 0x00000000 +Reading register 'faultmask' = 0x00000000 +Reading register 'control' = 0x00000000 +Reading register 'apsr' = 0x00000000 +Reading register 'epsr' = 0x01000000 +Reading register 'ipsr' = 0x00000000 +Reading register 'iapsr' = 0x00000000 +Reading register 'eapsr' = 0x01000000 +Reading register 'iepsr' = 0x01000000 +Reading register 'fpscr' = 0x00000000 +r0 0x7fff 32767 +r1 0x60101 393473 +r2 0x60100 393472 +r3 0x40011000 1073811456 +r4 0x80 128 +r5 0x80 128 +r6 0x0 0 +r7 0x601 1537 +r8 0x0 0 +r9 0x40 64 +r10 0x0 0 +r11 0x0 0 +r12 0x0 0 +sp 0x2000da00 0x2000da00 +lr 0x4fe19 327193 +pc 0x4fea0 0x4fea0 +xpsr 0x21000000 553648128 +msp 0x20040000 0x20040000 +psp 0x0 0x0 +primask 0x0 0 +basepri 0x0 0 +faultmask 0x0 0 +control 0x0 0 +apsr 0x0 0 +epsr 0x1000000 16777216 +ipsr 0x0 0 +iapsr 0x0 0 +eapsr 0x1000000 16777216 +iepsr 0x1000000 16777216 +fpscr 0x0 0 +Received monitor command: reset +Resetting target +Resetting target +GDB closed TCP/IP connection (Socket 888) +A debugging session is active. + + Inferior 1 [Remote target] will be killed. + +Quit anyway? (y or n) [answered Y; input not from terminal] +Restoring target state and closing J-Link connection... +Shutting down... diff --git a/apps/bttester/pkg.yml b/apps/bttester/pkg.yml index e763185fe5..b45faebfda 100644 --- a/apps/bttester/pkg.yml +++ b/apps/bttester/pkg.yml @@ -36,6 +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/bass" - "@apache-mynewt-nimble/nimble/host/store/config" - "@apache-mynewt-core/hw/drivers/uart" - "@apache-mynewt-core/hw/drivers/rtt" diff --git a/apps/bttester/src/btp/btp.h b/apps/bttester/src/btp/btp.h index 4403a16038..a4ae5225a2 100644 --- a/apps/bttester/src/btp/btp.h +++ b/apps/bttester/src/btp/btp.h @@ -48,6 +48,7 @@ #define BTP_SERVICE_ID_MESH 4 #define BTP_SERVICE_ID_GATTC 6 #define BTP_SERVICE_ID_BAP 14 +#define BTP_SERVICE_ID_BASS 14 #define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_BAP diff --git a/apps/bttester/src/btp/btp_bass.h b/apps/bttester/src/btp/btp_bass.h new file mode 100644 index 0000000000..8e840037e3 --- /dev/null +++ b/apps/bttester/src/btp/btp_bass.h @@ -0,0 +1,37 @@ +/* + * 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 H_BTP_BASS_ +#define H_BTP_BASS_ + +#include "nimble/ble.h" +#include + +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +/* BAS Service */ +/* commands */ +#define BTP_BASS_READ_SUPPORTED_COMMANDS 0x01 +struct btp_bass_read_supported_commands_rp { + uint8_t data[0]; +} __packed; + +#endif /* H_BTP_BASS_ */ \ No newline at end of file diff --git a/apps/bttester/src/btp/btp_gap.h b/apps/bttester/src/btp/btp_gap.h index 2a87b12930..7af0a42f92 100644 --- a/apps/bttester/src/btp/btp_gap.h +++ b/apps/bttester/src/btp/btp_gap.h @@ -70,6 +70,7 @@ struct btp_gap_read_controller_index_list_rp { #define BTP_GAP_SETTINGS_PRIVACY 13 #define BTP_GAP_SETTINGS_CONTROLLER_CONFIG 14 #define BTP_GAP_SETTINGS_STATIC_ADDRESS 15 +#define BTP_GAP_SETTINGS_EXTENDED_ADVERTISING 17 #define BTP_GAP_SETTINGS_PERIODIC_ADVERTISING 18 #define BTP_GAP_READ_CONTROLLER_INFO 0x03 @@ -258,6 +259,15 @@ struct btp_gap_set_filter_accept_list_cmd { ble_addr_t addrs[]; } __packed; +#define GAP_SET_EXT_ADV 0x21 +struct btp_gap_set_ext_advertising_cmd { + uint8_t flags; +} __packed; + +struct btp_gap_set_ext_advertising_rp { + uint32_t current_settings; +} __packed; + #define GAP_PADV_CONFIGURE 0x22 struct gap_periodic_adv_configure_cmd { uint8_t flags; diff --git a/apps/bttester/src/btp/bttester.h b/apps/bttester/src/btp/bttester.h index 7cb82b5c92..873a0803a0 100644 --- a/apps/bttester/src/btp/bttester.h +++ b/apps/bttester/src/btp/bttester.h @@ -148,6 +148,9 @@ tester_init_bap(void); uint8_t tester_unregister_bap(void); #endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ - -#endif /* __BTTESTER_H__ */ +uint8_t +tester_init_bass(void); +uint8_t +tester_unregister_bass(void); +#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ diff --git a/apps/bttester/src/btp_bass.c b/apps/bttester/src/btp_bass.c new file mode 100644 index 0000000000..8947232634 --- /dev/null +++ b/apps/bttester/src/btp_bass.c @@ -0,0 +1,77 @@ +/* + * 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_bass.c - Bluetooth Broadcast Audio Stream Service Tester */ + +#include "syscfg/syscfg.h" +#include + +#if MYNEWT_VAL(BLE_AUDIO) + +#include "btp/btp_bass.h" + + +#include "btp/btp.h" +#include "console/console.h" + +#include "nimble/ble.h" +#include "host/ble_hs.h" +#include "host/util/util.h" +#include "math.h" + +#include "audio/ble_audio_broadcast_source.h" +#include "services/bass/ble_audio_svc_bass.h" +#include "audio/ble_audio.h" +#include "host/ble_iso.h" + +#include "bsp/bsp.h" + +static uint8_t +supported_commands(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_BASS_READ_SUPPORTED_COMMANDS, + .index = BTP_INDEX_NONE, + .expect_len = 0, + .func = supported_commands, + }, +}; + +uint8_t +tester_init_bass(void) +{ + tester_register_command_handlers(BTP_SERVICE_ID_BASS, handlers, + ARRAY_SIZE(handlers)); + + return BTP_STATUS_SUCCESS; +} + +uint8_t +tester_unregister_bass(void) +{ + return BTP_STATUS_SUCCESS; +} + +#endif /* MYNEWT_VAL(BLE_AUDIO) */ + diff --git a/apps/bttester/src/btp_core.c b/apps/bttester/src/btp_core.c index a7b1878322..eeae816a9e 100644 --- a/apps/bttester/src/btp_core.c +++ b/apps/bttester/src/btp_core.c @@ -106,7 +106,7 @@ register_service(const void *cmd, uint16_t cmd_len, case BTP_SERVICE_ID_BAP: status = tester_init_bap(); break; -#endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ +#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ case BTP_SERVICE_ID_GATTC: status = tester_init_gatt_cl(); break; diff --git a/apps/bttester/src/btp_gap.c b/apps/bttester/src/btp_gap.c index d0aa7ce06e..71062f8946 100644 --- a/apps/bttester/src/btp_gap.c +++ b/apps/bttester/src/btp_gap.c @@ -160,6 +160,7 @@ supported_commands(const void *cmd, uint16_t cmd_len, /* octet 4 */ #if MYNEWT_VAL(BLE_PERIODIC_ADV) + tester_set_bit(rp->data, GAP_SET_EXT_ADV); tester_set_bit(rp->data, GAP_PADV_CONFIGURE); tester_set_bit(rp->data, GAP_PADV_START); tester_set_bit(rp->data, GAP_PADV_SET_DATA); @@ -2000,6 +2001,44 @@ set_filter_accept_list(const void *cmd, uint16_t cmd_len, return BTP_STATUS_SUCCESS; } +#if MYNEWT_VAL(BLE_EXT_ADV) +static uint8_t set_ext_advertising(const void *cmd, uint16_t cmd_len, + void *rsp, uint16_t *rsp_len) +{ + int rc; + //const struct btp_gap_set_ext_advertising_cmd *cp = cmd; + struct ble_gap_ext_adv_params ext_params = {0}; + struct btp_gap_set_ext_advertising_rp *rp = rsp; + + ext_params.connectable = 0; + ext_params.scannable = 0; + ext_params.legacy_pdu = 0; + ext_params.anonymous = 0; + ext_params.own_addr_type = own_addr_type; + ext_params.primary_phy = BLE_HCI_LE_PHY_1M; + ext_params.secondary_phy = BLE_HCI_LE_PHY_1M; + ext_params.sid = 1; + + rc = ble_gap_ext_adv_configure(1, &ext_params, NULL, gap_event_cb, NULL); + if (rc) { + SYS_LOG_ERR("Failed to configure extended advertiser; rc=%d", rc); + return BTP_STATUS_FAILED; + } + + rc = ble_gap_ext_adv_start(1,0,0); + if (rc) { + SYS_LOG_ERR("Failed to start extended advertiser; rc=%d", rc); + return BTP_STATUS_FAILED; + } + + current_settings |= BIT(BTP_GAP_SETTINGS_EXTENDED_ADVERTISING); + + rp->current_settings = htole32(current_settings); + *rsp_len = sizeof(*rp); + return BTP_STATUS_SUCCESS; +} +#endif + #if MYNEWT_VAL(BLE_PERIODIC_ADV) static uint8_t periodic_adv_configure(const void *cmd, uint16_t cmd_len, @@ -2330,6 +2369,13 @@ static const struct btp_handler handlers[] = { .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = set_filter_accept_list, }, +#if MYNEWT_VAL(BLE_EXT_ADV) + { + .opcode = GAP_SET_EXT_ADV, + .expect_len = sizeof(struct btp_gap_set_ext_advertising_cmd), + .func = set_ext_advertising, + }, +#endif /* BLE_EXT_ADV*/ #if MYNEWT_VAL(BLE_PERIODIC_ADV) { .opcode = GAP_PADV_CONFIGURE, diff --git a/apps/bttester/syscfg.yml b/apps/bttester/syscfg.yml index 80c377a7c1..6aba1d862f 100644 --- a/apps/bttester/syscfg.yml +++ b/apps/bttester/syscfg.yml @@ -94,6 +94,8 @@ syscfg.vals: BLE_ISO: 1 BLE_AUDIO: 1 BLE_ROLE_BROADCASTER: 1 + BLE_ISO_BROADCAST_SOURCE: 1 + BLE_ISO_BROADCAST_SINK: 1 BLE_ISO_MAX_BISES: 1 BLE_ISO_MAX_BIGS: 1 BLE_EXT_ADV: 1 @@ -101,7 +103,7 @@ syscfg.vals: BLE_EXT_ADV_MAX_SIZE: 40 BLE_PERIODIC_ADV: 1 BLE_ISO_BROADCAST_SOURCE: 1 - BLE_MULTI_ADV_INSTANCES: 1 + BLE_MULTI_ADV_INSTANCES: 3 OS_MAIN_STACK_SIZE: 512 SHELL_TASK: 0 diff --git a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c index 6a40c17a84..97f8afd937 100644 --- a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c +++ b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c @@ -861,7 +861,9 @@ ble_svc_audio_bass_init(void) ble_svc_audio_bass_chrs[0].uuid = bass_cp_uuid; ble_svc_audio_bass_chrs[0].access_cb = ble_svc_audio_bass_access; - ble_svc_audio_bass_chrs[0].flags = BLE_GATT_CHR_F_WRITE_NO_RSP | BLE_GATT_CHR_F_WRITE_ENC; + ble_svc_audio_bass_chrs[0].flags = BLE_GATT_CHR_F_WRITE_NO_RSP | + BLE_GATT_CHR_F_WRITE | + BLE_GATT_CHR_F_WRITE_ENC; for (i = 1; i <= MYNEWT_VAL(BLE_SVC_AUDIO_BASS_RECEIVE_STATE_MAX); i++) { ble_svc_audio_bass_chrs[i].uuid = bass_receive_state_uuid;