mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-25 09:35:42 +00:00
Merge branch 'develop' of https://github.com/bluekitchen/btstack into develop
This commit is contained in:
commit
918220e9f3
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
#include "wav_util.h"
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_debug.h"
|
||||
|
||||
static int wav_reader_fd;
|
||||
static int bytes_per_sample = 2;
|
||||
@ -164,7 +165,7 @@ int wav_writer_write_int16(int num_samples, int16_t * data){
|
||||
int wav_reader_open(const char * filepath){
|
||||
wav_reader_fd = open(filepath, O_RDONLY);
|
||||
if (!wav_reader_fd) {
|
||||
printf("Can't open file %s", filepath);
|
||||
log_error("Can't open file %s", filepath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -173,6 +174,10 @@ int wav_reader_open(const char * filepath){
|
||||
|
||||
int num_channels = little_endian_read_16(buf, 22);
|
||||
int block_align = little_endian_read_16(buf, 32);
|
||||
if (num_channels != 1 && num_channels != 2) {
|
||||
log_error("Unexpected num channels %d", num_channels);
|
||||
return 1;
|
||||
}
|
||||
bytes_per_sample = block_align/num_channels;
|
||||
if (bytes_per_sample > 2){
|
||||
bytes_per_sample = bytes_per_sample/8;
|
||||
|
4
port/libusb/.gitignore
vendored
4
port/libusb/.gitignore
vendored
@ -34,4 +34,6 @@ spp_and_le_counter
|
||||
spp_and_le_counter.h
|
||||
spp_counter
|
||||
spp_streamer
|
||||
spp_streamer
|
||||
spp_streamer
|
||||
sco_input*
|
||||
sco_output*
|
||||
|
@ -5,8 +5,8 @@ TOOLCHAIN = /usr/local/android-ndk
|
||||
SYSROOT = $(TOOLCHAIN)/sysroot
|
||||
GCC = $(TOOLCHAIN)/bin/arm-linux-androideabi-gcc
|
||||
STRIP = $(TOOLCHAIN)/bin/arm-linux-androideabi-strip
|
||||
CFLAGS = -march=armv7-a -mfloat-abi=softfp -I$(SYSROOT)/usr/include
|
||||
LDFLAGS = -Wl,--fix-cortex-a8 -L$(SYSROOT)/usr/lib
|
||||
CFLAGS = -march=armv7-a -mfloat-abi=softfp -I$(SYSROOT)/usr/include -fpie -fpic -fPIE -pie#
|
||||
LDFLAGS = -Wl,--fix-cortex-a8 -L$(SYSROOT)/usr/lib -fpie -fpic -fPIE -pie
|
||||
|
||||
BTSTACK_ROOT = ../..
|
||||
|
||||
|
@ -312,3 +312,14 @@ int sscanf_bd_addr(const char * addr_string, bd_addr_t addr){
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t btstack_atoi(const char *str){
|
||||
uint32_t val = 0;
|
||||
while (1){
|
||||
char chr = *str;
|
||||
if (!chr || chr < '0' || chr > '9')
|
||||
return val;
|
||||
val = (val * 10) + (chr - '0');
|
||||
str++;
|
||||
}
|
||||
}
|
@ -216,6 +216,14 @@ void uuid_add_bluetooth_prefix(uint8_t * uuid128, uint32_t short_uuid);
|
||||
*/
|
||||
int uuid_has_bluetooth_prefix(uint8_t * uuid128);
|
||||
|
||||
/**
|
||||
* @brief Parse unsigned number
|
||||
* @param str to parse
|
||||
* @return value
|
||||
*/
|
||||
uint32_t btstack_atoi(const char *str);
|
||||
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -258,7 +258,7 @@ void btstack_cvsd_plc_process_data(btstack_cvsd_plc_state_t * state, int8_t * in
|
||||
btstack_cvsd_plc_good_frame(state, in, out);
|
||||
state->good_frames_nr++;
|
||||
if (state->good_frames_nr == 1){
|
||||
printf("First good frame at index %d\n", state->frame_count-1);
|
||||
log_info("First good frame at index %d\n", state->frame_count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,12 +279,12 @@ void btstack_cvsd_plc_mark_bad_frame(btstack_cvsd_plc_state_t * state, int8_t *
|
||||
memcpy(out, in, size);
|
||||
state->good_frames_nr++;
|
||||
if (state->good_frames_nr == 1){
|
||||
printf("First good frame at index %d\n", state->frame_count-1);
|
||||
log_info("First good frame at index %d\n", state->frame_count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btstack_cvsd_dump_statistics(btstack_cvsd_plc_state_t * state){
|
||||
printf("Good frames: %d\n", state->good_frames_nr);
|
||||
printf("Bad frames: %d\n", state->bad_frames_nr);
|
||||
log_info("Good frames: %d\n", state->good_frames_nr);
|
||||
log_info("Bad frames: %d\n", state->bad_frames_nr);
|
||||
}
|
||||
|
@ -155,22 +155,6 @@ void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_n
|
||||
memcpy(codecs, tmp_codecs, tmp_codec_nr);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void hfp_set_codec(hfp_connection_t * hfp_connection, uint8_t *packet, uint16_t size){
|
||||
// parse available codecs
|
||||
int pos = 0;
|
||||
int i;
|
||||
for (i=0; i<size; i++){
|
||||
pos+=8;
|
||||
if (packet[pos] > hfp_connection->negotiated_codec){
|
||||
hfp_connection->negotiated_codec = packet[pos];
|
||||
}
|
||||
}
|
||||
printf("Negotiated Codec 0x%02x\n", hfp_connection->negotiated_codec);
|
||||
}
|
||||
#endif
|
||||
|
||||
// UTILS
|
||||
int get_bit(uint16_t bitmap, int position){
|
||||
return (bitmap >> position) & 1;
|
||||
@ -1086,30 +1070,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 +1107,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 +1132,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 +1162,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 +1173,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 +1193,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 +1202,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 +1251,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 +1270,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 +1294,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 +1303,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 +1322,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;
|
||||
|
@ -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]){
|
||||
|
@ -142,7 +142,6 @@ static void hfp_hf_emit_enhanced_call_status(btstack_packet_handler_t callback,
|
||||
static int has_codec_negotiation_feature(hfp_connection_t * hfp_connection){
|
||||
int hf = get_bit(hfp_supported_features, HFP_HFSF_CODEC_NEGOTIATION);
|
||||
int ag = get_bit(hfp_connection->remote_supported_features, HFP_AGSF_CODEC_NEGOTIATION);
|
||||
printf("local %d, remote %d\n", hf, ag);
|
||||
return hf && ag;
|
||||
}
|
||||
|
||||
@ -1005,7 +1004,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 +1017,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;
|
||||
|
@ -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);
|
||||
|
||||
@ -583,7 +583,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
|
||||
switch (event) {
|
||||
case HCI_EVENT_CONNECTION_REQUEST:
|
||||
printf("hsp HCI_EVENT_CONNECTION_REQUEST\n");
|
||||
hci_event_connection_request_get_bd_addr(packet, sco_event_addr);
|
||||
ag_establish_sco = 1;
|
||||
break;
|
||||
|
@ -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;
|
||||
|
@ -62,7 +62,7 @@
|
||||
* D: 8 byte data block
|
||||
* E: Extended Inquiry Result
|
||||
* N: Name up to 248 chars, \0 terminated
|
||||
* P: 16 byte Pairing code
|
||||
* P: 16 byte data block. Pairing code, Simple Pairing Hash and Randomizer
|
||||
* A: 31 bytes advertising data
|
||||
* S: Service Record (Data Element Sequence)
|
||||
* Q: 32 byte data block, e.g. for X and Y coordinates of P-256 public key
|
||||
@ -386,6 +386,15 @@ const hci_cmd_t hci_user_passkey_request_negative_reply = {
|
||||
OPCODE(OGF_LINK_CONTROL, 0x2f), "B"
|
||||
};
|
||||
|
||||
/**
|
||||
* @param bd_addr
|
||||
* @param c Simple Pairing Hash C
|
||||
* @param r Simple Pairing Randomizer R
|
||||
*/
|
||||
const hci_cmd_t hci_remote_oob_data_request_reply = {
|
||||
OPCODE(OGF_LINK_CONTROL, 0x30), "BPP"
|
||||
};
|
||||
|
||||
/**
|
||||
* @param bd_addr
|
||||
*/
|
||||
@ -677,6 +686,12 @@ const hci_cmd_t hci_write_simple_pairing_mode = {
|
||||
OPCODE(OGF_CONTROLLER_BASEBAND, 0x56), "1"
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
const hci_cmd_t hci_read_local_oob_data = {
|
||||
OPCODE(OGF_CONTROLLER_BASEBAND, 0x57), ""
|
||||
// return status, C, R
|
||||
};
|
||||
|
||||
/**
|
||||
* @param mode (0 = off, 1 = on)
|
||||
@ -701,6 +716,14 @@ OPCODE(OGF_CONTROLLER_BASEBAND, 0x6d), "11"
|
||||
// return: status
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
const hci_cmd_t hci_read_local_extended_ob_data = {
|
||||
OPCODE(OGF_CONTROLLER_BASEBAND, 0x7d), ""
|
||||
// return status, C_192, R_192, R_256, C_256
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Testing Commands
|
||||
*/
|
||||
|
@ -112,16 +112,19 @@ extern const hci_cmd_t hci_read_buffer_size;
|
||||
extern const hci_cmd_t hci_read_le_host_supported;
|
||||
extern const hci_cmd_t hci_read_link_policy_settings;
|
||||
extern const hci_cmd_t hci_read_link_supervision_timeout;
|
||||
extern const hci_cmd_t hci_read_local_extended_oob_data;
|
||||
extern const hci_cmd_t hci_read_local_name;
|
||||
extern const hci_cmd_t hci_read_local_version_information;
|
||||
extern const hci_cmd_t hci_read_local_oob_data;
|
||||
extern const hci_cmd_t hci_read_local_supported_commands;
|
||||
extern const hci_cmd_t hci_read_local_supported_features;
|
||||
extern const hci_cmd_t hci_read_local_version_information;
|
||||
extern const hci_cmd_t hci_read_num_broadcast_retransmissions;
|
||||
extern const hci_cmd_t hci_read_remote_supported_features_command;
|
||||
extern const hci_cmd_t hci_read_rssi;
|
||||
extern const hci_cmd_t hci_reject_connection_request;
|
||||
extern const hci_cmd_t hci_remote_name_request;
|
||||
extern const hci_cmd_t hci_remote_name_request_cancel;
|
||||
extern const hci_cmd_t hci_remote_oob_data_request_reply;
|
||||
extern const hci_cmd_t hci_remote_oob_data_request_negative_reply;
|
||||
extern const hci_cmd_t hci_reset;
|
||||
extern const hci_cmd_t hci_role_discovery;
|
||||
|
4
test/hfp/.gitignore
vendored
4
test/hfp/.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
hfp_hf_client_test
|
||||
hfp_ag_client_test
|
||||
hfp_hf_parser_test
|
||||
hfp_ag_parser_test
|
||||
hfp_ag_parser_test
|
||||
cvsd_plc_test
|
||||
results/*
|
||||
|
@ -61,7 +61,7 @@ EXAMPLES = hfp_ag_parser_test hfp_ag_client_test hfp_hf_parser_test hfp_hf_clien
|
||||
all: ${EXAMPLES}
|
||||
|
||||
clean:
|
||||
rm -rf *.o $(EXAMPLES) $(CLIENT_EXAMPLES) *.dSYM *.wav
|
||||
rm -rf *.o $(EXAMPLES) $(CLIENT_EXAMPLES) *.dSYM *.wav results/*
|
||||
|
||||
hfp_ag_parser_test: ${COMMON_OBJ} hfp_gsm_model.o hfp_ag.o hfp.o hfp_ag_parser_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
@ -79,6 +79,7 @@ cvsd_plc_test: ${COMMON_OBJ} btstack_cvsd_plc.o wav_util.o cvsd_plc_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
test: all
|
||||
mkdir -p results
|
||||
./hfp_ag_parser_test
|
||||
./hfp_ag_client_test
|
||||
./hfp_hf_parser_test
|
||||
|
@ -117,7 +117,7 @@ static void introduce_bad_frames_to_wav_file(const char * in_filename, const cha
|
||||
}
|
||||
|
||||
static void process_wav_file_with_plc(const char * in_filename, const char * out_filename){
|
||||
printf("\nProcess %s -> %s\n", in_filename, out_filename);
|
||||
// printf("\nProcess %s -> %s\n", in_filename, out_filename);
|
||||
btstack_cvsd_plc_init(&plc_state);
|
||||
wav_writer_open(out_filename, 1, 8000);
|
||||
wav_reader_open(in_filename);
|
||||
@ -133,10 +133,10 @@ static void process_wav_file_with_plc(const char * in_filename, const char * out
|
||||
}
|
||||
|
||||
static void mark_bad_frames_wav_file(const char * in_filename, const char * out_filename){
|
||||
printf("\nMark bad frame %s -> %s\n", in_filename, out_filename);
|
||||
// printf("\nMark bad frame %s -> %s\n", in_filename, out_filename);
|
||||
btstack_cvsd_plc_init(&plc_state);
|
||||
wav_writer_open(out_filename, 1, 8000);
|
||||
wav_reader_open(in_filename);
|
||||
CHECK_EQUAL(wav_writer_open(out_filename, 1, 8000), 0);
|
||||
CHECK_EQUAL(wav_reader_open(in_filename), 0);
|
||||
|
||||
while (wav_reader_read_int8(audio_samples_per_frame, audio_frame_in)){
|
||||
int8_t audio_frame_out[audio_samples_per_frame];
|
||||
@ -161,31 +161,31 @@ TEST(CVSD_PLC, CountEqBytes){
|
||||
|
||||
TEST(CVSD_PLC, TestLiveWavFile){
|
||||
int corruption_step = 10;
|
||||
introduce_bad_frames_to_wav_file("data/input/sco_input.wav", "data/sco_input.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("data/input/sco_input.wav", "data/sco_input_with_bad_frames.wav", corruption_step);
|
||||
introduce_bad_frames_to_wav_file("data/sco_input.wav", "results/sco_input.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("data/sco_input.wav", "results/sco_input_with_bad_frames.wav", corruption_step);
|
||||
|
||||
mark_bad_frames_wav_file("data/sco_input.wav", "data/sco_input_detected_frames.wav");
|
||||
process_wav_file_with_plc("data/sco_input.wav", "data/sco_input_after_plc.wav");
|
||||
process_wav_file_with_plc("data/sco_input_with_bad_frames.wav", "data/sco_input_with_bad_frames_after_plc.wav");
|
||||
mark_bad_frames_wav_file("results/sco_input.wav", "results/sco_input_detected_frames.wav");
|
||||
process_wav_file_with_plc("results/sco_input.wav", "results/sco_input_after_plc.wav");
|
||||
process_wav_file_with_plc("results/sco_input_with_bad_frames.wav", "results/sco_input_with_bad_frames_after_plc.wav");
|
||||
}
|
||||
|
||||
TEST(CVSD_PLC, TestFanfareFile){
|
||||
int corruption_step = 10;
|
||||
introduce_bad_frames_to_wav_file("data/input/fanfare_mono.wav", "data/fanfare_mono.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("data/fanfare_mono.wav", "data/fanfare_mono_with_bad_frames.wav", corruption_step);
|
||||
introduce_bad_frames_to_wav_file("data/input/fanfare_mono.wav", "results/fanfare_mono.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("results/fanfare_mono.wav", "results/fanfare_mono_with_bad_frames.wav", corruption_step);
|
||||
|
||||
mark_bad_frames_wav_file("data/fanfare_mono.wav", "data/fanfare_mono_detected_frames.wav");
|
||||
process_wav_file_with_plc("data/fanfare_mono.wav", "data/fanfare_mono_after_plc.wav");
|
||||
process_wav_file_with_plc("data/fanfare_mono_with_bad_frames.wav", "data/fanfare_mono_with_bad_frames_after_plc.wav");
|
||||
mark_bad_frames_wav_file("results/fanfare_mono.wav", "results/fanfare_mono_detected_frames.wav");
|
||||
process_wav_file_with_plc("results/fanfare_mono.wav", "results/fanfare_mono_after_plc.wav");
|
||||
process_wav_file_with_plc("results/fanfare_mono_with_bad_frames.wav", "results/fanfare_mono_with_bad_frames_after_plc.wav");
|
||||
}
|
||||
|
||||
TEST(CVSD_PLC, TestSineWave){
|
||||
int corruption_step = 10;
|
||||
create_sine_wav("data/sine_test.wav");
|
||||
introduce_bad_frames_to_wav_file("data/sine_test.wav", "data/sine_test_with_bad_frames.wav", corruption_step);
|
||||
create_sine_wav("results/sine_test.wav");
|
||||
introduce_bad_frames_to_wav_file("results/sine_test.wav", "results/sine_test_with_bad_frames.wav", corruption_step);
|
||||
|
||||
process_wav_file_with_plc("data/sine_test.wav", "data/sine_test_after_plc.wav");
|
||||
process_wav_file_with_plc("data/sine_test_with_bad_frames.wav", "data/sine_test_with_bad_frames_after_plc.wav");
|
||||
process_wav_file_with_plc("results/sine_test.wav", "results/sine_test_after_plc.wav");
|
||||
process_wav_file_with_plc("results/sine_test_with_bad_frames.wav", "results/sine_test_with_bad_frames_after_plc.wav");
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
|
Loading…
x
Reference in New Issue
Block a user