hfp.c (a4f85bd2c8ec26587caadb358d822f5a26269f11) hfp.c (553a4a561f786fff6050306fb8f8ca8e28d447d4)
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

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

348 event[0] = HCI_EVENT_HFP_META;
349 event[1] = sizeof(event) - 2;
350 event[2] = event_subtype;
351 little_endian_store_16(event, 3, acl_handle);
352 event[5] = value; // status 0 == OK
353 hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
354}
355
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

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

348 event[0] = HCI_EVENT_HFP_META;
349 event[1] = sizeof(event) - 2;
350 event[2] = event_subtype;
351 little_endian_store_16(event, 3, acl_handle);
352 event[5] = value; // status 0 == OK
353 hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
354}
355
356void hfp_emit_voice_recognition_state_event(hfp_connection_t * hfp_connection, uint8_t status){
357 hci_con_handle_t acl_handle = (hfp_connection != NULL) ? hfp_connection->acl_handle : HCI_CON_HANDLE_INVALID;
356void hfp_emit_voice_recognition_enabled(hfp_connection_t * hfp_connection, uint8_t status){
357 btstack_assert(hfp_connection != NULL);
358
358 uint8_t event[7];
359 event[0] = HCI_EVENT_HFP_META;
360 event[1] = sizeof(event) - 2;
359 uint8_t event[7];
360 event[0] = HCI_EVENT_HFP_META;
361 event[1] = sizeof(event) - 2;
361 event[2] = HFP_SUBEVENT_VOICE_RECOGNITION_STATUS;
362 event[2] = HFP_SUBEVENT_VOICE_RECOGNITION_ENABLED;
362
363
363 little_endian_store_16(event, 3, acl_handle);
364 little_endian_store_16(event, 3, hfp_connection->acl_handle);
364 event[5] = status; // 0:success
365 event[5] = status; // 0:success
366 event[6] = hfp_connection->enhanced_voice_recognition_enabled ? 1 : 0;
367 hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
368}
369
370void hfp_emit_voice_recognition_disabled(hfp_connection_t * hfp_connection, uint8_t status){
371 btstack_assert(hfp_connection != NULL);
372
373 uint8_t event[6];
374 event[0] = HCI_EVENT_HFP_META;
375 event[1] = sizeof(event) - 2;
376 event[2] = HFP_SUBEVENT_VOICE_RECOGNITION_DISABLED;
365
377
366 switch (hfp_connection->vra_state){
367 case HFP_VRA_VOICE_RECOGNITION_ACTIVATED:
368 event[6] = 1;
369 break;
370 case HFP_VRA_ENHANCED_VOICE_RECOGNITION_READY_FOR_AUDIO:
371 event[6] = 2;
372 break;
373 default:
374 event[6] = 0;
375 break;
376 }
378 little_endian_store_16(event, 3, hfp_connection->acl_handle);
379 event[5] = status; // 0:success
377 hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
378}
379
380void hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection_t * hfp_connection, uint8_t status){
381 hci_con_handle_t acl_handle = (hfp_connection != NULL) ? hfp_connection->acl_handle : HCI_CON_HANDLE_INVALID;
382
383 uint8_t event[6];
384 event[0] = HCI_EVENT_HFP_META;

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

533
534
535static void hfp_reset_voice_recognition(hfp_connection_t * hfp_connection){
536 btstack_assert(hfp_connection != NULL);
537 hfp_voice_recognition_activation_status_t current_vra_state = hfp_connection->vra_state;
538 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_OFF;
539
540 if (current_vra_state != HFP_VRA_VOICE_RECOGNITION_OFF){
380 hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
381}
382
383void hfp_emit_enhanced_voice_recognition_hf_ready_for_audio_event(hfp_connection_t * hfp_connection, uint8_t status){
384 hci_con_handle_t acl_handle = (hfp_connection != NULL) ? hfp_connection->acl_handle : HCI_CON_HANDLE_INVALID;
385
386 uint8_t event[6];
387 event[0] = HCI_EVENT_HFP_META;

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

536
537
538static void hfp_reset_voice_recognition(hfp_connection_t * hfp_connection){
539 btstack_assert(hfp_connection != NULL);
540 hfp_voice_recognition_activation_status_t current_vra_state = hfp_connection->vra_state;
541 hfp_connection->vra_state = HFP_VRA_VOICE_RECOGNITION_OFF;
542
543 if (current_vra_state != HFP_VRA_VOICE_RECOGNITION_OFF){
541 hfp_emit_voice_recognition_state_event(hfp_connection, HFP_VRA_VOICE_RECOGNITION_OFF);
544 hfp_emit_voice_recognition_disabled(hfp_connection, ERROR_CODE_SUCCESS);
542 } else if (hfp_connection->vra_state_requested != HFP_VRA_VOICE_RECOGNITION_OFF){
545 } else if (hfp_connection->vra_state_requested != HFP_VRA_VOICE_RECOGNITION_OFF){
543 hfp_emit_voice_recognition_state_event(hfp_connection, HFP_VRA_VOICE_RECOGNITION_OFF);
546 hfp_emit_voice_recognition_disabled(hfp_connection, ERROR_CODE_SUCCESS);
544 }
545
546 hfp_connection->vra_state_requested = HFP_VRA_VOICE_RECOGNITION_OFF;
547 hfp_connection->activate_voice_recognition = false;
548 hfp_connection->deactivate_voice_recognition = false;
549 hfp_connection->enhanced_voice_recognition_enabled = false;
550 hfp_connection->ag_vra_status = 0;
551 hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY;

--- 1477 unchanged lines hidden ---
547 }
548
549 hfp_connection->vra_state_requested = HFP_VRA_VOICE_RECOGNITION_OFF;
550 hfp_connection->activate_voice_recognition = false;
551 hfp_connection->deactivate_voice_recognition = false;
552 hfp_connection->enhanced_voice_recognition_enabled = false;
553 hfp_connection->ag_vra_status = 0;
554 hfp_connection->ag_vra_state = HFP_VOICE_RECOGNITION_STATE_AG_READY;

--- 1477 unchanged lines hidden ---