예제 #1
0
 private void btnGATTWriteValue_Click(object sender, EventArgs e)
 {
     bool flag = false;
     tbWriteStatus.Text = "Writing...";
     HCICmds.GATTCmds.GATT_WriteCharValue gattWriteCharValue = new HCICmds.GATTCmds.GATT_WriteCharValue();
     try
     {
         gattWriteCharValue.connHandle = Convert.ToUInt16(tbWriteConnHandle.Text, 16);
     }
     catch (Exception ex)
     {
         string msg = string.Format("Invalid Connection Handle\n\n{0}\n", ex.Message);
         msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, msg);
         tbWriteConnHandle.Focus();
         flag = true;
     }
     try
     {
         gattWriteCharValue.handle = Convert.ToUInt16(tbWriteAttrHandle.Text, 16);
     }
     catch (Exception ex)
     {
         string msg = string.Format("Invalid Characteristic Value Handle(s)\n\n{0}\n", ex.Message);
         msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, msg);
         tbWriteAttrHandle.Focus();
         flag = true;
     }
     if (GATTWriteValueValidation(tbWriteValue.Text) && !flag)
     {
         gattWriteCharValue.value = (string)tbWriteValue.Tag;
         devForm.sendCmds.SendGATT(gattWriteCharValue, (SendCmds.SendCmdResult)null);
     }
     else
     {
         tbWriteValue.Focus();
         tbWriteStatus.Text = "Error!!!";
     }
 }