hfp_hf.c (125560b8499b9a6889af2b4e01403de5e5bc2c32) hfp_hf.c (598d4936f0733c027ac68bc9a6130a7a76a81190)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 139 unchanged lines hidden (view full) ---

148 little_endian_store_16(event, 3, hfp_connection->acl_handle);
149 event[5] = status;
150 event[6] = hfp_connection->bnip_type;
151 memcpy(&event[7], hfp_connection->bnip_number, bnip_number_len);
152 event[7 + bnip_number_len] = 0;
153 (*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, 8 + bnip_number_len);
154}
155
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 139 unchanged lines hidden (view full) ---

148 little_endian_store_16(event, 3, hfp_connection->acl_handle);
149 event[5] = status;
150 event[6] = hfp_connection->bnip_type;
151 memcpy(&event[7], hfp_connection->bnip_number, bnip_number_len);
152 event[7 + bnip_number_len] = 0;
153 (*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, 8 + bnip_number_len);
154}
155
156static void hfp_hf_emit_type_and_number(const hfp_connection_t * hfp_connection, uint8_t event_subtype){
156static void hfp_hf_emit_type_number_alpha(const hfp_connection_t * hfp_connection, uint8_t event_subtype){
157 if (hfp_hf_callback == NULL) return;
158 uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
157 if (hfp_hf_callback == NULL) return;
158 uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
159 uint8_t event[6 + sizeof(hfp_connection->bnip_number)];
160 event[0] = HCI_EVENT_HFP_META;
161 event[1] = 5 + bnip_number_len;
162 event[2] = event_subtype;
159 // 10 fixed - 1 (bnip_number_len <= sizeof(hfp_connection->bnip_number)-1) + 1 (trailing \0 for line buffer)
160 uint8_t event[10 + sizeof(hfp_connection->bnip_number) + sizeof(hfp_connection->line_buffer)];
161 uint8_t alpha_len = hfp_connection->clip_have_alpha ? strlen((const char *) hfp_connection->line_buffer) : 0;
162 uint8_t pos = 0;
163 event[pos++] = HCI_EVENT_HFP_META;
164 event[pos++] = 8 + bnip_number_len + alpha_len;
165 event[pos++] = event_subtype;
163 little_endian_store_16(event, 3, hfp_connection->acl_handle);
166 little_endian_store_16(event, 3, hfp_connection->acl_handle);
164 event[5] = hfp_connection->bnip_type;
165 memcpy(&event[6], hfp_connection->bnip_number, bnip_number_len);
166 event[6 + bnip_number_len] = 0;
167 (*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, 7 + bnip_number_len);
167 pos += 2;
168 event[pos++] = hfp_connection->bnip_type;
169 event[pos++] = bnip_number_len;
170 memcpy(&event[7], hfp_connection->bnip_number, bnip_number_len);
171 pos += bnip_number_len;
172 event[pos++] = 0;
173 event[pos++] = alpha_len;
174 memcpy(&event[pos], hfp_connection->line_buffer, alpha_len);
175 pos += alpha_len;
176 event[pos++] = 0;
177 (*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, pos);
168}
169
170static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connection){
171 if (hfp_hf_callback == NULL) return;
172 uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
173 uint8_t event[11 + sizeof(hfp_connection->bnip_number)];
174 event[0] = HCI_EVENT_HFP_META;
175 event[1] = 10 + bnip_number_len;

--- 1121 unchanged lines hidden (view full) ---

1297 hfp_emit_event(hfp_connection, HFP_SUBEVENT_MICROPHONE_VOLUME, value);
1298 break;
1299 case HFP_CMD_AG_SENT_PHONE_NUMBER:
1300 hfp_connection->command = HFP_CMD_NONE;
1301 hfp_emit_string_event(hfp_connection, HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG, hfp_connection->bnip_number);
1302 break;
1303 case HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE:
1304 hfp_connection->command = HFP_CMD_NONE;
178}
179
180static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connection){
181 if (hfp_hf_callback == NULL) return;
182 uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
183 uint8_t event[11 + sizeof(hfp_connection->bnip_number)];
184 event[0] = HCI_EVENT_HFP_META;
185 event[1] = 10 + bnip_number_len;

--- 1121 unchanged lines hidden (view full) ---

1307 hfp_emit_event(hfp_connection, HFP_SUBEVENT_MICROPHONE_VOLUME, value);
1308 break;
1309 case HFP_CMD_AG_SENT_PHONE_NUMBER:
1310 hfp_connection->command = HFP_CMD_NONE;
1311 hfp_emit_string_event(hfp_connection, HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG, hfp_connection->bnip_number);
1312 break;
1313 case HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE:
1314 hfp_connection->command = HFP_CMD_NONE;
1305 hfp_hf_emit_type_and_number(hfp_connection, HFP_SUBEVENT_CALL_WAITING_NOTIFICATION);
1315 hfp_hf_emit_type_number_alpha(hfp_connection, HFP_SUBEVENT_CALL_WAITING_NOTIFICATION);
1306 break;
1307 case HFP_CMD_AG_SENT_CLIP_INFORMATION:
1308 hfp_connection->command = HFP_CMD_NONE;
1316 break;
1317 case HFP_CMD_AG_SENT_CLIP_INFORMATION:
1318 hfp_connection->command = HFP_CMD_NONE;
1309 hfp_hf_emit_type_and_number(hfp_connection, HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION);
1319 hfp_hf_emit_type_number_alpha(hfp_connection, HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION);
1310 break;
1311 case HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR:
1312 hfp_connection->command = HFP_CMD_NONE;
1313 hfp_connection->ok_pending = 0;
1314 hfp_connection->extended_audio_gateway_error = 0;
1315 hfp_emit_event(hfp_connection, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, hfp_connection->extended_audio_gateway_error_value);
1316 break;
1317 case HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION:

--- 882 unchanged lines hidden ---
1320 break;
1321 case HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR:
1322 hfp_connection->command = HFP_CMD_NONE;
1323 hfp_connection->ok_pending = 0;
1324 hfp_connection->extended_audio_gateway_error = 0;
1325 hfp_emit_event(hfp_connection, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, hfp_connection->extended_audio_gateway_error_value);
1326 break;
1327 case HFP_CMD_AG_ACTIVATE_VOICE_RECOGNITION:

--- 882 unchanged lines hidden ---