This commit is contained in:
hathach committed 2019-01-24 16:37:16 +07:00
1 parent bc36c95133
commit 6dd7918cc9
6 files changed
+13 -19

No files matched your search

+2 -2
View File
@@ -232,7 +232,7 @@ void srp_start(void)
srp.serverM1 = 0;
}
uint8_t srp_setA(uint8_t* abuf, uint16_t length, moretime_t moretime)
uint8_t srp_setA(uint8_t* abuf, uint16_t length, moretime_t moretime, uint16_t conn_hdl)
{
int err_code;
@@ -280,7 +280,7 @@ uint8_t srp_setA(uint8_t* abuf, uint16_t length, moretime_t moretime)
// These calculations take a long time. To avoid the connection dying we ask for more time now.
if (moretime)
{
moretime();
moretime(conn_hdl);
}
{
+2 -2
View File
@@ -36,11 +36,11 @@ extern "C"
extern srp_keys_t srp;
typedef void (*moretime_t)(void);
typedef void (*moretime_t)(uint16_t);
extern void srp_init(void);
extern void srp_start(void);
extern uint8_t srp_setA(uint8_t* a, uint16_t length, moretime_t moretime);
extern uint8_t srp_setA(uint8_t* a, uint16_t length, moretime_t moretime, uint16_t conn_hdl);
extern uint8_t srp_checkM1(uint8_t* m1, uint16_t length);
extern uint8_t* srp_getSalt(void);
extern uint8_t* srp_getB(void);
@@ -105,8 +105,7 @@ static const char* pairing_type_str[] =
void _pair_setup_write_cb (uint16_t conn_hdl, HAPCharacteristic* chr, HAPRequest_t const* hap_req);
void _pair_verify_write_cb (uint16_t conn_hdl, HAPCharacteristic* chr, HAPRequest_t const* hap_req);
// TODO add connection handle parameter
void gatt_reply_now(void)
void gatt_reply_now(uint16_t conn_hdl)
{
ble_gatts_rw_authorize_reply_params_t reply =
{
@@ -118,7 +117,7 @@ void gatt_reply_now(void)
}
}
};
VERIFY_STATUS( sd_ble_gatts_rw_authorize_reply(Bluefruit.connHandle(), &reply), );
VERIFY_STATUS( sd_ble_gatts_rw_authorize_reply(conn_hdl, &reply), );
}
HAPPairing::HAPPairing(void)
@@ -243,7 +242,7 @@ void HAPPairing::pair_setup_m3(uint16_t conn_hdl, HAPRequest_t const* hap_req, T
#endif
// Set iOS public key
srp_setA( (uint8_t*) pubkey.value, pubkey.len, gatt_reply_now);
srp_setA( (uint8_t*) pubkey.value, pubkey.len, gatt_reply_now, conn_hdl);
// Check proof
if ( srp_checkM1( (uint8_t*) proof.value, proof.len) )
@@ -446,6 +446,10 @@ void BLEConnection::_eventHandler(ble_evt_t* evt)
}
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(_conn_hdl, NULL, 0, 0);
break;
default: break;
}
}
@@ -156,10 +156,6 @@ void BLEPeriph::_eventHandler(ble_evt_t* evt)
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(conn_hdl, NULL, 0, 0);
break;
default: break;
}
}
+2 -7
View File
@@ -751,8 +751,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
* - Connect -> SEC_INFO_REQUEST -> CONN_SEC_UPDATE
*/
if ( conn_hdl == _conn_hdl ||
evt->header.evt_id == BLE_GAP_EVT_CONNECTED ||
evt->header.evt_id == BLE_GAP_EVT_TIMEOUT )
evt->header.evt_id == BLE_GAP_EVT_CONNECTED)
{
switch ( evt->header.evt_id )
{
@@ -762,7 +761,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
if (para->role == BLE_GAP_ROLE_PERIPH)
{
_conn_hdl = evt->evt.gap_evt.conn_handle;
_conn_hdl = evt->evt.gap_evt.conn_handle;
}
}
break;
@@ -771,10 +770,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
_conn_hdl = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(_conn_hdl, NULL, 0, 0);
break;
default: break;
}
}