From 8c0f36353fab940feb30b31f247a0b1bacc16cef Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Tue, 15 Aug 2017 13:47:16 +0200 Subject: [PATCH] remove Remove Ctrl-C from usage --- example/a2dp_sink_demo.c | 3 --- example/a2dp_source_demo.c | 1 - example/ancs_client_demo.c | 1 - example/hfp_ag_demo.c | 3 --- example/hfp_hf_demo.c | 5 +---- example/hsp_ag_demo.c | 5 +---- example/hsp_hs_demo.c | 4 +--- example/pbap_client_demo.c | 4 +--- src/classic/avdtp.c | 23 ++++++++++++++++++----- 9 files changed, 22 insertions(+), 27 deletions(-) diff --git a/example/a2dp_sink_demo.c b/example/a2dp_sink_demo.c index d4d91c232..fcd9abab3 100644 --- a/example/a2dp_sink_demo.c +++ b/example/a2dp_sink_demo.c @@ -475,7 +475,6 @@ static void media_processing_close(void){ } static void handle_l2cap_media_data_packet(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size){ - UNUSED(stream_endpoint); int pos = 0; @@ -793,8 +792,6 @@ static void show_usage(void){ printf("X - disable repeat mode\n"); printf("z - shuffle all tracks\n"); printf("Z - disable shuffle mode\n"); - - printf("Ctrl-c - exit\n"); printf("---\n"); } #endif diff --git a/example/a2dp_source_demo.c b/example/a2dp_source_demo.c index 9e8fc00c6..69ee1100d 100644 --- a/example/a2dp_source_demo.c +++ b/example/a2dp_source_demo.c @@ -437,7 +437,6 @@ static void show_usage(void){ printf("p - pause streaming\n"); printf("\n--- Bluetooth AVRCP Target Commands %s ---\n", bd_addr_to_str(iut_address)); - printf("Ctrl-c - exit\n"); printf("---\n"); } diff --git a/example/ancs_client_demo.c b/example/ancs_client_demo.c index 27d5a4a3d..91e6b0061 100644 --- a/example/ancs_client_demo.c +++ b/example/ancs_client_demo.c @@ -130,7 +130,6 @@ static void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet int btstack_main(int argc, const char * argv[]); int btstack_main(int argc, const char * argv[]){ - (void)argc; (void)argv; diff --git a/example/hfp_ag_demo.c b/example/hfp_ag_demo.c index 2272751b1..988039c79 100644 --- a/example/hfp_ag_demo.c +++ b/example/hfp_ag_demo.c @@ -169,9 +169,6 @@ static void show_usage(void){ printf("w - put incoming call on hold (Response and Hold)\n"); printf("x - accept held incoming call (Response and Hold)\n"); printf("X - reject held incoming call (Response and Hold)\n"); - - printf("---\n"); - printf("Ctrl-c - exit\n"); printf("---\n"); } diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 18eff3d47..b219da5e7 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -152,9 +152,7 @@ static void show_usage(void){ printf("{ - Accept held call(RHH 1) | } - Reject held call(RHH 2)\n"); printf("? - Query Subscriber Number (NUM)\n"); printf("! - Update HF indicator with assigned number 1 (HFI)\n"); - printf("---\n"); - printf("Ctrl-c - exit\n"); - printf("---\n"); + printf("\n"); } static void stdin_process(char c){ @@ -430,7 +428,6 @@ static void stdin_process(char c){ printf("Update HF indicator with assigned number 1 (HFI)\n"); hfp_hf_set_hf_indicator(acl_handle, 1, 1); break; - default: show_usage(); break; diff --git a/example/hsp_ag_demo.c b/example/hsp_ag_demo.c index a0721ac61..a7724e9f4 100644 --- a/example/hsp_ag_demo.c +++ b/example/hsp_ag_demo.c @@ -115,9 +115,7 @@ static void show_usage(void){ printf("S - set speaker gain 15\n"); printf("r - start ringing\n"); printf("t - stop ringing\n"); - printf("---\n"); - printf("Ctrl-c - exit\n"); - printf("---\n"); + printf("\n"); } #ifdef HAVE_BTSTACK_STDIN @@ -170,7 +168,6 @@ static void stdin_process(char c){ default: show_usage(); break; - } } #endif diff --git a/example/hsp_hs_demo.c b/example/hsp_hs_demo.c index 60c45b929..535af3d55 100644 --- a/example/hsp_hs_demo.c +++ b/example/hsp_hs_demo.c @@ -115,9 +115,7 @@ static void show_usage(void){ printf("o - set speaker gain 0\n"); printf("s - set speaker gain 8\n"); printf("S - set speaker gain 15\n"); - printf("---\n"); - printf("Ctrl-c - exit\n"); - printf("---\n"); + printf("\n"); } #ifdef HAVE_BTSTACK_STDIN diff --git a/example/pbap_client_demo.c b/example/pbap_client_demo.c index 0857e70e0..0504cd0fd 100644 --- a/example/pbap_client_demo.c +++ b/example/pbap_client_demo.c @@ -83,9 +83,7 @@ static void show_usage(void){ printf("c - set phonebook '/SIM1/telecom/pb'\n"); printf("d - pull phonebook\n"); printf("e - disconnnect\n"); - printf("---\n"); - printf("Ctrl-c - exit\n"); - printf("---\n"); + printf("\n"); } static void stdin_process(char c){ diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 25743ace4..9679b5fd6 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -291,6 +291,11 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp uint8_t status; bd_addr_t address; + if (!connection){ + log_error("avdtp: connection does not exist."); + return; + } + switch (packet_type){ case L2CAP_DATA_PACKET:{ int offset = avdtp_read_signaling_header(&connection->signaling_packet, packet, size); @@ -302,6 +307,11 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp break; } case HCI_EVENT_PACKET: + if (!stream_endpoint){ + log_error("avdtp: stream_endpoint does not exist."); + return; + } + switch (event){ case L2CAP_EVENT_CHANNEL_OPENED: l2cap_event_channel_opened_get_address(packet, address); @@ -333,7 +343,7 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp case L2CAP_EVENT_CHANNEL_CLOSED: local_cid = l2cap_event_channel_closed_get_local_cid(packet); if (stream_endpoint->l2cap_media_cid == local_cid){ - avdtp_streaming_emit_connection_released(context->avdtp_callback, stream_endpoint->connection->avdtp_cid, avdtp_local_seid(stream_endpoint)); + avdtp_streaming_emit_connection_released(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint)); stream_endpoint->l2cap_media_cid = 0; stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE; stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE; @@ -502,9 +512,11 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet break; } - if (channel == stream_endpoint->connection->l2cap_signaling_cid){ - stream_endpoint_state_machine(stream_endpoint->connection, stream_endpoint, L2CAP_DATA_PACKET, 0, packet, size, context); - break; + if (stream_endpoint->connection){ + if (channel == stream_endpoint->connection->l2cap_signaling_cid){ + stream_endpoint_state_machine(stream_endpoint->connection, stream_endpoint, L2CAP_DATA_PACKET, 0, packet, size, context); + break; + } } if (channel == stream_endpoint->l2cap_media_cid){ @@ -599,7 +611,8 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet connection = avdtp_connection_for_l2cap_signaling_cid(local_cid, context); stream_endpoint = avdtp_stream_endpoint_for_l2cap_cid(local_cid, context); - if (stream_endpoint){ + if (stream_endpoint){ + printf("stream_endpoint %p, connection %p, se con %p \n", stream_endpoint, connection, stream_endpoint->connection); stream_endpoint_state_machine(connection, stream_endpoint, HCI_EVENT_PACKET, L2CAP_EVENT_CHANNEL_CLOSED, packet, size, context); break; }