hfp_hf_demo: use API calls to access event values, remove ag indicatior status on initial retrieval

This commit is contained in:
Milanka Ringwald 2018-12-14 11:11:16 +01:00
parent c741b03209
commit 22587df049
3 changed files with 37 additions and 13 deletions

View File

@ -515,22 +515,31 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * even
(const char*) hfp_subevent_ag_indicator_status_changed_get_indicator_name(event)); (const char*) hfp_subevent_ag_indicator_status_changed_get_indicator_name(event));
break; break;
case HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED: case HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED:
printf("NETWORK_OPERATOR_CHANGED, operator mode: %d, format: %d, name: %s\n", event[3], event[4], (char *) &event[5]); printf("NETWORK_OPERATOR_CHANGED, operator mode: %d, format: %d, name: %s\n",
hfp_subevent_network_operator_changed_get_network_operator_mode(event),
hfp_subevent_network_operator_changed_get_network_operator_format(event),
(char *) hfp_subevent_network_operator_changed_get_network_operator_name(event));
break; break;
case HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR: case HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR:
printf("EXTENDED_AUDIO_GATEWAY_ERROR_REPORT, status : %d\n", event[3]); printf("EXTENDED_AUDIO_GATEWAY_ERROR_REPORT, status : %d\n",
hfp_subevent_extended_audio_gateway_error_get_error(event));
break; break;
case HFP_SUBEVENT_RING: case HFP_SUBEVENT_RING:
printf("** Ring **\n"); printf("** Ring **\n");
break; break;
case HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG: case HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG:
printf("Phone number for voice tag: %s\n", (const char *) &event[3]); printf("Phone number for voice tag: %s\n",
(const char *) hfp_subevent_number_for_voice_tag_get_number(event));
break; break;
case HFP_SUBEVENT_SPEAKER_VOLUME: case HFP_SUBEVENT_SPEAKER_VOLUME:
printf("Speaker volume: %u\n", event[3]); printf("Speaker volume: status %u, gain %u\n",
hfp_subevent_speaker_volume_get_status(event),
hfp_subevent_speaker_volume_get_gain(event));
break; break;
case HFP_SUBEVENT_MICROPHONE_VOLUME: case HFP_SUBEVENT_MICROPHONE_VOLUME:
printf("Microphone volume: %u\n", event[3]); printf("Microphone volume: status %u, gain %u\n",
hfp_subevent_microphone_volume_get_status(event),
hfp_subevent_microphone_volume_get_gain(event));
break; break;
case HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION: case HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION:
printf("Caller ID, number %s\n", hfp_subevent_calling_line_identification_notification_get_number(event)); printf("Caller ID, number %s\n", hfp_subevent_calling_line_identification_notification_get_number(event));

View File

@ -1090,7 +1090,6 @@ static void hfp_hf_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, ui
} }
break; break;
case HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS: case HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS:
case HFP_CMD_RETRIEVE_AG_INDICATORS:
for (i = 0; i < hfp_connection->ag_indicators_nr; i++){ for (i = 0; i < hfp_connection->ag_indicators_nr; i++){
hfp_emit_ag_indicator_event(hfp_hf_callback, hfp_connection->ag_indicators[i]); hfp_emit_ag_indicator_event(hfp_hf_callback, hfp_connection->ag_indicators[i]);
} }

View File

@ -429,26 +429,42 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * event, uint
printf("HFP AG HFP_SUBEVENT_COMPLETE.\n"); printf("HFP AG HFP_SUBEVENT_COMPLETE.\n");
break; break;
case HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED: case HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED:
printf("AG_INDICATOR_STATUS_CHANGED, AG indicator '%s' (index: %d) to: %d\n", (const char*) &event[5], event[3], event[4]); printf("AG_INDICATOR_STATUS_CHANGED, AG indicator (index: %d) to: %d of range [%d, %d], name '%s'\n",
hfp_subevent_ag_indicator_status_changed_get_indicator_index(event),
hfp_subevent_ag_indicator_status_changed_get_indicator_status(event),
hfp_subevent_ag_indicator_status_changed_get_indicator_min_range(event),
hfp_subevent_ag_indicator_status_changed_get_indicator_max_range(event),
(const char*) hfp_subevent_ag_indicator_status_changed_get_indicator_name(event));
break; break;
case HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED: case HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED:
printf("NETWORK_OPERATOR_CHANGED, operator mode: %d, format: %d, name: %s\n", event[3], event[4], (char *) &event[5]); printf("NETWORK_OPERATOR_CHANGED, operator mode: %d, format: %d, name: %s\n",
hfp_subevent_network_operator_changed_get_network_operator_mode(event),
hfp_subevent_network_operator_changed_get_network_operator_format(event),
(char *) hfp_subevent_network_operator_changed_get_network_operator_name(event));
break; break;
case HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR: case HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR:
if (event[4]) printf("EXTENDED_AUDIO_GATEWAY_ERROR_REPORT, status : %d\n",
printf("EXTENDED_AUDIO_GATEWAY_ERROR_REPORT, status : %d\n", event[3]); hfp_subevent_extended_audio_gateway_error_get_error(event));
break; break;
case HFP_SUBEVENT_RING: case HFP_SUBEVENT_RING:
printf("** Ring **\n"); printf("** Ring **\n");
break; break;
case HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG: case HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG:
printf("Phone number for voice tag: %s\n", (const char *) &event[3]); printf("Phone number for voice tag: %s\n",
(const char *) hfp_subevent_number_for_voice_tag_get_number(event));
break; break;
case HFP_SUBEVENT_SPEAKER_VOLUME: case HFP_SUBEVENT_SPEAKER_VOLUME:
printf("Speaker volume: %u\n", event[3]); printf("Speaker volume: status %u, gain %u\n",
hfp_subevent_speaker_volume_get_status(event),
hfp_subevent_speaker_volume_get_gain(event));
break; break;
case HFP_SUBEVENT_MICROPHONE_VOLUME: case HFP_SUBEVENT_MICROPHONE_VOLUME:
printf("Microphone volume: %u\n", event[3]); printf("Microphone volume: status %u, gain %u\n",
hfp_subevent_microphone_volume_get_status(event),
hfp_subevent_microphone_volume_get_gain(event));
break;
case HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION:
printf("Caller ID, number %s\n", hfp_subevent_calling_line_identification_notification_get_number(event));
break; break;
default: default:
printf("event not handled %u\n", event[2]); printf("event not handled %u\n", event[2]);