mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-05 21:59:45 +00:00
Merge branch 'develop' into a2dp
This commit is contained in:
commit
7568a9a4d3
@ -51,21 +51,24 @@
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_chipset_bcm.h"
|
||||
|
||||
#ifdef HAVE_POSIX_FILE_IO
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static int send_download_command;
|
||||
static uint32_t init_script_offset;
|
||||
|
||||
// Embedded == non posix systems
|
||||
|
||||
// actual init script provided by separate bt_firmware_image.c from WICED SDK
|
||||
extern const uint8_t brcm_patchram_buf[];
|
||||
extern const int brcm_patch_ram_length;
|
||||
extern const char brcm_patch_version[];
|
||||
|
||||
//
|
||||
static uint32_t init_script_offset;
|
||||
static int send_download_command;
|
||||
|
||||
static void chipset_init(const void * config){
|
||||
log_info("Broadcom init script %s, len %u", brcm_patch_version, brcm_patch_ram_length);
|
||||
init_script_offset = 0;
|
||||
send_download_command = 1;
|
||||
}
|
||||
|
||||
// @note: Broadcom chips require higher UART clock for baud rate > 3000000 -> limit baud rate in hci.c
|
||||
static void chipset_set_baudrate_command(uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
||||
hci_cmd_buffer[0] = 0x18;
|
||||
@ -84,6 +87,170 @@ static void chipset_set_bd_addr_command(bd_addr_t addr, uint8_t *hci_cmd_buffer)
|
||||
reverse_bd_addr(addr, &hci_cmd_buffer[3]);
|
||||
}
|
||||
|
||||
#ifdef HAVE_POSIX_FILE_IO
|
||||
|
||||
static const char * hcd_file_path;
|
||||
static const char * hcd_folder_path = ".";
|
||||
static int hcd_fd;
|
||||
static char matched_file[1000];
|
||||
|
||||
|
||||
static void chipset_init(const void * config){
|
||||
if (hcd_file_path){
|
||||
log_info("chipset-bcm: init file %s", hcd_file_path);
|
||||
} else {
|
||||
log_info("chipset-bcm: init folder %s", hcd_folder_path);
|
||||
}
|
||||
send_download_command = 1;
|
||||
init_script_offset = 0;
|
||||
hcd_fd = -1;
|
||||
}
|
||||
|
||||
static const uint8_t download_command[] = {0x2e, 0xfc, 0x00};
|
||||
|
||||
static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){
|
||||
if (hcd_fd < 0){
|
||||
log_info("chipset-bcm: open file %s", hcd_file_path);
|
||||
hcd_fd = open(hcd_file_path, O_RDONLY);
|
||||
if (hcd_fd < 0){
|
||||
log_error("chipset-bcm: can't open file %s", hcd_file_path);
|
||||
return BTSTACK_CHIPSET_DONE;
|
||||
}
|
||||
}
|
||||
|
||||
// send download firmware command
|
||||
if (send_download_command){
|
||||
send_download_command = 0;
|
||||
memcpy(hci_cmd_buffer, download_command, sizeof(download_command));
|
||||
return BTSTACK_CHIPSET_VALID_COMMAND;
|
||||
}
|
||||
|
||||
// read next command, but skip download command
|
||||
do {
|
||||
// read command
|
||||
int res = read(hcd_fd, hci_cmd_buffer, 3);
|
||||
if (res == 0){
|
||||
log_info("chipset-bcm: end of file, size %u", init_script_offset);
|
||||
close(hcd_fd);
|
||||
|
||||
// wait for firmware patch to be applied - shorter delay possible
|
||||
sleep(1);
|
||||
|
||||
return BTSTACK_CHIPSET_DONE;
|
||||
}
|
||||
if (res < 0){
|
||||
log_error("chipset-bcm: read error at %u", init_script_offset);
|
||||
return BTSTACK_CHIPSET_DONE;
|
||||
}
|
||||
init_script_offset += 3;
|
||||
|
||||
// read parameters
|
||||
int param_len = hci_cmd_buffer[2];
|
||||
if (param_len){
|
||||
res = read(hcd_fd, &hci_cmd_buffer[3], param_len);
|
||||
}
|
||||
if (res < 0){
|
||||
log_error("chipset-bcm: read error at %u", init_script_offset);
|
||||
return BTSTACK_CHIPSET_DONE;
|
||||
}
|
||||
init_script_offset += param_len;
|
||||
|
||||
} while (memcmp(hci_cmd_buffer, download_command, sizeof(download_command)) == 1);
|
||||
return BTSTACK_CHIPSET_VALID_COMMAND;
|
||||
}
|
||||
|
||||
void btstack_chipset_bcm_set_hcd_file_path(const char * path){
|
||||
hcd_file_path = path;
|
||||
}
|
||||
|
||||
void btstack_chipset_bcm_set_hcd_folder_path(const char * path){
|
||||
hcd_folder_path = path;
|
||||
}
|
||||
|
||||
static int equal_ignore_case(const char *str1, const char *str2){
|
||||
if (!str1 || !str2) return (1);
|
||||
int i = 0;
|
||||
while (1){
|
||||
if (!str1[i] && !str2[i]) return 1;
|
||||
if (tolower(str1[i]) != tolower(str2[i])) return 0;
|
||||
if (!str1[i] || !str2[i]) return 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// assumption starts with BCM or bcm
|
||||
#define MAX_DEVICE_NAME_LEN 15
|
||||
void btstack_chipset_bcm_set_device_name(const char * device_name){
|
||||
// ignore if file path already set
|
||||
if (hcd_file_path) {
|
||||
log_error("chipset-bcm: set device name called %s although path %s already set", device_name, hcd_file_path);
|
||||
return;
|
||||
}
|
||||
// construct filename for long variant
|
||||
if (strlen(device_name) > MAX_DEVICE_NAME_LEN){
|
||||
log_error("chipset-bcm: device name %s too long", device_name);
|
||||
return;
|
||||
}
|
||||
char filename_complete[MAX_DEVICE_NAME_LEN+5];
|
||||
strcpy(filename_complete, device_name);
|
||||
strcat(filename_complete, ".hcd");
|
||||
|
||||
// construct short variant without revision info
|
||||
char filename_short[MAX_DEVICE_NAME_LEN+5];
|
||||
strcpy(filename_short, device_name);
|
||||
int len = strlen(filename_short);
|
||||
while (len > 3){
|
||||
char c = filename_short[len-1];
|
||||
if (isdigit(c) == 0) break;
|
||||
len--;
|
||||
}
|
||||
if (len > 3){
|
||||
filename_short[len-1] = 0;
|
||||
}
|
||||
strcat(filename_short, ".hcd");
|
||||
log_info("chipset-bcm: looking for %s and %s", filename_short, filename_complete);
|
||||
|
||||
// find in folder
|
||||
DIR *dirp = opendir(hcd_folder_path);
|
||||
int match_short = 0;
|
||||
int match_complete = 0;
|
||||
if (!dirp){
|
||||
log_error("chipset-bcm: could not get directory for %s", hcd_folder_path);
|
||||
return;
|
||||
}
|
||||
while (1){
|
||||
struct dirent *dp = readdir(dirp);
|
||||
if (!dp) break;
|
||||
if (equal_ignore_case(filename_complete, dp->d_name)){
|
||||
match_complete = 1;
|
||||
continue;
|
||||
}
|
||||
if (equal_ignore_case(filename_short, dp->d_name)){
|
||||
match_short = 1;
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
if (match_complete){
|
||||
sprintf(matched_file, "%s/%s", hcd_folder_path, filename_complete);
|
||||
hcd_file_path = matched_file;
|
||||
return;
|
||||
}
|
||||
if (match_short){
|
||||
sprintf(matched_file, "%s/%s", hcd_folder_path, filename_short);
|
||||
hcd_file_path = matched_file;
|
||||
return;
|
||||
}
|
||||
log_error("chipset-bcm: could not find %s or %s, please provide .hcd file in %s", filename_complete, filename_short, hcd_folder_path);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void chipset_init(const void * config){
|
||||
log_info("chipset-bcm: init script %s, len %u", brcm_patch_version, brcm_patch_ram_length);
|
||||
init_script_offset = 0;
|
||||
send_download_command = 1;
|
||||
}
|
||||
|
||||
static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){
|
||||
// send download firmware command
|
||||
if (send_download_command){
|
||||
@ -103,6 +270,7 @@ static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){
|
||||
init_script_offset += cmd_len;
|
||||
return BTSTACK_CHIPSET_VALID_COMMAND;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
|
@ -52,6 +52,27 @@ extern "C" {
|
||||
|
||||
const btstack_chipset_t * btstack_chipset_bcm_instance(void);
|
||||
|
||||
|
||||
// Support for loading .hcd init files on POSIX systems
|
||||
|
||||
/**
|
||||
* @brief Set path to .hcd init file
|
||||
* @param path
|
||||
*/
|
||||
void btstack_chipset_bcm_set_hcd_file_path(const char * path);
|
||||
|
||||
/**
|
||||
* @brief Set folder to look for .hcd init files
|
||||
* @param path
|
||||
*/
|
||||
void btstack_chipset_bcm_set_hcd_folder_path(const char * path);
|
||||
|
||||
/**
|
||||
* @brief Look for .hcd init file based on device name
|
||||
* @param device_name e.g. BCM43430A1
|
||||
*/
|
||||
void btstack_chipset_bcm_set_device_name(const char * path);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -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
|
||||
|
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*
|
||||
|
@ -3,6 +3,7 @@ BTSTACK_ROOT = ../..
|
||||
|
||||
CORE += \
|
||||
bluetooth_init_cc2564B_1.4_BT_Spec_4.1.c \
|
||||
btstack_chipset_bcm.c \
|
||||
btstack_chipset_cc256x.c \
|
||||
btstack_chipset_csr.c \
|
||||
btstack_chipset_em9301.c \
|
||||
@ -16,7 +17,6 @@ CORE += \
|
||||
main.c \
|
||||
stdin_support.c \
|
||||
# bluetooth_init_cc2564_2.14.c \
|
||||
# btstack_chipset_bcm.c \
|
||||
|
||||
# TI-WL183x requires TIInit_11.8.32.c
|
||||
|
||||
|
@ -66,6 +66,8 @@
|
||||
#include "btstack_chipset_stlc2500d.h"
|
||||
#include "btstack_chipset_tc3566x.h"
|
||||
|
||||
int is_bcm;
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
@ -80,9 +82,24 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE) return;
|
||||
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) return;
|
||||
printf("BTstack up and running.\n");
|
||||
switch (hci_event_packet_get_type(packet)){
|
||||
case BTSTACK_EVENT_STATE:
|
||||
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
|
||||
printf("BTstack up and running.\n");
|
||||
break;
|
||||
case HCI_EVENT_COMMAND_COMPLETE:
|
||||
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_name)){
|
||||
// terminate, name 248 chars
|
||||
packet[6+248] = 0;
|
||||
printf("Local name: %s\n", &packet[6]);
|
||||
if (is_bcm){
|
||||
btstack_chipset_bcm_set_device_name((const char *)&packet[6]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sigint_handler(int param){
|
||||
@ -131,7 +148,7 @@ static void local_version_information_callback(uint8_t * packet){
|
||||
printf("- Manufacturer 0x%04x\n", manufacturer);
|
||||
switch (manufacturer){
|
||||
case COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
|
||||
printf("Cambridge Silicon Radio CSR chipset.\n");
|
||||
printf("Cambridge Silicon Radio - CSR chipset.\n");
|
||||
use_fast_uart();
|
||||
hci_set_chipset(btstack_chipset_csr_instance());
|
||||
break;
|
||||
@ -146,8 +163,9 @@ static void local_version_information_callback(uint8_t * packet){
|
||||
#endif
|
||||
break;
|
||||
case COMPANY_ID_BROADCOM_CORPORATION:
|
||||
printf("Broadcom chipset. Not supported yet\n");
|
||||
// hci_set_chipset(btstack_chipset_bcm_instance());
|
||||
printf("Broadcom - using BCM driver.\n");
|
||||
hci_set_chipset(btstack_chipset_bcm_instance());
|
||||
is_bcm = 1;
|
||||
break;
|
||||
case COMPANY_ID_ST_MICROELECTRONICS:
|
||||
printf("ST Microelectronics - using STLC2500d driver.\n");
|
||||
@ -159,7 +177,7 @@ static void local_version_information_callback(uint8_t * packet){
|
||||
hci_set_chipset(btstack_chipset_em9301_instance());
|
||||
break;
|
||||
case COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA:
|
||||
printf("Nordic Semicondutor ASA nRF5 chipset.\n");
|
||||
printf("Nordic Semiconductor nRF5 chipset.\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown manufacturer / manufacturer not supported yet.\n");
|
||||
@ -177,7 +195,7 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// pick serial port
|
||||
config.device_name = "/dev/tty.usbserial-A900K0VK";
|
||||
config.device_name = "/dev/tty.usbserial-A9GN71D5";
|
||||
|
||||
// init HCI
|
||||
const btstack_uart_block_t * uart_driver = btstack_uart_block_posix_instance();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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]){
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user