mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
classic: fix warnings in audio profiles
This commit is contained in:
parent
f785062493
commit
ab2445a020
@ -146,11 +146,11 @@ void a2dp_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
|
||||
|
||||
// 0x0100 "Service Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
|
||||
de_add_data(service, DE_STRING, strlen(service_name), (uint8_t *) service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(service_name), (uint8_t *) service_name);
|
||||
|
||||
// 0x0100 "Provider Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0102);
|
||||
de_add_data(service, DE_STRING, strlen(service_provider_name), (uint8_t *) service_provider_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t)strlen(service_provider_name), (uint8_t *) service_provider_name);
|
||||
|
||||
// 0x0311 "Supported Features"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0311);
|
||||
|
@ -69,12 +69,12 @@ static uint16_t avdtp_sdp_query_context_avdtp_cid = 0;
|
||||
|
||||
// registered stream endpoints
|
||||
static btstack_linked_list_t avdtp_stream_endpoints;
|
||||
static uint16_t avdtp_stream_endpoints_id_counter = 0;
|
||||
static uint8_t avdtp_stream_endpoints_id_counter = 0;
|
||||
|
||||
static bool avdtp_l2cap_registered;
|
||||
|
||||
static btstack_linked_list_t avdtp_connections;
|
||||
static uint16_t avdtp_transaction_id_counter = 0;
|
||||
static uint8_t avdtp_transaction_id_counter = 0;
|
||||
|
||||
static int avdtp_record_id;
|
||||
static uint8_t avdtp_attribute_value[45];
|
||||
@ -227,7 +227,7 @@ static avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_signaling_cid(uin
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t avdtp_get_next_transaction_label(void){
|
||||
uint8_t avdtp_get_next_transaction_label(void){
|
||||
avdtp_transaction_id_counter++;
|
||||
if (avdtp_transaction_id_counter == 16){
|
||||
avdtp_transaction_id_counter = 1;
|
||||
@ -261,8 +261,9 @@ static uint16_t avdtp_get_next_cid(void){
|
||||
return avdtp_cid_counter;
|
||||
}
|
||||
|
||||
static uint16_t avdtp_get_next_local_seid(void){
|
||||
if (avdtp_stream_endpoints_id_counter == 0xffff) {
|
||||
// Stream Endpoint Identifier are 6-bit
|
||||
static uint8_t avdtp_get_next_local_seid(void){
|
||||
if (avdtp_stream_endpoints_id_counter >= 0x3f) {
|
||||
avdtp_stream_endpoints_id_counter = 1;
|
||||
} else {
|
||||
avdtp_stream_endpoints_id_counter++;
|
||||
|
@ -450,7 +450,7 @@ typedef struct {
|
||||
uint16_t offset;
|
||||
uint8_t acp_seid;
|
||||
uint8_t int_seid;
|
||||
uint16_t transaction_label;
|
||||
uint8_t transaction_label;
|
||||
uint16_t num_packets;
|
||||
avdtp_signal_identifier_t signal_identifier;
|
||||
avdtp_message_type_t message_type;
|
||||
@ -683,7 +683,7 @@ uint8_t avdtp_stream_endpoint_seid(avdtp_stream_endpoint_t * stream_endpoint);
|
||||
|
||||
uint8_t is_avdtp_remote_seid_registered(avdtp_stream_endpoint_t * stream_endpoint);
|
||||
|
||||
uint16_t avdtp_get_next_transaction_label(void);
|
||||
uint8_t avdtp_get_next_transaction_label(void);
|
||||
|
||||
#ifdef ENABLE_AVDTP_ACCEPTOR_EXPLICIT_START_STREAM_CONFIRMATION
|
||||
uint8_t avdtp_start_stream_accept(uint16_t avdtp_cid, uint8_t local_seid);
|
||||
|
@ -707,7 +707,7 @@ static void avdtp_signaling_emit_media_codec_atrac_capability(uint16_t avdtp_cid
|
||||
|
||||
uint8_t version = media_codec_information[0] >> 5;
|
||||
uint8_t channel_mode_bitmap = (media_codec_information[0] >> 2) & 0x07;
|
||||
uint16_t sampling_frequency_bitmap = (media_codec_information[1] >> 4) & 0x03;
|
||||
uint8_t sampling_frequency_bitmap = (media_codec_information[1] >> 4) & 0x03;
|
||||
uint8_t vbr = (media_codec_information[1] >> 3) & 0x01;
|
||||
uint16_t bit_rate_index_bitmap = ((media_codec_information[1]) & 0x07) << 16 | (media_codec_information[2] << 8) | media_codec_information[3];
|
||||
uint16_t maximum_sul = (media_codec_information[4] << 8) | media_codec_information[5];
|
||||
|
@ -308,24 +308,24 @@ void avrcp_create_sdp_record(uint8_t controller, uint8_t * service, uint32_t ser
|
||||
// 0x0100 "Service Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
|
||||
if (service_name){
|
||||
de_add_data(service, DE_STRING, strlen(service_name), (uint8_t *) service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(service_name), (uint8_t *) service_name);
|
||||
} else {
|
||||
if (controller){
|
||||
de_add_data(service, DE_STRING, strlen(avrcp_default_controller_service_name), (uint8_t *) avrcp_default_controller_service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(avrcp_default_controller_service_name), (uint8_t *) avrcp_default_controller_service_name);
|
||||
} else {
|
||||
de_add_data(service, DE_STRING, strlen(avrcp_defaul_target_service_name), (uint8_t *) avrcp_defaul_target_service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(avrcp_defaul_target_service_name), (uint8_t *) avrcp_defaul_target_service_name);
|
||||
}
|
||||
}
|
||||
|
||||
// 0x0100 "Provider Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0102);
|
||||
if (service_provider_name){
|
||||
de_add_data(service, DE_STRING, strlen(service_provider_name), (uint8_t *) service_provider_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(service_provider_name), (uint8_t *) service_provider_name);
|
||||
} else {
|
||||
if (controller){
|
||||
de_add_data(service, DE_STRING, strlen(avrcp_default_controller_service_provider_name), (uint8_t *) avrcp_default_controller_service_provider_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(avrcp_default_controller_service_provider_name), (uint8_t *) avrcp_default_controller_service_provider_name);
|
||||
} else {
|
||||
de_add_data(service, DE_STRING, strlen(avrcp_default_target_service_provider_name), (uint8_t *) avrcp_default_target_service_provider_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(avrcp_default_target_service_provider_name), (uint8_t *) avrcp_default_target_service_provider_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,8 +595,8 @@ typedef struct {
|
||||
|
||||
// target only
|
||||
// PID check
|
||||
bool target_reject_transport_header;
|
||||
uint8_t target_invalid_pid;
|
||||
bool target_reject_transport_header;
|
||||
uint16_t target_invalid_pid;
|
||||
|
||||
uint8_t target_notifications_transaction_label[AVRCP_NOTIFICATION_EVENT_MAX_VALUE + 1];
|
||||
|
||||
|
@ -270,7 +270,8 @@ uint8_t avrcp_browsing_target_send_get_folder_items_response(uint16_t avrcp_brow
|
||||
}
|
||||
(void)memcpy(&connection->cmd_operands[pos], attr_list, attr_list_size);
|
||||
pos += attr_list_size;
|
||||
connection->cmd_operands_length = pos;
|
||||
btstack_assert(pos <= 255);
|
||||
connection->cmd_operands_length = (uint8_t) pos;
|
||||
|
||||
connection->state = AVCTP_W2_SEND_RESPONSE;
|
||||
avrcp_browsing_request_can_send_now(connection, connection->l2cap_browsing_cid);
|
||||
@ -316,7 +317,8 @@ uint8_t avrcp_browsing_target_send_accept_set_browsed_player(uint16_t avrcp_brow
|
||||
|
||||
(void)memcpy(&connection->cmd_operands[pos], response, response_size);
|
||||
pos += response_size;
|
||||
connection->cmd_operands_length = pos;
|
||||
btstack_assert(pos <= 255);
|
||||
connection->cmd_operands_length = (uint8_t) pos;
|
||||
|
||||
connection->state = AVCTP_W2_SEND_RESPONSE;
|
||||
avrcp_browsing_request_can_send_now(connection, connection->l2cap_browsing_cid);
|
||||
|
@ -123,7 +123,7 @@ static int avrcp_controller_supports_browsing(uint16_t controller_supported_feat
|
||||
return controller_supported_features & AVRCP_FEATURE_MASK_BROWSING;
|
||||
}
|
||||
|
||||
static void avrcp_controller_prepare_custom_command_response(avrcp_connection_t * connection, uint8_t response_len, uint8_t * in_place_buffer){
|
||||
static void avrcp_controller_prepare_custom_command_response(avrcp_connection_t * connection, uint16_t response_len, uint8_t * in_place_buffer){
|
||||
uint8_t pos = 0;
|
||||
in_place_buffer[pos++] = HCI_EVENT_AVRCP_META;
|
||||
// skip len
|
||||
@ -381,12 +381,12 @@ static void avrcp_controller_emit_now_playing_info_event_done(btstack_packet_han
|
||||
|
||||
static void avrcp_controller_emit_now_playing_info_event(btstack_packet_handler_t callback, uint16_t avrcp_cid, uint8_t ctype, avrcp_media_attribute_id_t attr_id, uint8_t * value, uint16_t value_len){
|
||||
uint8_t event[HCI_EVENT_BUFFER_SIZE];
|
||||
int pos = 0;
|
||||
uint16_t pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVRCP_META;
|
||||
// reserve one byte for subevent type and data len
|
||||
int data_len_pos = pos;
|
||||
uint16_t data_len_pos = pos;
|
||||
pos++;
|
||||
int subevent_type_pos = pos;
|
||||
uint16_t subevent_type_pos = pos;
|
||||
pos++;
|
||||
little_endian_store_16(event, pos, avrcp_cid);
|
||||
pos += 2;
|
||||
@ -395,22 +395,26 @@ static void avrcp_controller_emit_now_playing_info_event(btstack_packet_handler_
|
||||
switch (attr_id){
|
||||
case AVRCP_MEDIA_ATTR_TITLE:
|
||||
event[subevent_type_pos] = AVRCP_SUBEVENT_NOW_PLAYING_TITLE_INFO;
|
||||
event[pos++] = value_len;
|
||||
btstack_assert(value_len <= 255);
|
||||
event[pos++] = (uint8_t) value_len;
|
||||
(void)memcpy(event + pos, value, value_len);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_ARTIST:
|
||||
event[subevent_type_pos] = AVRCP_SUBEVENT_NOW_PLAYING_ARTIST_INFO;
|
||||
event[pos++] = value_len;
|
||||
btstack_assert(value_len <= 255);
|
||||
event[pos++] = (uint8_t) value_len;
|
||||
(void)memcpy(event + pos, value, value_len);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_ALBUM:
|
||||
event[subevent_type_pos] = AVRCP_SUBEVENT_NOW_PLAYING_ALBUM_INFO;
|
||||
event[pos++] = value_len;
|
||||
btstack_assert(value_len <= 255);
|
||||
event[pos++] = (uint8_t) value_len;
|
||||
(void)memcpy(event + pos, value, value_len);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_GENRE:
|
||||
event[subevent_type_pos] = AVRCP_SUBEVENT_NOW_PLAYING_GENRE_INFO;
|
||||
event[pos++] = value_len;
|
||||
btstack_assert(value_len <= 255);
|
||||
event[pos++] = (uint8_t) value_len;
|
||||
(void)memcpy(event + pos, value, value_len);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_SONG_LENGTH_MS:
|
||||
@ -570,7 +574,8 @@ static void avrcp_send_cmd_with_avctp_fragmentation(avrcp_connection_t * connect
|
||||
uint16_t num_payload_bytes = param_len - max_payload_size;
|
||||
uint16_t frame_size_for_continue_packet = max_frame_size - avctp_get_num_bytes_for_header(AVCTP_CONTINUE_PACKET);
|
||||
uint16_t num_avctp_packets = (num_payload_bytes + frame_size_for_continue_packet - 1)/frame_size_for_continue_packet + 1;
|
||||
packet[pos++] = num_avctp_packets;
|
||||
btstack_assert(num_avctp_packets <= 255);
|
||||
packet[pos++] = (uint8_t) num_avctp_packets;
|
||||
}
|
||||
|
||||
switch (connection->avctp_packet_type){
|
||||
@ -687,7 +692,9 @@ static uint8_t avrcp_controller_request_pass_through_release_control_cmd(avrcp_c
|
||||
}
|
||||
|
||||
static uint8_t avrcp_controller_request_pass_through_press_control_cmd(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint16_t playback_speed, bool continuous_cmd){
|
||||
log_info("Send command %d", opid);
|
||||
UNUSED(playback_speed);
|
||||
|
||||
log_info("Send command %d", opid);
|
||||
avrcp_connection_t * connection = avrcp_get_connection_for_avrcp_cid_for_role(AVRCP_CONTROLLER, avrcp_cid);
|
||||
if (!connection){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
@ -699,11 +706,6 @@ static uint8_t avrcp_controller_request_pass_through_press_control_cmd(uint16_t
|
||||
}
|
||||
connection->state = AVCTP_W2_SEND_PRESS_COMMAND;
|
||||
avrcp_controller_pass_through_command_data_init(connection, opid);
|
||||
|
||||
if (playback_speed > 0){
|
||||
connection->data[0] = playback_speed;
|
||||
connection->data_len = 1;
|
||||
}
|
||||
|
||||
connection->controller_press_and_hold_cmd_active = continuous_cmd;
|
||||
if (connection->controller_press_and_hold_cmd_active){
|
||||
@ -1093,7 +1095,7 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
|
||||
for (i = (uint8_t)AVRCP_NOTIFICATION_EVENT_FIRST_INDEX; i < (uint8_t) AVRCP_NOTIFICATION_EVENT_LAST_INDEX; i++){
|
||||
if ((connection->controller_notifications_to_register & (1 << i)) != 0){
|
||||
if ((connection->notifications_supported_by_target & (1 << i)) == 0){
|
||||
avrcp_controller_emit_notification_complete(connection, ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE, i, false);
|
||||
avrcp_controller_emit_notification_complete(connection, ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE, (uint8_t) i, false);
|
||||
connection->controller_notifications_to_register &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
|
@ -136,13 +136,13 @@ static uint16_t avrcp_now_playing_info_attr_id_value_len(avrcp_connection_t * co
|
||||
case AVRCP_MEDIA_ATTR_NONE:
|
||||
return 0;
|
||||
case AVRCP_MEDIA_ATTR_TRACK:
|
||||
str_len = sprintf(buffer, "%0" PRIu32, connection->target_track_nr);
|
||||
str_len = snprintf(buffer, sizeof(buffer), "%" PRIu32, connection->target_track_nr);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_TOTAL_NUM_ITEMS:
|
||||
str_len = sprintf(buffer, "%0" PRIu32, connection->target_total_tracks);
|
||||
str_len = snprintf(buffer, sizeof(buffer), "%" PRIu32, connection->target_total_tracks);
|
||||
break;
|
||||
case AVRCP_MEDIA_ATTR_SONG_LENGTH_MS:
|
||||
str_len = sprintf(buffer, "%0" PRIu32, connection->target_song_length_ms);
|
||||
str_len = snprintf(buffer, sizeof(buffer), "%" PRIu32, connection->target_song_length_ms);
|
||||
break;
|
||||
default:
|
||||
str_len = connection->target_now_playing_info[(uint16_t)attr_id - 1].len;
|
||||
@ -181,7 +181,8 @@ static uint8_t * avrcp_get_attribute_value_from_u32(avrcp_connection_t * connect
|
||||
*num_bytes_to_copy = 0;
|
||||
|
||||
if (connection->attribute_value_len == 0){
|
||||
connection->attribute_value_len = sprintf((char *)connection->attribute_value, "%0" PRIu32, value);
|
||||
// "4294967296" = 10 chars + \0
|
||||
connection->attribute_value_len = snprintf((char *)connection->attribute_value, 11, "%" PRIu32, value);
|
||||
connection->attribute_value_offset = 0;
|
||||
}
|
||||
*num_bytes_to_copy = connection->attribute_value_len - connection->attribute_value_offset;
|
||||
@ -292,7 +293,8 @@ static void avrcp_send_response_with_avctp_fragmentation(avrcp_connection_t * co
|
||||
uint16_t num_payload_bytes = param_len - max_payload_size;
|
||||
uint16_t frame_size_for_continue_packet = max_frame_size - avctp_get_num_bytes_for_header(AVCTP_CONTINUE_PACKET);
|
||||
uint16_t num_avctp_packets = (num_payload_bytes + frame_size_for_continue_packet - 1)/frame_size_for_continue_packet + 1;
|
||||
packet[pos++] = num_avctp_packets;
|
||||
btstack_assert(num_avctp_packets <= 255);
|
||||
packet[pos++] = (uint8_t) num_avctp_packets;
|
||||
}
|
||||
|
||||
uint16_t bytes_stored = 0;
|
||||
@ -727,8 +729,10 @@ uint8_t avrcp_target_play_status(uint16_t avrcp_cid, uint32_t song_length_ms, ui
|
||||
static uint8_t avrcp_target_store_media_attr(avrcp_connection_t * connection, avrcp_media_attribute_id_t attr_id, const char * value){
|
||||
int index = attr_id - 1;
|
||||
if (!value) return AVRCP_STATUS_INVALID_PARAMETER;
|
||||
connection->target_now_playing_info[index].value = (uint8_t*)value;
|
||||
connection->target_now_playing_info[index].len = strlen(value);
|
||||
uint16_t value_len = (uint16_t)strlen(value);
|
||||
btstack_assert(value_len <= 255);
|
||||
connection->target_now_playing_info[index].value = (uint8_t*)value;
|
||||
connection->target_now_playing_info[index].len = value_len;
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ const char * hfp_ag_feature(int index){
|
||||
int send_str_over_rfcomm(uint16_t cid, char * command){
|
||||
if (!rfcomm_can_send_packet_now(cid)) return 1;
|
||||
log_info("HFP_TX %s", command);
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, strlen(command));
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, (uint16_t) strlen(command));
|
||||
if (err){
|
||||
log_error("rfcomm_send -> error 0x%02x \n", err);
|
||||
}
|
||||
@ -473,7 +473,7 @@ void hfp_emit_string_event(hfp_connection_t * hfp_connection, uint8_t event_subt
|
||||
#else
|
||||
uint8_t event[40];
|
||||
#endif
|
||||
uint16_t string_len = btstack_min(strlen(value), sizeof(event) - 6);
|
||||
uint16_t string_len = btstack_min((uint16_t) strlen(value), sizeof(event) - 6);
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = 4 + string_len;
|
||||
event[2] = event_subtype;
|
||||
@ -699,7 +699,7 @@ void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, ui
|
||||
|
||||
// 0x0100 "Service Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
|
||||
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(name), (uint8_t *) name);
|
||||
}
|
||||
|
||||
static void hfp_handle_slc_setup_error(hfp_connection_t * hfp_connection, uint8_t status){
|
||||
@ -1583,7 +1583,7 @@ static void parse_sequence(hfp_connection_t * hfp_connection){
|
||||
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)btstack_atoi((char*)hfp_connection->line_buffer);
|
||||
hfp_connection->remote_codecs[hfp_connection->parser_item_index] = (uint8_t)btstack_atoi((char*)hfp_connection->line_buffer);
|
||||
hfp_next_codec_index(hfp_connection);
|
||||
hfp_connection->remote_codecs_nr = hfp_connection->parser_item_index;
|
||||
break;
|
||||
|
@ -544,7 +544,7 @@ typedef struct hfp_connection {
|
||||
bd_addr_t remote_addr;
|
||||
hci_con_handle_t acl_handle;
|
||||
hci_con_handle_t sco_handle;
|
||||
uint16_t rfcomm_channel_nr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t rfcomm_cid;
|
||||
uint16_t rfcomm_mtu;
|
||||
|
||||
|
@ -307,7 +307,7 @@ static int hfp_ag_indicators_cmd_generator_num_segments(hfp_connection_t * hfp_c
|
||||
// get size of individual segment for hfp_ag_retrieve_indicators_cmd
|
||||
static int hfp_ag_indicators_cmd_generator_get_segment_len(hfp_connection_t * hfp_connection, int index){
|
||||
if (index == 0) {
|
||||
return strlen(HFP_INDICATOR) + 3; // "\n\r%s:""
|
||||
return (uint16_t) strlen(HFP_INDICATOR) + 3; // "\n\r%s:""
|
||||
}
|
||||
index--;
|
||||
int num_indicators = hfp_ag_get_ag_indicators_nr(hfp_connection);
|
||||
@ -325,7 +325,7 @@ static void hfp_ag_indicators_cmd_generator_store_segment(hfp_connection_t * hfp
|
||||
if (index == 0){
|
||||
*buffer++ = '\r';
|
||||
*buffer++ = '\n';
|
||||
int len = strlen(HFP_INDICATOR);
|
||||
int len = (uint16_t) strlen(HFP_INDICATOR);
|
||||
(void)memcpy(buffer, HFP_INDICATOR, len);
|
||||
buffer += len;
|
||||
*buffer++ = ':';
|
||||
@ -2583,7 +2583,7 @@ void hfp_ag_init_call_hold_services(int call_hold_services_nr, const char * call
|
||||
}
|
||||
|
||||
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr){
|
||||
void hfp_ag_init(uint8_t rfcomm_channel_nr){
|
||||
|
||||
hfp_init();
|
||||
hfp_ag_call_hold_services_nr = 0;
|
||||
@ -3006,7 +3006,7 @@ uint8_t hfp_ag_enhanced_voice_recognition_send_message(hci_con_handle_t acl_hand
|
||||
return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
|
||||
}
|
||||
|
||||
uint16_t message_len = strlen(msg.text);
|
||||
uint16_t message_len = (uint16_t) strlen(msg.text);
|
||||
|
||||
if (message_len > HFP_MAX_VR_TEXT_SIZE){
|
||||
return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
|
||||
|
@ -73,7 +73,7 @@ void hfp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
|
||||
* @brief Set up HFP Audio Gateway (AG) device without additional supported features.
|
||||
* @param rfcomm_channel_nr
|
||||
*/
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr);
|
||||
void hfp_ag_init(uint8_t rfcomm_channel_nr);
|
||||
|
||||
/**
|
||||
* @brief Set codecs.
|
||||
|
@ -140,7 +140,7 @@ static hfp_connection_t * get_hfp_hf_connection_context_for_acl_handle(uint16_t
|
||||
|
||||
static void hfp_hf_emit_subscriber_information(const hfp_connection_t * hfp_connection, uint8_t status){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
|
||||
uint16_t bnip_number_len = btstack_min((uint16_t) strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
|
||||
uint8_t event[7 + sizeof(hfp_connection->bnip_number)];
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = 6 + bnip_number_len;
|
||||
@ -155,10 +155,10 @@ static void hfp_hf_emit_subscriber_information(const hfp_connection_t * hfp_conn
|
||||
|
||||
static void hfp_hf_emit_type_number_alpha(const hfp_connection_t * hfp_connection, uint8_t event_subtype){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
uint16_t bnip_number_len = btstack_min(strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
|
||||
uint16_t bnip_number_len = btstack_min((uint16_t) strlen(hfp_connection->bnip_number), sizeof(hfp_connection->bnip_number)-1);
|
||||
// 10 fixed - 1 (bnip_number_len <= sizeof(hfp_connection->bnip_number)-1) + 1 (trailing \0 for line buffer)
|
||||
uint8_t event[10 + sizeof(hfp_connection->bnip_number) + sizeof(hfp_connection->line_buffer)];
|
||||
uint8_t alpha_len = hfp_connection->clip_have_alpha ? strlen((const char *) hfp_connection->line_buffer) : 0;
|
||||
uint8_t alpha_len = hfp_connection->clip_have_alpha ? (uint16_t) strlen((const char *) hfp_connection->line_buffer) : 0;
|
||||
uint8_t pos = 0;
|
||||
event[pos++] = HCI_EVENT_HFP_META;
|
||||
event[pos++] = 8 + bnip_number_len + alpha_len;
|
||||
@ -180,7 +180,7 @@ static void hfp_hf_emit_type_number_alpha(const hfp_connection_t * hfp_connectio
|
||||
static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connection){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
|
||||
uint16_t bnip_number_len = strlen((const char *) hfp_connection->bnip_number);
|
||||
uint16_t bnip_number_len = (uint16_t) strlen((const char *) hfp_connection->bnip_number);
|
||||
uint8_t event[11 + HFP_BNEP_NUM_MAX_SIZE];
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = 10 + bnip_number_len + 1;
|
||||
@ -200,7 +200,7 @@ static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connec
|
||||
static void hfp_emit_ag_indicator_mapping_event(const hfp_connection_t * hfp_connection, const hfp_ag_indicator_t * indicator){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
uint8_t event[8 + HFP_MAX_INDICATOR_DESC_SIZE];
|
||||
uint16_t indicator_len = btstack_min(strlen(indicator->name), HFP_MAX_INDICATOR_DESC_SIZE-1);
|
||||
uint16_t indicator_len = btstack_min((uint16_t) strlen(indicator->name), HFP_MAX_INDICATOR_DESC_SIZE-1);
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = 7 + indicator_len;
|
||||
event[2] = HFP_SUBEVENT_AG_INDICATOR_MAPPING;
|
||||
@ -216,7 +216,7 @@ static void hfp_emit_ag_indicator_mapping_event(const hfp_connection_t * hfp_con
|
||||
static void hfp_emit_ag_indicator_status_event(const hfp_connection_t * hfp_connection, const hfp_ag_indicator_t * indicator){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
uint8_t event[12+HFP_MAX_INDICATOR_DESC_SIZE];
|
||||
uint16_t indicator_len = btstack_min(strlen(indicator->name), HFP_MAX_INDICATOR_DESC_SIZE-1);
|
||||
uint16_t indicator_len = btstack_min((uint16_t) strlen(indicator->name), HFP_MAX_INDICATOR_DESC_SIZE-1);
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = 11 + indicator_len;
|
||||
event[2] = HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED;
|
||||
@ -235,7 +235,7 @@ static void hfp_emit_ag_indicator_status_event(const hfp_connection_t * hfp_conn
|
||||
|
||||
static void hfp_emit_network_operator_event(const hfp_connection_t * hfp_connection){
|
||||
if (hfp_hf_callback == NULL) return;
|
||||
uint16_t operator_len = btstack_min(strlen(hfp_connection->network_operator.name), HFP_MAX_NETWORK_OPERATOR_NAME_SIZE-1);
|
||||
uint16_t operator_len = btstack_min((uint16_t) strlen(hfp_connection->network_operator.name), HFP_MAX_NETWORK_OPERATOR_NAME_SIZE-1);
|
||||
uint8_t event[7+HFP_MAX_NETWORK_OPERATOR_NAME_SIZE];
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = sizeof(event) - 2;
|
||||
@ -1473,7 +1473,7 @@ static void hfp_hf_set_defaults(void){
|
||||
hfp_hf_indicators_nr = 0;
|
||||
}
|
||||
|
||||
uint8_t hfp_hf_init(uint16_t rfcomm_channel_nr){
|
||||
uint8_t hfp_hf_init(uint8_t rfcomm_channel_nr){
|
||||
uint8_t status = rfcomm_register_service(hfp_hf_rfcomm_packet_handler, rfcomm_channel_nr, 0xffff);
|
||||
if (status != ERROR_CODE_SUCCESS){
|
||||
return status;
|
||||
@ -1519,7 +1519,7 @@ void hfp_hf_init_hf_indicators(int indicators_nr, const uint16_t * indicators){
|
||||
hfp_hf_indicators_nr = indicators_nr;
|
||||
int i;
|
||||
for (i = 0; i < hfp_hf_indicators_nr ; i++){
|
||||
hfp_hf_indicators[i] = indicators[i];
|
||||
hfp_hf_indicators[i] = (uint8_t) indicators[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
|
||||
* - RFCOMM_SERVICE_ALREADY_REGISTERED or
|
||||
* - BTSTACK_MEMORY_ALLOC_FAILED if allocation of any of RFCOMM or L2CAP services failed
|
||||
*/
|
||||
uint8_t hfp_hf_init(uint16_t rfcomm_channel_nr);
|
||||
uint8_t hfp_hf_init(uint8_t rfcomm_channel_nr);
|
||||
|
||||
/**
|
||||
* @brief Set codecs.
|
||||
|
@ -260,14 +260,14 @@ void hsp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle,
|
||||
// 0x0100 "Service Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
|
||||
if (name){
|
||||
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(name), (uint8_t *) name);
|
||||
} else {
|
||||
de_add_data(service, DE_STRING, strlen(hsp_ag_default_service_name), (uint8_t *) hsp_ag_default_service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(hsp_ag_default_service_name), (uint8_t *) hsp_ag_default_service_name);
|
||||
}
|
||||
}
|
||||
|
||||
static int hsp_ag_send_str_over_rfcomm(const uint16_t cid, const char * command){
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, strlen(command));
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, (uint16_t) strlen(command));
|
||||
if (err){
|
||||
log_error("rfcomm_send_internal -> error 0X%02x", err);
|
||||
return err;
|
||||
@ -585,13 +585,14 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
} else if (strncmp((char *)packet, "AT+", 3) == 0){
|
||||
hsp_ag_send_error = 1;
|
||||
if (!hsp_ag_callback) return;
|
||||
if ((size + 4) > 255) return;
|
||||
// re-use incoming buffer to avoid reserving buffers/memcpy - ugly but efficient
|
||||
uint8_t * event = packet - 6;
|
||||
uint8_t * event = packet - 6;
|
||||
event[0] = HCI_EVENT_HSP_META;
|
||||
event[1] = size + 4;
|
||||
event[1] = (uint8_t) (size + 4);
|
||||
event[2] = HSP_SUBEVENT_HS_COMMAND;
|
||||
little_endian_store_16(event, 3, hsp_ag_rfcomm_handle);
|
||||
event[5] = size;
|
||||
event[5] = (uint8_t) size;
|
||||
(*hsp_ag_callback)(HCI_EVENT_PACKET, 0, event, size+6);
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ static void emit_event_audio_disconnected(uint16_t sco_handle){
|
||||
|
||||
static int hsp_hs_send_str_over_rfcomm(uint16_t cid, const char * command){
|
||||
if (!rfcomm_can_send_packet_now(hsp_hs_rfcomm_cid)) return 1;
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, strlen(command));
|
||||
int err = rfcomm_send(cid, (uint8_t*) command, (uint16_t) strlen(command));
|
||||
if (err){
|
||||
log_info("rfcomm_send_internal -> error 0X%02x", err);
|
||||
}
|
||||
@ -281,9 +281,9 @@ void hsp_hs_create_sdp_record(uint8_t * service, uint32_t service_record_handle
|
||||
// 0x0100 "Service Name"
|
||||
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
|
||||
if (name){
|
||||
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(name), (uint8_t *) name);
|
||||
} else {
|
||||
de_add_data(service, DE_STRING, strlen(hsp_hs_default_service_name), (uint8_t *) hsp_hs_default_service_name);
|
||||
de_add_data(service, DE_STRING, (uint16_t) strlen(hsp_hs_default_service_name), (uint8_t *) hsp_hs_default_service_name);
|
||||
}
|
||||
|
||||
// Remote audio volume control
|
||||
@ -550,15 +550,16 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
while ((size > 0) && ((packet[size-1] == '\n') || (packet[size-1] == '\r'))){
|
||||
size--;
|
||||
}
|
||||
if ((size + 4) > 255) return;
|
||||
// add trailing \0
|
||||
packet[size] = 0;
|
||||
// re-use incoming buffer to avoid reserving buffers/memcpy - ugly but efficient
|
||||
uint8_t * event = packet - 6;
|
||||
event[0] = HCI_EVENT_HSP_META;
|
||||
event[1] = size + 4;
|
||||
event[1] = (uint8_t) (size + 4);
|
||||
event[2] = HSP_SUBEVENT_AG_INDICATION;
|
||||
little_endian_store_16(event, 3, hsp_hs_rfcomm_handle);
|
||||
event[5] = size;
|
||||
event[5] = (uint8_t) size;
|
||||
(*hsp_hs_callback)(HCI_EVENT_PACKET, 0, event, size+6);
|
||||
}
|
||||
hsp_run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user