mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-26 18:41:12 +00:00
hfp: improve log_info for rfcomm data
This commit is contained in:
parent
20af858ff1
commit
186dd3d22a
@ -1518,3 +1518,31 @@ void hfp_set_hf_run_for_context(void (*callback)(hfp_connection_t * hfp_connecti
|
||||
|
||||
void hfp_init(void){
|
||||
}
|
||||
|
||||
#define HFP_HF_RX_DEBUG_PRINT_LINE 80
|
||||
|
||||
void hfp_log_rfcomm_message(const char * tag, uint8_t * packet, uint16_t size){
|
||||
#ifdef ENABLE_LOG_INFO
|
||||
// encode \n\r
|
||||
char printable[HFP_HF_RX_DEBUG_PRINT_LINE+2];
|
||||
int i;
|
||||
int pos;
|
||||
for (i=0,pos=0;(pos < size) && (i < (HFP_HF_RX_DEBUG_PRINT_LINE - 3)); pos++){
|
||||
switch (packet[pos]){
|
||||
case '\n':
|
||||
printable[i++] = '\\';
|
||||
printable[i++] = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
printable[i++] = '\\';
|
||||
printable[i++] = 'r';
|
||||
break;
|
||||
default:
|
||||
printable[i++] = packet[pos];
|
||||
break;
|
||||
}
|
||||
}
|
||||
printable[i] = 0;
|
||||
log_info("%s: '%s'", tag, printable);
|
||||
#endif
|
||||
}
|
||||
|
@ -680,6 +680,8 @@ void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_n
|
||||
const char * hfp_hf_feature(int index);
|
||||
const char * hfp_ag_feature(int index);
|
||||
|
||||
void hfp_log_rfcomm_message(const char * tag, uint8_t * packet, uint16_t size);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1833,19 +1833,16 @@ static void hfp_ag_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uin
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_rfcomm_cid(channel);
|
||||
if (!hfp_connection) return;
|
||||
|
||||
// temp overwrite last byte (most likely \n for log_info)
|
||||
char last_char = packet[size-1];
|
||||
packet[size-1] = 0;
|
||||
log_info("HFP_RX %s", packet);
|
||||
packet[size-1] = last_char;
|
||||
hfp_log_rfcomm_message("HFP_AG_RX", packet, size);
|
||||
|
||||
// process messages byte-wise
|
||||
int pos;
|
||||
for (pos = 0; pos < size ; pos++){
|
||||
hfp_parse(hfp_connection, packet[pos], 0);
|
||||
}
|
||||
hfp_generic_status_indicator_t * indicator;
|
||||
|
||||
int value;
|
||||
hfp_generic_status_indicator_t * indicator;
|
||||
switch(hfp_connection->command){
|
||||
case HFP_CMD_RESPONSE_AND_HOLD_QUERY:
|
||||
if (hfp_ag_response_and_hold_active){
|
||||
|
@ -972,7 +972,6 @@ static void hfp_hf_switch_on_ok(hfp_connection_t *hfp_connection){
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
}
|
||||
|
||||
|
||||
static void hfp_hf_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(packet_type); // ok: only called with RFCOMM_DATA_PACKET
|
||||
|
||||
@ -982,18 +981,16 @@ static void hfp_hf_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, ui
|
||||
hfp_connection_t * hfp_connection = get_hfp_connection_context_for_rfcomm_cid(channel);
|
||||
if (!hfp_connection) return;
|
||||
|
||||
// temp overwrite last byte (most likely \n for log_info)
|
||||
char last_char = packet[size-1];
|
||||
packet[size-1] = 0;
|
||||
log_info("HFP_RX %s", packet);
|
||||
packet[size-1] = last_char;
|
||||
|
||||
hfp_log_rfcomm_message("HFP_HF_RX", packet, size);
|
||||
|
||||
// process messages byte-wise
|
||||
int pos, i, value;
|
||||
int pos;
|
||||
for (pos = 0; pos < size ; pos++){
|
||||
hfp_parse(hfp_connection, packet[pos], 1);
|
||||
}
|
||||
|
||||
int value;
|
||||
int i;
|
||||
switch (hfp_connection->command){
|
||||
case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION:
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user