hfp: added event to sniff strings sent over rfcomm

This commit is contained in:
Matthias Ringwald 2021-01-21 11:30:29 +01:00
parent 26fbdc19f5
commit e43d1938b9
7 changed files with 49 additions and 3 deletions

View File

@ -19,6 +19,7 @@ A2DP Source: allow to configure non-SBC endpoints by calling `a2dp_source_set_co
A2DP Source, AVDTP Source: allow to send complete media packet with `avdtp_source_stream_send_media_packet` and `a2dp_source_stream_send_media_packet`
A2DP Source AVDTP Source: add `avdtp_source_stream_send_media_payload_rtp`
A2DP Source: support multiple Stream Endpoints with different Media Codec types
HFP: `ENABLE_HFP_AT_MESSAGES` lets HFP emit `HFP_SUBEVENT_AT_MESSAGE_SENT` and `HFP_SUBEVENT_AT_MESSAGE_RECEIVED`
### Fixed
L2CAP: fix packet size check for incoming classic basic channels (regression introduced in v1.2.1)

View File

@ -83,7 +83,8 @@ ENABLE_LOG_INFO | Enable log_info messages
ENABLE_SCO_OVER_HCI | Enable SCO over HCI for chipsets (if supported)
ENABLE_SCO_OVER_PCM | Enable SCO ofer PCM/I2S for chipsets (if supported)
ENABLE_HFP_WIDE_BAND_SPEECH | Enable support for mSBC codec used in HFP profile for Wide-Band Speech
ENBALE_LE_PERIPHERAL | Enable support for LE Peripheral Role in HCI and Security Manager
ENABLE_HFP_AT_MESSAGES | Enable `HFP_SUBEVENT_AT_MESSAGE_SENT` and `HFP_SUBEVENT_AT_MESSAGE_RECEIVED` events
ENABLE_LE_PERIPHERAL | Enable support for LE Peripheral Role in HCI and Security Manager
ENBALE_LE_CENTRAL | Enable support for LE Central Role in HCI and Security Manager
ENABLE_LE_SECURE_CONNECTIONS | Enable LE Secure Connections
ENABLE_LE_PROACTIVE_AUTHENTICATION | Enable automatic encryption for bonded devices on re-connect

View File

@ -1672,6 +1672,20 @@ typedef uint8_t sm_key_t[16];
*/
#define HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS 0x1A
/**
* @format 1T
* @param subevent_code
* @param command
*/
#define HFP_SUBEVENT_AT_MESSAGE_SENT 0x1B
/**
* @format 1T
* @param subevent_code
* @param command
*/
#define HFP_SUBEVENT_AT_MESSAGE_RECEIVED 0x1C
// ANCS Client
/**

View File

@ -4241,6 +4241,26 @@ static inline const char * hfp_subevent_response_and_hold_status_get_value(const
return (const char *) &event[3];
}
/**
* @brief Get field command from event HFP_SUBEVENT_AT_MESSAGE_SENT
* @param event packet
* @return command
* @note: btstack_type T
*/
static inline const char * hfp_subevent_at_message_sent_get_command(const uint8_t * event){
return (const char *) &event[3];
}
/**
* @brief Get field command from event HFP_SUBEVENT_AT_MESSAGE_RECEIVED
* @param event packet
* @return command
* @note: btstack_type T
*/
static inline const char * hfp_subevent_at_message_received_get_command(const uint8_t * event){
return (const char *) &event[3];
}
#ifdef ENABLE_BLE
/**
* @brief Get field handle from event ANCS_SUBEVENT_CLIENT_CONNECTED

View File

@ -239,6 +239,10 @@ int send_str_over_rfcomm(uint16_t cid, char * command){
if (err){
log_error("rfcomm_send -> error 0x%02x \n", err);
}
#ifdef ENABLE_HFP_AT_MESSAGES
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_rfcomm_cid(cid);
hfp_emit_string_event(hfp_connection, HFP_SUBEVENT_AT_MESSAGE_SENT, command);
#endif
return 1;
}

View File

@ -1846,7 +1846,10 @@ static void hfp_ag_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uin
if (!hfp_connection) return;
hfp_log_rfcomm_message("HFP_AG_RX", packet, size);
#ifdef ENABLE_HFP_AT_MESSAGES
hfp_emit_string_event(hfp_connection, HFP_SUBEVENT_AT_MESSAGE_RECEIVED, (char *) packet);
#endif
// process messages byte-wise
int pos;
for (pos = 0; pos < size ; pos++){

View File

@ -1147,6 +1147,9 @@ static void hfp_hf_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uin
if (!hfp_connection) return;
hfp_log_rfcomm_message("HFP_HF_RX", packet, size);
#ifdef ENABLE_HFP_AT_MESSAGES
hfp_emit_string_event(hfp_connection, HFP_SUBEVENT_AT_MESSAGE_RECEIVED, (char *) packet);
#endif
// process messages byte-wise
int pos;
@ -1826,4 +1829,4 @@ void hfp_hf_register_packet_handler(btstack_packet_handler_t callback){
}
hfp_hf_callback = callback;
hfp_set_hf_callback(callback);
}
}