ams_c.h
1
65 #ifndef __AMS_C_H__
66 #define __AMS_C_H__
67
68 #include "gr55xx_sys.h"
69 #include "ble_prf_types.h"
70 #include "custom_config.h"
71
76 #define AMS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
77 10 : CFG_MAX_CONNECTIONS)
78 #define AMS_C_ATTR_COUNT_MAX 256
79 #define AMS_C_TRUNCATED_FLAG (0x01<<0)
80 #define AMS_SRVC_UUID 0xdc, 0xf8, 0x55, 0xad, 0x02, 0xc5, 0xf4, 0x8e,\
81 0x3a, 0x43, 0x36, 0x0f, 0x2b, 0x50, 0xd3, 0x89
82 #define AMS_CMD_UUID 0xc2, 0x51, 0xca, 0xf7, 0x56, 0x0e, 0xdf, 0xb8,\
83 0x8a, 0x4a, 0xb1, 0x57, 0xd8, 0x81, 0x3c, 0x9b
84 #define AMS_ATTR_UPDATE_UUID 0x02, 0xC1, 0x96, 0xBA, 0x92, 0xBB, 0x0C, 0x9A,\
85 0x1F, 0x41, 0x8D, 0x80, 0xCE, 0xAB, 0x7C, 0x2F
86 #define AMS_ATTR_DISPLAY_UUID 0xd7, 0xd5, 0xbb, 0x70, 0xa8, 0xa3, 0xab, 0xa6,\
87 0xd8, 0x46, 0xab, 0x23, 0x8c, 0xf3, 0xb2, 0xc6
96 typedef enum
97 {
98 AMS_CMD_ID_PLAY,
99 AMS_CMD_ID_PAUSE,
100 AMS_CMD_ID_TOGGLE_PLAY_PAUSE,
101 AMS_CMD_ID_NEXT_TRACK,
102 AMS_CMD_ID_PREVIOUS_TRACK,
103 AMS_CMD_ID_VOLUME_UP,
104 AMS_CMD_ID_VOLUME_DOWN,
105 AMS_CMD_ID_ADVANCE_REPEAT_MODE,
106 AMS_CMD_ID_ADVANCE_SHUFFLE_MODE,
107 AMS_CMD_ID_SKIP_FORWARD,
108 AMS_CMD_ID_SKIP_BACKWARD,
109 AMS_CMD_ID_LIKE_TRACK,
110 AMS_CMD_ID_DISLIKE_TRACK,
111 AMS_CMD_ID_BOOK_MARK_TRACK,
112 } ams_c_cmd_id_t;
113
115 typedef enum
116 {
117 AMS_ETT_ID_PLAYER,
118 AMS_ETT_ID_QUEUE,
119 AMS_ETT_ID_TRACK,
120 } ams_c_ett_id_t;
121
123 enum
124 {
125 AMS_PLAYER_ATTR_ID_NAME,
126 AMS_PLAYER_ATTR_ID_PLAYBACK_INFO,
127 AMS_PLAYER_ATTR_ID_VOLUME,
128 };
129
131 enum
132 {
133 AMS_QUEUE_ATTR_ID_INDEX,
134 AMS_QUEUE_ATTR_ID_COUNT,
135 AMS_QUEUE_ATTR_ID_SHUFFLE_MODE,
136 AMS_QUEUE_ATTR_ID_REPEAT_MODE,
137 };
138
140 enum
141 {
142 AMS_TRACK_ATTR_ID_ARTIST,
143 AMS_TRACK_ATTR_ID_ALBUM,
144 AMS_TRACK_ATTR_ID_TITTLE,
145 AMS_TRACK_ATTR_ID_DURATION,
146 };
147
149 typedef enum
150 {
151 AMS_C_EVT_INVALID,
152 AMS_C_EVT_DISCOVERY_CPLT,
153 AMS_C_EVT_DISCOVERY_FAIL,
154 AMS_C_EVT_CMD_SEND_SUCCESS,
155 AMS_C_EVT_CMD_UPDATE_RECEIVE,
156 AMS_C_EVT_CMD_UPDATE_NTF_SET_SUCCESS,
157 AMS_C_EVT_ATTR_FOCUS_SET_SUCCESS,
158 AMS_C_EVT_ATTR_UPDATE_RECEIVE,
159 AMS_C_EVT_ATTR_UPDATE_NTF_SET_SUCCESS,
160 AMS_C_EVT_CPLT_ATTR_DISPLAY_SET_SUCCESS,
161 AMS_C_EVT_CPLT_ATTR_READ_RSP,
162 AMS_C_EVT_WRITE_OP_ERR,
163 } ams_c_evt_type_t;
172 typedef struct
173 {
174 ams_c_ett_id_t ett_id;
175 uint8_t attr_id[AMS_C_ATTR_COUNT_MAX];
176 uint16_t attr_count;
177 } ams_c_ett_attr_id_t;
178
180 typedef struct
181 {
182 ams_c_cmd_id_t *p_cmd;
183 uint16_t length;
184 } ams_c_cmd_list_t;
185
187 typedef struct
188 {
189 ams_c_ett_id_t ett_id;
190 uint8_t attr_id;
191 uint8_t flag;
192 uint8_t *p_data;
193 uint16_t length;
194 } ams_c_attr_info_t;
195
197 typedef struct
198 {
199 uint8_t *p_data;
200 uint16_t length;
201 } ams_c_cplt_attr_data_t;
202
204 typedef struct
205 {
206 uint16_t ams_srvc_start_handle;
207 uint16_t ams_srvc_end_handle;
208 uint16_t ams_cmd_handle;
209 uint16_t ams_cmd_cccd_handle;
210 uint16_t ams_attr_update_handle;
211 uint16_t ams_attr_update_cccd_handle;
212 uint16_t ams_attr_display_handle;
213 } ams_c_handles_t;
214
216 typedef struct
217 {
218 uint8_t conn_idx;
219 ams_c_evt_type_t evt_type;
220 union
221 {
222 ams_c_cmd_list_t cmd_list;
223 ams_c_attr_info_t attr_info;
224 ams_c_cplt_attr_data_t cplt_attr_data;
225 } param;
226 } ams_c_evt_t;
234 typedef void (*ams_c_evt_handler_t)(ams_c_evt_t *p_evt);
251 sdk_err_t ams_c_client_init(ams_c_evt_handler_t evt_handler);;
252
262 sdk_err_t ams_c_disc_srvc_start(uint8_t conn_idx);
263
274 sdk_err_t ams_c_cmd_notify_set(uint8_t conn_idx, bool is_enable);
275
286 sdk_err_t ams_c_attr_update_notify_set(uint8_t conn_idx, bool is_enable);
287
297 sdk_err_t ams_c_cplt_attr_read(uint8_t conn_idx);
298
309 sdk_err_t ams_c_cmd_send(uint8_t conn_idx, uint8_t cmd_id);
310
321 sdk_err_t ams_c_attr_focus_set(uint8_t conn_idx, const ams_c_ett_attr_id_t *p_ett_attr_id);
322
333 sdk_err_t ams_c_attr_display_set(uint8_t conn_idx, const ams_c_attr_info_t *p_attr_info);
334
344 bool ams_c_cmd_enable_check(ams_c_cmd_id_t cmd_id);
347 #endif
348
AMS_C_EVT_INVALID
@ AMS_C_EVT_INVALID
Definition: ams_c.h:151
ams_c_cmd_send
sdk_err_t ams_c_cmd_send(uint8_t conn_idx, uint8_t cmd_id)
Send command to peer device.
AMS_C_EVT_DISCOVERY_FAIL
@ AMS_C_EVT_DISCOVERY_FAIL
Definition: ams_c.h:153
ams_c_cmd_enable_check
bool ams_c_cmd_enable_check(ams_c_cmd_id_t cmd_id)
Check if the command is available.
ams_c_cmd_list_t
Structure that stores new command list.
Definition: ams_c.h:181
ams_c_evt_t::attr_info
ams_c_attr_info_t attr_info
Definition: ams_c.h:223
ams_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: ams_c.h:205
AMS_CMD_ID_BOOK_MARK_TRACK
@ AMS_CMD_ID_BOOK_MARK_TRACK
Definition: ams_c.h:111
ams_c_disc_srvc_start
sdk_err_t ams_c_disc_srvc_start(uint8_t conn_idx)
Discover Apple Media Service on peer.
ams_c_evt_type_t
ams_c_evt_type_t
Apple Media Service Client Event type.
Definition: ams_c.h:150
AMS_CMD_ID_VOLUME_UP
@ AMS_CMD_ID_VOLUME_UP
Definition: ams_c.h:103
ams_c_handles_t::ams_cmd_handle
uint16_t ams_cmd_handle
Definition: ams_c.h:208
AMS_CMD_ID_SKIP_FORWARD
@ AMS_CMD_ID_SKIP_FORWARD
Definition: ams_c.h:107
AMS_ETT_ID_QUEUE
@ AMS_ETT_ID_QUEUE
Definition: ams_c.h:118
ams_c_handles_t::ams_srvc_start_handle
uint16_t ams_srvc_start_handle
Definition: ams_c.h:206
ams_c_evt_t::cplt_attr_data
ams_c_cplt_attr_data_t cplt_attr_data
Definition: ams_c.h:224
AMS_CMD_ID_PAUSE
@ AMS_CMD_ID_PAUSE
Definition: ams_c.h:99
AMS_CMD_ID_SKIP_BACKWARD
@ AMS_CMD_ID_SKIP_BACKWARD
Definition: ams_c.h:108
AMS_TRACK_ATTR_ID_TITTLE
@ AMS_TRACK_ATTR_ID_TITTLE
Definition: ams_c.h:144
ams_c_handles_t::ams_attr_update_handle
uint16_t ams_attr_update_handle
Definition: ams_c.h:210
ams_c_ett_attr_id_t::attr_count
uint16_t attr_count
Definition: ams_c.h:176
AMS_QUEUE_ATTR_ID_INDEX
@ AMS_QUEUE_ATTR_ID_INDEX
Definition: ams_c.h:133
ams_c_ett_attr_id_t::ett_id
ams_c_ett_id_t ett_id
Definition: ams_c.h:174
ams_c_attr_info_t::attr_id
uint8_t attr_id
Definition: ams_c.h:190
AMS_TRACK_ATTR_ID_DURATION
@ AMS_TRACK_ATTR_ID_DURATION
Definition: ams_c.h:145
gr55xx_sys.h
GR55XX System API.
ams_c_attr_update_notify_set
sdk_err_t ams_c_attr_update_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer updated attribute notify.
AMS_QUEUE_ATTR_ID_SHUFFLE_MODE
@ AMS_QUEUE_ATTR_ID_SHUFFLE_MODE
Definition: ams_c.h:135
ams_c_attr_focus_set
sdk_err_t ams_c_attr_focus_set(uint8_t conn_idx, const ams_c_ett_attr_id_t *p_ett_attr_id)
Set concerned attribute.
ams_c_cmd_list_t::length
uint16_t length
Definition: ams_c.h:183
ams_c_cplt_attr_data_t
Complete attribution's value .
Definition: ams_c.h:198
ams_c_evt_t::conn_idx
uint8_t conn_idx
Definition: ams_c.h:218
AMS_C_EVT_ATTR_UPDATE_NTF_SET_SUCCESS
@ AMS_C_EVT_ATTR_UPDATE_NTF_SET_SUCCESS
Definition: ams_c.h:159
AMS_C_EVT_WRITE_OP_ERR
@ AMS_C_EVT_WRITE_OP_ERR
Definition: ams_c.h:162
ams_c_cmd_id_t
ams_c_cmd_id_t
Apple Media Service Command ID.
Definition: ams_c.h:97
AMS_C_EVT_CMD_UPDATE_RECEIVE
@ AMS_C_EVT_CMD_UPDATE_RECEIVE
Definition: ams_c.h:155
ams_c_attr_info_t::length
uint16_t length
Definition: ams_c.h:193
AMS_CMD_ID_NEXT_TRACK
@ AMS_CMD_ID_NEXT_TRACK
Definition: ams_c.h:101
ams_c_cplt_attr_read
sdk_err_t ams_c_cplt_attr_read(uint8_t conn_idx)
Read complete value of updated attrbute .
ams_c_handles_t::ams_attr_update_cccd_handle
uint16_t ams_attr_update_cccd_handle
Definition: ams_c.h:211
AMS_QUEUE_ATTR_ID_REPEAT_MODE
@ AMS_QUEUE_ATTR_ID_REPEAT_MODE
Definition: ams_c.h:136
ams_c_evt_t::evt_type
ams_c_evt_type_t evt_type
Definition: ams_c.h:219
AMS_ETT_ID_TRACK
@ AMS_ETT_ID_TRACK
Definition: ams_c.h:119
ble_prf_types.h
Profile/Service Common Types.
ams_c_handles_t::ams_srvc_end_handle
uint16_t ams_srvc_end_handle
Definition: ams_c.h:207
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
AMS_ETT_ID_PLAYER
@ AMS_ETT_ID_PLAYER
Definition: ams_c.h:117
AMS_PLAYER_ATTR_ID_PLAYBACK_INFO
@ AMS_PLAYER_ATTR_ID_PLAYBACK_INFO
Definition: ams_c.h:126
AMS_C_ATTR_COUNT_MAX
#define AMS_C_ATTR_COUNT_MAX
Definition: ams_c.h:78
ams_c_attr_info_t::flag
uint8_t flag
Definition: ams_c.h:191
AMS_C_EVT_CPLT_ATTR_DISPLAY_SET_SUCCESS
@ AMS_C_EVT_CPLT_ATTR_DISPLAY_SET_SUCCESS
Definition: ams_c.h:160
ams_c_attr_info_t
Structure that stores attribute information.
Definition: ams_c.h:188
AMS_CMD_ID_TOGGLE_PLAY_PAUSE
@ AMS_CMD_ID_TOGGLE_PLAY_PAUSE
Definition: ams_c.h:100
ams_c_evt_handler_t
void(* ams_c_evt_handler_t)(ams_c_evt_t *p_evt)
Apple Media Service Client event handler type.
Definition: ams_c.h:234
ams_c_attr_display_set
sdk_err_t ams_c_attr_display_set(uint8_t conn_idx, const ams_c_attr_info_t *p_attr_info)
Set the attribute that needs to be completely displayed.
ams_c_cplt_attr_data_t::p_data
uint8_t * p_data
Definition: ams_c.h:199
AMS_CMD_ID_PLAY
@ AMS_CMD_ID_PLAY
Definition: ams_c.h:98
AMS_CMD_ID_VOLUME_DOWN
@ AMS_CMD_ID_VOLUME_DOWN
Definition: ams_c.h:104
ams_c_cmd_notify_set
sdk_err_t ams_c_cmd_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer new command list notify.
AMS_CMD_ID_ADVANCE_REPEAT_MODE
@ AMS_CMD_ID_ADVANCE_REPEAT_MODE
Definition: ams_c.h:105
ams_c_cplt_attr_data_t::length
uint16_t length
Definition: ams_c.h:200
AMS_CMD_ID_ADVANCE_SHUFFLE_MODE
@ AMS_CMD_ID_ADVANCE_SHUFFLE_MODE
Definition: ams_c.h:106
ams_c_cmd_list_t::p_cmd
ams_c_cmd_id_t * p_cmd
Definition: ams_c.h:182
AMS_C_EVT_CMD_SEND_SUCCESS
@ AMS_C_EVT_CMD_SEND_SUCCESS
Definition: ams_c.h:154
ams_c_evt_t::cmd_list
ams_c_cmd_list_t cmd_list
Definition: ams_c.h:222
ams_c_evt_t
Apple Media Service Client event.
Definition: ams_c.h:217
ams_c_attr_info_t::p_data
uint8_t * p_data
Definition: ams_c.h:192
ams_c_client_init
sdk_err_t ams_c_client_init(ams_c_evt_handler_t evt_handler)
Register AMS Client event handler.
AMS_CMD_ID_LIKE_TRACK
@ AMS_CMD_ID_LIKE_TRACK
Definition: ams_c.h:109
AMS_C_EVT_CMD_UPDATE_NTF_SET_SUCCESS
@ AMS_C_EVT_CMD_UPDATE_NTF_SET_SUCCESS
Definition: ams_c.h:156
AMS_C_EVT_ATTR_FOCUS_SET_SUCCESS
@ AMS_C_EVT_ATTR_FOCUS_SET_SUCCESS
Definition: ams_c.h:157
ams_c_ett_attr_id_t
Structure that stores the attribute to be concerned or to display completely.
Definition: ams_c.h:173
AMS_C_EVT_DISCOVERY_CPLT
@ AMS_C_EVT_DISCOVERY_CPLT
Definition: ams_c.h:152
AMS_PLAYER_ATTR_ID_VOLUME
@ AMS_PLAYER_ATTR_ID_VOLUME
Definition: ams_c.h:127
ams_c_attr_info_t::ett_id
ams_c_ett_id_t ett_id
Definition: ams_c.h:189
AMS_C_EVT_CPLT_ATTR_READ_RSP
@ AMS_C_EVT_CPLT_ATTR_READ_RSP
Definition: ams_c.h:161
ams_c_handles_t::ams_cmd_cccd_handle
uint16_t ams_cmd_cccd_handle
Definition: ams_c.h:209
AMS_CMD_ID_DISLIKE_TRACK
@ AMS_CMD_ID_DISLIKE_TRACK
Definition: ams_c.h:110
AMS_CMD_ID_PREVIOUS_TRACK
@ AMS_CMD_ID_PREVIOUS_TRACK
Definition: ams_c.h:102
AMS_QUEUE_ATTR_ID_COUNT
@ AMS_QUEUE_ATTR_ID_COUNT
Definition: ams_c.h:134
AMS_TRACK_ATTR_ID_ALBUM
@ AMS_TRACK_ATTR_ID_ALBUM
Definition: ams_c.h:143
ams_c_ett_id_t
ams_c_ett_id_t
Apple Media Service entities index.
Definition: ams_c.h:116
AMS_TRACK_ATTR_ID_ARTIST
@ AMS_TRACK_ATTR_ID_ARTIST
Definition: ams_c.h:142
ams_c_handles_t::ams_attr_display_handle
uint16_t ams_attr_display_handle
Definition: ams_c.h:212
AMS_PLAYER_ATTR_ID_NAME
@ AMS_PLAYER_ATTR_ID_NAME
Definition: ams_c.h:125
AMS_C_EVT_ATTR_UPDATE_RECEIVE
@ AMS_C_EVT_ATTR_UPDATE_RECEIVE
Definition: ams_c.h:158