hfp: extend HFP_SUBEVENT_VOICE_RECOGNITION_STATUS with status field, rename activated param to state

This commit is contained in:
Milanka Ringwald 2021-06-29 11:23:07 +02:00
parent 3c1b6907ea
commit 7253db3c8f
6 changed files with 79 additions and 14 deletions

View File

@ -537,10 +537,21 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
printf("Call answered by HF\n");
break;
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
if (hfp_subevent_voice_recognition_status_get_activated(event) > 0){
printf("Voice recognition status activated\n");
} else {
printf("Voice recognition status disabled\n");
status = hfp_subevent_voice_recognition_status_get_status(event);
if (status != ERROR_CODE_SUCCESS){
printf("Voice Recognition command failed with status 0x%02x\n", status);
break;
}
switch(hfp_subevent_voice_recognition_status_get_state(event)){
case 0:
printf("Voice recognition status deactivated\n");
break;
case 1:
printf("Voice recognition status activated\n");
break;
default:
btstack_assert(false);
break;
}
break;
default:

View File

@ -562,10 +562,21 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
printf(" - number : %s \n", hfp_subevent_enhanced_call_status_get_bnip_number(event));
break;
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
if (hfp_subevent_voice_recognition_status_get_activated(event) > 0){
printf("Voice recognition status activated\n");
} else {
printf("Voice recognition status disabled\n");
status = hfp_subevent_voice_recognition_status_get_status(event);
if (status != ERROR_CODE_SUCCESS){
printf("Voice Recognition command failed with status 0x%02x\n", status);
break;
}
switch(hfp_subevent_voice_recognition_status_get_state(event)){
case 0:
printf("Voice recognition status deactivated\n");
break;
case 1:
printf("Voice recognition status activated\n");
break;
default:
btstack_assert(false);
break;
}
break;
default:

View File

@ -1772,10 +1772,11 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_IN_BAND_RING_TONE 0x1D
/**
* @format 1H1
* @format 1H11
* @param subevent_code
* @param acl_handle
* @param activated
* @param status
* @param state
*/
#define HFP_SUBEVENT_VOICE_RECOGNITION_STATUS 0x1E

View File

@ -4727,14 +4727,23 @@ static inline hci_con_handle_t hfp_subevent_voice_recognition_status_get_acl_han
return little_endian_read_16(event, 3);
}
/**
* @brief Get field activated from event HFP_SUBEVENT_VOICE_RECOGNITION_STATUS
* @brief Get field status from event HFP_SUBEVENT_VOICE_RECOGNITION_STATUS
* @param event packet
* @return activated
* @return status
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_voice_recognition_status_get_activated(const uint8_t * event){
static inline uint8_t hfp_subevent_voice_recognition_status_get_status(const uint8_t * event){
return event[5];
}
/**
* @brief Get field state from event HFP_SUBEVENT_VOICE_RECOGNITION_STATUS
* @param event packet
* @return state
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_voice_recognition_status_get_state(const uint8_t * event){
return event[6];
}
/**
* @brief Get field acl_handle from event HFP_SUBEVENT_ENHANCED_VOICE_RECOGNITION_STATUS

View File

@ -623,6 +623,24 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
case HFP_SUBEVENT_MICROPHONE_VOLUME:
printf("Set microphone volume to %d\n", hfp_subevent_microphone_volume_get_gain(event));
break;
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
status = hfp_subevent_voice_recognition_status_get_status(event);
if (status != ERROR_CODE_SUCCESS){
printf("Voice Recognition command failed with status 0x%02x\n", status);
break;
}
switch(hfp_subevent_voice_recognition_status_get_state(event)){
case 0:
printf("Voice recognition status deactivated\n");
break;
case 1:
printf("Voice recognition status activated\n");
break;
default:
btstack_assert(false);
break;
}
break;
default:
break;
}

View File

@ -578,7 +578,22 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
break;
case HFP_SUBEVENT_VOICE_RECOGNITION_STATUS:
printf("Voice recognition status %d\n", hfp_subevent_voice_recognition_status_get_activated(event));
status = hfp_subevent_voice_recognition_status_get_status(event);
if (status != ERROR_CODE_SUCCESS){
printf("Voice Recognition command failed with status 0x%02x\n", status);
break;
}
switch(hfp_subevent_voice_recognition_status_get_state(event)){
case 0:
printf("Voice recognition status deactivated\n");
break;
case 1:
printf("Voice recognition status activated\n");
break;
default:
btstack_assert(false);
break;
}
break;
default:
break;