hci: use bool for le_advertisements_active and le_advertisements_enabled

This commit is contained in:
Matthias Ringwald 2020-09-10 14:13:58 +02:00
parent a41310b780
commit 5226d7f2d7
2 changed files with 9 additions and 9 deletions

View File

@ -2693,7 +2693,7 @@ static void event_handler(uint8_t *packet, uint16_t size){
} else { } else {
#ifdef ENABLE_LE_PERIPHERAL #ifdef ENABLE_LE_PERIPHERAL
// if we're slave, it was an incoming connection, advertisements have stopped // if we're slave, it was an incoming connection, advertisements have stopped
hci_stack->le_advertisements_active = 0; hci_stack->le_advertisements_active = false;
#endif #endif
} }
// LE connections are auto-accepted, so just create a connection if there isn't one already // LE connections are auto-accepted, so just create a connection if there isn't one already
@ -3695,7 +3695,7 @@ static bool hci_run_general_gap_le(void){
#ifdef ENABLE_LE_CENTRAL #ifdef ENABLE_LE_CENTRAL
if (scanning_stop){ if (scanning_stop){
hci_stack->le_scanning_active = 0; hci_stack->le_scanning_active = false;
hci_send_cmd(&hci_le_set_scan_enable, 0, 0); hci_send_cmd(&hci_le_set_scan_enable, 0, 0);
return true; return true;
} }
@ -3712,7 +3712,7 @@ static bool hci_run_general_gap_le(void){
#ifdef ENABLE_LE_PERIPHERAL #ifdef ENABLE_LE_PERIPHERAL
if (advertising_stop){ if (advertising_stop){
hci_stack->le_advertisements_active = 0; hci_stack->le_advertisements_active = false;
hci_send_cmd(&hci_le_set_advertise_enable, 0); hci_send_cmd(&hci_le_set_advertise_enable, 0);
return true; return true;
} }
@ -3831,9 +3831,9 @@ static bool hci_run_general_gap_le(void){
#ifdef ENABLE_LE_PERIPHERAL #ifdef ENABLE_LE_PERIPHERAL
// re-start advertising // re-start advertising
if (hci_stack->le_advertisements_enabled_for_current_roles && (hci_stack->le_advertisements_active == 0)){ if (hci_stack->le_advertisements_enabled_for_current_roles && hci_stack->le_advertisements_active){
// check if advertisements should be enabled given // check if advertisements should be enabled given
hci_stack->le_advertisements_active = 1; hci_stack->le_advertisements_active = true;
hci_send_cmd(&hci_le_set_advertise_enable, 1); hci_send_cmd(&hci_le_set_advertise_enable, 1);
return true; return true;
} }
@ -4400,7 +4400,7 @@ int hci_send_cmd_packet(uint8_t *packet, int size){
break; break;
#ifdef ENABLE_LE_PERIPHERAL #ifdef ENABLE_LE_PERIPHERAL
case HCI_OPCODE_HCI_LE_SET_ADVERTISE_ENABLE: case HCI_OPCODE_HCI_LE_SET_ADVERTISE_ENABLE:
hci_stack->le_advertisements_active = packet[3]; hci_stack->le_advertisements_active = packet[3] != 0;
break; break;
#endif #endif
#ifdef ENABLE_LE_CENTRAL #ifdef ENABLE_LE_CENTRAL
@ -5220,7 +5220,7 @@ void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * sca
* @param enabled * @param enabled
*/ */
void gap_advertisements_enable(int enabled){ void gap_advertisements_enable(int enabled){
hci_stack->le_advertisements_enabled = enabled; hci_stack->le_advertisements_enabled = enabled != 0;
hci_update_advertisements_enabled_for_current_roles(); hci_update_advertisements_enabled_for_current_roles();
hci_run(); hci_run();
} }

View File

@ -924,8 +924,8 @@ typedef struct {
uint8_t * le_scan_response_data; uint8_t * le_scan_response_data;
uint8_t le_scan_response_data_len; uint8_t le_scan_response_data_len;
uint8_t le_advertisements_active; bool le_advertisements_active;
uint8_t le_advertisements_enabled; bool le_advertisements_enabled;
bool le_advertisements_enabled_for_current_roles; bool le_advertisements_enabled_for_current_roles;
uint8_t le_advertisements_todo; uint8_t le_advertisements_todo;