diff --git a/example/hfp_ag_demo.c b/example/hfp_ag_demo.c index edc5d3df1..707b6251f 100644 --- a/example/hfp_ag_demo.c +++ b/example/hfp_ag_demo.c @@ -130,15 +130,15 @@ enum STATE state = INIT; static void dump_supported_codecs(void){ int i; int mSBC_skipped = 0; - printf("Supported codecs:"); + printf("Supported codecs: "); for (i = 0; i < sizeof(codecs); i++){ switch(codecs[i]){ case HFP_CODEC_CVSD: - printf(" CVSD"); + printf("CVSD"); break; case HFP_CODEC_MSBC: if (hci_extended_sco_link_supported()){ - printf("mSBC"); + printf(", mSBC"); } else { mSBC_skipped = 1; } diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 89f8687c0..7592dd108 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -86,15 +86,15 @@ char cmd; static void dump_supported_codecs(void){ int i; int mSBC_skipped = 0; - printf("Supported codecs:"); + printf("Supported codecs: "); for (i = 0; i < sizeof(codecs); i++){ switch(codecs[i]){ case HFP_CODEC_CVSD: - printf(" CVSD"); + printf("CVSD"); break; case HFP_CODEC_MSBC: if (hci_extended_sco_link_supported()){ - printf("mSBC"); + printf(", mSBC"); } else { mSBC_skipped = 1; } diff --git a/example/sco_demo_util.c b/example/sco_demo_util.c index 937be539b..4f51715e1 100644 --- a/example/sco_demo_util.c +++ b/example/sco_demo_util.c @@ -66,7 +66,7 @@ #ifdef HAVE_POSIX_FILE_IO #define SCO_WAV_FILENAME "sco_input.wav" #define SCO_MSBC_OUT_FILENAME "sco_output.msbc" -#define SCO_MSBC_IN_FILENAME "sco_input.mscb" +#define SCO_MSBC_IN_FILENAME "sco_input.msbc" #define SCO_WAV_DURATION_IN_SECONDS 15 #endif diff --git a/port/libusb/.gitignore b/port/libusb/.gitignore index 12b4f649d..f3950a0b7 100644 --- a/port/libusb/.gitignore +++ b/port/libusb/.gitignore @@ -34,4 +34,6 @@ spp_and_le_counter spp_and_le_counter.h spp_counter spp_streamer -spp_streamer \ No newline at end of file +spp_streamer +sco_input* +sco_output* diff --git a/src/classic/hfp.c b/src/classic/hfp.c index c8a1bade6..43d112523 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -1086,30 +1086,30 @@ void hfp_parse(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree) switch (hfp_connection->command){ case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME: log_info("format %s, ", hfp_connection->line_buffer); - hfp_connection->network_operator.format = atoi((char *)&hfp_connection->line_buffer[0]); + hfp_connection->network_operator.format = btstack_atoi((char *)&hfp_connection->line_buffer[0]); break; case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT: log_info("format %s \n", hfp_connection->line_buffer); - hfp_connection->network_operator.format = atoi((char *)&hfp_connection->line_buffer[0]); + hfp_connection->network_operator.format = btstack_atoi((char *)&hfp_connection->line_buffer[0]); break; case HFP_CMD_LIST_GENERIC_STATUS_INDICATORS: case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS: case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE: - hfp_connection->generic_status_indicators[hfp_connection->parser_item_index].state = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->generic_status_indicators[hfp_connection->parser_item_index].state = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); break; case HFP_CMD_TRANSFER_AG_INDICATOR_STATUS: - hfp_connection->ag_indicators[hfp_connection->parser_item_index].status = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->ag_indicators[hfp_connection->parser_item_index].status = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); log_info("%d \n", hfp_connection->ag_indicators[hfp_connection->parser_item_index].status); hfp_connection->ag_indicators[hfp_connection->parser_item_index].status_changed = 1; break; case HFP_CMD_RETRIEVE_AG_INDICATORS: - hfp_connection->ag_indicators[hfp_connection->parser_item_index].min_range = atoi((char *)hfp_connection->line_buffer); + hfp_connection->ag_indicators[hfp_connection->parser_item_index].min_range = btstack_atoi((char *)hfp_connection->line_buffer); log_info("%s, ", hfp_connection->line_buffer); break; case HFP_CMD_AG_SENT_PHONE_NUMBER: case HFP_CMD_AG_SENT_CALL_WAITING_NOTIFICATION_UPDATE: case HFP_CMD_AG_SENT_CLIP_INFORMATION: - hfp_connection->bnip_type = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->bnip_type = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); break; default: break; @@ -1123,7 +1123,7 @@ void hfp_parse(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree) log_info("name %s\n", hfp_connection->line_buffer); break; case HFP_CMD_RETRIEVE_AG_INDICATORS: - hfp_connection->ag_indicators[hfp_connection->parser_item_index].max_range = atoi((char *)hfp_connection->line_buffer); + hfp_connection->ag_indicators[hfp_connection->parser_item_index].max_range = btstack_atoi((char *)hfp_connection->line_buffer); hfp_connection->parser_item_index++; hfp_connection->ag_indicators_nr = hfp_connection->parser_item_index; log_info("%s)\n", hfp_connection->line_buffer); @@ -1148,7 +1148,7 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ int value; switch (hfp_connection->command){ case HFP_CMD_SET_GENERIC_STATUS_INDICATOR_STATUS: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); int i; switch (hfp_connection->parser_item_index){ case 0: @@ -1178,7 +1178,7 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ hfp_connection->bnip_number[sizeof(hfp_connection->bnip_number)-1] = 0; break; case 1: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->bnip_type = value; break; default: @@ -1189,19 +1189,19 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ case HFP_CMD_LIST_CURRENT_CALLS: switch(hfp_connection->parser_item_index){ case 0: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->clcc_idx = value; break; case 1: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->clcc_dir = value; break; case 2: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->clcc_status = value; break; case 3: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->clcc_mpty = value; break; case 4: @@ -1209,7 +1209,7 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ hfp_connection->bnip_number[sizeof(hfp_connection->bnip_number)-1] = 0; break; case 5: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->bnip_type = value; break; default: @@ -1218,45 +1218,45 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ hfp_connection->parser_item_index++; break; case HFP_CMD_SET_MICROPHONE_GAIN: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->microphone_gain = value; log_info("hfp parse HFP_CMD_SET_MICROPHONE_GAIN %d\n", value); break; case HFP_CMD_SET_SPEAKER_GAIN: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->speaker_gain = value; log_info("hfp parse HFP_CMD_SET_SPEAKER_GAIN %d\n", value); break; case HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->ag_activate_voice_recognition = value; log_info("hfp parse HFP_CMD_HF_ACTIVATE_VOICE_RECOGNITION %d\n", value); break; case HFP_CMD_TURN_OFF_EC_AND_NR: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->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 *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->remote_supported_features = store_bit(hfp_connection->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE, value); log_info("hfp parse HFP_CHANGE_IN_BAND_RING_TONE_SETTING %d\n", value); break; case HFP_CMD_HF_CONFIRMED_CODEC: - hfp_connection->codec_confirmed = atoi((char*)hfp_connection->line_buffer); + hfp_connection->codec_confirmed = btstack_atoi((char*)hfp_connection->line_buffer); log_info("hfp parse HFP_CMD_HF_CONFIRMED_CODEC %d\n", hfp_connection->codec_confirmed); break; case HFP_CMD_AG_SUGGESTED_CODEC: - hfp_connection->suggested_codec = atoi((char*)hfp_connection->line_buffer); + hfp_connection->suggested_codec = btstack_atoi((char*)hfp_connection->line_buffer); log_info("hfp parse HFP_CMD_AG_SUGGESTED_CODEC %d\n", hfp_connection->suggested_codec); break; case HFP_CMD_SUPPORTED_FEATURES: - hfp_connection->remote_supported_features = atoi((char*)hfp_connection->line_buffer); + hfp_connection->remote_supported_features = btstack_atoi((char*)hfp_connection->line_buffer); log_info("Parsed supported feature %d\n", hfp_connection->remote_supported_features); break; case HFP_CMD_AVAILABLE_CODECS: log_info("Parsed codec %s\n", hfp_connection->line_buffer); - hfp_connection->remote_codecs[hfp_connection->parser_item_index] = (uint16_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->remote_codecs[hfp_connection->parser_item_index] = (uint16_t)btstack_atoi((char*)hfp_connection->line_buffer); hfp_connection->parser_item_index++; hfp_connection->remote_codecs_nr = hfp_connection->parser_item_index; break; @@ -1267,14 +1267,14 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ break; case HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS: log_info("Parsed Indicator %d with status: %s\n", hfp_connection->parser_item_index+1, hfp_connection->line_buffer); - hfp_connection->ag_indicators[hfp_connection->parser_item_index].status = atoi((char *) hfp_connection->line_buffer); + hfp_connection->ag_indicators[hfp_connection->parser_item_index].status = btstack_atoi((char *) hfp_connection->line_buffer); hfp_connection->parser_item_index++; break; case HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE: hfp_connection->parser_item_index++; if (hfp_connection->parser_item_index != 4) break; log_info("Parsed Enable indicators: %s\n", hfp_connection->line_buffer); - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->enable_status_update_for_ag_indicators = (uint8_t) value; break; case HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES: @@ -1286,17 +1286,17 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ case HFP_CMD_LIST_GENERIC_STATUS_INDICATORS: case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS: log_info("Parsed Generic status indicator: %s\n", hfp_connection->line_buffer); - hfp_connection->generic_status_indicators[hfp_connection->parser_item_index].uuid = (uint16_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->generic_status_indicators[hfp_connection->parser_item_index].uuid = (uint16_t)btstack_atoi((char*)hfp_connection->line_buffer); hfp_connection->parser_item_index++; hfp_connection->generic_status_indicators_nr = hfp_connection->parser_item_index; break; case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE: // HF parses inital AG gen. ind. state log_info("Parsed List generic status indicator %s state: ", hfp_connection->line_buffer); - hfp_connection->parser_item_index = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->parser_item_index = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); break; case HFP_CMD_HF_INDICATOR_STATUS: - hfp_connection->parser_indicator_index = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->parser_indicator_index = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); log_info("Parsed HF indicator index %u", hfp_connection->parser_indicator_index); break; case HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE: @@ -1310,7 +1310,7 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ log_info("Parsed Enable AG indicator pos %u('%s') - ignore (mandatory)\n", hfp_connection->parser_item_index, hfp_connection->ag_indicators[hfp_connection->parser_item_index].name); } else { - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); hfp_connection->ag_indicators[hfp_connection->parser_item_index].enabled = value; log_info("Parsed Enable AG indicator pos %u('%s'): %u\n", hfp_connection->parser_item_index, hfp_connection->ag_indicators[hfp_connection->parser_item_index].name, value); @@ -1319,11 +1319,11 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ break; case HFP_CMD_TRANSFER_AG_INDICATOR_STATUS: // indicators are indexed starting with 1 - hfp_connection->parser_item_index = atoi((char *)&hfp_connection->line_buffer[0]) - 1; + hfp_connection->parser_item_index = btstack_atoi((char *)&hfp_connection->line_buffer[0]) - 1; log_info("Parsed status of the AG indicator %d, status ", hfp_connection->parser_item_index); break; case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME: - hfp_connection->network_operator.mode = atoi((char *)&hfp_connection->line_buffer[0]); + hfp_connection->network_operator.mode = btstack_atoi((char *)&hfp_connection->line_buffer[0]); log_info("Parsed network operator mode: %d, ", hfp_connection->network_operator.mode); break; case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT: @@ -1338,10 +1338,10 @@ static void parse_sequence(hfp_connection_t * hfp_connection){ break; case HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR: hfp_connection->extended_audio_gateway_error = 1; - hfp_connection->extended_audio_gateway_error_value = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->extended_audio_gateway_error_value = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); break; case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR: - hfp_connection->enable_extended_audio_gateway_error_report = (uint8_t)atoi((char*)hfp_connection->line_buffer); + hfp_connection->enable_extended_audio_gateway_error_report = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer); hfp_connection->ok_pending = 1; hfp_connection->extended_audio_gateway_error = 0; break; diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index 7818f8efa..8e98c8010 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -1837,7 +1837,7 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_ hfp_connection->ok_pending = 1; break; case HFP_CMD_RESPONSE_AND_HOLD_COMMAND: - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); log_info("HF Response and Hold: %u", value); switch(value){ case HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD: @@ -1862,7 +1862,7 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_ hfp_connection->send_error = 1; break; } - value = atoi((char *)&hfp_connection->line_buffer[0]); + value = btstack_atoi((char *)&hfp_connection->line_buffer[0]); switch (indicator->uuid){ case 1: // enhanced security if (value > 1) { @@ -1939,7 +1939,7 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_ hfp_connection->call_index = 0; if (hfp_connection->line_buffer[1] != '\0'){ - hfp_connection->call_index = atoi((char *)&hfp_connection->line_buffer[1]); + hfp_connection->call_index = btstack_atoi((char *)&hfp_connection->line_buffer[1]); } switch (hfp_connection->line_buffer[0]){ diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index 2bac88752..e96dfaa68 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -1005,7 +1005,7 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8 case HFP_CMD_RESPONSE_AND_HOLD_STATUS: hfp_connection->command = HFP_CMD_NONE; // printf("Response and Hold status: %s\n", hfp_connection->line_buffer); - hfp_emit_event(hfp_callback, HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS, atoi((char *)&hfp_connection->line_buffer[0])); + hfp_emit_event(hfp_callback, HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS, btstack_atoi((char *)&hfp_connection->line_buffer[0])); break; case HFP_CMD_LIST_CURRENT_CALLS: hfp_connection->command = HFP_CMD_NONE; @@ -1018,13 +1018,13 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8 break; case HFP_CMD_SET_SPEAKER_GAIN: hfp_connection->command = HFP_CMD_NONE; - value = atoi((char*)hfp_connection->line_buffer); + value = btstack_atoi((char*)hfp_connection->line_buffer); hfp_hf_speaker_gain = value; hfp_emit_event(hfp_callback, HFP_SUBEVENT_SPEAKER_VOLUME, value); break; case HFP_CMD_SET_MICROPHONE_GAIN: hfp_connection->command = HFP_CMD_NONE; - value = atoi((char*)hfp_connection->line_buffer); + value = btstack_atoi((char*)hfp_connection->line_buffer); hfp_hf_microphone_gain = value; hfp_emit_event(hfp_callback, HFP_SUBEVENT_MICROPHONE_VOLUME, value); break; diff --git a/src/classic/hsp_ag.c b/src/classic/hsp_ag.c index ce74f5623..c7979f757 100644 --- a/src/classic/hsp_ag.c +++ b/src/classic/hsp_ag.c @@ -551,12 +551,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack break; } } else if (strncmp((char *)packet, HSP_HS_MICROPHONE_GAIN, strlen(HSP_HS_MICROPHONE_GAIN)) == 0){ - uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_HS_MICROPHONE_GAIN)]); + uint8_t gain = (uint8_t)btstack_atoi((char*)&packet[strlen(HSP_HS_MICROPHONE_GAIN)]); ag_send_ok = 1; emit_event(HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED, gain); } else if (strncmp((char *)packet, HSP_HS_SPEAKER_GAIN, strlen(HSP_HS_SPEAKER_GAIN)) == 0){ - uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_HS_SPEAKER_GAIN)]); + uint8_t gain = (uint8_t)btstack_atoi((char*)&packet[strlen(HSP_HS_SPEAKER_GAIN)]); ag_send_ok = 1; emit_event(HSP_SUBEVENT_SPEAKER_GAIN_CHANGED, gain); diff --git a/src/classic/hsp_hs.c b/src/classic/hsp_hs.c index 8b8995166..a4c7b0663 100644 --- a/src/classic/hsp_hs.c +++ b/src/classic/hsp_hs.c @@ -454,11 +454,11 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack } else if (strncmp((char *)packet, HSP_AG_OK, strlen(HSP_AG_OK)) == 0){ wait_ok = 0; } else if (strncmp((char *)packet, HSP_MICROPHONE_GAIN, strlen(HSP_MICROPHONE_GAIN)) == 0){ - uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_MICROPHONE_GAIN)]); + uint8_t gain = (uint8_t)btstack_atoi((char*)&packet[strlen(HSP_MICROPHONE_GAIN)]); emit_event(HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED, gain); } else if (strncmp((char *)packet, HSP_SPEAKER_GAIN, strlen(HSP_SPEAKER_GAIN)) == 0){ - uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_SPEAKER_GAIN)]); + uint8_t gain = (uint8_t)btstack_atoi((char*)&packet[strlen(HSP_SPEAKER_GAIN)]); emit_event(HSP_SUBEVENT_SPEAKER_GAIN_CHANGED, gain); } else { if (!hsp_hs_callback) return;