Esempio n. 1
0
 private void btnSendPairingRequest_Click(object sender, EventArgs e)
 {
     PairBondFieldTabDisable(true);
     HCICmds.GAPCmds.GAP_Authenticate gapAuthenticate = new HCICmds.GAPCmds.GAP_Authenticate();
     gapAuthenticate.connHandle = devForm.devInfo.Handle;
     try
     {
         gapAuthenticate.connHandle = Convert.ToUInt16(tbPairingConnHandle.Text.Trim(), 16);
     }
     catch (Exception ex)
     {
         msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Connection Handle\nFormat: 0x0000\n\n{0}\n", ex.Message));
         tbPairingConnHandle.Focus();
         PairBondUserInputControl();
         return;
     }
     tbPasskeyConnHandle.Text = tbPairingConnHandle.Text;
     gapAuthenticate.secReq_ioCaps = HCICmds.GAP_IOCaps.KeyboardDisplay;
     gapAuthenticate.secReq_oobAvailable = HCICmds.GAP_TrueFalse.False;
     gapAuthenticate.secReq_oob = "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00";
     byte num = (byte)0;
     if (ckBoxBondingEnabled.Checked && ckBoxAuthMitmEnabled.Checked)
         num = (byte)5;
     else if (ckBoxBondingEnabled.Checked)
         num = (byte)1;
     else if (ckBoxAuthMitmEnabled.Checked)
         num = (byte)4;
     gapAuthenticate.secReq_authReq = num;
     gapAuthenticate.secReq_maxEncKeySize = (byte)16;
     gapAuthenticate.secReq_keyDist = (byte)63;
     gapAuthenticate.pairReq_Enable = HCICmds.GAP_EnableDisable.Disable;
     gapAuthenticate.pairReq_ioCaps = HCICmds.GAP_IOCaps.NoInputNoOutput;
     gapAuthenticate.pairReq_oobDataFlag = HCICmds.GAP_EnableDisable.Disable;
     gapAuthenticate.pairReq_authReq = (byte)1;
     gapAuthenticate.pairReq_maxEncKeySize = (byte)16;
     gapAuthenticate.pairReq_keyDist = (byte)63;
     ShowProgress(true);
     devForm.StartTimer(DeviceForm.EventType.PairBond);
     devForm.sendCmds.SendGAP(gapAuthenticate);
 }