mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
hfp: ag turns off EC and NG on request
This commit is contained in:
parent
ccc726e1b2
commit
acd5be0219
@ -621,6 +621,10 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
|
||||
static hfp_command_t parse_command(const char * line_buffer, int isHandsFree){
|
||||
int offset = isHandsFree ? 0 : 2;
|
||||
|
||||
if (strncmp(line_buffer, HFP_TURN_OFF_EC_AND_NR, strlen(HFP_TURN_OFF_EC_AND_NR))){
|
||||
return HFP_CMD_TURN_OFF_EC_AND_NR;
|
||||
}
|
||||
|
||||
if (strncmp(line_buffer, HFP_CALL_ANSWERED, strlen(HFP_CALL_ANSWERED)) == 0){
|
||||
return HFP_CMD_CALL_ANSWERED;
|
||||
}
|
||||
@ -912,6 +916,11 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree){
|
||||
|
||||
case HFP_PARSER_CMD_SEQUENCE: // parse comma separated sequence, ignore breacktes
|
||||
switch (context->command){
|
||||
case HFP_CMD_TURN_OFF_EC_AND_NR:
|
||||
value = atoi((char *)&context->line_buffer[0]);
|
||||
context->ag_echo_and_noise_reduction = value;
|
||||
log_info("hfp parse HFP_CMD_TURN_OFF_EC_AND_NR %d\n", value);
|
||||
break;
|
||||
case HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING:
|
||||
value = atoi((char *)&context->line_buffer[0]);
|
||||
context->remote_supported_features = store_bit(context->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE, value);
|
||||
|
@ -122,6 +122,7 @@ extern "C" {
|
||||
#define HFP_CHANGE_IN_BAND_RING_TONE_SETTING "+BSIR"
|
||||
#define HFP_CALL_PHONE_NUMBER "ATD"
|
||||
#define HFP_REDIAL_LAST_NUMBER "AT+BLDN"
|
||||
#define HFP_TURN_OFF_EC_AND_NR "AT+NREC" // EC (Echo CAnceling), NR (Noise Reduction)
|
||||
|
||||
#define HFP_OK "OK"
|
||||
#define HFP_ERROR "ERROR"
|
||||
@ -168,7 +169,8 @@ typedef enum {
|
||||
HFP_CMD_HANG_UP_CALL,
|
||||
HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING,
|
||||
HFP_CMD_CALL_PHONE_NUMBER,
|
||||
HFP_CMD_REDIAL_LAST_NUMBER
|
||||
HFP_CMD_REDIAL_LAST_NUMBER,
|
||||
HFP_CMD_TURN_OFF_EC_AND_NR
|
||||
} hfp_command_t;
|
||||
|
||||
typedef enum {
|
||||
@ -435,7 +437,8 @@ typedef struct hfp_connection {
|
||||
uint8_t change_in_band_ring_tone_setting;
|
||||
uint8_t ag_ring;
|
||||
uint8_t ag_send_clip;
|
||||
|
||||
uint8_t ag_echo_and_noise_reduction;
|
||||
|
||||
timer_source_t hfp_timeout;
|
||||
} hfp_connection_t;
|
||||
|
||||
|
10
src/hfp_ag.c
10
src/hfp_ag.c
@ -212,7 +212,7 @@ static int hfp_ag_send_clip(uint16_t cid){
|
||||
clip_number[0] = 0;
|
||||
}
|
||||
char buffer[50];
|
||||
sprintf(buffer, "\r\n+CLIP: \"%s\",%u\r\n", clip_number, clip_type);
|
||||
sprintf(buffer, "\r\n%s: \"%s\",%u\r\n", HFP_ENABLE_CLIP, clip_number, clip_type);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
@ -1275,6 +1275,14 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_
|
||||
hfp_parse(context, packet[pos], 0);
|
||||
}
|
||||
switch(context->command){
|
||||
case HFP_CMD_TURN_OFF_EC_AND_NR:
|
||||
if (get_bit(hfp_supported_features, HFP_AGSF_EC_NR_FUNCTION)){
|
||||
context->ok_pending = 1;
|
||||
hfp_supported_features = store_bit(hfp_supported_features, HFP_AGSF_EC_NR_FUNCTION, context->ag_echo_and_noise_reduction);
|
||||
} else {
|
||||
context->send_error = 1;
|
||||
}
|
||||
break;
|
||||
case HFP_CMD_CALL_ANSWERED:
|
||||
context->command = HFP_CMD_NONE;
|
||||
printf("HFP: ATA\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user