Skip to content

Commit 555e4a3

Browse files
committed
add LED_RED & LED_BLUE macro
1 parent 80508ca commit 555e4a3

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

libraries/Bluefruit52Lib/src/BLECentral.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void BLECentral::_event_handler(ble_evt_t* evt)
211211
if (para->role == BLE_GAP_ROLE_CENTRAL)
212212
{
213213
Bluefruit.stopConnLed();
214-
if (Bluefruit._led_conn) ledOn(LED_CONN);
214+
if (Bluefruit._led_conn) ledOn(LED_BLUE);
215215

216216
_conn_hdl = evt->evt.gap_evt.conn_handle;
217217

@@ -223,7 +223,7 @@ void BLECentral::_event_handler(ble_evt_t* evt)
223223
case BLE_GAP_EVT_DISCONNECTED:
224224
if ( _conn_hdl == evt->evt.gap_evt.conn_handle)
225225
{
226-
if (Bluefruit._led_conn) ledOff(LED_CONN);
226+
if (Bluefruit._led_conn) ledOff(LED_BLUE);
227227

228228
_conn_hdl = BLE_CONN_HANDLE_INVALID;
229229

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void adafruit_soc_task(void* arg);
7878
static void bluefruit_blinky_cb( TimerHandle_t xTimer )
7979
{
8080
(void) xTimer;
81-
ledToggle(LED_CONN);
81+
ledToggle(LED_BLUE);
8282
}
8383

8484
/**
@@ -472,7 +472,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
472472
if (para->role == BLE_GAP_ROLE_PERIPH)
473473
{
474474
stopConnLed();
475-
if (_led_conn) ledOn(LED_CONN);
475+
if (_led_conn) ledOn(LED_BLUE);
476476

477477
_conn_hdl = evt->evt.gap_evt.conn_handle;
478478
_conn_interval = para->conn_params.min_conn_interval;
@@ -509,7 +509,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
509509
// Check if it is peripheral connection
510510
if (_conn_hdl == evt->evt.gap_evt.conn_handle)
511511
{
512-
if (_led_conn) ledOff(LED_CONN);
512+
if (_led_conn) ledOff(LED_BLUE);
513513

514514
// Save all configured cccd
515515
if (_bonded) _saveBondedCCCD();
@@ -519,6 +519,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
519519
varclr(&_peer_addr);
520520

521521
vSemaphoreDelete(_txbuf_sem);
522+
_txbuf_sem = NULL;
522523

523524
if ( _discconnect_cb ) _discconnect_cb(evt->evt.gap_evt.params.disconnected.reason);
524525

@@ -535,22 +536,26 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
535536
break;
536537

537538
case BLE_EVT_TX_COMPLETE:
538-
for(uint8_t i=0; i<evt->evt.common_evt.params.tx_complete.count; i++)
539+
if ( _txbuf_sem )
539540
{
540-
xSemaphoreGive(_txbuf_sem);
541+
for(uint8_t i=0; i<evt->evt.common_evt.params.tx_complete.count; i++)
542+
{
543+
xSemaphoreGive(_txbuf_sem);
544+
}
541545
}
542546
break;
543547

544548
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
545549
{
550+
// Pairing in progress
546551
varclr(&_bond_data);
547552
_bond_data.own_enc.master_id.ediv = 0xFFFF; // invalid value for ediv
548553

549554
/* Step 1: Pairing/Bonding
550555
* - Central supplies its parameters
551556
* - We replies with our security parameters
552557
*/
553-
// ble_gap_sec_params_t* peer = &evt->evt.gap_evt.params.sec_params_request.peer_params;
558+
// ble_gap_sec_params_t* peer = &evt->evt.gap_evt.params.sec_params_request.peer_params;
554559

555560
ble_gap_sec_params_t sec_para =
556561
{
@@ -598,7 +603,7 @@ COMMENT_OUT(
598603

599604
case BLE_GAP_EVT_SEC_INFO_REQUEST:
600605
{
601-
// If bonded previously, Central will ask for stored keys.
606+
// Reconnection. If bonded previously, Central will ask for stored keys.
602607
// return security information. Otherwise NULL
603608
ble_gap_evt_sec_info_request_t* sec_request = (ble_gap_evt_sec_info_request_t*) &evt->evt.gap_evt.params.sec_info_request;
604609

@@ -616,10 +621,10 @@ COMMENT_OUT(
616621

617622
case BLE_GAP_EVT_PASSKEY_DISPLAY:
618623
{
619-
// ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
624+
// ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
620625
//
621-
// PRINT_INT(passkey_display->match_request);
622-
// PRINT_BUFFER(passkey_display->passkey, 6);
626+
// PRINT_INT(passkey_display->match_request);
627+
// PRINT_BUFFER(passkey_display->passkey, 6);
623628

624629
// sd_ble_gap_auth_key_reply
625630
}
@@ -645,7 +650,7 @@ COMMENT_OUT(
645650
{
646651
ble_gap_evt_auth_status_t* status = &evt->evt.gap_evt.params.auth_status;
647652

648-
// Bonding succeeded --> save encryption keys
653+
// Pairing/Bonding succeeded --> save encryption keys
649654
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
650655
{
651656
_saveBondKeys();

variants/feather52/variant.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ extern "C"
4343

4444
#define LED_BUILTIN PIN_LED1
4545
#define LED_CONN PIN_LED2
46-
#define LED_STATE_ON 1
46+
47+
#define LED_RED PIN_LED1
48+
#define LED_BLUE PIN_LED2
49+
50+
#define LED_STATE_ON 1 // State when LED is litted
4751

4852
// Buttons
4953
/*

0 commit comments

Comments
 (0)