uds.h
Go to the documentation of this file.
1 
59 #ifndef __UDS_H__
60 #define __UDS_H__
61 
62 #include "gr55xx_sys.h"
63 #include "custom_config.h"
64 #include "ble_prf_utils.h"
65 #include <stdint.h>
66 #include <stdbool.h>
67 
72 #define UDS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
73  10 : CFG_MAX_CONNECTIONS)
75 #define UDS_AGE_VAL_LEN_MAX 2
76 #define UDS_DATE_OF_BIRTH_VAL_LEN_MAX 4
77 #define UDS_FIRST_NAME_VAL_LEN_MAX 50
78 #define UDS_HEIGHT_VAL_LEN_MAX 2
79 #define UDS_GENDER_VAL_LEN_MAX 2
80 #define UDS_DB_CHANGE_INCR_VAL_LEN_MAX 4
81 #define UDS_USER_INDEX_VAL_LEN_MAX 1
82 #define UDS_CTRL_PT_RSP_LEN_MIN 3
83 #define UDS_CTRL_PT_RSP_LEN_MAX 20
84 #define UDS_CTRL_PT_VAL_LEN_MAX 19
85 #define UDS_REGI_USER_DATA_LEN_MAX 19
86 #define UDS_REGI_USER_VAL_LEN_MAX 20
88 #define UDS_ERROR_UD_ACCESS_NOT_PERMIT 0x80
89 #define UDS_ERROR_PROC_IN_PROGRESS 0xFE
90 #define UDS_ERROR_CCCD_INVALID 0xFD
92 #define UDS_DB_CHANGE_INCR_DEFAULT_VAL 0x00
93 #define UDS_UNKNOWN_USER 0xFF
94 #define UDS_CONSENT_CODE_VAL_MAX 0x270F
95 #define UDS_CONSENT_TRY_NUM_MAX 0x04
97 #define UDS_MIDDLE_REGI_USER_SEGM 0x00
98 #define UDS_FIRST_REGI_USER_SEGM 0x01
99 #define UDS_LAST_REGI_USER_SEGM 0x02
100 #define UDS_ONLY_REGI_USER_SEGM 0x03
107 #define UDS_CHAR_MANDATORY 0x000001FF
108 #define UDS_CHAR_AGE_SUP 0x00000600
109 #define UDS_CHAR_DATE_OF_BIRTH_SUP 0x00001800
110 #define UDS_CHAR_FIRST_NAME_SUP 0x00006000
111 #define UDS_CHAR_HEIGHT_SUP 0x00018000
112 #define UDS_CHAR_GENDER_SUP 0x00060000
113 #define UDS_CHAR_REGIST_USER_SUP 0x00380000
114 #define UDS_CHAR_FULL 0x003FFFFF
123 typedef enum
124 {
133 
135 typedef enum
136 {
144 
146 typedef enum
147 {
167  UDS_EVT_DEL_USER_DATA,
168  UDS_EVT_DEL_USERS,
170 
173 {
180 };
181 
184 {
187 };
195 typedef struct
196 {
197  uint16_t year;
198  uint8_t month;
199  uint8_t day;
200 } birth_date_t;
201 
203 typedef struct
204 {
205  uint8_t weight_present :1;
206  uint8_t age_present :1;
207  uint8_t birth_date_present :1;
208  uint8_t first_name_present :1;
209  uint8_t height_present :1;
210  uint8_t gender_present :1;
212 
214 typedef struct
215 {
216  uint16_t weight;
217  uint16_t age;
219  uint16_t height;
220  uint8_t gender;
221  uint8_t *p_first_name;
222  uint16_t name_length;
224 
226 typedef struct
227 {
229  uint8_t user_name_truncated :1;
230  uint8_t reserved :6;
232 
234 typedef struct
235 {
236  uint8_t conn_idx;
238  const uint8_t *p_data;
239  uint16_t length;
240  uint16_t consent_code;
243 } uds_evt_t;
251 typedef void (*uds_evt_handler_t)(uds_evt_t *p_evt);
259 typedef struct
260 {
261  uint8_t *p_data;
262  uint16_t length;
263  uint16_t offset;
264  uint16_t *p_segm_length;
265  uint16_t segm_num;
266  uint16_t segm_offset;
268 
270 typedef struct
271 {
273  uint32_t char_mask;
274  uint8_t user_index;
278 } uds_init_t;
295 
306 
317 sdk_err_t uds_db_change_incr_val_send(uint8_t conn_idx, uint8_t user_idx);
318 
330 sdk_err_t uds_ctrl_pt_rsp_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
331 
341 uint8_t uds_get_cur_user_index(uint8_t conn_idx);
342 
351 void uds_set_cur_user_index(uint8_t conn_idx, uint8_t user_index);
352 
353 #if defined(PTS_AUTO_TEST)
354 void uds_regist_new_user(uint8_t conn_idx);
355 #endif
356 
359 #endif
360 
UDS_CHARS_WEIGHT_PRESENT
@ UDS_CHARS_WEIGHT_PRESENT
Definition: uds.h:174
UDS_EVT_CTRL_POINT_INDICATION_DISABLE
@ UDS_EVT_CTRL_POINT_INDICATION_DISABLE
Definition: uds.h:152
UDS_CTRL_PT_RSP_RESERVED
@ UDS_CTRL_PT_RSP_RESERVED
Definition: uds.h:137
uds_evt_t::length
uint16_t length
Definition: uds.h:239
UDS_EVT_REGIST_NEW_USER
@ UDS_EVT_REGIST_NEW_USER
Definition: uds.h:166
uds_chars_val_t::height
uint16_t height
Definition: uds.h:219
uds_evt_t::uds_chars_val
uds_chars_val_t uds_chars_val
Definition: uds.h:241
UDS_CTRL_PT_RSP_INVALID_PARAM
@ UDS_CTRL_PT_RSP_INVALID_PARAM
Definition: uds.h:140
UDS_EVT_GENDER_SET_BY_PEER
@ UDS_EVT_GENDER_SET_BY_PEER
Definition: uds.h:162
UDS_CTRL_PT_OP_REGIST_NEW_USER
@ UDS_CTRL_PT_OP_REGIST_NEW_USER
Definition: uds.h:126
uds_init_t::user_index
uint8_t user_index
Definition: uds.h:274
UDS_EVT_HEIGHT_SET_BY_PEER
@ UDS_EVT_HEIGHT_SET_BY_PEER
Definition: uds.h:161
UDS_CTRL_PT_OP_RSP_CODE
@ UDS_CTRL_PT_OP_RSP_CODE
Definition: uds.h:131
uds_init_t::char_mask
uint32_t char_mask
Definition: uds.h:273
uds_chars_flag_t::gender_present
uint8_t gender_present
Definition: uds.h:210
uds_chars_flag_t::weight_present
uint8_t weight_present
Definition: uds.h:205
UDS_CHARS_HEIGHT_PRESENT
@ UDS_CHARS_HEIGHT_PRESENT
Definition: uds.h:178
uds_regi_user_data_flag_t::regi_user_name_present
uint8_t regi_user_name_present
Definition: uds.h:228
uds_regi_user_data_flag_t::user_name_truncated
uint8_t user_name_truncated
Definition: uds.h:229
gr55xx_sys.h
GR55XX System API.
uds_chars_val_t::p_first_name
uint8_t * p_first_name
Definition: uds.h:221
UDS_EVT_DB_CHANGE_INCR_NOTIFICATION_DISABLE
@ UDS_EVT_DB_CHANGE_INCR_NOTIFICATION_DISABLE
Definition: uds.h:150
UDS_EVT_CTRL_POINT_INDICATION_ENABLE
@ UDS_EVT_CTRL_POINT_INDICATION_ENABLE
Definition: uds.h:151
uds_chars_val_t::gender
uint8_t gender
Definition: uds.h:220
uds_chars_flag_t
UDS Characteristics Flags structure.
Definition: uds.h:204
uds_init_t::db_change_incr_val
uint8_t db_change_incr_val
Definition: uds.h:275
uds_init_t::uds_regi_user_data_flag
uds_regi_user_data_flag_t uds_regi_user_data_flag
Definition: uds.h:276
uds_get_cur_user_index
uint8_t uds_get_cur_user_index(uint8_t conn_idx)
Get current user index.
UDS_CTRL_PT_RSP_SUCCESS
@ UDS_CTRL_PT_RSP_SUCCESS
Definition: uds.h:138
uds_regi_user_data_stream_t::length
uint16_t length
Definition: uds.h:262
uds_chars_flag_t::first_name_present
uint8_t first_name_present
Definition: uds.h:208
UDS_CTRL_PT_OP_LIST_ALL_USERS
@ UDS_CTRL_PT_OP_LIST_ALL_USERS
Definition: uds.h:129
uds_evt_t::conn_idx
uint8_t conn_idx
Definition: uds.h:236
UDS_CTRL_PT_OP_DEL_USERS
@ UDS_CTRL_PT_OP_DEL_USERS
Definition: uds.h:130
UDS_EVT_DB_CHANGE_INCR_SEND_CPLT
@ UDS_EVT_DB_CHANGE_INCR_SEND_CPLT
Definition: uds.h:155
UDS_EVT_DATE_OF_BIRTH_SET_BY_PEER
@ UDS_EVT_DATE_OF_BIRTH_SET_BY_PEER
Definition: uds.h:159
uds_regi_user_data_stream_t
UDS Registered User Data stream.
Definition: uds.h:260
uds_regi_user_data_stream_t::segm_offset
uint16_t segm_offset
Definition: uds.h:266
uds_ctrl_pt_rsp_send
sdk_err_t uds_ctrl_pt_rsp_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send User Control Point response if it's indication has been enabled.
uds_regi_user_data_stream_t::offset
uint16_t offset
Definition: uds.h:263
UDS_EVT_REGIST_USER_INDICATION_DISABLE
@ UDS_EVT_REGIST_USER_INDICATION_DISABLE
Definition: uds.h:154
uds_regi_user_data_flag_bits
uds_regi_user_data_flag_bits
Registered User Data Flags.
Definition: uds.h:184
uds_evt_handler_t
void(* uds_evt_handler_t)(uds_evt_t *p_evt)
User Data Service event handler type.
Definition: uds.h:251
uds_evt_t::p_data
const uint8_t * p_data
Definition: uds.h:238
UDS_CTRL_PT_OP_DEL_USER_DATA
@ UDS_CTRL_PT_OP_DEL_USER_DATA
Definition: uds.h:128
UDS_CHARS_FIRST_NAME_PRESENT
@ UDS_CHARS_FIRST_NAME_PRESENT
Definition: uds.h:177
UDS_CHARS_AGE_PRESENT
@ UDS_CHARS_AGE_PRESENT
Definition: uds.h:175
UDS_CTRL_PT_RSP_NOT_SUP
@ UDS_CTRL_PT_RSP_NOT_SUP
Definition: uds.h:139
uds_evt_type_t
uds_evt_type_t
User Data Service event type.
Definition: uds.h:147
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
UDS_CTRL_PT_RSP_FAILED
@ UDS_CTRL_PT_RSP_FAILED
Definition: uds.h:141
uds_regi_user_data_flag_t::reserved
uint8_t reserved
Definition: uds.h:230
uds_evt_t::db_change_incr_val
uint32_t db_change_incr_val
Definition: uds.h:242
UDS_CHARS_BIRTH_DATE_PRESENT
@ UDS_CHARS_BIRTH_DATE_PRESENT
Definition: uds.h:176
uds_db_change_incr_val_send
sdk_err_t uds_db_change_incr_val_send(uint8_t conn_idx, uint8_t user_idx)
Send Database Change Increment Characteristic value if UDS Characteristics value has been changed.
UDS_EVT_REGIST_USER_RSP_CPLT
@ UDS_EVT_REGIST_USER_RSP_CPLT
Definition: uds.h:157
uds_chars_val_t::name_length
uint16_t name_length
Definition: uds.h:222
birth_date_t::year
uint16_t year
Definition: uds.h:197
uds_chars_val_t::weight
uint16_t weight
Definition: uds.h:216
uds_evt_t::evt_type
uds_evt_type_t evt_type
Definition: uds.h:237
UDS_EVT_USER_GRANT_ACCESS
@ UDS_EVT_USER_GRANT_ACCESS
Definition: uds.h:165
uds_regi_user_data_stream_t::p_data
uint8_t * p_data
Definition: uds.h:261
uds_chars_flag_t::age_present
uint8_t age_present
Definition: uds.h:206
uds_init_t::uds_chars_flag
uds_chars_flag_t uds_chars_flag
Definition: uds.h:277
UDS_CHARS_GENDER_PRESENT
@ UDS_CHARS_GENDER_PRESENT
Definition: uds.h:179
UDS_EVT_AGE_SET_BY_PEER
@ UDS_EVT_AGE_SET_BY_PEER
Definition: uds.h:158
uds_regi_user_data_stream_t::segm_num
uint16_t segm_num
Definition: uds.h:265
uds_chars_val_t::date_of_birth
birth_date_t date_of_birth
Definition: uds.h:218
UDS_EVT_REGIST_USER_INDICATION_ENABLE
@ UDS_EVT_REGIST_USER_INDICATION_ENABLE
Definition: uds.h:153
uds_service_init
sdk_err_t uds_service_init(uds_init_t *p_uds_init)
Initialize a User Data Service instance and add in the DB.
UDS_CTRL_PT_OP_CONSENT
@ UDS_CTRL_PT_OP_CONSENT
Definition: uds.h:127
uds_chars_val_t::age
uint16_t age
Definition: uds.h:217
UDS_EVT_FIRST_NAME_SET_BY_PEER
@ UDS_EVT_FIRST_NAME_SET_BY_PEER
Definition: uds.h:160
uds_chars_flag_bits
uds_chars_flag_bits
UDS Characteristics Flags.
Definition: uds.h:173
UDS_EVT_CTRL_POINT_RSP_CPLT
@ UDS_EVT_CTRL_POINT_RSP_CPLT
Definition: uds.h:156
UDS_EVT_DB_CHANGE_INCR_SET_BY_PEER
@ UDS_EVT_DB_CHANGE_INCR_SET_BY_PEER
Definition: uds.h:163
UDS_EVT_CTRL_POINT_SET_BY_PEER
@ UDS_EVT_CTRL_POINT_SET_BY_PEER
Definition: uds.h:164
ble_prf_utils.h
Profile/Service Utilities API.
uds_evt_t
User Data Service event.
Definition: uds.h:235
UDS_CTRL_PT_OP_RESERVED
@ UDS_CTRL_PT_OP_RESERVED
Definition: uds.h:125
uds_regi_user_val_send
sdk_err_t uds_regi_user_val_send(uint8_t conn_idx)
Send Registered User Characteristic value.
uds_chars_flag_t::height_present
uint8_t height_present
Definition: uds.h:209
UDS_EVT_DB_CHANGE_INCR_NOTIFICATION_ENABLE
@ UDS_EVT_DB_CHANGE_INCR_NOTIFICATION_ENABLE
Definition: uds.h:149
UDS_CTRL_PT_RSP_USER_NOT_AUTH
@ UDS_CTRL_PT_RSP_USER_NOT_AUTH
Definition: uds.h:142
birth_date_t::day
uint8_t day
Definition: uds.h:199
birth_date_t::month
uint8_t month
Definition: uds.h:198
uds_evt_t::consent_code
uint16_t consent_code
Definition: uds.h:240
uds_ctrl_pt_op_code_t
uds_ctrl_pt_op_code_t
User Data Service Control Point Operation Code.
Definition: uds.h:124
uds_ctrl_pt_rsp_t
uds_ctrl_pt_rsp_t
User Data Service Control Point Response value.
Definition: uds.h:136
uds_init_t::evt_handler
uds_evt_handler_t evt_handler
Definition: uds.h:272
birth_date_t
UDS Characteristic - birthdate's structure.
Definition: uds.h:196
uds_regi_user_data_flag_t
Registered User Data Flags structure.
Definition: uds.h:227
UDS_REGI_USER_NAME_PRESENT
@ UDS_REGI_USER_NAME_PRESENT
Definition: uds.h:185
uds_regi_user_data_stream_t::p_segm_length
uint16_t * p_segm_length
Definition: uds.h:264
UDS_USER_NAME_TRUNCATED
@ UDS_USER_NAME_TRUNCATED
Definition: uds.h:186
uds_chars_flag_t::birth_date_present
uint8_t birth_date_present
Definition: uds.h:207
uds_chars_val_t
UDS Characteristics value structure.
Definition: uds.h:215
uds_set_cur_user_index
void uds_set_cur_user_index(uint8_t conn_idx, uint8_t user_index)
Set current user index.
uds_init_t
User Data Service init structure. This contains all option and data needed for initialization of the ...
Definition: uds.h:271
UDS_EVT_INVALID
@ UDS_EVT_INVALID
Definition: uds.h:148