Skip to content

Commit

Permalink
src: remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
milamikica committed Oct 30, 2020
1 parent 8143b3c commit bbc383f
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 61 deletions.
14 changes: 0 additions & 14 deletions src/ble/gatt-service/cycling_power_service_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ static void cycling_power_service_vector_can_send_now(void * context){
break;
}
case CP_VECTOR_FLAG_FIRST_CRANK_MEASUREMENT_ANGLE_PRESENT:
// printf("CP_VECTOR_FLAG_FIRST_CRANK_MEASUREMENT_ANGLE_PRESENT \n");
little_endian_store_16(value, pos, instance->vector_first_crank_measurement_angle_deg);
pos += 2;
break;
Expand Down Expand Up @@ -572,11 +571,6 @@ static void cycling_power_service_response_can_send_now(void * context){
return;
}

// if (instance->w4_indication_complete){
// printf("cycling_power_service_response_can_send_now: w4_indication_complete\n");
// return;
// }

// use preprocessor instead of btstack_max to get compile-time constant
#if (CP_SENSOR_LOCATION_RESERVED > (CYCLING_POWER_MANUFACTURER_SPECIFIC_DATA_MAX_SIZE + 5))
#define MAX_RESPONSE_PAYLOAD CP_SENSOR_LOCATION_RESERVED
Expand Down Expand Up @@ -669,8 +663,6 @@ static void cycling_power_service_response_can_send_now(void * context){
uint8_t status = att_server_indicate(instance->con_handle, instance->control_point_value_handle, &value[0], pos);
if (status == ERROR_CODE_SUCCESS){
instance->w4_indication_complete = 1;
// printf("cycling_power_service_response_can_send_now: set w4_indication_complete\n");
// printf("can_send_now set opcode to CP_OPCODE_IDLE\n");
instance->request_opcode = CP_OPCODE_IDLE;
} else {
log_error("can_send_now failed 0x%2x", status);
Expand All @@ -686,7 +678,6 @@ static int cycling_power_service_write_callback(hci_con_handle_t con_handle, uin
cycling_power_sensor_location_t location;
cycling_power_t * instance = &cycling_power;

// printf("cycling_power_service_write_callback: attr handle 0x%02x\n", attribute_handle);
if (attribute_handle == instance->measurement_client_configuration_descriptor_handle){
if (buffer_size < 2u){
return ATT_ERROR_INVALID_OFFSET;
Expand Down Expand Up @@ -860,7 +851,6 @@ static int cycling_power_service_write_callback(hci_con_handle_t con_handle, uin
((has_feature(CP_FEATURE_FLAG_SENSOR_MEASUREMENT_CONTEXT) == CP_SENSOR_MEASUREMENT_CONTEXT_FORCE) ||
(has_feature(CP_FEATURE_FLAG_SENSOR_MEASUREMENT_CONTEXT) == CP_SENSOR_MEASUREMENT_CONTEXT_TORQUE))
){
// printf("start offset compensation procedure, enhanced %d\n", (instance->request_opcode == CP_OPCODE_START_ENHANCED_OFFSET_COMPENSATION));
uint8_t event[7];
int index = 0;
event[index++] = HCI_EVENT_GATTSERVICE_META;
Expand Down Expand Up @@ -934,8 +924,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
instance->con_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);
// print connection parameters (without using float operations)
instance->con_interval = hci_subevent_le_connection_complete_get_conn_interval(packet);
// printf("Initial Connection Interval: %u, %u.%02u ms\n", instance->con_interval, instance->con_interval * 125 / 100, 25 * (instance->con_interval & 3));
// printf("Initial Connection Latency: %u\n", hci_subevent_le_connection_complete_get_conn_latency(packet));
instance->con_interval_status = CP_CONNECTION_INTERVAL_STATUS_RECEIVED;
break;

Expand Down Expand Up @@ -1112,7 +1100,6 @@ void cycling_power_service_add_energy(uint16_t energy_kJ){
} else {
instance->accumulated_energy_kJ = 0xffff;
}
// printf("energy %d\n", instance->accumulated_energy_kJ);
}

void cycling_power_service_server_set_instantaneous_power(int16_t instantaneous_power_watt){
Expand Down Expand Up @@ -1234,7 +1221,6 @@ void cycling_power_service_server_packet_handler(btstack_packet_handler_t callba
void cycling_power_server_calibration_done(cycling_power_sensor_measurement_context_t measurement_type, uint16_t calibrated_value){
cycling_power_t * instance = &cycling_power;
if (instance->response_value != CP_RESPONSE_VALUE_W4_VALUE_AVAILABLE){
// printf("cycling_power_server_calibration_done : CP_RESPONSE_VALUE_W4_VALUE_AVAILABLE con_handle 0x%02x\n", instance->con_handle);
return;
}
instance->response_value = CP_RESPONSE_VALUE_SUCCESS;
Expand Down
14 changes: 0 additions & 14 deletions src/ble/gatt-service/cycling_speed_and_cadence_service_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ static uint16_t cycling_speed_and_cadence_service_read_callback(hci_con_handle_t
static void cycling_speed_and_cadence_service_csc_measurement_can_send_now(void * context){
cycling_speed_and_cadence_t * instance = (cycling_speed_and_cadence_t *) context;
if (!instance){
// printf("instance is null (cycling_speed_and_cadence_service_csc_measurement_can_send_now)\n");
return;
}
uint8_t flags = (instance->wheel_revolution_data_supported << CSC_FLAG_WHEEL_REVOLUTION_DATA_SUPPORTED);
Expand All @@ -153,7 +152,6 @@ static void cycling_speed_and_cadence_service_csc_measurement_can_send_now(void
pos += 4;
little_endian_store_16(value, pos, instance->last_wheel_event_time);
pos += 2;
// printf("send cumulative 0x%04x\n", instance->cumulative_wheel_revolutions);
}

if (instance->crank_revolution_data_supported){
Expand All @@ -169,7 +167,6 @@ static void cycling_speed_and_cadence_service_csc_measurement_can_send_now(void
static void cycling_speed_and_cadence_service_response_can_send_now(void * context){
cycling_speed_and_cadence_t * instance = (cycling_speed_and_cadence_t *) context;
if (!instance){
// printf("instance is null (cycling_speed_and_cadence_service_response_can_send_now)\n");
return;
}

Expand Down Expand Up @@ -216,16 +213,12 @@ static int cycling_speed_and_cadence_service_write_callback(hci_con_handle_t con
UNUSED(buffer_size);
cycling_speed_and_cadence_t * instance = &cycling_speed_and_cadence;

// printf("cycling_speed_and_cadence_service_write_callback: attr handle 0x%02x\n", attribute_handle);
if (attribute_handle == instance->measurement_client_configuration_descriptor_handle){
if (buffer_size < 2u){
return ATT_ERROR_INVALID_OFFSET;
}
instance->measurement_client_configuration_descriptor_notify = little_endian_read_16(buffer, 0);
instance->con_handle = con_handle;
// if (instance->measurement_client_configuration_descriptor_notify){
// printf("enable notification\n");
// }
return 0;
}

Expand All @@ -235,9 +228,6 @@ static int cycling_speed_and_cadence_service_write_callback(hci_con_handle_t con
}
instance->control_point_client_configuration_descriptor_indicate = little_endian_read_16(buffer, 0);
instance->con_handle = con_handle;
// if (instance->control_point_client_configuration_descriptor_indicate){
// printf("enable indication\n");
// }
return 0;
}

Expand Down Expand Up @@ -276,7 +266,6 @@ static int cycling_speed_and_cadence_service_write_callback(hci_con_handle_t con
instance->response_value = CSC_RESPONSE_VALUE_OP_CODE_NOT_SUPPORTED;
break;
}
// printf("control point, opcode %02x, response %02x\n", instance->request_opcode, instance->response_value);

if (instance->control_point_client_configuration_descriptor_indicate){
instance->control_point_callback.callback = &cycling_speed_and_cadence_service_response_can_send_now;
Expand All @@ -286,7 +275,6 @@ static int cycling_speed_and_cadence_service_write_callback(hci_con_handle_t con
return 0;
}

// printf("heart_rate_service_read_callback, not handeled read on handle 0x%02x\n", attribute_handle);
return 0;
}

Expand Down Expand Up @@ -351,7 +339,6 @@ static void cycling_speed_and_cadence_service_calculate_cumulative_wheel_revolut
instance->cumulative_wheel_revolutions = 0xffffffff;
}
}
// printf("cumulative 0x%04x, wheel revolution change %d\n", instance->cumulative_wheel_revolutions, revolutions_change);
}

static void cycling_speed_and_cadence_service_calculate_cumulative_crank_revolutions(uint16_t revolutions_change){
Expand All @@ -377,7 +364,6 @@ void cycling_speed_and_cadence_service_server_update_values(int32_t wheel_revolu
if (instance->measurement_client_configuration_descriptor_notify){
instance->measurement_callback.callback = &cycling_speed_and_cadence_service_csc_measurement_can_send_now;
instance->measurement_callback.context = (void*) instance;
// printf("cycling_speed_and_cadence_service_server_update_values instance %p, context %p\n", instance, instance->measurement_callback.context);
att_server_register_can_send_now_callback(&instance->measurement_callback, instance->con_handle);
}
}
2 changes: 0 additions & 2 deletions src/btstack_hid_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ int btstack_hid_get_report_size_for_id(int report_id, hid_report_type_t report_t
while (hid_descriptor_len){
int valid_report_type = 0;
hid_descriptor_item_t item;
// printf("item: 0x%02x (%p)\n", *hid_descriptor, hid_descriptor);
btstack_hid_parse_descriptor_item(&item, hid_descriptor, hid_descriptor_len);
switch (item.item_type){
case Global:
Expand Down Expand Up @@ -495,7 +494,6 @@ hid_report_id_status_t btstack_hid_id_valid(int report_id, uint16_t hid_descript
switch ((GlobalItemTag)item.item_tag){
case ReportID:
current_report_id = item.item_value;
// printf("current ID %d, searched ID %d\n", current_report_id, report_id);
if (current_report_id != report_id) break;
return HID_REPORT_ID_VALID;
default:
Expand Down
3 changes: 0 additions & 3 deletions src/btstack_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ char * uuid128_to_str(const uint8_t * uuid){

static char bd_addr_to_str_buffer[6*3]; // 12:45:78:01:34:67\0
char * bd_addr_to_str(const bd_addr_t addr){
// orig code
// sprintf(bd_addr_to_str_buffer, "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
// sprintf-free code
char * p = bd_addr_to_str_buffer;
int i;
for (i = 0; i < 6 ; i++) {
Expand Down
2 changes: 0 additions & 2 deletions src/classic/avrcp_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ static void avrcp_controller_emit_now_playing_info_event_done(btstack_packet_han
pos += 2;
event[pos++] = ctype;
event[pos++] = status;
// printf_hexdump(event, pos);
(*callback)(HCI_EVENT_PACKET, 0, event, pos);
}

Expand Down Expand Up @@ -355,7 +354,6 @@ static void avrcp_parser_reset(avrcp_connection_t * connection){
static void avrcp_parser_process_byte(uint8_t byte, avrcp_connection_t * connection, avrcp_command_type_t ctype){
uint16_t attribute_total_value_len;
uint32_t attribute_id;
// printf("avrcp_parser_process_byte: %02x, state %02x\n", byte, connection->parser_state);
switch(connection->parser_state){
case AVRCP_PARSER_GET_ATTRIBUTE_HEADER:
connection->parser_attribute_header[connection->parser_attribute_header_pos++] = byte;
Expand Down
8 changes: 5 additions & 3 deletions src/classic/btstack_sbc_decoder_bluedroid.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@
#include "btstack_config.h"

#include <stdint.h>
#include <stdio.h>

#include <stdlib.h>
#include <string.h>

#ifdef LOG_FRAME_STATUS
#include <stdio.h>
#endif

#include "btstack_sbc.h"
#include "btstack_sbc_plc.h"

Expand Down Expand Up @@ -197,8 +201,6 @@ void btstack_sbc_decoder_init(btstack_sbc_decoder_state_t * state, btstack_sbc_m
static void append_received_sbc_data(bludroid_decoder_state_t * state, uint8_t * buffer, int size){
int numFreeBytes = sizeof(state->frame_buffer) - state->bytes_in_frame_buffer;

// printf("append_received_sbc_data: bytes to append %u, sizeof %u, bytes in buffer %u, free %u\n", size,sizeof(state->frame_buffer), state->bytes_in_frame_buffer, numFreeBytes);

if (size > numFreeBytes){
log_error("SBC data: more bytes read %u than free bytes in buffer %u", size, numFreeBytes);
}
Expand Down
1 change: 0 additions & 1 deletion src/classic/btstack_sbc_encoder_bluedroid.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "btstack_config.h"

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand Down
1 change: 0 additions & 1 deletion src/classic/btstack_sbc_plc.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ uint8_t * btstack_sbc_plc_zero_signal_frame(void){
void btstack_sbc_plc_init(btstack_sbc_plc_state_t *plc_state){
plc_state->nbf=0;
plc_state->bestlag=0;
// printf("size\n");
memset(plc_state->hist,0,sizeof(plc_state->hist));
}

Expand Down
3 changes: 0 additions & 3 deletions src/classic/hfp_ag.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ static int codecs_exchange_state_machine(hfp_connection_t * hfp_connection){
break;
}

// printf(" -> State machine: CC\n");

switch (hfp_connection->command){
case HFP_CMD_AVAILABLE_CODECS:
if (hfp_connection->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED){
Expand Down Expand Up @@ -1101,7 +1099,6 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
int callheld_indicator_index = get_ag_indicator_index_for_name("callheld");
int call_indicator_index = get_ag_indicator_index_for_name("call");

//printf("hfp_ag_call_sm event %d \n", event);
switch (event){
case HFP_AG_INCOMING_CALL:
switch (hfp_gsm_call_status()){
Expand Down
15 changes: 0 additions & 15 deletions src/classic/hid_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ static hid_handshake_param_type_t hid_device_set_report_cmd_is_valid(uint16_t ci
default:
break;
}
// printf("hid_device_set_report_cmd_is_valid: report_id %d, status %d \n", report_id, report_id_status);
}

if (!hid_report_size_valid(cid, report_id, report_type, report_size-pos)){
Expand Down Expand Up @@ -450,7 +449,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
return;
}
message_type = (hid_message_type_t)(packet[0] >> 4);
// printf("L2CAP_DATA_PACKET message_type %d, packet_size %d \n", message_type, packet_size);
switch (message_type){
case HID_MESSAGE_TYPE_GET_REPORT:

Expand Down Expand Up @@ -527,7 +525,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack

switch (device->protocol_mode){
case HID_PROTOCOL_MODE_BOOT:
// printf("HID_PROTOCOL_MODE_BOOT \n");
if (packet_size < 3){
device->report_status = HID_HANDSHAKE_PARAM_TYPE_ERR_INVALID_PARAMETER;
break;
Expand All @@ -538,7 +535,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
(*hci_device_set_report)(device->cid, device->report_type, packet_size-1, &packet[1]);
break;
case HID_PROTOCOL_MODE_REPORT:
// printf("HID_PROTOCOL_MODE_REPORT \n");
device->report_status = hid_device_set_report_cmd_is_valid(device->cid, device->report_type, packet_size - 1, &packet[1]);
if (device->report_status != HID_HANDSHAKE_PARAM_TYPE_SUCCESSFUL) break;

Expand All @@ -557,15 +553,13 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
l2cap_request_can_send_now_event(device->control_cid);
break;
case HID_MESSAGE_TYPE_GET_PROTOCOL:
// printf(" HID_MESSAGE_TYPE_GET_PROTOCOL\n");
device->state = HID_DEVICE_W2_GET_PROTOCOL;
if (packet_size != 1) {
device->report_status = HID_HANDSHAKE_PARAM_TYPE_ERR_INVALID_PARAMETER;
break;
}
device->report_status = HID_HANDSHAKE_PARAM_TYPE_SUCCESSFUL;
// hid_device_request_can_send_now_event(channel);
// printf("HID_MESSAGE_TYPE_GET_PROTOCOL l2cap_request_can_send_now_event\n");
l2cap_request_can_send_now_event(device->control_cid);
break;

Expand All @@ -583,10 +577,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
device->protocol_mode = (hid_protocol_mode_t) param;
switch (device->protocol_mode){
case HID_PROTOCOL_MODE_BOOT:
// printf("Set protocol mode to BOOT\n");
break;
case HID_PROTOCOL_MODE_REPORT:
// printf("Set protocol mode to REPORT\n");
break;
default:
btstack_assert(false);
Expand Down Expand Up @@ -714,7 +706,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack

// connect HID Interrupt for outgoing
if ((device->incoming == 0) && (psm == PSM_HID_CONTROL)){
// printf("Create outgoing HID Interrupt\n");
status = l2cap_create_channel(packet_handler, device->bd_addr, PSM_HID_INTERRUPT, 48, &device->interrupt_cid);
break;
}
Expand Down Expand Up @@ -753,7 +744,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
if (!device) return;
switch (device->state){
case HID_DEVICE_W2_GET_REPORT:{
// printf("HID_DEVICE_W2_GET_REPORT. on entry device->report_status %d \n", device->report_status);
if (device->report_status != HID_HANDSHAKE_PARAM_TYPE_SUCCESSFUL) {
report[0] = (HID_MESSAGE_TYPE_HANDSHAKE << 4) | device->report_status;
hid_device_send_control_message(device->cid, &report[0], 1);
Expand All @@ -765,11 +755,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
if (device->report_id){
report[pos++] = device->report_id;
}
// printf(" report size with header and id %d\n", pos);

report_size = 0;
status = (*hci_device_get_report)(device->cid, device->report_type, device->report_id, &report_size, &report[pos]);
// printf(" report size %d, status after callback %d, expected report_size %d\n", report_size + pos, status, device->report_size + pos);

switch (status){
case 0:
Expand Down Expand Up @@ -802,7 +790,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
// break;
// }

// printf("report type %d, report_size %d, report_size %d \n", device->report_type, report_size, device->report_size);
hid_device_send_control_message(device->cid, &report[0], device->report_size);
// device->state = HID_DEVICE_IDLE;
break;
Expand All @@ -814,13 +801,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * pack
break;
case HID_DEVICE_W2_GET_PROTOCOL:
if (device->report_status != HID_HANDSHAKE_PARAM_TYPE_SUCCESSFUL){
// printf("send HID_MESSAGE_TYPE_HANDSHAKE, report_status %d \n", device->report_status);
report[0] = (HID_MESSAGE_TYPE_HANDSHAKE << 4) | device->report_status;
hid_device_send_control_message(device->cid, &report[0], 1);
break;
}

// printf("send HID_MESSAGE_TYPE_DATA, protocol_mode %d \n", device->protocol_mode);
report[0] = (HID_MESSAGE_TYPE_DATA << 4);
report[1] = device->protocol_mode;
hid_device_send_control_message(device->cid, &report[0], 2);
Expand Down
Loading

0 comments on commit bbc383f

Please sign in to comment.