nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
ams_client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_AMS_CLIENT_H_
8#define BT_AMS_CLIENT_H_
9
18#include <zephyr/bluetooth/gatt.h>
19#include <zephyr/bluetooth/conn.h>
20#include <bluetooth/gatt_dm.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27#define BT_UUID_AMS_VAL \
28 BT_UUID_128_ENCODE(0x89d3502b, 0x0f36, 0x433a, 0x8ef4, 0xc502ad55f8dc)
29
31#define BT_UUID_AMS_REMOTE_COMMAND_VAL \
32 BT_UUID_128_ENCODE(0x9b3c81d8, 0x57b1, 0x4a8a, 0xb8df, 0x0e56f7ca51c2)
33
35#define BT_UUID_AMS_ENTITY_UPDATE_VAL \
36 BT_UUID_128_ENCODE(0x2f7cabce, 0x808d, 0x411f, 0x9a0c, 0xbb92ba96c102)
37
39#define BT_UUID_AMS_ENTITY_ATTRIBUTE_VAL \
40 BT_UUID_128_ENCODE(0xc6b2f38c, 0x23ab, 0x46d8, 0xa6ab, 0xa3a870bbd5d7)
41
42#define BT_UUID_AMS BT_UUID_DECLARE_128(BT_UUID_AMS_VAL)
43#define BT_UUID_AMS_REMOTE_COMMAND \
44 BT_UUID_DECLARE_128(BT_UUID_AMS_REMOTE_COMMAND_VAL)
45#define BT_UUID_AMS_ENTITY_UPDATE \
46 BT_UUID_DECLARE_128(BT_UUID_AMS_ENTITY_UPDATE_VAL)
47#define BT_UUID_AMS_ENTITY_ATTRIBUTE BT_UUID_DECLARE_128(BT_UUID_AMS_ENTITY_ATTRIBUTE_VAL)
48
50#define BT_AMS_EU_NOTIF_ENTITY_IDX 0
52#define BT_AMS_EU_NOTIF_ATTRIBUTE_IDX 1
54#define BT_AMS_EU_NOTIF_FLAGS_IDX 2
56#define BT_AMS_EU_NOTIF_VALUE_IDX 3
57
59#define BT_AMS_ENTITY_UPDATE_FLAG_TRUNCATED 0
60
62#define BT_AMS_EU_CMD_ENTITY_IDX 0
64#define BT_AMS_EU_CMD_ATTRIBUTE_IDX 1
66#define BT_AMS_EU_CMD_ATTRIBUTE_COUNT_MAX 4
67
69#define BT_AMS_EA_CMD_ENTITY_IDX 0
71#define BT_AMS_EA_CMD_ATTRIBUTE_IDX 1
73#define BT_AMS_EA_CMD_LEN 2
74
76#define BT_ATT_ERR_AMS_MS_INVALID_STATE 0xA0
78#define BT_ATT_ERR_AMS_MS_INVALID_COMMAND 0xA1
80#define BT_ATT_ERR_AMS_MS_ABSENT_ATTRIBUTE 0xA2
81
98};
99
106
113
121
128
135
143
148
150 union {
155};
156
161
163 union {
168
171};
172
177
179 uint8_t flags;
180
182 const uint8_t *data;
183
185 size_t len;
186};
187
188struct bt_ams_client;
189
197 struct bt_ams_client *ams_c,
198 const uint8_t *data,
199 size_t len);
200
209 struct bt_ams_client *ams_c,
210 const struct bt_ams_entity_update_notif *notif,
211 int err);
212
218typedef void (*bt_ams_write_cb)(struct bt_ams_client *ams_c,
219 uint8_t err);
220
228typedef void (*bt_ams_read_cb)(struct bt_ams_client *ams_c,
229 uint8_t err, const uint8_t *data, size_t len);
230
234 struct bt_conn *conn;
235
239 uint16_t handle;
240
242 uint16_t handle_ccc;
243
245 struct bt_gatt_subscribe_params notif_params;
246
249
251 struct bt_gatt_write_params write_params;
252
255
257 uint8_t data;
259
263 uint16_t handle;
264
266 uint16_t handle_ccc;
267
269 struct bt_gatt_subscribe_params notif_params;
270
273
275 struct bt_gatt_write_params write_params;
276
279
283
287 uint16_t handle;
288
290 struct bt_gatt_write_params write_params;
291
294
297
299 struct bt_gatt_read_params read_params;
300
304
306 atomic_t state;
307};
308
317
331int bt_ams_handles_assign(struct bt_gatt_dm *dm,
332 struct bt_ams_client *ams_c);
333
344
353
364
373
384 enum bt_ams_remote_command_id command,
385 bt_ams_write_cb func);
386
397 const struct bt_ams_entity_attribute_list *ent_attr_list,
398 bt_ams_write_cb func);
399
410 const struct bt_ams_entity_attribute *ent_attr,
411 bt_ams_write_cb func);
412
422 bt_ams_read_cb func);
423
424#ifdef __cplusplus
425}
426#endif
427
432#endif /* BT_AMS_CLIENT_H_ */
int bt_ams_write_entity_attribute(struct bt_ams_client *ams_c, const struct bt_ams_entity_attribute *ent_attr, bt_ams_write_cb func)
Write data to the Entity Attribute characteristic.
int bt_ams_unsubscribe_entity_update(struct bt_ams_client *ams_c)
Unsubscribe from the Entity Update notification.
#define BT_AMS_EU_CMD_ATTRIBUTE_COUNT_MAX
Entity Update command: Maximum value of Attribute ID count.
Definition: ams_client.h:66
bt_ams_player_attribute_id
Player Attribute ID values.
Definition: ams_client.h:108
@ BT_AMS_PLAYER_ATTRIBUTE_ID_PLAYBACK_INFO
Definition: ams_client.h:110
@ BT_AMS_PLAYER_ATTRIBUTE_ID_VOLUME
Definition: ams_client.h:111
@ BT_AMS_PLAYER_ATTRIBUTE_ID_NAME
Definition: ams_client.h:109
bt_ams_repeat_mode
Repeat Mode constants.
Definition: ams_client.h:130
@ BT_AMS_REPEAT_MODE_ONE
Definition: ams_client.h:132
@ BT_AMS_REPEAT_MODE_OFF
Definition: ams_client.h:131
@ BT_AMS_REPEAT_MODE_ALL
Definition: ams_client.h:133
int bt_ams_write_entity_update(struct bt_ams_client *ams_c, const struct bt_ams_entity_attribute_list *ent_attr_list, bt_ams_write_cb func)
Write data to the Entity Update characteristic.
int bt_ams_handles_assign(struct bt_gatt_dm *dm, struct bt_ams_client *ams_c)
Assign handles to the AMS Client instance.
bt_ams_entity_id
Entity ID values.
Definition: ams_client.h:101
@ BT_AMS_ENTITY_ID_PLAYER
Definition: ams_client.h:102
@ BT_AMS_ENTITY_ID_TRACK
Definition: ams_client.h:104
@ BT_AMS_ENTITY_ID_QUEUE
Definition: ams_client.h:103
bt_ams_queue_attribute_id
Queue Attribute ID values.
Definition: ams_client.h:115
@ BT_AMS_QUEUE_ATTRIBUTE_ID_REPEAT_MODE
Definition: ams_client.h:119
@ BT_AMS_QUEUE_ATTRIBUTE_ID_COUNT
Definition: ams_client.h:117
@ BT_AMS_QUEUE_ATTRIBUTE_ID_INDEX
Definition: ams_client.h:116
@ BT_AMS_QUEUE_ATTRIBUTE_ID_SHUFFLE_MODE
Definition: ams_client.h:118
bt_ams_remote_command_id
Remote Command ID values.
Definition: ams_client.h:83
@ BT_AMS_REMOTE_COMMAND_ID_VOLUME_DOWN
Definition: ams_client.h:90
@ BT_AMS_REMOTE_COMMAND_ID_TOGGLE_PLAY_PAUSE
Definition: ams_client.h:86
@ BT_AMS_REMOTE_COMMAND_ID_PLAY
Definition: ams_client.h:84
@ BT_AMS_REMOTE_COMMAND_ID_LIKE_TRACK
Definition: ams_client.h:95
@ BT_AMS_REMOTE_COMMAND_ID_DISLIKE_TRACK
Definition: ams_client.h:96
@ BT_AMS_REMOTE_COMMAND_ID_NEXT_TRACK
Definition: ams_client.h:87
@ BT_AMS_REMOTE_COMMAND_ID_BOOKMARK_TRACK
Definition: ams_client.h:97
@ BT_AMS_REMOTE_COMMAND_ID_SKIP_BACKWARD
Definition: ams_client.h:94
@ BT_AMS_REMOTE_COMMAND_ID_SKIP_FORWARD
Definition: ams_client.h:93
@ BT_AMS_REMOTE_COMMAND_ID_PAUSE
Definition: ams_client.h:85
@ BT_AMS_REMOTE_COMMAND_ID_VOLUME_UP
Definition: ams_client.h:89
@ BT_AMS_REMOTE_COMMAND_ID_ADVANCE_SHUFFLE_MODE
Definition: ams_client.h:92
@ BT_AMS_REMOTE_COMMAND_ID_PREVIOUS_TRACK
Definition: ams_client.h:88
@ BT_AMS_REMOTE_COMMAND_ID_ADVANCE_REPEAT_MODE
Definition: ams_client.h:91
int bt_ams_subscribe_remote_command(struct bt_ams_client *ams_c, bt_ams_remote_command_notify_cb func)
Subscribe to the Remote Command notification.
void(* bt_ams_read_cb)(struct bt_ams_client *ams_c, uint8_t err, const uint8_t *data, size_t len)
Read response callback function.
Definition: ams_client.h:228
void(* bt_ams_entity_update_notify_cb)(struct bt_ams_client *ams_c, const struct bt_ams_entity_update_notif *notif, int err)
Entity Update notification callback function.
Definition: ams_client.h:208
#define BT_AMS_EA_CMD_LEN
Entity Attribute command length.
Definition: ams_client.h:73
int bt_ams_unsubscribe_remote_command(struct bt_ams_client *ams_c)
Unsubscribe from the Remote Command notification.
int bt_ams_read_entity_attribute(struct bt_ams_client *ams_c, bt_ams_read_cb func)
Read data from the Entity Attribute characteristic.
bt_ams_shuffle_mode
Shuffle Mode constants.
Definition: ams_client.h:123
@ BT_AMS_SHUFFLE_MODE_ALL
Definition: ams_client.h:126
@ BT_AMS_SHUFFLE_MODE_ONE
Definition: ams_client.h:125
@ BT_AMS_SHUFFLE_MODE_OFF
Definition: ams_client.h:124
bt_ams_track_attribute_id
Track Attribute ID values.
Definition: ams_client.h:137
@ BT_AMS_TRACK_ATTRIBUTE_ID_DURATION
Definition: ams_client.h:141
@ BT_AMS_TRACK_ATTRIBUTE_ID_ALBUM
Definition: ams_client.h:139
@ BT_AMS_TRACK_ATTRIBUTE_ID_TITLE
Definition: ams_client.h:140
@ BT_AMS_TRACK_ATTRIBUTE_ID_ARTIST
Definition: ams_client.h:138
int bt_ams_client_init(struct bt_ams_client *ams_c)
Initialize the AMS Client instance.
void(* bt_ams_remote_command_notify_cb)(struct bt_ams_client *ams_c, const uint8_t *data, size_t len)
Remote Command notification callback function.
Definition: ams_client.h:196
int bt_ams_subscribe_entity_update(struct bt_ams_client *ams_c, bt_ams_entity_update_notify_cb func)
Subscribe to the Entity Update notification.
int bt_ams_write_remote_command(struct bt_ams_client *ams_c, enum bt_ams_remote_command_id command, bt_ams_write_cb func)
Write data to the Remote Command characteristic.
void(* bt_ams_write_cb)(struct bt_ams_client *ams_c, uint8_t err)
Write response callback function.
Definition: ams_client.h:218
uint8_t data[2]
Definition: ams_client.h:296
bt_ams_read_cb read_cb
Definition: ams_client.h:302
uint16_t handle
Definition: ams_client.h:287
struct bt_gatt_read_params read_params
Definition: ams_client.h:299
struct bt_gatt_write_params write_params
Definition: ams_client.h:290
bt_ams_write_cb write_cb
Definition: ams_client.h:293
bt_ams_write_cb write_cb
Definition: ams_client.h:278
struct bt_gatt_write_params write_params
Definition: ams_client.h:275
uint16_t handle_ccc
Definition: ams_client.h:266
uint16_t handle
Definition: ams_client.h:263
bt_ams_entity_update_notify_cb notify_cb
Definition: ams_client.h:272
uint8_t data[4+1]
Definition: ams_client.h:281
struct bt_gatt_subscribe_params notif_params
Definition: ams_client.h:269
struct bt_gatt_subscribe_params notif_params
Definition: ams_client.h:245
uint8_t data
Definition: ams_client.h:257
bt_ams_remote_command_notify_cb notify_cb
Definition: ams_client.h:248
bt_ams_write_cb write_cb
Definition: ams_client.h:254
uint16_t handle
Definition: ams_client.h:239
uint16_t handle_ccc
Definition: ams_client.h:242
struct bt_gatt_write_params write_params
Definition: ams_client.h:251
struct bt_ams_client::bt_ams_entity_update_characteristic entity_update
atomic_t state
Definition: ams_client.h:306
struct bt_conn * conn
Definition: ams_client.h:234
struct bt_ams_client::bt_ams_remote_command_characteristic remote_command
struct bt_ams_client::bt_ams_entity_attribute_characteristic entity_attribute
AMS client structure, which contains various status information for the client.
Definition: ams_client.h:232
enum bt_ams_queue_attribute_id * queue
Definition: ams_client.h:165
enum bt_ams_entity_id entity
Definition: ams_client.h:160
size_t attribute_count
Definition: ams_client.h:170
union bt_ams_entity_attribute_list::@167 attribute
enum bt_ams_player_attribute_id * player
Definition: ams_client.h:164
enum bt_ams_track_attribute_id * track
Definition: ams_client.h:166
Structure for Entity Attribute pair list.
Definition: ams_client.h:158
enum bt_ams_entity_id entity
Definition: ams_client.h:147
enum bt_ams_player_attribute_id player
Definition: ams_client.h:151
enum bt_ams_queue_attribute_id queue
Definition: ams_client.h:152
union bt_ams_entity_attribute::@166 attribute
enum bt_ams_track_attribute_id track
Definition: ams_client.h:153
Structure for Entity Attribute pair.
Definition: ams_client.h:145
size_t len
Definition: ams_client.h:185
const uint8_t * data
Definition: ams_client.h:182
struct bt_ams_entity_attribute ent_attr
Definition: ams_client.h:176
uint8_t flags
Definition: ams_client.h:179
Structure for Entity Update notification.
Definition: ams_client.h:174