ags.h
Go to the documentation of this file.
1
57 #ifndef __AGS_H__
58 #define __AGS_H__
59
60 #include "gr55xx_sys.h"
61 #include "custom_config.h"
62 #include <stdint.h>
63 #include <stdbool.h>
64
69 #define AGS_SERVICE_UUID 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,\
70 0x00, 0x10, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00
72 #define AGS_HEADER_FIRST_RES 0x00
74 #define AGS_HEADER_ACK_RES_1 0x00
75 #define AGS_HEADER_ACK_PAYLOAD_LEN 0x02
76 #define AGS_HEADER_ACK_RES_2 0x01
78 #define AGS_TX_VAL_LEN_MAX 244
79 #define AGS_RX_VAL_LEN_MAX 244
89 #define AGS_PAIR_ADV_FLAG 0x01
90 #define AGS_RECONNECT_ADV_FLAG 0x00
93 #define AGS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
94 10 : CFG_MAX_CONNECTIONS)
101 #define AGS_CHAR_MANDATORY 0x003f
102 #define AGS_CHAR_FULL 0x003f
116 typedef enum
117 {
118 AGS_CONTROL_STREAM_ID,
119 AGS_ALEXA_STREAM_ID = 0x06,
120 AGS_OTA_STREAM_ID = 0x02,
121 } ags_header_stream_id_t;
122
127 typedef enum
128 {
129 AGS_TRANSACTION_TYPE_FIRST,
130 AGS_TRANSACTION_TYPE_CONT,
131 AGS_TRANSACTION_TYPE_LAST,
132 AGS_TRANSACTION_TYPE_CTRL,
133 } ags_header_trxn_type_t;
134
137 typedef enum
138 {
139 AGS_ACK_NACK,
141 AGS_ACK_ACK,
142 } ags_header_ack_flag_t;
143
146 typedef enum
147 {
148 AGS_LEN_EXT_NO_EXT,
149 AGS_LEN_EXT_EXT,
151 } ags_header_length_ext_t;
152
155 typedef enum
156 {
157 AGS_RES_CODE_SUCCESS,
158 AGS_RES_CODE_UNKNOWN,
159 AGS_RES_CODE_UNSUPPORTED = 0x03,
161 } ags_header_result_code_t;
162
164 typedef enum
165 {
166 AGS_EVT_INVALID,
167 AGS_EVT_ECHO_RX_DATA_SENT,
168 AGS_EVT_ECHO_TX_DATA_RECEIVED,
169 AGS_EVT_ECHO_RX_NOTI_ENABLE,
170 AGS_EVT_ECHO_RX_NOTI_DISABLE,
171 } ags_evt_type_t;
179 typedef struct
180 {
181 uint8_t trxn_id :4;
182 uint8_t stream_id :4;
183 uint8_t length_ext :1;
184 uint8_t ack_flag :1;
185 uint8_t trxn_type :2;
186 uint8_t sequ_num :4;
189 } ags_header_base_t;
190
192 typedef struct
193 {
194 ags_header_base_t header_base;
195 uint8_t reserved;
196 uint8_t total_trxn_length[2];
197 uint8_t payload_length;
198 } ags_header_first_t;
199
201 typedef struct
202 {
203 ags_header_base_t header_base;
204 uint8_t reserved;
205 uint8_t total_trxn_length[2];
206 uint8_t payload_length[2];
207 } ags_header_first_ext_t;
208
210 typedef struct
211 {
212 ags_header_base_t header_base;
213 uint8_t payload_length;
214 } ags_header_subs_t;
215
217 typedef struct
218 {
219 ags_header_base_t header_base;
220 uint8_t payload_length[2];
221 } ags_header_subs_ext_t;
222
224 typedef struct
225 {
226 ags_header_base_t header_base;
227 uint8_t reserved_1;
228 uint8_t payload_length;
229 uint8_t reserved_2;
230 uint8_t result_code;
231 } ags_ack_packet_t;
232
234 typedef struct
235 {
236 ags_header_stream_id_t stream_id;
237 uint8_t is_active;
238 uint8_t ack_flag;
239 uint8_t trxn_id;
240 uint16_t total_length;
241 uint16_t received_length;
242 } ags_stream_env_t;
243
245 typedef struct
246 {
247 ags_evt_type_t evt_type;
248 uint8_t conn_idx;
249 const uint8_t *p_data;
250 uint16_t length;
251 } ags_evt_t;
259 typedef void (*ags_evt_handler_t)(ags_evt_t *p_evt);
260
262 typedef bool (*ags_stream_cb_t)(uint8_t conn_idx, const uint8_t *const p_data, uint16_t length, uint8_t still_receiving);
270 typedef struct
271 {
272 ags_evt_handler_t evt_handler;
273 ags_stream_cb_t ags_control_stream_cb;
274 ags_stream_cb_t ags_alexa_stream_cb;
275 uint16_t char_mask;
276 } ags_init_t;
292 sdk_err_t ags_service_init(ags_init_t *p_ags_init);
293
306 sdk_err_t ags_stream_send(uint8_t conn_idx, uint8_t stream_id, void *p_data, uint16_t length);
307
319 sdk_err_t ags_non_stream_send(uint8_t conn_idx, void *p_data, uint16_t length);
322 #endif
323
ags_evt_t::evt_type
ags_evt_type_t evt_type
Definition: ags.h:247
ags_header_base_t::stream_id
uint8_t stream_id
Definition: ags.h:182
ags_stream_cb_t
bool(* ags_stream_cb_t)(uint8_t conn_idx, const uint8_t *const p_data, uint16_t length, uint8_t still_receiving)
Alexa Gadget Service stream callback.
Definition: ags.h:262
ags_init_t::evt_handler
ags_evt_handler_t evt_handler
Definition: ags.h:272
ags_header_first_ext_t
Alexa Gadget Service extended version of header in first packet.
Definition: ags.h:202
AGS_RES_CODE_UNKNOWN
@ AGS_RES_CODE_UNKNOWN
Definition: ags.h:158
ags_header_first_t
Alexa Gadget Service header in first packet.
Definition: ags.h:193
ags_evt_t::conn_idx
uint8_t conn_idx
Definition: ags.h:248
AGS_TRANSACTION_TYPE_FIRST
@ AGS_TRANSACTION_TYPE_FIRST
Definition: ags.h:129
ags_header_subs_ext_t
Alexa Gadget Service extended version of header in subsequent packets.
Definition: ags.h:218
AGS_EVT_ECHO_RX_NOTI_DISABLE
@ AGS_EVT_ECHO_RX_NOTI_DISABLE
Definition: ags.h:170
ags_header_base_t::sequ_num
uint8_t sequ_num
Definition: ags.h:186
AGS_ACK_ACK
@ AGS_ACK_ACK
Definition: ags.h:141
ags_init_t::ags_alexa_stream_cb
ags_stream_cb_t ags_alexa_stream_cb
Definition: ags.h:274
ags_evt_type_t
ags_evt_type_t
Alexa Gadget Service event type.
Definition: ags.h:165
gr55xx_sys.h
GR55XX System API.
ags_header_length_ext_t
ags_header_length_ext_t
Alexa Gadget Service Length extender.
Definition: ags.h:147
AGS_CONTROL_STREAM_ID
@ AGS_CONTROL_STREAM_ID
Definition: ags.h:118
AGS_RES_CODE_SUCCESS
@ AGS_RES_CODE_SUCCESS
Definition: ags.h:157
ags_ack_packet_t::header_base
ags_header_base_t header_base
Definition: ags.h:226
ags_header_trxn_type_t
ags_header_trxn_type_t
Alexa Gadget Service transaction type. It indicate where the packet is within the transaction....
Definition: ags.h:128
ags_stream_env_t::is_active
uint8_t is_active
Definition: ags.h:237
AGS_TRANSACTION_TYPE_LAST
@ AGS_TRANSACTION_TYPE_LAST
Definition: ags.h:131
ags_header_ack_flag_t
ags_header_ack_flag_t
Alexa Gadget Service ACK Flag.
Definition: ags.h:138
ags_evt_t::p_data
const uint8_t * p_data
Definition: ags.h:249
AGS_LEN_EXT_EXT
@ AGS_LEN_EXT_EXT
Definition: ags.h:149
ags_ack_packet_t::reserved_2
uint8_t reserved_2
Definition: ags.h:229
ags_init_t::ags_control_stream_cb
ags_stream_cb_t ags_control_stream_cb
Definition: ags.h:273
AGS_EVT_ECHO_RX_DATA_SENT
@ AGS_EVT_ECHO_RX_DATA_SENT
Definition: ags.h:167
ags_header_first_ext_t::reserved
uint8_t reserved
Definition: ags.h:204
ags_header_subs_t::header_base
ags_header_base_t header_base
Definition: ags.h:212
ags_header_base_t::length_ext
uint8_t length_ext
Definition: ags.h:183
ags_stream_env_t::total_length
uint16_t total_length
Definition: ags.h:240
ags_evt_handler_t
void(* ags_evt_handler_t)(ags_evt_t *p_evt)
Alexa Gadget Service event handler type.
Definition: ags.h:259
ags_stream_env_t::stream_id
ags_header_stream_id_t stream_id
Definition: ags.h:236
ags_evt_t
Alexa Gadget Service event.
Definition: ags.h:246
ags_ack_packet_t::payload_length
uint8_t payload_length
Definition: ags.h:228
ags_header_first_ext_t::header_base
ags_header_base_t header_base
Definition: ags.h:203
AGS_TRANSACTION_TYPE_CTRL
@ AGS_TRANSACTION_TYPE_CTRL
Definition: ags.h:132
AGS_EVT_ECHO_RX_NOTI_ENABLE
@ AGS_EVT_ECHO_RX_NOTI_ENABLE
Definition: ags.h:169
ags_non_stream_send
sdk_err_t ags_non_stream_send(uint8_t conn_idx, void *p_data, uint16_t length)
Send data to the Echo device in non-stream format.
ags_header_base_t
Alexa Gadget Service base part of data packet header.
Definition: ags.h:180
AGS_OTA_STREAM_ID
@ AGS_OTA_STREAM_ID
Definition: ags.h:120
ags_evt_t::length
uint16_t length
Definition: ags.h:250
AGS_TRANSACTION_TYPE_CONT
@ AGS_TRANSACTION_TYPE_CONT
Definition: ags.h:130
ags_header_subs_ext_t::header_base
ags_header_base_t header_base
Definition: ags.h:219
ags_ack_packet_t::reserved_1
uint8_t reserved_1
Definition: ags.h:227
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
ags_ack_packet_t
Alexa Gadget Service ACK packet.
Definition: ags.h:225
AGS_EVT_INVALID
@ AGS_EVT_INVALID
Definition: ags.h:166
ags_stream_env_t::ack_flag
uint8_t ack_flag
Definition: ags.h:238
ags_header_base_t::ack_flag
uint8_t ack_flag
Definition: ags.h:184
ags_service_init
sdk_err_t ags_service_init(ags_init_t *p_ags_init)
Initialize a Alexa Gadget Service instance and add in the DB.
ags_header_stream_id_t
ags_header_stream_id_t
Alexa Gadget Service Stream ID. At any time, there is only one control stream, one Alexa stream,...
Definition: ags.h:117
ags_stream_send
sdk_err_t ags_stream_send(uint8_t conn_idx, uint8_t stream_id, void *p_data, uint16_t length)
Send data to the Echo device in stream format.
AGS_ALEXA_STREAM_ID
@ AGS_ALEXA_STREAM_ID
Definition: ags.h:119
AGS_EVT_ECHO_TX_DATA_RECEIVED
@ AGS_EVT_ECHO_TX_DATA_RECEIVED
Definition: ags.h:168
ags_header_first_t::reserved
uint8_t reserved
Definition: ags.h:195
AGS_ACK_NACK
@ AGS_ACK_NACK
Definition: ags.h:139
AGS_LEN_EXT_NO_EXT
@ AGS_LEN_EXT_NO_EXT
Definition: ags.h:148
ags_stream_env_t::trxn_id
uint8_t trxn_id
Definition: ags.h:239
ags_stream_env_t::received_length
uint16_t received_length
Definition: ags.h:241
ags_init_t::char_mask
uint16_t char_mask
Definition: ags.h:275
ags_header_base_t::trxn_id
uint8_t trxn_id
Definition: ags.h:181
ags_init_t
Alexa Gadget Service init stucture. This contains all option and data needed for initialization of th...
Definition: ags.h:271
ags_header_subs_t
Alexa Gadget Service header in subsequent packets.
Definition: ags.h:211
ags_header_subs_t::payload_length
uint8_t payload_length
Definition: ags.h:213
ags_header_first_t::payload_length
uint8_t payload_length
Definition: ags.h:197
ags_header_base_t::trxn_type
uint8_t trxn_type
Definition: ags.h:185
AGS_RES_CODE_UNSUPPORTED
@ AGS_RES_CODE_UNSUPPORTED
Definition: ags.h:159
ags_header_first_t::header_base
ags_header_base_t header_base
Definition: ags.h:194
ags_stream_env_t
Alexa Gadget Service gadget stream enviorenment variable.
Definition: ags.h:235
ags_header_result_code_t
ags_header_result_code_t
Alexa Gadget Service result code.
Definition: ags.h:156
ags_ack_packet_t::result_code
uint8_t result_code
Definition: ags.h:230