zephyr/subsys/bluetooth/audio/unicast_server.c
Emil Gydesen 18466530ab Bluetooth: PACS: Refactor PAC location read/write
Refactor the PAC location read and write. Instead
of storing the location in the service, the
location is now stored in the application, and
is retrieved by the service via callbacks.

Similarly, if a client writes the location, this
request is being sent to the application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-11 11:36:19 -08:00

59 lines
1.1 KiB
C

/* Bluetooth Audio Unicast Server */
/*
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/check.h>
#include <bluetooth/audio/audio.h>
#include "pacs_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_UNICAST_SERVER)
#define LOG_MODULE_NAME bt_unicast_server
#include "common/log.h"
const struct bt_audio_unicast_server_cb *unicast_server_cb;
int bt_audio_unicast_server_register_cb(const struct bt_audio_unicast_server_cb *cb)
{
CHECKIF(cb == NULL) {
BT_DBG("cb is NULL");
return -EINVAL;
}
if (unicast_server_cb != NULL) {
BT_DBG("callback structure already registered");
return -EALREADY;
}
unicast_server_cb = cb;
return 0;
}
int bt_audio_unicast_server_unregister_cb(const struct bt_audio_unicast_server_cb *cb)
{
CHECKIF(cb == NULL) {
BT_DBG("cb is NULL");
return -EINVAL;
}
if (unicast_server_cb != cb) {
BT_DBG("callback structure not registered");
return -EINVAL;
}
unicast_server_cb = NULL;
return 0;
}
int bt_audio_unicast_server_location_changed(enum bt_audio_pac_type type)
{
return bt_pacs_location_changed(type);
}