mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-05 09:40:00 +00:00
use bool instead of int vars
This commit is contained in:
parent
9305033e02
commit
1979f09cf0
@ -1271,14 +1271,14 @@ uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid16(uint16_t st
|
||||
uint16_t gatt_server_get_descriptor_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16, uint16_t descriptor_uuid16){
|
||||
att_iterator_t it;
|
||||
att_iterator_init(&it);
|
||||
int characteristic_found = 0;
|
||||
bool characteristic_found = false;
|
||||
while (att_iterator_has_next(&it)){
|
||||
att_iterator_fetch_next(&it);
|
||||
if (it.handle && (it.handle < start_handle)) continue;
|
||||
if (it.handle > end_handle) break; // (1)
|
||||
if (it.handle == 0u) break;
|
||||
if (att_iterator_match_uuid16(&it, characteristic_uuid16)){
|
||||
characteristic_found = 1;
|
||||
characteristic_found = true;
|
||||
continue;
|
||||
}
|
||||
if (att_iterator_match_uuid16(&it, GATT_PRIMARY_SERVICE_UUID)
|
||||
|
@ -131,15 +131,15 @@ static void att_server_request_can_send_now(hci_connection_t * hci_connection){
|
||||
att_dispatch_server_request_can_send_now_event(att_connection->con_handle);
|
||||
}
|
||||
|
||||
static int att_server_can_send_packet(hci_connection_t * hci_connection){
|
||||
static bool att_server_can_send_packet(hci_connection_t * hci_connection){
|
||||
#ifdef ENABLE_GATT_OVER_CLASSIC
|
||||
att_server_t * att_server = &hci_connection->att_server;
|
||||
if (att_server->l2cap_cid != 0){
|
||||
return l2cap_can_send_packet_now(att_server->l2cap_cid);
|
||||
return l2cap_can_send_packet_now(att_server->l2cap_cid) != 0;
|
||||
}
|
||||
#endif
|
||||
att_connection_t * att_connection = &hci_connection->att_connection;
|
||||
return att_dispatch_server_can_send_now(att_connection->con_handle);
|
||||
return att_dispatch_server_can_send_now(att_connection->con_handle) != 0;
|
||||
}
|
||||
|
||||
static void att_handle_value_indication_notify_client(uint8_t status, uint16_t client_handle, uint16_t attribute_handle){
|
||||
@ -674,7 +674,7 @@ static void att_run_for_context(hci_connection_t * hci_connection){
|
||||
}
|
||||
}
|
||||
|
||||
static int att_server_data_ready_for_phase(att_server_t * att_server, att_server_run_phase_t phase){
|
||||
static bool att_server_data_ready_for_phase(att_server_t * att_server, att_server_run_phase_t phase){
|
||||
switch (phase){
|
||||
case ATT_SERVER_RUN_PHASE_1_REQUESTS:
|
||||
return att_server->state == ATT_SERVER_REQUEST_RECEIVED_AND_VALIDATED;
|
||||
@ -684,7 +684,7 @@ static int att_server_data_ready_for_phase(att_server_t * att_server, att_serve
|
||||
return (!btstack_linked_list_empty(&att_server->notification_requests));
|
||||
default:
|
||||
btstack_assert(false);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ static void att_server_handle_can_send_now(void){
|
||||
|
||||
hci_con_handle_t last_send_con_handle = HCI_CON_HANDLE_INVALID;
|
||||
hci_connection_t * request_hci_connection = NULL;
|
||||
int can_send_now = 1;
|
||||
bool can_send_now = true;
|
||||
int phase_index;
|
||||
|
||||
for (phase_index = ATT_SERVER_RUN_PHASE_1_REQUESTS; phase_index <= ATT_SERVER_RUN_PHASE_3_NOTIFICATIONS; phase_index++){
|
||||
@ -729,7 +729,7 @@ static void att_server_handle_can_send_now(void){
|
||||
att_server_t * att_server = &connection->att_server;
|
||||
att_connection_t * att_connection = &connection->att_connection;
|
||||
|
||||
int data_ready = att_server_data_ready_for_phase(att_server, phase);
|
||||
bool data_ready = att_server_data_ready_for_phase(att_server, phase);
|
||||
|
||||
// log_debug("phase %u, handle 0x%04x, skip until 0x%04x, data ready %u", phase, att_connection->con_handle, skip_connections_until, data_ready);
|
||||
|
||||
|
@ -883,16 +883,16 @@ static int is_value_valid(gatt_client_t *gatt_client, uint8_t *packet, uint16_t
|
||||
}
|
||||
|
||||
// returns 1 if packet was sent
|
||||
static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
static bool gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
|
||||
// wait until re-encryption is complete
|
||||
if (gap_reconnect_security_setup_active(gatt_client->con_handle)) return 0;
|
||||
if (gap_reconnect_security_setup_active(gatt_client->con_handle)) return false;
|
||||
|
||||
// wait until re-encryption is complete
|
||||
if (gatt_client->reencryption_active) return 0;
|
||||
if (gatt_client->reencryption_active) return false;
|
||||
|
||||
// wait until pairing complete (either reactive authentication or due to required security level)
|
||||
if (gatt_client->wait_for_authentication_complete) return 0;
|
||||
if (gatt_client->wait_for_authentication_complete) return false;
|
||||
|
||||
bool client_request_pending = gatt_client->gatt_client_state != P_READY;
|
||||
|
||||
@ -912,16 +912,16 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
}
|
||||
sm_request_pairing(gatt_client->con_handle);
|
||||
// sm probably just sent a pdu
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (gatt_client->mtu_state) {
|
||||
case SEND_MTU_EXCHANGE:
|
||||
gatt_client->mtu_state = SENT_MTU_EXCHANGE;
|
||||
att_exchange_mtu_request(gatt_client->con_handle);
|
||||
return 1;
|
||||
return true;
|
||||
case SENT_MTU_EXCHANGE:
|
||||
return 0;
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -929,7 +929,7 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
if (gatt_client->send_confirmation){
|
||||
gatt_client->send_confirmation = 0;
|
||||
att_confirmation(gatt_client->con_handle);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check MTU for writes
|
||||
@ -940,7 +940,7 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
log_error("gatt_client_run: value len %u > MTU %u - 3\n", gatt_client->attribute_length,gatt_client->mtu);
|
||||
gatt_client_handle_transaction_complete(gatt_client);
|
||||
emit_gatt_complete_event(gatt_client, ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH);
|
||||
return 0;
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -949,92 +949,92 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
case P_W2_SEND_SERVICE_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_SERVICE_QUERY_RESULT;
|
||||
send_gatt_services_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_SERVICE_WITH_UUID_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_SERVICE_WITH_UUID_RESULT;
|
||||
send_gatt_services_by_uuid_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT;
|
||||
send_gatt_characteristic_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT;
|
||||
send_gatt_characteristic_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT;
|
||||
send_gatt_characteristic_descriptor_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_INCLUDED_SERVICE_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_INCLUDED_SERVICE_QUERY_RESULT;
|
||||
send_gatt_included_service_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT;
|
||||
send_gatt_included_service_uuid_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_READ_CHARACTERISTIC_VALUE_RESULT;
|
||||
send_gatt_read_characteristic_value_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_BLOB_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_READ_BLOB_RESULT;
|
||||
send_gatt_read_blob_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_BY_TYPE_REQUEST:
|
||||
gatt_client->gatt_client_state = P_W4_READ_BY_TYPE_RESPONSE;
|
||||
send_gatt_read_by_type_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_MULTIPLE_REQUEST:
|
||||
gatt_client->gatt_client_state = P_W4_READ_MULTIPLE_RESPONSE;
|
||||
send_gatt_read_multiple_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE:
|
||||
gatt_client->gatt_client_state = P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT;
|
||||
send_gatt_write_attribute_value_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_PREPARE_WRITE:
|
||||
gatt_client->gatt_client_state = P_W4_PREPARE_WRITE_RESULT;
|
||||
send_gatt_prepare_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_PREPARE_WRITE_SINGLE:
|
||||
gatt_client->gatt_client_state = P_W4_PREPARE_WRITE_SINGLE_RESULT;
|
||||
send_gatt_prepare_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_PREPARE_RELIABLE_WRITE:
|
||||
gatt_client->gatt_client_state = P_W4_PREPARE_RELIABLE_WRITE_RESULT;
|
||||
send_gatt_prepare_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_EXECUTE_PREPARED_WRITE:
|
||||
gatt_client->gatt_client_state = P_W4_EXECUTE_PREPARED_WRITE_RESULT;
|
||||
send_gatt_execute_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_CANCEL_PREPARED_WRITE:
|
||||
gatt_client->gatt_client_state = P_W4_CANCEL_PREPARED_WRITE_RESULT;
|
||||
send_gatt_cancel_prepared_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH:
|
||||
gatt_client->gatt_client_state = P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT;
|
||||
send_gatt_cancel_prepared_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
#ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY
|
||||
case P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY:
|
||||
@ -1047,37 +1047,37 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
gatt_client->gatt_client_state = P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT;
|
||||
send_gatt_read_client_characteristic_configuration_request(gatt_client);
|
||||
#endif
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||
send_gatt_read_characteristic_descriptor_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY:
|
||||
gatt_client->gatt_client_state = P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||
send_gatt_read_blob_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR:
|
||||
gatt_client->gatt_client_state = P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||
send_gatt_write_attribute_value_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION:
|
||||
gatt_client->gatt_client_state = P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT;
|
||||
send_gatt_write_client_characteristic_configuration_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR:
|
||||
gatt_client->gatt_client_state = P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||
send_gatt_prepare_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
case P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR:
|
||||
gatt_client->gatt_client_state = P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT;
|
||||
send_gatt_execute_write_request(gatt_client);
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
#ifdef ENABLE_LE_SIGNED_WRITE
|
||||
case P_W4_IDENTITY_RESOLVING:
|
||||
@ -1090,9 +1090,9 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
case IRK_LOOKUP_FAILED:
|
||||
gatt_client_handle_transaction_complete(gatt_client);
|
||||
emit_gatt_complete_event(gatt_client, ATT_ERROR_BONDING_INFORMATION_MISSING);
|
||||
return 0;
|
||||
return false;
|
||||
default:
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Fall through */
|
||||
@ -1105,7 +1105,7 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
gatt_client->gatt_client_state = P_W4_CMAC_RESULT;
|
||||
sm_cmac_signed_write_start(csrk, ATT_SIGNED_WRITE_COMMAND, gatt_client->attribute_handle, gatt_client->attribute_length, gatt_client->attribute_value, sign_counter, att_signed_write_handle_cmac_result);
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
case P_W2_SEND_SIGNED_WRITE: {
|
||||
gatt_client->gatt_client_state = P_W4_SEND_SINGED_WRITE_DONE;
|
||||
@ -1117,7 +1117,7 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
// finally, notifiy client that write is complete
|
||||
gatt_client_handle_transaction_complete(gatt_client);
|
||||
emit_gatt_complete_event(gatt_client, ATT_ERROR_SUCCESS);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
@ -1133,10 +1133,10 @@ static int gatt_client_run_for_gatt_client(gatt_client_t * gatt_client){
|
||||
event[1] = sizeof(event) - 2u;
|
||||
little_endian_store_16(event, 2, gatt_client->con_handle);
|
||||
packet_handler(HCI_EVENT_PACKET, gatt_client->con_handle, event, sizeof(event));
|
||||
return 1; // to trigger requeueing (even if higher layer didn't sent)
|
||||
return true; // to trigger requeueing (even if higher layer didn't sent)
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gatt_client_run(void){
|
||||
@ -1147,7 +1147,7 @@ static void gatt_client_run(void){
|
||||
att_dispatch_client_request_can_send_now_event(gatt_client->con_handle);
|
||||
return;
|
||||
}
|
||||
int packet_sent = gatt_client_run_for_gatt_client(gatt_client);
|
||||
bool packet_sent = gatt_client_run_for_gatt_client(gatt_client);
|
||||
if (packet_sent){
|
||||
// request new permission
|
||||
att_dispatch_client_request_can_send_now_event(gatt_client->con_handle);
|
||||
|
62
src/ble/sm.c
62
src/ble/sm.c
@ -195,7 +195,7 @@ static uint8_t sm_auth_req = 0;
|
||||
static uint8_t sm_io_capabilities = IO_CAPABILITY_NO_INPUT_NO_OUTPUT;
|
||||
static uint8_t sm_slave_request_security;
|
||||
static uint32_t sm_fixed_passkey_in_display_role;
|
||||
static uint8_t sm_reconstruct_ltk_without_le_device_db_entry;
|
||||
static bool sm_reconstruct_ltk_without_le_device_db_entry;
|
||||
|
||||
#ifdef ENABLE_LE_SECURE_CONNECTIONS
|
||||
static bool sm_sc_only_mode;
|
||||
@ -205,7 +205,7 @@ static sm_sc_oob_state_t sm_sc_oob_state;
|
||||
#endif
|
||||
|
||||
|
||||
static uint8_t sm_persistent_keys_random_active;
|
||||
static bool sm_persistent_keys_random_active;
|
||||
static const btstack_tlv_t * sm_tlv_impl;
|
||||
static void * sm_tlv_context;
|
||||
|
||||
@ -465,21 +465,21 @@ static inline void sm_pairing_packet_set_responder_key_distribution(sm_pairing_p
|
||||
}
|
||||
|
||||
// @returns 1 if all bytes are 0
|
||||
static int sm_is_null(uint8_t * data, int size){
|
||||
static bool sm_is_null(uint8_t * data, int size){
|
||||
int i;
|
||||
for (i=0; i < size ; i++){
|
||||
if (data[i] != 0) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int sm_is_null_random(uint8_t random[8]){
|
||||
static bool sm_is_null_random(uint8_t random[8]){
|
||||
return sm_is_null(random, 8);
|
||||
}
|
||||
|
||||
static int sm_is_null_key(uint8_t * key){
|
||||
static bool sm_is_null_key(uint8_t * key){
|
||||
return sm_is_null(key, 16);
|
||||
}
|
||||
|
||||
@ -842,15 +842,15 @@ static void sm_setup_tk(void){
|
||||
|
||||
|
||||
// decide if OOB will be used based on SC vs. Legacy and oob flags
|
||||
int use_oob = 0;
|
||||
bool use_oob;
|
||||
if (setup->sm_use_secure_connections){
|
||||
// In LE Secure Connections pairing, the out of band method is used if at least
|
||||
// one device has the peer device's out of band authentication data available.
|
||||
use_oob = sm_pairing_packet_get_oob_data_flag(setup->sm_m_preq) | sm_pairing_packet_get_oob_data_flag(setup->sm_s_pres);
|
||||
use_oob = (sm_pairing_packet_get_oob_data_flag(setup->sm_m_preq) | sm_pairing_packet_get_oob_data_flag(setup->sm_s_pres)) != 0;
|
||||
} else {
|
||||
// In LE legacy pairing, the out of band method is used if both the devices have
|
||||
// the other device's out of band authentication data available.
|
||||
use_oob = sm_pairing_packet_get_oob_data_flag(setup->sm_m_preq) & sm_pairing_packet_get_oob_data_flag(setup->sm_s_pres);
|
||||
use_oob = (sm_pairing_packet_get_oob_data_flag(setup->sm_m_preq) & sm_pairing_packet_get_oob_data_flag(setup->sm_s_pres)) != 0;
|
||||
}
|
||||
if (use_oob){
|
||||
log_info("SM: have OOB data");
|
||||
@ -1261,9 +1261,9 @@ static void sm_address_resolution_handle_event(address_resolution_event_t event)
|
||||
|
||||
sm_connection_t * sm_connection;
|
||||
sm_key_t ltk;
|
||||
int have_ltk;
|
||||
bool have_ltk;
|
||||
#ifdef ENABLE_LE_CENTRAL
|
||||
int trigger_pairing;
|
||||
bool trigger_pairing;
|
||||
#endif
|
||||
switch (mode){
|
||||
case ADDRESS_RESOLUTION_GENERAL:
|
||||
@ -1305,7 +1305,7 @@ static void sm_address_resolution_handle_event(address_resolution_event_t event)
|
||||
#endif
|
||||
|
||||
log_info("peripheral: pairing request local %u, have_ltk %u => trigger_security_request %u",
|
||||
sm_connection->sm_pairing_requested, have_ltk, trigger_security_request);
|
||||
sm_connection->sm_pairing_requested, (int) have_ltk, trigger_security_request);
|
||||
|
||||
if (trigger_security_request){
|
||||
sm_connection->sm_engine_state = SM_RESPONDER_SEND_SECURITY_REQUEST;
|
||||
@ -1323,7 +1323,7 @@ static void sm_address_resolution_handle_event(address_resolution_event_t event)
|
||||
// check if pairing already requested and reset requests
|
||||
trigger_pairing = sm_connection->sm_pairing_requested || sm_connection->sm_security_request_received;
|
||||
log_info("central: pairing request local %u, remote %u => trigger_pairing %u. have_ltk %u",
|
||||
sm_connection->sm_pairing_requested, sm_connection->sm_security_request_received, trigger_pairing, have_ltk);
|
||||
sm_connection->sm_pairing_requested, sm_connection->sm_security_request_received, (int) trigger_pairing, (int) have_ltk);
|
||||
sm_connection->sm_security_request_received = 0;
|
||||
sm_connection->sm_pairing_requested = 0;
|
||||
bool trigger_reencryption = false;
|
||||
@ -1407,7 +1407,7 @@ static void sm_key_distribution_handle_all_received(sm_connection_t * sm_conn){
|
||||
int le_db_index = -1;
|
||||
|
||||
// only store pairing information if both sides are bondable, i.e., the bonadble flag is set
|
||||
int bonding_enabed = ( sm_pairing_packet_get_auth_req(setup->sm_m_preq)
|
||||
bool bonding_enabed = ( sm_pairing_packet_get_auth_req(setup->sm_m_preq)
|
||||
& sm_pairing_packet_get_auth_req(setup->sm_s_pres)
|
||||
& SM_AUTHREQ_BONDING ) != 0u;
|
||||
|
||||
@ -2216,7 +2216,7 @@ static void sm_run_activate_connection(void){
|
||||
hci_connection_t * hci_connection = (hci_connection_t *) btstack_linked_list_iterator_next(&it);
|
||||
sm_connection_t * sm_connection = &hci_connection->sm_connection;
|
||||
// - if no connection locked and we're ready/waiting for setup context, fetch it and start
|
||||
int done = 1;
|
||||
bool done = true;
|
||||
int err;
|
||||
UNUSED(err);
|
||||
|
||||
@ -2250,7 +2250,7 @@ static void sm_run_activate_connection(void){
|
||||
// just lock context
|
||||
break;
|
||||
default:
|
||||
done = 0;
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
if (done){
|
||||
@ -2331,7 +2331,7 @@ static void sm_run(void){
|
||||
uint8_t action = 0;
|
||||
for (i=SM_KEYPRESS_PASSKEY_ENTRY_STARTED;i<=SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED;i++){
|
||||
if (flags & (1u<<i)){
|
||||
int clear_flag = 1;
|
||||
bool clear_flag = true;
|
||||
switch (i){
|
||||
case SM_KEYPRESS_PASSKEY_ENTRY_STARTED:
|
||||
case SM_KEYPRESS_PASSKEY_CLEARED:
|
||||
@ -2484,8 +2484,8 @@ static void sm_run(void){
|
||||
#ifdef ENABLE_LE_SECURE_CONNECTIONS
|
||||
|
||||
case SM_SC_SEND_PUBLIC_KEY_COMMAND: {
|
||||
int trigger_user_response = 0;
|
||||
int trigger_start_calculating_local_confirm = 0;
|
||||
bool trigger_user_response = false;
|
||||
bool trigger_start_calculating_local_confirm = false;
|
||||
uint8_t buffer[65];
|
||||
buffer[0] = SM_CODE_PAIRING_PUBLIC_KEY;
|
||||
//
|
||||
@ -2507,7 +2507,7 @@ static void sm_run(void){
|
||||
case NUMERIC_COMPARISON:
|
||||
if (IS_RESPONDER(connection->sm_role)){
|
||||
// responder
|
||||
trigger_start_calculating_local_confirm = 1;
|
||||
trigger_start_calculating_local_confirm = true;
|
||||
connection->sm_engine_state = SM_SC_W4_LOCAL_NONCE;
|
||||
} else {
|
||||
// initiator
|
||||
@ -2529,7 +2529,7 @@ static void sm_run(void){
|
||||
// initiator
|
||||
connection->sm_engine_state = SM_SC_W4_PUBLIC_KEY_COMMAND;
|
||||
}
|
||||
trigger_user_response = 1;
|
||||
trigger_user_response = true;
|
||||
break;
|
||||
case OOB:
|
||||
if (IS_RESPONDER(connection->sm_role)){
|
||||
@ -3344,13 +3344,13 @@ static void sm_handle_random_result_ph3_random(void * arg){
|
||||
}
|
||||
static void sm_validate_er_ir(void){
|
||||
// warn about default ER/IR
|
||||
int warning = 0;
|
||||
bool warning = false;
|
||||
if (sm_ir_is_default()){
|
||||
warning = 1;
|
||||
warning = true;
|
||||
log_error("Persistent IR not set with sm_set_ir. Use of private addresses will cause pairing issues");
|
||||
}
|
||||
if (sm_er_is_default()){
|
||||
warning = 1;
|
||||
warning = true;
|
||||
log_error("Persistent ER not set with sm_set_er. Legacy Pairing LTK is not secure");
|
||||
}
|
||||
if (warning) {
|
||||
@ -3359,7 +3359,7 @@ static void sm_validate_er_ir(void){
|
||||
}
|
||||
|
||||
static void sm_handle_random_result_ir(void *arg){
|
||||
sm_persistent_keys_random_active = 0;
|
||||
sm_persistent_keys_random_active = false;
|
||||
if (arg != NULL){
|
||||
// key generated, store in tlv
|
||||
int status = sm_tlv_impl->store_tag(sm_tlv_context, BTSTACK_TAG32('S','M','I','R'), sm_persistent_ir, 16u);
|
||||
@ -3378,7 +3378,7 @@ static void sm_handle_random_result_ir(void *arg){
|
||||
}
|
||||
|
||||
static void sm_handle_random_result_er(void *arg){
|
||||
sm_persistent_keys_random_active = 0;
|
||||
sm_persistent_keys_random_active = false;
|
||||
if (arg != 0){
|
||||
// key generated, store in tlv
|
||||
int status = sm_tlv_impl->store_tag(sm_tlv_context, BTSTACK_TAG32('S','M','E','R'), sm_persistent_er, 16u);
|
||||
@ -3395,7 +3395,7 @@ static void sm_handle_random_result_er(void *arg){
|
||||
sm_handle_random_result_ir( NULL );
|
||||
} else {
|
||||
// invalid, generate new random one
|
||||
sm_persistent_keys_random_active = 1;
|
||||
sm_persistent_keys_random_active = true;
|
||||
btstack_crypto_random_generate(&sm_crypto_random_request, sm_persistent_ir, 16, &sm_handle_random_result_ir, &sm_persistent_ir);
|
||||
}
|
||||
}
|
||||
@ -3428,7 +3428,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
||||
sm_handle_random_result_er( NULL );
|
||||
} else {
|
||||
// invalid, generate random one
|
||||
sm_persistent_keys_random_active = 1;
|
||||
sm_persistent_keys_random_active = true;
|
||||
btstack_crypto_random_generate(&sm_crypto_random_request, sm_persistent_er, 16, &sm_handle_random_result_er, &sm_persistent_er);
|
||||
}
|
||||
} else {
|
||||
@ -4359,7 +4359,7 @@ void sm_init(void){
|
||||
sm_min_encryption_key_size = 7;
|
||||
|
||||
sm_fixed_passkey_in_display_role = 0xffffffff;
|
||||
sm_reconstruct_ltk_without_le_device_db_entry = 1;
|
||||
sm_reconstruct_ltk_without_le_device_db_entry = true;
|
||||
|
||||
#ifdef USE_CMAC_ENGINE
|
||||
sm_cmac_active = 0;
|
||||
@ -4402,7 +4402,7 @@ void sm_use_fixed_passkey_in_display_role(uint32_t passkey){
|
||||
}
|
||||
|
||||
void sm_allow_ltk_reconstruction_without_le_device_db_entry(int allow){
|
||||
sm_reconstruct_ltk_without_le_device_db_entry = allow;
|
||||
sm_reconstruct_ltk_without_le_device_db_entry = allow != 0;
|
||||
}
|
||||
|
||||
static sm_connection_t * sm_get_connection_for_handle(hci_con_handle_t con_handle){
|
||||
|
@ -374,8 +374,8 @@ void btstack_hid_parser_get_field(btstack_hid_parser_t * parser, uint16_t * usag
|
||||
*usage_page = parser->usage_minimum >> 16;
|
||||
|
||||
// read field (up to 32 bit unsigned, up to 31 bit signed - 32 bit signed behaviour is undefined) - check report len
|
||||
int is_variable = parser->descriptor_item.item_value & 2;
|
||||
int is_signed = parser->global_logical_minimum < 0;
|
||||
bool is_variable = (parser->descriptor_item.item_value & 2) != 0;
|
||||
bool is_signed = parser->global_logical_minimum < 0;
|
||||
int pos_start = btstack_min( parser->report_pos_in_bit >> 3, parser->report_len);
|
||||
int pos_end = btstack_min( (parser->report_pos_in_bit + parser->global_report_size - 1u) >> 3u, parser->report_len);
|
||||
int bytes_to_read = pos_end - pos_start + 1;
|
||||
|
14
src/hci.c
14
src/hci.c
@ -683,11 +683,11 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
|
||||
// get current data
|
||||
const uint16_t acl_header_pos = hci_stack->acl_fragmentation_pos - 4u;
|
||||
int current_acl_data_packet_length = hci_stack->acl_fragmentation_total_size - hci_stack->acl_fragmentation_pos;
|
||||
int more_fragments = 0;
|
||||
bool more_fragments = false;
|
||||
|
||||
// if ACL packet is larger than Bluetooth packet buffer, only send max_acl_data_packet_length
|
||||
if (current_acl_data_packet_length > max_acl_data_packet_length){
|
||||
more_fragments = 1;
|
||||
more_fragments = true;
|
||||
current_acl_data_packet_length = max_acl_data_packet_length;
|
||||
}
|
||||
|
||||
@ -703,7 +703,7 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
|
||||
|
||||
// count packet
|
||||
connection->num_packets_sent++;
|
||||
log_debug("hci_send_acl_packet_fragments loop before send (more fragments %d)", more_fragments);
|
||||
log_debug("hci_send_acl_packet_fragments loop before send (more fragments %d)", (int) more_fragments);
|
||||
|
||||
// update state for next fragment (if any) as "transport done" might be sent during send_packet already
|
||||
if (more_fragments){
|
||||
@ -722,7 +722,7 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
|
||||
hci_stack->acl_fragmentation_tx_active = 1;
|
||||
err = hci_stack->hci_transport->send_packet(HCI_ACL_DATA_PACKET, packet, size);
|
||||
|
||||
log_debug("hci_send_acl_packet_fragments loop after send (more fragments %d)", more_fragments);
|
||||
log_debug("hci_send_acl_packet_fragments loop after send (more fragments %d)", (int) more_fragments);
|
||||
|
||||
// done yet?
|
||||
if (!more_fragments) break;
|
||||
@ -1279,14 +1279,14 @@ static void hci_initializing_run(void){
|
||||
// Custom initialization
|
||||
if (hci_stack->chipset && hci_stack->chipset->next_command){
|
||||
hci_stack->chipset_result = (*hci_stack->chipset->next_command)(hci_stack->hci_packet_buffer);
|
||||
int send_cmd = 0;
|
||||
bool send_cmd = false;
|
||||
switch (hci_stack->chipset_result){
|
||||
case BTSTACK_CHIPSET_VALID_COMMAND:
|
||||
send_cmd = 1;
|
||||
send_cmd = true;
|
||||
hci_stack->substate = HCI_INIT_W4_CUSTOM_INIT;
|
||||
break;
|
||||
case BTSTACK_CHIPSET_WARMSTART_REQUIRED:
|
||||
send_cmd = 1;
|
||||
send_cmd = true;
|
||||
// CSR Warm Boot: Wait a bit, then send HCI Reset until HCI Command Complete
|
||||
log_info("CSR Warm Boot");
|
||||
btstack_run_loop_set_timer(&hci_stack->timeout, HCI_RESET_RESEND_TIMEOUT_MS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user