@@ -107,6 +107,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
107
107
for (uint8_t i=0 ; i<BLE_MAX_CHARS; i++) _chars_list[i] = NULL ;
108
108
109
109
varclr (&_bond_data);
110
+ _bond_data.own_enc .master_id .ediv = 0xFFFF ; // invalid value for ediv
110
111
111
112
_connect_cb = NULL ;
112
113
_discconnect_cb = NULL ;
@@ -620,8 +621,6 @@ void AdafruitBluefruit::_poll(void)
620
621
_conn_hdl = evt->evt .gap_evt .conn_handle ;
621
622
_peer_addr = para->peer_addr ;
622
623
623
- PRINT_HEX (_conn_hdl);
624
-
625
624
uint8_t txbuf_max;
626
625
(void ) sd_ble_tx_packet_count_get (_conn_hdl, &txbuf_max);
627
626
_txbuf_sem = xSemaphoreCreateCounting (txbuf_max, txbuf_max);
@@ -637,6 +636,12 @@ void AdafruitBluefruit::_poll(void)
637
636
{
638
637
if (_led_conn) ledOff (LED_CONN);
639
638
639
+ // Save all configured cccd
640
+ if ( _bonded )
641
+ {
642
+ saveAllCCCD ();
643
+ }
644
+
640
645
_conn_hdl = BLE_GATT_HANDLE_INVALID;
641
646
_bonded = false ;
642
647
varclr (&_peer_addr);
@@ -722,15 +727,11 @@ void AdafruitBluefruit::_poll(void)
722
727
// return security information. Otherwise NULL
723
728
ble_gap_evt_sec_info_request_t * sec_request = (ble_gap_evt_sec_info_request_t *) &evt->evt .gap_evt .params .sec_info_request ;
724
729
725
- PRINT_HEX (sec_request->master_id .ediv );
726
- // EDIV_INIT_VAL
727
730
if (_bond_data.own_enc .master_id .ediv == sec_request->master_id .ediv )
728
731
{
729
- PRINT_LOCATION ();
730
732
sd_ble_gap_sec_info_reply (evt->evt .gap_evt .conn_handle , &_bond_data.own_enc .enc_info , &_bond_data.peer_id .id_info , NULL );
731
733
} else
732
734
{
733
- PRINT_LOCATION ();
734
735
sd_ble_gap_sec_info_reply (evt->evt .gap_evt .conn_handle , NULL , NULL , NULL );
735
736
}
736
737
}
@@ -756,11 +757,14 @@ void AdafruitBluefruit::_poll(void)
756
757
case BLE_GAP_EVT_AUTH_STATUS:
757
758
{
758
759
ble_gap_evt_auth_status_t * status = &evt->evt .gap_evt .params .auth_status ;
760
+
759
761
// Bonding succeeded --> save encryption keys
760
- PRINT_HEX (status->auth_status );
761
762
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status )
762
763
{
763
764
_bonded = true ;
765
+ }else
766
+ {
767
+ PRINT_HEX (status->auth_status );
764
768
}
765
769
}
766
770
break ;
@@ -770,24 +774,6 @@ void AdafruitBluefruit::_poll(void)
770
774
// sd_ble_gatts_sys_attr_set(_conn_hdl, NULL, 0, 0);
771
775
break ;
772
776
773
- case BLE_GATTS_EVT_WRITE:
774
- // Auto Save when CCCD is enabled/disabled if bonded
775
- if ( _bonded )
776
- {
777
- ble_gatts_evt_write_t * write = &evt->evt .gatts_evt .params .write ;
778
-
779
- for (int i=0 ; i<_chars_count; i++)
780
- {
781
- if (_chars_list[i]->handles ().cccd_handle == write->handle )
782
- {
783
- saveAllCCCD ();
784
- break ;
785
- }
786
- }
787
- }
788
- break ;
789
-
790
-
791
777
default : break ;
792
778
}
793
779
0 commit comments