hfp_hf: emit event for custom at commands

This commit is contained in:
Matthias Ringwald 2023-05-26 16:44:38 +02:00
parent 6e64d9fef6
commit 892f58a83a

View File

@ -275,6 +275,20 @@ static void hfp_hf_emit_enhanced_voice_recognition_text(hfp_connection_t * hfp_c
(*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, pos);
}
static void hfp_hf_emit_custom_command_event(hfp_connection_t * hfp_connection){
btstack_assert(sizeof(hfp_connection->line_buffer) < (255-5));
uint16_t line_len = strlen((const char*)hfp_connection->line_buffer) + 1;
uint8_t event[7 + sizeof(hfp_connection->line_buffer)];
event[0] = HCI_EVENT_HFP_META;
event[1] = 5 + line_len;
event[2] = HFP_SUBEVENT_CUSTOM_AT_COMMAND;
little_endian_store_16(event, 3, hfp_connection->acl_handle);
little_endian_store_16(event, 5, hfp_connection->custom_at_command_id);
memcpy(&event[7], hfp_connection->line_buffer, line_len);
(*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, 7 + line_len);
}
/* send commands */
static inline int hfp_hf_send_cmd(uint16_t cid, const char * cmd){
@ -1412,6 +1426,12 @@ static void hfp_hf_handle_rfcomm_command(hfp_connection_t * hfp_connection){
break;
case HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING:
hfp_emit_event(hfp_connection, HFP_SUBEVENT_IN_BAND_RING_TONE, get_bit(hfp_connection->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE));
case HFP_CMD_CUSTOM_MESSAGE:
hfp_connection->command = HFP_CMD_NONE;
hfp_parser_reset_line_buffer(hfp_connection);
log_info("Custom AT Command ID 0x%04x", hfp_connection->custom_at_command_id);
hfp_hf_emit_custom_command_event(hfp_connection);
break;
default:
break;
}