@@ -78,7 +78,7 @@ void adafruit_soc_task(void* arg);
7878static 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 ();
0 commit comments