diff --git a/src/ble/gatt-service/audio_input_control_service_server.c b/src/ble/gatt-service/audio_input_control_service_server.c index 1c84ab59f..c53a40683 100644 --- a/src/ble/gatt-service/audio_input_control_service_server.c +++ b/src/ble/gatt-service/audio_input_control_service_server.c @@ -360,7 +360,7 @@ static int aics_write_callback(hci_con_handle_t con_handle, uint16_t attribute_h if (attribute_handle == aics->audio_input_description_value_handle){ btstack_strcpy(aics->info->audio_input_description, AICS_MAX_AUDIO_INPUT_DESCRIPTION_LENGTH, (char *)buffer); - aics->audio_input_description_len = strlen(aics->info->audio_input_description); + aics->audio_input_description_len = (uint8_t) strlen(aics->info->audio_input_description); aics_emit_audio_input_description(aics); audio_input_control_service_server_set_callback(aics, AICS_TASK_SEND_AUDIO_INPUT_DESCRIPTION); } @@ -485,7 +485,7 @@ void audio_input_control_service_server_set_audio_input_status(audio_input_contr void audio_input_control_service_server_set_audio_input_description(audio_input_control_service_server_t * aics, const char * audio_input_desc){ btstack_assert(aics != NULL); btstack_strcpy(aics->info->audio_input_description, AICS_MAX_AUDIO_INPUT_DESCRIPTION_LENGTH, (char *)audio_input_desc); - aics->audio_input_description_len = strlen(aics->info->audio_input_description); + aics->audio_input_description_len = (uint8_t) strlen(aics->info->audio_input_description); audio_input_control_service_server_set_callback(aics, AICS_TASK_SEND_AUDIO_INPUT_DESCRIPTION); } diff --git a/src/ble/gatt-service/cycling_power_service_server.c b/src/ble/gatt-service/cycling_power_service_server.c index e6af9d9a2..9ddd7e39c 100644 --- a/src/ble/gatt-service/cycling_power_service_server.c +++ b/src/ble/gatt-service/cycling_power_service_server.c @@ -633,15 +633,14 @@ static void cycling_power_service_response_can_send_now(void * context){ } if (calibrated_value == CP_CALIBRATION_STATUS_INCORRECT_CALIBRATION_POSITION){ - value[pos++] = calibrated_value; + value[pos++] = (uint8_t) calibrated_value; // do not include manufacturer ID and data break; } else if (calibrated_value == CP_CALIBRATION_STATUS_MANUFACTURER_SPECIFIC_ERROR_FOLLOWS){ - value[pos++] = calibrated_value; + value[pos++] = (uint8_t) calibrated_value; } else { little_endian_store_16(value, pos, calibrated_value); pos += 2; - } if (instance->request_opcode == CP_OPCODE_START_OFFSET_COMPENSATION) break; @@ -1077,8 +1076,9 @@ void cycling_power_service_server_add_wheel_revolution(int32_t wheel_revolution, cycling_power_t * instance = &cycling_power; instance->last_wheel_event_time_s = wheel_event_time_s; if (wheel_revolution < 0){ - if (instance->cumulative_wheel_revolutions > -wheel_revolution){ - instance->cumulative_wheel_revolutions += wheel_revolution; + uint32_t wheel_revolution_to_subtract = (uint32_t) (-wheel_revolution); + if (instance->cumulative_wheel_revolutions > wheel_revolution_to_subtract){ + instance->cumulative_wheel_revolutions -= wheel_revolution_to_subtract; } else { instance->cumulative_wheel_revolutions = 0; } diff --git a/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c b/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c index 1fbe0ee71..5deaf494e 100644 --- a/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c +++ b/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c @@ -326,8 +326,9 @@ void cycling_speed_and_cadence_service_server_init(uint32_t supported_sensor_loc static void cycling_speed_and_cadence_service_calculate_cumulative_wheel_revolutions(int32_t revolutions_change){ cycling_speed_and_cadence_t * instance = &cycling_speed_and_cadence; if (revolutions_change < 0){ - if (instance->cumulative_wheel_revolutions > -revolutions_change){ - instance->cumulative_wheel_revolutions += revolutions_change; + uint32_t revolutions_to_subtract = (uint32_t)(-revolutions_change); + if (instance->cumulative_wheel_revolutions > revolutions_to_subtract){ + instance->cumulative_wheel_revolutions -= revolutions_to_subtract; } else { instance->cumulative_wheel_revolutions = 0; } diff --git a/src/ble/gatt-service/device_information_service_server.c b/src/ble/gatt-service/device_information_service_server.c index a0dccb9f1..49feb8275 100644 --- a/src/ble/gatt-service/device_information_service_server.c +++ b/src/ble/gatt-service/device_information_service_server.c @@ -85,7 +85,7 @@ static uint8_t device_information_pnp_id[7]; static att_service_handler_t device_information_service; static void set_string(device_information_field_id_t field_id, const char * text){ device_information_fields[field_id].data = (uint8_t*) text; - device_information_fields[field_id].len = strlen(text); + device_information_fields[field_id].len = (uint8_t) strlen(text); } static uint16_t device_information_service_read_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){ @@ -197,8 +197,8 @@ void device_information_service_server_set_software_revision(const char * softwa * @param organizationally_unique_identifier uint24 */ void device_information_service_server_set_system_id(uint64_t manufacturer_identifier, uint32_t organizationally_unique_identifier){ - little_endian_store_32(device_information_system_id, 0, manufacturer_identifier); - device_information_system_id[4] = manufacturer_identifier >> 32; + little_endian_store_32(device_information_system_id, 0, (uint32_t)(manufacturer_identifier & 0xffffffff)); + device_information_system_id[4] = (uint8_t) (manufacturer_identifier >> 32); little_endian_store_16(device_information_system_id, 5, organizationally_unique_identifier); device_information_system_id[7] = organizationally_unique_identifier >> 16; } diff --git a/src/ble/gatt-service/hids_device.c b/src/ble/gatt-service/hids_device.c index f23f161c7..2f191af5e 100644 --- a/src/ble/gatt-service/hids_device.c +++ b/src/ble/gatt-service/hids_device.c @@ -60,7 +60,7 @@ typedef struct{ uint16_t hid_descriptor_size; uint16_t hid_report_map_handle; - uint16_t hid_protocol_mode; + uint8_t hid_protocol_mode; uint16_t hid_protocol_mode_value_handle; uint16_t hid_boot_mouse_input_value_handle; @@ -219,30 +219,30 @@ static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, if (att_handle == instance->hid_boot_mouse_input_client_configuration_handle){ uint16_t new_value = little_endian_read_16(buffer, 0); instance->hid_boot_mouse_input_client_configuration_value = new_value; - hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_MOUSE_INPUT_REPORT_ENABLE, con_handle, new_value); + hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_MOUSE_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value); } if (att_handle == instance->hid_boot_keyboard_input_client_configuration_handle){ uint16_t new_value = little_endian_read_16(buffer, 0); instance->hid_boot_keyboard_input_client_configuration_value = new_value; - hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_KEYBOARD_INPUT_REPORT_ENABLE, con_handle, new_value); + hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_KEYBOARD_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value); } if (att_handle == instance->hid_report_input_client_configuration_handle){ uint16_t new_value = little_endian_read_16(buffer, 0); instance->hid_report_input_client_configuration_value = new_value; log_info("Enable Report Input notifications: %x", new_value); - hids_device_emit_event_with_uint8(HIDS_SUBEVENT_INPUT_REPORT_ENABLE, con_handle, new_value); + hids_device_emit_event_with_uint8(HIDS_SUBEVENT_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value); } if (att_handle == instance->hid_report_output_client_configuration_handle){ uint16_t new_value = little_endian_read_16(buffer, 0); instance->hid_report_output_client_configuration_value = new_value; log_info("Enable Report Output notifications: %x", new_value); - hids_device_emit_event_with_uint8(HIDS_SUBEVENT_OUTPUT_REPORT_ENABLE, con_handle, new_value); + hids_device_emit_event_with_uint8(HIDS_SUBEVENT_OUTPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value); } if (att_handle == instance->hid_report_feature_client_configuration_handle){ uint16_t new_value = little_endian_read_16(buffer, 0); instance->hid_report_feature_client_configuration_value = new_value; log_info("Enable Report Feature notifications: %x", new_value); - hids_device_emit_event_with_uint8(HIDS_SUBEVENT_FEATURE_REPORT_ENABLE, con_handle, new_value); + hids_device_emit_event_with_uint8(HIDS_SUBEVENT_FEATURE_REPORT_ENABLE, con_handle, (uint8_t) new_value); } if (att_handle == instance->hid_protocol_mode_value_handle){ diff --git a/src/ble/gatt-service/microphone_control_service_server.c b/src/ble/gatt-service/microphone_control_service_server.c index 6b9691efc..376d66ab6 100644 --- a/src/ble/gatt-service/microphone_control_service_server.c +++ b/src/ble/gatt-service/microphone_control_service_server.c @@ -180,7 +180,7 @@ void microphone_control_service_server_init(gatt_microphone_control_mute_t mute_ service->index = aics_services_num; service->info = &aics_info[aics_services_num]; - service->audio_input_description_len = strlen(aics_info->audio_input_description); + service->audio_input_description_len = (uint8_t) strlen(aics_info->audio_input_description); audio_input_control_service_server_init(service); diff --git a/src/ble/gatt-service/volume_control_service_server.c b/src/ble/gatt-service/volume_control_service_server.c index a91a46319..ad25bccf5 100644 --- a/src/ble/gatt-service/volume_control_service_server.c +++ b/src/ble/gatt-service/volume_control_service_server.c @@ -360,7 +360,7 @@ static void volume_control_init_included_aics_services(uint16_t vcs_start_handle service->index = aics_services_num; service->info = &aics_info[aics_services_num]; - service->audio_input_description_len = strlen(aics_info->audio_input_description); + service->audio_input_description_len = (uint8_t) strlen(aics_info->audio_input_description); audio_input_control_service_server_init(service); @@ -395,7 +395,7 @@ static void volume_control_init_included_vocs_services(uint16_t vcs_start_handle service->index = vocs_services_num; service->info = &vocs_info[vocs_services_num]; - service->audio_output_description_len = strlen(vocs_info->audio_output_description); + service->audio_output_description_len = (uint8_t) strlen(vocs_info->audio_output_description); volume_offset_control_service_server_init(service); diff --git a/src/ble/gatt-service/volume_offset_control_service_server.c b/src/ble/gatt-service/volume_offset_control_service_server.c index 7f098cf55..2dcee27dd 100644 --- a/src/ble/gatt-service/volume_offset_control_service_server.c +++ b/src/ble/gatt-service/volume_offset_control_service_server.c @@ -88,7 +88,7 @@ static uint16_t vocs_read_callback(hci_con_handle_t con_handle, uint16_t attribu } if (attribute_handle == vocs->audio_output_description_value_handle){ - return att_read_callback_handle_blob((uint8_t *)vocs->info->audio_output_description, strlen(vocs->info->audio_output_description), offset, buffer, buffer_size); + return att_read_callback_handle_blob((uint8_t *)vocs->info->audio_output_description, (uint16_t) strlen(vocs->info->audio_output_description), offset, buffer, buffer_size); } @@ -290,7 +290,7 @@ static int vocs_write_callback(hci_con_handle_t con_handle, uint16_t attribute_h if (attribute_handle == vocs->audio_output_description_value_handle){ btstack_strcpy(vocs->info->audio_output_description, vocs->audio_output_description_len, (char *)buffer); - vocs->audio_output_description_len = strlen(vocs->info->audio_output_description); + vocs->audio_output_description_len = (uint8_t) strlen(vocs->info->audio_output_description); vocs_emit_audio_output_description(vocs); volume_offset_control_service_server_set_callback(vocs, VOCS_TASK_SEND_AUDIO_OUTPUT_DESCRIPTION); } @@ -403,6 +403,6 @@ uint8_t volume_offset_control_service_server_set_audio_location(volume_offset_co void volume_offset_control_service_server_set_audio_output_description(volume_offset_control_service_server_t * vocs, const char * audio_output_desc){ btstack_assert(vocs != NULL); btstack_strcpy(vocs->info->audio_output_description, vocs->audio_output_description_len, (char *)audio_output_desc); - vocs->audio_output_description_len = strlen(vocs->info->audio_output_description); + vocs->audio_output_description_len = (uint8_t) strlen(vocs->info->audio_output_description); volume_offset_control_service_server_set_callback(vocs, VOCS_TASK_SEND_AUDIO_OUTPUT_DESCRIPTION); }