Lines Matching refs:obex_parser
75 static void obex_parser_init(obex_parser_t * obex_parser, obex_parser_callback_t obex_parser_callba… in obex_parser_init() argument
76 memset(obex_parser, 0, sizeof(obex_parser_t)); in obex_parser_init()
77 obex_parser->packet_size = 3; in obex_parser_init()
78 obex_parser->user_data = user_data; in obex_parser_init()
79 obex_parser->callback = obex_parser_callback; in obex_parser_init()
82 void obex_parser_init_for_request(obex_parser_t * obex_parser, obex_parser_callback_t obex_parser_c… in obex_parser_init_for_request() argument
83 obex_parser_init(obex_parser, obex_parser_callback, user_data); in obex_parser_init_for_request()
84 obex_parser->state = OBEX_PARSER_STATE_W4_OPCODE; in obex_parser_init_for_request()
87 void obex_parser_init_for_response(obex_parser_t * obex_parser, uint8_t opcode, obex_parser_callbac… in obex_parser_init_for_response() argument
88 obex_parser_init(obex_parser, obex_parser_callback, user_data); in obex_parser_init_for_response()
89 obex_parser->state = OBEX_PARSER_STATE_W4_RESPONSE_CODE; in obex_parser_init_for_response()
90 obex_parser->opcode = opcode; in obex_parser_init_for_response()
93 obex_parser_object_state_t obex_parser_process_data(obex_parser_t *obex_parser, const uint8_t *data… in obex_parser_process_data() argument
97 switch (obex_parser->state){ in obex_parser_process_data()
99 obex_parser->opcode = *data_buffer; in obex_parser_process_data()
100 obex_parser->state = OBEX_PARSER_STATE_W4_PACKET_LEN; in obex_parser_process_data()
101 obex_parser->item_len = obex_parser_param_size_for_request(obex_parser->opcode); in obex_parser_process_data()
102 obex_parser->packet_size = 1 + obex_parser->item_len; in obex_parser_process_data()
105 obex_parser->response_code = *data_buffer; in obex_parser_process_data()
106 obex_parser->state = OBEX_PARSER_STATE_W4_PACKET_LEN; in obex_parser_process_data()
107 obex_parser->item_len = obex_parser_param_size_for_response(obex_parser->opcode); in obex_parser_process_data()
108 obex_parser->packet_size = 1 + obex_parser->item_len; in obex_parser_process_data()
111 bytes_to_consume = btstack_min(2 - obex_parser->item_pos, data_len); in obex_parser_process_data()
112 memcpy(&obex_parser->params[obex_parser->item_pos], data_buffer, bytes_to_consume); in obex_parser_process_data()
113 obex_parser->item_pos += bytes_to_consume; in obex_parser_process_data()
114 if (obex_parser->item_pos == 2){ in obex_parser_process_data()
116 obex_parser->packet_size = big_endian_read_16(obex_parser->params, 0); in obex_parser_process_data()
117 if (obex_parser->packet_size < (obex_parser->item_len + 1)){ in obex_parser_process_data()
119 obex_parser->state = OBEX_PARSER_STATE_INVALID; in obex_parser_process_data()
123 if (obex_parser->item_len == 2){ in obex_parser_process_data()
124 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_ID; in obex_parser_process_data()
126 obex_parser->state = OBEX_PARSER_STATE_W4_PARAMS; in obex_parser_process_data()
131 … bytes_to_consume = btstack_min(obex_parser->item_len - obex_parser->item_pos, data_len); in obex_parser_process_data()
132 memcpy(&obex_parser->params[obex_parser->item_pos], data_buffer, bytes_to_consume); in obex_parser_process_data()
133 obex_parser->item_pos += bytes_to_consume; in obex_parser_process_data()
134 if (obex_parser->item_pos == obex_parser->item_len){ in obex_parser_process_data()
135 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_ID; in obex_parser_process_data()
139 …obex_parser->header_id = *data_buffer; // constants in obex.h encode type as well, so just use the… in obex_parser_process_data()
141 obex_parser->item_pos = 0; in obex_parser_process_data()
146 obex_parser->item_len = 2; in obex_parser_process_data()
147 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_LEN_FIRST; in obex_parser_process_data()
151 obex_parser->item_len = 1; in obex_parser_process_data()
152 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_VALUE; in obex_parser_process_data()
156 obex_parser->item_len = 4; in obex_parser_process_data()
157 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_VALUE; in obex_parser_process_data()
165 obex_parser->item_len = *data_buffer << 8; in obex_parser_process_data()
166 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_LEN_SECOND; in obex_parser_process_data()
169 obex_parser->item_len = obex_parser->item_len + *data_buffer; in obex_parser_process_data()
170 if (obex_parser->item_len < 3){ in obex_parser_process_data()
172 obex_parser->state = OBEX_PARSER_STATE_INVALID; in obex_parser_process_data()
175 if (obex_parser->item_len == 3){ in obex_parser_process_data()
177 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_ID; in obex_parser_process_data()
180 obex_parser->item_len -= 3; in obex_parser_process_data()
181 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_VALUE; in obex_parser_process_data()
184 … bytes_to_consume = btstack_min(obex_parser->item_len - obex_parser->item_pos, data_len); in obex_parser_process_data()
185 if (*obex_parser->callback != NULL){ in obex_parser_process_data()
186 …(*obex_parser->callback)(obex_parser->user_data, obex_parser->header_id, obex_parser->item_len, ob… in obex_parser_process_data()
188 obex_parser->item_pos += bytes_to_consume; in obex_parser_process_data()
189 if (obex_parser->item_pos == obex_parser->item_len){ in obex_parser_process_data()
190 obex_parser->state = OBEX_PARSER_STATE_W4_HEADER_ID; in obex_parser_process_data()
194 obex_parser->state = OBEX_PARSER_STATE_OVERRUN; in obex_parser_process_data()
205 obex_parser->packet_pos += bytes_to_consume; in obex_parser_process_data()
208 if (obex_parser->packet_pos == obex_parser->packet_size){ in obex_parser_process_data()
209 if (obex_parser->state == OBEX_PARSER_STATE_W4_HEADER_ID){ in obex_parser_process_data()
210 obex_parser->state = OBEX_PARSER_STATE_COMPLETE; in obex_parser_process_data()
212 obex_parser->state = OBEX_PARSER_STATE_INVALID; in obex_parser_process_data()
217 switch (obex_parser->state){ in obex_parser_process_data()
229 void obex_parser_get_operation_info(obex_parser_t * obex_parser, obex_parser_operation_info_t * obe… in obex_parser_get_operation_info() argument
231 obex_operation_info->opcode = obex_parser->opcode; in obex_parser_get_operation_info()
232 obex_operation_info->response_code = obex_parser->response_code; in obex_parser_get_operation_info()
233 switch (obex_parser->opcode){ in obex_parser_get_operation_info()
235 obex_operation_info->obex_version_number = obex_parser->params[2]; in obex_parser_get_operation_info()
236 obex_operation_info->flags = obex_parser->params[3]; in obex_parser_get_operation_info()
237 obex_operation_info->max_packet_length = big_endian_read_16(obex_parser->params, 4); in obex_parser_get_operation_info()
240 obex_operation_info->flags = obex_parser->params[2]; in obex_parser_get_operation_info()