Skip to content

Commit

Permalink
WIP Broadcast test
Browse files Browse the repository at this point in the history
  • Loading branch information
sc committed Feb 19, 2024
1 parent 572e5fb commit 1cf37d2
Show file tree
Hide file tree
Showing 9 changed files with 5,047 additions and 8 deletions.
5 changes: 3 additions & 2 deletions apps/bttester/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ pkg.deps:
- "@apache-mynewt-core/sys/log/modlog"
- "@apache-mynewt-core/sys/stats"
- "@apache-mynewt-core/sys/shell"
- "@apache-mynewt-nimble/nimble/host"
- "@apache-mynewt-nimble/nimble/host/util"
- "@apache-mynewt-nimble/nimble/host/services/gap"
- "@apache-mynewt-nimble/nimble/host/services/gatt"
- "@apache-mynewt-nimble/nimble/host/services/gatt"
- "@apache-mynewt-nimble/nimble/host/services/dis"
- "@apache-mynewt-nimble/nimble/host/store/config"
- "@apache-mynewt-core/hw/drivers/uart"
- "@apache-mynewt-core/hw/drivers/rtt"
- "@apache-mynewt-core/sys/sysinit"
- "@apache-mynewt-core/sys/id"

4,415 changes: 4,415 additions & 0 deletions apps/bttester/src/audio_data.h

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions apps/bttester/src/btp/btp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include "btp_gattc.h"
#include "btp_l2cap.h"
#include "btp_mesh.h"
#include "btp_bap.h"

#define BTP_MTU MYNEWT_VAL(BTTESTER_BTP_DATA_SIZE_MAX)
#define BTP_MTU 2048
#define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))

#define BTP_INDEX_NONE 0xff
Expand All @@ -46,8 +47,9 @@
#define BTP_SERVICE_ID_L2CAP 3
#define BTP_SERVICE_ID_MESH 4
#define BTP_SERVICE_ID_GATTC 6
#define BTP_SERVICE_ID_BAP 14

#define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_GATTC
#define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_BAP

#define BTP_STATUS_SUCCESS 0x00
#define BTP_STATUS_FAILED 0x01
Expand Down
121 changes: 121 additions & 0 deletions apps/bttester/src/btp/btp_bap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* 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_BAP_
#define H_BTP_BAP_

#include "nimble/ble.h"
#include <stdint.h>

#ifndef __packed
#define __packed __attribute__((__packed__))
#endif

/* BAP Service */
/* commands */
#define BTP_BAP_READ_SUPPORTED_COMMANDS 0x01
struct btp_bap_read_supported_commands_rp {
uint8_t data[0];
} __packed;

#define BTP_BAP_DISCOVER 0x02
#define BTP_BAP_SEND 0x03
#define BTP_BAP_BROADCAST_SOURCE_SETUP 0x04
struct bap_broadcast_source_setup_cmd {
uint8_t streams_per_subgroup;
uint8_t subgroups;
uint8_t sdu_interval[3];
uint8_t framing;
uint16_t max_sdu;
uint8_t rtn;
uint16_t max_transport_lat;
uint8_t presentation_delay[3];
uint8_t coding_fmt;
uint16_t vid;
uint16_t cid;
uint8_t cc_ltvs_len;
uint8_t cc_ltvs[];
} __packed;

struct codec_config {
uint16_t freq;
uint16_t duration;
uint32_t octets_per_frame;
uint16_t frames_sdu;
} __packed;

struct bap_broadcast_source_setup_rp {
uint32_t gap_settings;
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_SOURCE_RELEASE 0x05
struct bap_bap_broadcast_source_release_cmd {
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_ADV_START 0x06
struct bap_bap_broadcast_adv_start_cmd {
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_ADV_STOP 0x07
struct bap_bap_broadcast_adv_stop_cmd {
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_SOURCE_START 0x08
struct bap_bap_broadcast_source_start_cmd {
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_SOURCE_STOP 0x09
struct bap_bap_broadcast_source_stop_cmd {
uint8_t broadcast_id[3];
} __packed;

#define BTP_BAP_BROADCAST_SINK_SETUP 0x0a
#define BTP_BAP_BROADCAST_SINK_RELEASE 0x0b
#define BTP_BAP_BROADCAST_SCAN_START 0x0c
#define BTP_BAP_BROADCAST_SCAN_STOP 0x0d
#define BTP_BAP_BROADCAST_SINK_SYNC 0x0e
#define BTP_BAP_BROADCAST_SINK_STOP 0x0f
#define BTP_BAP_BROADCAST_SINK_BIS_SYNC 0x10
#define BTP_BAP_DISCOVER_SCAN_DELEGATOR 0x11
#define BTP_BAP_BROADCAST_ASSISTANT_SCAN_START 0x12
#define BTP_BAP_BROADCAST_ASSISTANT_SCAN_STOP 0x13
#define BTP_BAP_ADD_BROADCAST_SRC 0x14
#define BTP_BAP_REMOVE_BROADCAST_SRC 0x15
#define BTP_BAP_MODIFY_BROADCAST_SRC 0x16
#define BTP_BAP_SET_BROADCAST_CODE 0x17
#define BTP_BAP_SEND_PAST 0x18

#define BTP_BAP_EV_DISCOVERY_COMPLETED 0x80
#define BTP_BAP_EV_CODEC_CAP_FOUND 0x81
#define BTP_BAP_EV_ASE_FOUND 0x82
#define BTP_BAP_EV_STREAM_RECEIVED 0x83
#define BTP_BAP_EV_BAA_FOUND 0x84
#define BTP_BAP_EV_BIS_FOUND 0x85
#define BTP_BAP_EV_BIS_SYNCED 0x86
#define BTP_BAP_EV_BIS_STREAM_RECEIVED 0x87
#define BTP_BAP_EV_SCAN_DELEGATOR_FOUND 0x88
#define BTP_BAP_EV_BROADCAST_RECEIVE_STATE 0x89
#define BTP_BAP_EV_PA_SYNC_REQ 0x8a

#endif /* H_BTP_BAP_ */
7 changes: 6 additions & 1 deletion apps/bttester/src/btp/bttester.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg);

int
gatt_svr_init(void);
#endif /* __BTTESTER_H__ */
#endif /* __BTTESTER_H__ */

uint8_t
tester_init_bap(void);
uint8_t
tester_unregister_bap(void);
Loading

0 comments on commit 1cf37d2

Please sign in to comment.