Skip to content

Commit

Permalink
Bluetooth: GMAP: Add initial implementation of GMAP
Browse files Browse the repository at this point in the history
Add initial implementation of GMAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley committed May 10, 2023
1 parent e4d1e4d commit dcdbe23
Show file tree
Hide file tree
Showing 12 changed files with 2,103 additions and 13 deletions.
123 changes: 123 additions & 0 deletions include/zephyr/bluetooth/audio/gmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/** @file
* @brief Header for Bluetooth GMAP.
*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_

#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/util_macro.h>

/**
* @brief Bluetooth Gaming Profile (GMAP)
* @defgroup bt_gmap Bluetooth Gaming Profile
* @ingroup bluetooth
* @{
*/

/** Gaming Role bitfield */
enum bt_gmap_role {
/** Gaming Role Unicast Game Gateway */
BT_GMAP_ROLE_UGG = BIT(0),
/** Gaming Role Unicast Game Terminal */
BT_GMAP_ROLE_UGT = BIT(1),
/** Gaming Role Broadcast Game Sender */
BT_GMAP_ROLE_BGS = BIT(2),
/** Gaming Role Broadcast Game Receiver */
BT_GMAP_ROLE_BGR = BIT(3),
};

/* TBD: Should we declare a single enum for feature supported, and then transform from the spec
* defined values to Zephyr define values
*/

/** Unicast Game Gateway Feature bitfield */
enum bt_gmap_ugg_feat {
/** Multiframe support */
BT_GMAP_UGG_FEAT_MULTIFRAME = BIT(0),
/** 96 kbps support */
BT_GMAP_UGG_FEAT_96KBPS = BIT(1),
/** Multisink support */
BT_GMAP_UGG_FEAT_MULTISINK = BIT(2),
};

/** Unicast Game Terminal Feature bitfield */
enum bt_gmap_ugt_feat {
/** Source support */
BT_GMAP_UGT_FEAT_SOURCE = BIT(0),
/** 80 kbps source support */
BT_GMAP_UGT_FEAT_80KBPS_SOURCE = BIT(1),
/** Sink support */
BT_GMAP_UGT_FEAT_SINK = BIT(2),
/** 64 kbps sink support */
BT_GMAP_UGT_FEAT_64KBPS_SINK = BIT(3),
/** Multiframe support */
BT_GMAP_UGT_FEAT_MULTIFRAME = BIT(4),
/** Multisink support */
BT_GMAP_UGT_FEAT_MULTISINK = BIT(5),
/** Multisource support */
BT_GMAP_UGT_FEAT_MULTISOURCE = BIT(6),
};

/** Broadcast Game Sender Feature bitfield */
enum bt_gmap_bgs_feat {
/** 96 kbps support */
BT_GMAP_BGS_FEAT_96KBPS = BIT(0),
};

/** Broadcast Game Receiver Feature bitfield */
enum bt_gmap_bgr_feat {
/** Multisink support */
BT_GMAP_BGR_FEAT_MULTISINK = BIT(0),
/** Multiframe support */
BT_GMAP_BGR_FEAT_MULTIFRAME = BIT(1),
};

/** @brief Hearing Access Service Client callback structure. */
struct bt_gmap_cb {
/**
* @brief Callback function for bt_has_discover.
*
* This callback is called when discovery procedure is complete.
*
* @param conn Bluetooth connection object.
* @param err 0 on success, ATT error or negative errno otherwise.
* @param role Role of remote device. 0 on failure.
* @param ugg_feat Remote Unicast Game Gateway features. 0 if not supported or on error.
* @param ugt_feat Remote Unicast Game Terminal features. 0 if not supported or on error.
* @param bgs_feat Remote Broadcast Game Sender features. 0 if not supported or on error.
* @param bgr_feat Remote Broadcast Game Receiver features. 0 if not supported or on error.
*/
void (*discover)(struct bt_conn *conn, int err, enum bt_gmap_role role,
enum bt_gmap_ugg_feat ugg_feat, enum bt_gmap_ugt_feat ugt_feat,
enum bt_gmap_bgs_feat bgs_feat, enum bt_gmap_bgr_feat bgr_feat);
};

/** @brief Registers the callbacks used by the Gaming Profile.
*
* @param cb The callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_gmap_cb_register(const struct bt_gmap_cb *cb);

/**
* @brief Discover Gaming Service on a remote device.
*
* Procedure to find a Gaming Service on a server identified by @p conn.
* The @ref bt_gmap_cb.discover callback is called when the discovery procedure completes of fails.
* On discovery success the callback contains information about the remote device.
*
* @param conn Bluetooth connection object.
*
* @return 0 if success, errno on failure.
*/
int bt_gmap_discover(struct bt_conn *conn);

/** @} */ /* end of bt_gmap */

#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_ */
55 changes: 55 additions & 0 deletions include/zephyr/bluetooth/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -5090,6 +5090,61 @@ struct bt_uuid_128 {
*/
#define BT_UUID_GATT_SL \
BT_UUID_DECLARE_16(BT_UUID_GATT_SL_VAL)

/**
* @brief Gaming Service UUID value
*/
#define BT_UUID_GMAS_VAL 0x7FAC
/**
* @brief Common Audio Service
*/
#define BT_UUID_GMAS BT_UUID_DECLARE_16(BT_UUID_GMAS_VAL)

/**
* @brief Gaming Profile Role UUID value
*/
#define BT_UUID_GMAP_ROLE_VAL 0x7FAB
/**
* @brief Gaming Profile Role
*/
#define BT_UUID_GMAP_ROLE BT_UUID_DECLARE_16(BT_UUID_GMAP_ROLE_VAL)

/**
* @brief Gaming Profile Unicast Game Gateway Features UUID value
*/
#define BT_UUID_GMAP_UGG_FEAT_VAL 0x7FAA
/**
* @brief Gaming Profile Unicast Game Gateway Features
*/
#define BT_UUID_GMAP_UGG_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_UGG_FEAT_VAL)

/**
* @brief Gaming Profile Unicast Game Terminal Features UUID value
*/
#define BT_UUID_GMAP_UGT_FEAT_VAL 0x7FA9
/**
* @brief Gaming Profile Unicast Game Terminal Features
*/
#define BT_UUID_GMAP_UGT_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_UGT_FEAT_VAL)

/**
* @brief Gaming Profile Broadcast Game Sender Features UUID value
*/
#define BT_UUID_GMAP_BGS_FEAT_VAL 0x7FA8
/**
* @brief Gaming Profile Broadcast Game Sender Features
*/
#define BT_UUID_GMAP_BGS_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_BGS_FEAT_VAL)

/**
* @brief Gaming Profile Broadcast Game Receiver Features UUID value
*/
#define BT_UUID_GMAP_BGR_FEAT_VAL 0x7FA7
/**
* @brief Gaming Profile Broadcast Game Receiver Features
*/
#define BT_UUID_GMAP_BGR_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_BGR_FEAT_VAL)

/*
* Protocol UUIDs
*/
Expand Down
2 changes: 2 additions & 0 deletions subsys/bluetooth/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ zephyr_library_sources_ifdef(CONFIG_BT_HAS_CLIENT has_client.c)
zephyr_library_sources_ifdef(CONFIG_BT_CAP cap_stream.c)
zephyr_library_sources_ifdef(CONFIG_BT_CAP_ACCEPTOR cap_acceptor.c)
zephyr_library_sources_ifdef(CONFIG_BT_CAP_INITIATOR cap_initiator.c)
zephyr_library_sources_ifdef(CONFIG_BT_GMAS gmap_server.c)
zephyr_library_sources_ifdef(CONFIG_BT_GMAP gmap_client.c)
1 change: 1 addition & 0 deletions subsys/bluetooth/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rsource "Kconfig.has"
rsource "Kconfig.mpl"
rsource "Kconfig.mctl"
rsource "Kconfig.cap"
rsource "Kconfig.gmap"

module = BT_AUDIO
module-str = "Bluetooth Audio"
Expand Down
161 changes: 161 additions & 0 deletions subsys/bluetooth/audio/Kconfig.gmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Bluetooth Audio - Gaming Profile (CAP) options
#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

config BT_GMAP
def_bool BT_GMAP_UGG || BT_GMAP_UGT || BT_GMAP_BGS || BT_GMAP_BGR

config BT_GMAS
def_bool BT_GMAP_UGG || BT_GMAP_UGT || BT_GMAP_BGS_SERVICE || BT_GMAP_BGR

config BT_GMAP_UGG
bool "Gaming Profile Unicast Game Gateway Role Support [EXPERIMENTAL]"
depends on BT_CAP_INITIATOR && BT_BAP_UNICAST_CLIENT && BT_VCP_VOL_CTLR
# TODO: Add BT_CAP_COMMANDER dependency
select EXPERIMENTAL
help
Enabling this will enable the GMAP Unicast Game Gateway role.
This instantiates the Gaming Service (GMAS).

config BT_GMAP_UGG_MULTIFRAME_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multiframe Support [EXPERIMENTAL]"
depends on BT_GMAP_UGG
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGG multiframe feature
is supported.

config BT_GMAP_UGG_96KBPS_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role 96 kbps Support [EXPERIMENTAL]"
depends on BT_GMAP_UGG
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGG 96 kbps Source feature
is supported.

config BT_GMAP_UGG_MULTISINK_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multisink Support [EXPERIMENTAL]"
depends on BT_GMAP_UGG
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGG Multisink feature
is supported.

config BT_GMAP_UGT
bool "Gaming Profile Unicast Game Gateway Role Support [EXPERIMENTAL]"
depends on BT_CAP_ACCEPTOR && BT_BAP_UNICAST_SERVER
select EXPERIMENTAL
help
Enabling this will enable the GMAP Unicast Game Terminal role.
This instantiates the Gaming Service (GMAS).

config BT_GMAP_UGT_SOURCE_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Source Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT && BT_MICP_MIC_DEV
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT Source feature
is supported.

config BT_GMAP_UGT_80KBPS_SOURCE_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role 80 kbps Source Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT_SOURCE_SUPPORT
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT 80 KBPS Source feature
is supported.

config BT_GMAP_UGT_SINK_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Sink Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT && BT_VCP_VOL_REND
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT Sink feature
is supported.

config BT_GMAP_UGT_64KBPS_SINK_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role 64 kbps Sink Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT_SINK_SUPPORT
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT 64 kbps Sink feature
is supported.

config BT_GMAP_UGT_MULTIFRAME_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multiframe Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT Multiframe feature
is supported.

config BT_GMAP_UGT_MULTISINK_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multisink Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT_SINK_SUPPORT
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT Multisink feature
is supported.

config BT_GMAP_UGT_MULTISOURCE_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multisource Support [EXPERIMENTAL]"
depends on BT_GMAP_UGT_SOURCE_SUPPORT
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP UGT Multisource feature
is supported.

config BT_GMAP_BGS
bool "Gaming Profile Broadcast Game Sender Role Support [EXPERIMENTAL]"
depends on BT_CAP_INITIATOR && BT_BAP_BROADCAST_SOURCE
# TODO: Add BT_CAP_COMMANDER dependency
select EXPERIMENTAL
help
Enabling this will enable the GMAP Broadcast Game Sender role.

config BT_GMAP_BGS_SERVICE
bool "Gaming Profile Broadcast Game Sender Role Support [EXPERIMENTAL]"
depends on BT_GMAP_BGS
select EXPERIMENTAL
help
Enabling this will instantiate the Gaming Service (GMAS).

config BT_GMAP_BGS_96KBPS_SUPPORT
bool "Gaming Profile Broadcast Game Sender Role 96 kbps Support [EXPERIMENTAL]"
depends on BT_GMAP_BGS
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP BGS Multisource feature
is supported.

config BT_GMAP_BGR
bool "Gaming Profile Broadcast Game Receiver Role Support [EXPERIMENTAL]"
depends on BT_CAP_ACCEPTOR && BT_BAP_BROADCAST_SINK && BT_VCP_VOL_REND
select EXPERIMENTAL
help
Enabling this will enable the GMAP Broadcast Game Receiver Role role.
This instantiates the Gaming Service (GMAS).

config BT_GMAP_BGR_MULTISINK_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multisink Support [EXPERIMENTAL]"
depends on BT_GMAP_BGR
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP BGR Multisink feature
is supported.

config BT_GMAP_BGR_MULTIFRAME_SUPPORT
bool "Gaming Profile Unicast Game Gateway Role Multiframe Support [EXPERIMENTAL]"
depends on BT_GMAP_BGR
select EXPERIMENTAL
help
Enabling this will let remote devices know that the GMAP BGR Multiframe feature
is supported.

parent-module = BT
module = BT_GMAP
module-str = "Bluetooth Gaming Profile"
source "subsys/logging/Kconfig.template.log_config_inherit"

0 comments on commit dcdbe23

Please sign in to comment.