コード例 #1
0
ファイル: RspHandlersUtils.cs プロジェクト: zhimaijoy/BTool
 public bool CheckValidResponse(HCIReplies hciReplies)
 {
     if (hciReplies == null || hciReplies.HciLeExtEvent == null)
     {
         return(false);
     }
     return(true);
 }
コード例 #2
0
ファイル: AttReadByTypeRsp.cs プロジェクト: x893/BTool
 public bool GetATT_ReadByTypeRsp(HCIReplies hciReplies, ref bool dataFound)
 {
     dataFound = false;
     bool flag = rspHdlrsUtils.CheckValidResponse(hciReplies);
     if (flag)
     {
         HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
         HCIReplies.HCI_LE_ExtEvent.ATT_ReadByTypeRsp attReadByTypeRsp = hciLeExtEvent.AttReadByTypeRsp;
         HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
         if (attReadByTypeRsp != null)
         {
             dataFound = true;
             switch (leExtEventHeader.EventStatus)
             {
                 case 0:
                     if (attReadByTypeRsp.HandleData != null)
                     {
                         Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                         foreach (HCIReplies.HandleData handleData in attReadByTypeRsp.HandleData)
                         {
                             string attrKey = attrUuidUtils.GetAttrKey(attReadByTypeRsp.AttMsgHdr.ConnHandle, handleData.Handle);
                             DataAttr dataAttr = new DataAttr();
                             bool dataChanged = false;
                             if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttReadByTypeRsp"))
                             {
                                 flag = false;
                                 break;
                             }
                             dataAttr.Key = attrKey;
                             dataAttr.ConnHandle = attReadByTypeRsp.AttMsgHdr.ConnHandle;
                             dataAttr.Handle = handleData.Handle;
                             dataAttr.Value = devUtils.UnloadColonData(handleData.Data, false);
                             if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                             {
                                 flag = false;
                                 break;
                             }
                         }
                         if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                             flag = false;
                     }
                     break;
                 case 23:
                 case 26:
                     SendRspCallback(hciReplies, true);
                     break;
                 default:
                     flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadByTypeRsp");
                     break;
             }
         }
     }
     if (!flag && dataFound)
         SendRspCallback(hciReplies, false);
     return flag;
 }
コード例 #3
0
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttReadByTypeRspCallback != null)
     {
         AttReadByTypeRspCallback(new AttReadByTypeRsp.RspInfo()
         {
             Success           = success,
             Header            = hciReplies.HciLeExtEvent.Header,
             ATT_ReadByTypeRsp = hciReplies.HciLeExtEvent.AttReadByTypeRsp
         });
     }
 }
コード例 #4
0
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttHandleValueNotificationCallback == null)
     {
         return;
     }
     AttHandleValueNotificationCallback(new AttHandleValueNotification.RspInfo()
     {
         success = success,
         header  = hciReplies.HciLeExtEvent.Header,
         aTT_HandleValueNotification = hciReplies.HciLeExtEvent.AttHandleValueNotification
     });
 }
コード例 #5
0
ファイル: AttFindInfoRsp.cs プロジェクト: zhimaijoy/BTool
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttFindInfoRspCallback == null)
     {
         return;
     }
     AttFindInfoRspCallback(new AttFindInfoRsp.RspInfo()
     {
         success         = success,
         header          = hciReplies.HciLeExtEvent.Header,
         aTT_FindInfoRsp = hciReplies.HciLeExtEvent.AttFindInfoRsp
     });
 }
コード例 #6
0
ファイル: RspDataInThread.cs プロジェクト: x893/BTool
 private bool ProcessQData(HCIReplies hciReplies, ref bool dataFound)
 {
     bool success = true;
     dataFound = false;
     if (hciReplies == null || hciReplies.HciLeExtEvent == null)
         return false;
     switch (hciReplies.HciLeExtEvent.Header.EventCode)
     {
         case 1281:
             success = AttErrorRsp.GetATT_ErrorRsp(hciReplies, ref dataFound);
             break;
         case 1285:
             success = m_attFindInfoRsp.GetATT_FindInfoRsp(hciReplies, ref dataFound);
             break;
         case 1287:
             success = m_attFindByTypeValueRsp.GetATT_FindByTypeValueRsp(hciReplies, ref dataFound);
             break;
         case 1289:
             success = m_attReadByTypeRsp.GetATT_ReadByTypeRsp(hciReplies, ref dataFound);
             break;
         case 1291:
             success = AttReadRsp.GetATT_ReadRsp(hciReplies, ref dataFound);
             break;
         case 1293:
             success = AttReadBlobRsp.GetATT_ReadBlobRsp(hciReplies, ref dataFound);
             break;
         case 1297:
             success = m_attReadByGrpTypeRsp.GetATT_ReadByGrpTypeRsp(hciReplies, ref dataFound);
             break;
         case 1299:
             success = AttWriteRsp.GetATT_WriteRsp(hciReplies, ref dataFound);
             break;
         case 1303:
             success = AttPrepareWriteRsp.GetATT_PrepareWriteRsp(hciReplies, ref dataFound);
             break;
         case 1305:
             success = AttExecuteWriteRsp.GetATT_ExecuteWriteRsp(hciReplies, ref dataFound);
             break;
         case 1307:
             success = AttHandleValueNotification.GetATT_HandleValueNotification(hciReplies, ref dataFound);
             break;
         case 1309:
             success = AttHandleValueIndication.GetATT_HandleValueIndication(hciReplies, ref dataFound);
             break;
         case 1663:
             success = ExtCmdStatus.GetExtensionCommandStatus(hciReplies, ref dataFound);
             break;
     }
     return success;
 }
コード例 #7
0
        private bool QueueDataReady()
        {
            object data    = new HCIReplies();
            bool   success = DataQueue.RemoveQHead(ref data);

            if (success)
            {
                HCIReplies hciReplies = (HCIReplies)data;
                bool       dataFound  = false;
                success = ProcessQData(hciReplies, ref dataFound);
                if (success && dataFound && RspDataInChangedCallback != null)
                {
                    RspDataInChangedCallback();
                }
            }
            Thread.Sleep(10);
            return(success);
        }
コード例 #8
0
ファイル: RspDataInThread.cs プロジェクト: x893/BTool
 private bool QueueDataReady()
 {
     object data = new HCIReplies();
     bool success = DataQueue.RemoveQHead(ref data);
     if (success)
     {
         HCIReplies hciReplies = (HCIReplies)data;
         bool dataFound = false;
         success = ProcessQData(hciReplies, ref dataFound);
         if (success && dataFound && RspDataInChangedCallback != null)
             RspDataInChangedCallback();
     }
     Thread.Sleep(10);
     return success;
 }
コード例 #9
0
        public bool GetATT_ReadByTypeRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag = rspHdlrsUtils.CheckValidResponse(hciReplies);

            if (flag)
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_ReadByTypeRsp attReadByTypeRsp = hciLeExtEvent.AttReadByTypeRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (attReadByTypeRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case 0:
                        if (attReadByTypeRsp.HandleData != null)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            foreach (HCIReplies.HandleData handleData in attReadByTypeRsp.HandleData)
                            {
                                string   attrKey     = attrUuidUtils.GetAttrKey(attReadByTypeRsp.AttMsgHdr.ConnHandle, handleData.Handle);
                                DataAttr dataAttr    = new DataAttr();
                                bool     dataChanged = false;
                                if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttReadByTypeRsp"))
                                {
                                    flag = false;
                                    break;
                                }
                                dataAttr.Key        = attrKey;
                                dataAttr.ConnHandle = attReadByTypeRsp.AttMsgHdr.ConnHandle;
                                dataAttr.Handle     = handleData.Handle;
                                dataAttr.Value      = devUtils.UnloadColonData(handleData.Data, false);
                                if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                            {
                                flag = false;
                            }
                        }
                        break;

                    case 23:
                    case 26:
                        SendRspCallback(hciReplies, true);
                        break;

                    default:
                        flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadByTypeRsp");
                        break;
                    }
                }
            }
            if (!flag && dataFound)
            {
                SendRspCallback(hciReplies, false);
            }
            return(flag);
        }
コード例 #10
0
        public bool GetATT_HandleValueNotification(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool success;

            if (success = rspHdlrsUtils.CheckValidResponse(hciReplies))
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueNotification valueNotification = hciLeExtEvent.AttHandleValueNotification;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (valueNotification != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case (byte)0:
                        if (valueNotification.Value != null)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            string   attrKey     = attrUuidUtils.GetAttrKey(valueNotification.AttMsgHdr.ConnHandle, valueNotification.Handle);
                            DataAttr dataAttr    = new DataAttr();
                            bool     dataChanged = false;
                            if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttHandleValueNotification"))
                            {
                                success = false;
                                break;
                            }
                            else
                            {
                                dataAttr.Key        = attrKey;
                                dataAttr.ConnHandle = valueNotification.AttMsgHdr.ConnHandle;
                                dataAttr.Handle     = valueNotification.Handle;
                                dataAttr.Value      = valueNotification.Value;
                                if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                {
                                    success = false;
                                    break;
                                }
                                else if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                                {
                                    success = false;
                                    break;
                                }
                                else
                                {
                                    SendRspCallback(hciReplies, true);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            break;
                        }

                    default:
                        success = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttHandleValueNotification");
                        break;
                    }
                }
            }
            if (!success && dataFound)
            {
                SendRspCallback(hciReplies, false);
            }
            return(success);
        }
コード例 #11
0
ファイル: AttReadBlobRsp.cs プロジェクト: x893/BTool
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttReadBlobRspCallback == null)
         return;
     AttReadBlobRspCallback(
         new AttReadBlobRsp.RspInfo()
         {
             Success = success,
             Header = hciReplies.HciLeExtEvent.Header,
             ATT_ReadBlobRsp = hciReplies.HciLeExtEvent.AttReadBlobRsp
         });
 }
コード例 #12
0
ファイル: AttReadByGrpTypeRsp.cs プロジェクト: x893/BTool
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttReadByGrpTypeRspCallback != null)
     {
         AttReadByGrpTypeRspCallback(
             new AttReadByGrpTypeRsp.RspInfo()
             {
                 Success = success,
                 Header = hciReplies.HciLeExtEvent.Header,
                 ATT_ReadByGrpTypeRsp = hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp
             });
     }
 }
コード例 #13
0
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttHandleValueNotificationCallback == null)
         return;
     AttHandleValueNotificationCallback(new AttHandleValueNotification.RspInfo()
     {
         success = success,
         header = hciReplies.HciLeExtEvent.Header,
         aTT_HandleValueNotification = hciReplies.HciLeExtEvent.AttHandleValueNotification
     });
 }
コード例 #14
0
 public bool GetATT_HandleValueNotification(HCIReplies hciReplies, ref bool dataFound)
 {
     dataFound = false;
     bool success;
     if (success = rspHdlrsUtils.CheckValidResponse(hciReplies))
     {
         HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
         HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueNotification valueNotification = hciLeExtEvent.AttHandleValueNotification;
         HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
         if (valueNotification != null)
         {
             dataFound = true;
             switch (leExtEventHeader.EventStatus)
             {
                 case (byte)0:
                     if (valueNotification.Value != null)
                     {
                         Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                         string attrKey = attrUuidUtils.GetAttrKey(valueNotification.AttMsgHdr.ConnHandle, valueNotification.Handle);
                         DataAttr dataAttr = new DataAttr();
                         bool dataChanged = false;
                         if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttHandleValueNotification"))
                         {
                             success = false;
                             break;
                         }
                         else
                         {
                             dataAttr.Key = attrKey;
                             dataAttr.ConnHandle = valueNotification.AttMsgHdr.ConnHandle;
                             dataAttr.Handle = valueNotification.Handle;
                             dataAttr.Value = valueNotification.Value;
                             if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                             {
                                 success = false;
                                 break;
                             }
                             else if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                             {
                                 success = false;
                                 break;
                             }
                             else
                             {
                                 SendRspCallback(hciReplies, true);
                                 break;
                             }
                         }
                     }
                     else
                         break;
                 default:
                     success = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttHandleValueNotification");
                     break;
             }
         }
     }
     if (!success && dataFound)
         SendRspCallback(hciReplies, false);
     return success;
 }
コード例 #15
0
        public bool GetATT_ReadByGrpTypeRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag = rspHdlrsUtils.CheckValidResponse(hciReplies);

            if (flag)
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_ReadByGrpTypeRsp readByGrpTypeRsp = hciLeExtEvent.AttReadByGrpTypeRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (readByGrpTypeRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case 0:
                        if (readByGrpTypeRsp.HandleData != null)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            foreach (HCIReplies.HandleHandleData handleHandleData in readByGrpTypeRsp.HandleData)
                            {
                                string   attrKey1     = attrUuidUtils.GetAttrKey(readByGrpTypeRsp.AttMsgHdr.ConnHandle, handleHandleData.Handle1);
                                DataAttr dataAttr1    = new DataAttr();
                                bool     dataChanged1 = false;
                                if (!attrDataUtils.GetDataAttr(ref dataAttr1, ref dataChanged1, attrKey1, "AttReadByGrpTypeRsp"))
                                {
                                    flag = false;
                                    break;
                                }

                                dataAttr1.Key        = attrKey1;
                                dataAttr1.ConnHandle = readByGrpTypeRsp.AttMsgHdr.ConnHandle;
                                dataAttr1.Handle     = handleHandleData.Handle1;
                                dataAttr1.Value      = devUtils.UnloadColonData(handleHandleData.Data, false);
                                if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr1, dataChanged1, attrKey1))
                                {
                                    flag = false;
                                    break;
                                }

                                if (handleHandleData.Handle2 != ushort.MaxValue)
                                {
                                    if ((int)handleHandleData.Handle2 - (int)handleHandleData.Handle1 <= 0)
                                    {
                                        flag = false;
                                        break;
                                    }
                                    for (int index = handleHandleData.Handle1 + 1; index <= handleHandleData.Handle2; ++index)
                                    {
                                        string   attrKey2     = attrUuidUtils.GetAttrKey(readByGrpTypeRsp.AttMsgHdr.ConnHandle, (ushort)index);
                                        DataAttr dataAttr2    = new DataAttr();
                                        bool     dataChanged2 = false;
                                        if (!attrDataUtils.GetDataAttr(ref dataAttr2, ref dataChanged2, attrKey2, "AttReadByGrpTypeRsp"))
                                        {
                                            flag = false;
                                            break;
                                        }
                                        dataAttr2.Key        = attrKey2;
                                        dataAttr2.ConnHandle = readByGrpTypeRsp.AttMsgHdr.ConnHandle;
                                        dataAttr2.Handle     = (ushort)index;
                                        if (devForm.attrData.sendAutoCmds)
                                        {
                                            sendCmds.SendGATT(new HCICmds.GATTCmds.GATT_ReadLongCharValue()
                                            {
                                                connHandle = dataAttr2.ConnHandle,
                                                handle     = dataAttr2.Handle
                                            }, TxDataOut.CmdTypes.DiscUuidAndValues, null);
                                        }
                                        if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr2, dataChanged2, attrKey2))
                                        {
                                            flag = false;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                            {
                                flag = false;
                            }
                        }
                        break;

                    case 23:
                    case 26:
                        SendRspCallback(hciReplies, true);
                        break;

                    default:
                        flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadByGrpTypeRsp");
                        break;
                    }
                }
            }
            if (!flag && dataFound)
            {
                SendRspCallback(hciReplies, false);
            }
            return(flag);
        }
コード例 #16
0
ファイル: RxDataInRspData.cs プロジェクト: x893/BTool
 public byte UnloadAttMsgHeader(ref byte[] data, ref int index, ref bool dataErr, ref HCIReplies.ATT_MsgHeader attMsgHdr)
 {
     attMsgHdr.ConnHandle = 0;
     attMsgHdr.PduLength = 0;
     try
     {
         attMsgHdr.ConnHandle = m_dataUtils.Unload16Bits(data, ref index, ref dataErr, false);
         attMsgHdr.PduLength = m_dataUtils.Unload8Bits(data, ref index, ref dataErr);
     }
     catch (Exception ex)
     {
         m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("UnloadAttMsgHeader Failed\nMessage Data Transfer Issue.\n\n{0}\n", ex.Message));
         dataErr = true;
     }
     return attMsgHdr.PduLength;
 }
コード例 #17
0
ファイル: RxDataInRspData.cs プロジェクト: x893/BTool
 public void GetRspData(RxDataIn rxDataIn, HCIStopWait.StopWaitEvent stopWaitEvent)
 {
     int index1 = 0;
     bool dataErr = false;
     int num1 = 0;
     try
     {
         HCIReplies hciReplies = new HCIReplies();
         hciReplies.ObjTag = null;
         hciReplies.CmdType = TxDataOut.CmdTypes.General;
         if (stopWaitEvent != null)
         {
             hciReplies.ObjTag = stopWaitEvent.Tag;
             hciReplies.CmdType = stopWaitEvent.CmdType;
         }
         switch (rxDataIn.CmdOpcode)
         {
             case byte.MaxValue:
                 byte num2 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                 if (dataErr)
                     break;
                 hciReplies.HciLeExtEvent = new HCIReplies.HCI_LE_ExtEvent();
                 hciReplies.HciLeExtEvent.Header.EventCode = rxDataIn.EventOpcode;
                 hciReplies.HciLeExtEvent.Header.EventStatus = num2;
                 ushort num3 = rxDataIn.EventOpcode;
                 if (num3 <= 1171U)
                 {
                     if (num3 <= 1153U)
                         return;
                     else if (num3 == 1163 || num3 == 1171)
                         break;
                     else
                         break;
                 }
                 else if (num3 <= 1408U)
                 {
                     switch (num3)
                     {
                         case 1281:
                             hciReplies.HciLeExtEvent.AttErrorRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ErrorRsp();
                             if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttErrorRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             byte num4 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttErrorRsp.ReqOpCode = num4;
                             hciReplies.HciLeExtEvent.AttErrorRsp.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttErrorRsp.ErrorCode = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1282:
                             return;
                         case 1283:
                             return;
                         case 1284:
                             return;
                         case 1285:
                             hciReplies.HciLeExtEvent.AttFindInfoRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_FindInfoRsp();
                             if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttFindInfoRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttFindInfoRsp.Format = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             int uuidLength = m_deviceUtils.GetUuidLength(hciReplies.HciLeExtEvent.AttFindInfoRsp.Format, ref dataErr);
                             if (dataErr)
                                 return;
                             int dataLength1 = uuidLength + 2;
                             int totalLength1 = (int)rxDataIn.Length - index1;
                             hciReplies.HciLeExtEvent.AttFindInfoRsp.HandleData = new List<HCIReplies.HandleData>();
                             m_deviceUtils.UnloadHandleValueData(rxDataIn.Data, ref index1, totalLength1, dataLength1, ref dataErr, "Uuid", ref hciReplies.HciLeExtEvent.AttFindInfoRsp.HandleData);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1286:
                             return;
                         case 1287:
                             hciReplies.HciLeExtEvent.AttFindByTypeValueRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_FindByTypeValueRsp();
                             int num5;
                             if ((num5 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             if (num5 >= 2)
                             {
                                 int length = num5 / 2;
                                 hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.Handle = new ushort[length];
                                 for (int index2 = 0; index2 < length && !dataErr; ++index2)
                                 {
                                     hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.Handle[index2] = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                                     if (dataErr)
                                         break;
                                 }
                             }
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1288:
                             return;
                         case 1289:
                             hciReplies.HciLeExtEvent.AttReadByTypeRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadByTypeRsp();
                             int num6;
                             if ((num6 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByTypeRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             int dataLength2 = (int)m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttReadByTypeRsp.Length = (byte)dataLength2;
                             int totalLength2 = num6 - 1;
                             if (dataLength2 == 0)
                                 return;
                             string handleStr = string.Empty;
                             string valueStr = string.Empty;
                             hciReplies.HciLeExtEvent.AttReadByTypeRsp.HandleData = new List<HCIReplies.HandleData>();
                             m_deviceUtils.UnloadHandleValueData(rxDataIn.Data, ref index1, totalLength2, dataLength2, ref handleStr, ref valueStr, ref dataErr, "Data", ref hciReplies.HciLeExtEvent.AttReadByTypeRsp.HandleData);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1290:
                             return;
                         case 1291:
                             hciReplies.HciLeExtEvent.AttReadRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadRsp();
                             int length1;
                             if ((length1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttReadRsp.Data = new byte[length1];
                             for (int index2 = 0; index2 < length1 && !dataErr; ++index2)
                                 hciReplies.HciLeExtEvent.AttReadRsp.Data[index2] = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1292:
                             return;
                         case 1293:
                             hciReplies.HciLeExtEvent.AttReadBlobRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadBlobRsp();
                             int length2 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadBlobRsp.AttMsgHdr);
                             if (dataErr)
                                 return;
                             if (length2 > 0)
                             {
                                 hciReplies.HciLeExtEvent.AttReadBlobRsp.Data = new byte[length2];
                                 for (int index2 = 0; index2 < length2 && !dataErr; ++index2)
                                     hciReplies.HciLeExtEvent.AttReadBlobRsp.Data[index2] = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             }
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1294:
                             return;
                         case 1295:
                             return;
                         case 1296:
                             return;
                         case 1297:
                             hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadByGrpTypeRsp();
                             if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.AttMsgHdr)) == 0 || dataErr)
                                 return;
                             byte num7 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.Length = num7;
                             if ((int)num7 == 0)
                                 return;
                             int dataLength3 = (int)num7;
                             int totalLength3 = (int)rxDataIn.Length - 3 - index1 + 1;
                             hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.HandleData = new List<HCIReplies.HandleHandleData>();
                             m_deviceUtils.UnloadHandleHandleValueData(rxDataIn.Data, ref index1, totalLength3, dataLength3, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.HandleData);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1298:
                             return;
                         case 1299:
                             hciReplies.HciLeExtEvent.AttWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_WriteRsp();
                             if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttWriteRsp.attMsgHdr)) == 0 || dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1300:
                             return;
                         case 1301:
                             return;
                         case 1302:
                             return;
                         case 1303:
                             hciReplies.HciLeExtEvent.AttPrepareWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_PrepareWriteRsp();
                             num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttPrepareWriteRsp.AttMsgHdr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Offset = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1304:
                             return;
                         case 1305:
                             hciReplies.HciLeExtEvent.AttExecuteWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ExecuteWriteRsp();
                             num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttExecuteWriteRsp.AttMsgHdr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1306:
                             return;
                         case 1307:
                             hciReplies.HciLeExtEvent.AttHandleValueNotification = new HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueNotification();
                             num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttHandleValueNotification.AttMsgHdr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttHandleValueNotification.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttHandleValueNotification.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1308:
                             return;
                         case 1309:
                             hciReplies.HciLeExtEvent.AttHandleValueIndication = new HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueIndication();
                             num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttHandleValueIndication.AttMsgHdr);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttHandleValueIndication.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.AttHandleValueIndication.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                             if (dataErr)
                                 return;
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         case 1310:
                             return;
                         case 1408:
                             return;
                         default:
                             return;
                     }
                 }
                 else
                 {
                     switch (num3)
                     {
                         case 1536:
                         case 1537:
                         case 1538:
                         case 1539:
                         case 1540:
                         case 1541:
                         case 1542:
                         case 1543:
                         case 1544:
                         case 1545:
                         case 1546:
                         case 1547:
                         case 1548:
                         case 1549:
                         case 1550:
                         case 1551:
                             return;
                         case 1663:
                             hciReplies.HciLeExtEvent.GapHciCmdStat = new HCIReplies.HCI_LE_ExtEvent.GAP_HCI_ExtentionCommandStatus();
                             hciReplies.HciLeExtEvent.GapHciCmdStat.CmdOpCode = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                             if (dataErr)
                                 return;
                             hciReplies.HciLeExtEvent.GapHciCmdStat.DataLength = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                             if (dataErr)
                                 return;
                             ushort num8 = hciReplies.HciLeExtEvent.GapHciCmdStat.CmdOpCode;
                             if ((uint)num8 <= 64918U)
                             {
                                 if ((uint)num8 <= 64658U)
                                 {
                                     if ((int)num8 == 64650 || (int)num8 == 64658)
                                         return;
                                     else
                                         return;
                                 }
                                 else
                                 {
                                     switch (num8)
                                     {
                                         case 64778:
                                         case 64779:
                                         case 64780:
                                         case 64781:
                                         case 64786:
                                         case 64787:
                                         case 64790:
                                         case 64791:
                                         case 64792:
                                         case 64793:
                                         case 64902:
                                         case 64912:
                                         case 64908:
                                         case 64914:
                                         case 64918:
                                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                                             return;
                                         case 64900:
                                         case 64904:
                                         case 64906:
                                             break;
                                         default:
                                             return;
                                     }
                                 }
                             }
                             else if (num8 <= 64962U)
                             {
                                 if (num8 != 64946U)
                                     return;
                             }
                             else
                             {
                                 return;
                             }
                             m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                             return;
                         default:
                             return;
                     }
                 }
         }
     }
     catch (Exception ex)
     {
         m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Get Response Data Problem.\n" + ex.Message + "\nRxDataInRspData\n");
     }
 }
コード例 #18
0
        public bool GetATT_FindByTypeValueRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag;

            if (flag = rspHdlrsUtils.CheckValidResponse(hciReplies))
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_FindByTypeValueRsp findByTypeValueRsp = hciLeExtEvent.AttFindByTypeValueRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (findByTypeValueRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case (byte)0:
                        if (findByTypeValueRsp.Handle != null)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            foreach (ushort handle in findByTypeValueRsp.Handle)
                            {
                                string   attrKey     = attrUuidUtils.GetAttrKey(findByTypeValueRsp.AttMsgHdr.ConnHandle, handle);
                                DataAttr dataAttr    = new DataAttr();
                                bool     dataChanged = false;
                                if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttFindByTypeValueRsp"))
                                {
                                    flag = false;
                                    break;
                                }
                                else
                                {
                                    dataAttr.Key        = attrKey;
                                    dataAttr.ConnHandle = findByTypeValueRsp.AttMsgHdr.ConnHandle;
                                    dataAttr.Handle     = handle;
                                    if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                            if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                            {
                                flag = false;
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }

                    case (byte)23:
                    case (byte)26:
                        SendRspCallback(hciReplies, true);
                        break;

                    default:
                        flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttFindByTypeValueRsp");
                        break;
                    }
                }
            }
            if (!flag && dataFound)
            {
                SendRspCallback(hciReplies, false);
            }
            return(flag);
        }
コード例 #19
0
ファイル: AttFindByTypeValueRsp.cs プロジェクト: x893/BTool
 private void SendRspCallback(HCIReplies hciReplies, bool success)
 {
     if (AttFindByTypeValueRspCallback == null)
         return;
     AttFindByTypeValueRspCallback(new AttFindByTypeValueRsp.RspInfo()
     {
         success = success,
         header = hciReplies.HciLeExtEvent.Header,
         aTT_FindByTypeValueRsp = hciReplies.HciLeExtEvent.AttFindByTypeValueRsp
     });
 }
コード例 #20
0
ファイル: RspHandlersUtils.cs プロジェクト: zhimaijoy/BTool
 public bool UnexpectedRspEventStatus(HCIReplies hciReplies, string moduleName)
 {
     return(false);
 }
コード例 #21
0
ファイル: AttFindInfoRsp.cs プロジェクト: zhimaijoy/BTool
        public bool GetATT_FindInfoRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool success;

            if (success = rspHdlrsUtils.CheckValidResponse(hciReplies))
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_FindInfoRsp attFindInfoRsp = hciLeExtEvent.AttFindInfoRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader             = hciLeExtEvent.Header;
                if (attFindInfoRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case (byte)0:
                        if (attFindInfoRsp.HandleData != null)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            foreach (HCIReplies.HandleData handleData in attFindInfoRsp.HandleData)
                            {
                                string   attrKey     = m_attrUuidUtils.GetAttrKey(attFindInfoRsp.AttMsgHdr.ConnHandle, handleData.Handle);
                                DataAttr dataAttr    = new DataAttr();
                                bool     dataChanged = false;
                                if (!m_attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttFindInfoRsp"))
                                {
                                    success = false;
                                    break;
                                }
                                else
                                {
                                    dataAttr.Key          = attrKey;
                                    dataAttr.ConnHandle   = attFindInfoRsp.AttMsgHdr.ConnHandle;
                                    dataAttr.Handle       = handleData.Handle;
                                    dataAttr.Uuid         = m_deviceFormUtils.UnloadColonData(handleData.Data, false);
                                    dataAttr.UuidHex      = m_dataUtils.GetStringFromBytes(handleData.Data, true);
                                    dataAttr.IndentLevel  = m_attrUuidUtils.GetIndentLevel(dataAttr.UuidHex);
                                    dataAttr.UuidDesc     = m_attrUuidUtils.GetUuidDesc(dataAttr.UuidHex);
                                    dataAttr.ValueDesc    = m_attrUuidUtils.GetUuidValueDesc(dataAttr.UuidHex);
                                    dataAttr.ForeColor    = m_attrUuidUtils.GetForegroundColor(dataAttr.UuidHex);
                                    dataAttr.BackColor    = m_attrUuidUtils.GetBackgroundColor(dataAttr.UuidHex);
                                    dataAttr.ValueDisplay = m_attrUuidUtils.GetValueDsp(dataAttr.UuidHex);
                                    dataAttr.ValueEdit    = m_attrUuidUtils.GetValueEdit(dataAttr.UuidHex);
                                    if (m_deviceForm.attrData.sendAutoCmds || hciReplies.CmdType == TxDataOut.CmdTypes.DiscUuidAndValues)
                                    {
                                        m_sendCmds.SendGATT(new HCICmds.GATTCmds.GATT_ReadLongCharValue()
                                        {
                                            connHandle = dataAttr.ConnHandle,
                                            handle     = dataAttr.Handle
                                        }, TxDataOut.CmdTypes.DiscUuidAndValues, (SendCmds.SendCmdResult)null);
                                    }
                                    if (!m_attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                    {
                                        success = false;
                                        break;
                                    }
                                }
                            }
                            if (!m_attrDataUtils.UpdateAttrDict(tmpAttrDict))
                            {
                                success = false;
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }

                    case (byte)23:
                    case (byte)26:
                        SendRspCallback(hciReplies, true);
                        break;

                    default:
                        success = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttFindInfoRsp");
                        break;
                    }
                }
            }
            if (!success && dataFound)
            {
                SendRspCallback(hciReplies, false);
            }
            return(success);
        }
コード例 #22
0
ファイル: AttFindByTypeValueRsp.cs プロジェクト: x893/BTool
 public bool GetATT_FindByTypeValueRsp(HCIReplies hciReplies, ref bool dataFound)
 {
     dataFound = false;
     bool flag;
     if (flag = rspHdlrsUtils.CheckValidResponse(hciReplies))
     {
         HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
         HCIReplies.HCI_LE_ExtEvent.ATT_FindByTypeValueRsp findByTypeValueRsp = hciLeExtEvent.AttFindByTypeValueRsp;
         HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
         if (findByTypeValueRsp != null)
         {
             dataFound = true;
             switch (leExtEventHeader.EventStatus)
             {
                 case (byte)0:
                     if (findByTypeValueRsp.Handle != null)
                     {
                         Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                         foreach (ushort handle in findByTypeValueRsp.Handle)
                         {
                             string attrKey = attrUuidUtils.GetAttrKey(findByTypeValueRsp.AttMsgHdr.ConnHandle, handle);
                             DataAttr dataAttr = new DataAttr();
                             bool dataChanged = false;
                             if (!attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttFindByTypeValueRsp"))
                             {
                                 flag = false;
                                 break;
                             }
                             else
                             {
                                 dataAttr.Key = attrKey;
                                 dataAttr.ConnHandle = findByTypeValueRsp.AttMsgHdr.ConnHandle;
                                 dataAttr.Handle = handle;
                                 if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                 {
                                     flag = false;
                                     break;
                                 }
                             }
                         }
                         if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                         {
                             flag = false;
                             break;
                         }
                         else
                             break;
                     }
                     else
                         break;
                 case (byte)23:
                 case (byte)26:
                     SendRspCallback(hciReplies, true);
                     break;
                 default:
                     flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttFindByTypeValueRsp");
                     break;
             }
         }
     }
     if (!flag && dataFound)
         SendRspCallback(hciReplies, false);
     return flag;
 }
コード例 #23
0
        private bool ProcessQData(HCIReplies hciReplies, ref bool dataFound)
        {
            bool success = true;

            dataFound = false;
            if (hciReplies == null || hciReplies.HciLeExtEvent == null)
            {
                return(false);
            }
            switch (hciReplies.HciLeExtEvent.Header.EventCode)
            {
            case 1281:
                success = AttErrorRsp.GetATT_ErrorRsp(hciReplies, ref dataFound);
                break;

            case 1285:
                success = m_attFindInfoRsp.GetATT_FindInfoRsp(hciReplies, ref dataFound);
                break;

            case 1287:
                success = m_attFindByTypeValueRsp.GetATT_FindByTypeValueRsp(hciReplies, ref dataFound);
                break;

            case 1289:
                success = m_attReadByTypeRsp.GetATT_ReadByTypeRsp(hciReplies, ref dataFound);
                break;

            case 1291:
                success = AttReadRsp.GetATT_ReadRsp(hciReplies, ref dataFound);
                break;

            case 1293:
                success = AttReadBlobRsp.GetATT_ReadBlobRsp(hciReplies, ref dataFound);
                break;

            case 1297:
                success = m_attReadByGrpTypeRsp.GetATT_ReadByGrpTypeRsp(hciReplies, ref dataFound);
                break;

            case 1299:
                success = AttWriteRsp.GetATT_WriteRsp(hciReplies, ref dataFound);
                break;

            case 1303:
                success = AttPrepareWriteRsp.GetATT_PrepareWriteRsp(hciReplies, ref dataFound);
                break;

            case 1305:
                success = AttExecuteWriteRsp.GetATT_ExecuteWriteRsp(hciReplies, ref dataFound);
                break;

            case 1307:
                success = AttHandleValueNotification.GetATT_HandleValueNotification(hciReplies, ref dataFound);
                break;

            case 1309:
                success = AttHandleValueIndication.GetATT_HandleValueIndication(hciReplies, ref dataFound);
                break;

            case 1663:
                success = ExtCmdStatus.GetExtensionCommandStatus(hciReplies, ref dataFound);
                break;
            }
            return(success);
        }
コード例 #24
0
ファイル: AttReadBlobRsp.cs プロジェクト: zhimaijoy/BTool
        public bool GetATT_ReadBlobRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag;

            if (flag = rspHdlrsUtils.CheckValidResponse(hciReplies))
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_ReadBlobRsp attReadBlobRsp = hciLeExtEvent.AttReadBlobRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader             = hciLeExtEvent.Header;
                if (attReadBlobRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                    case 0:
                        if (attReadBlobRsp.Data != null)
                        {
                            int    length = attReadBlobRsp.Data.Length;
                            byte[] data   = attReadBlobRsp.Data;
                            if (length > 0)
                            {
                                if (readBlobData == null)
                                {
                                    readBlobData = new byte[length];
                                    readBlobData = data;
                                }
                                else
                                {
                                    byte[] bytes = readBlobData;
                                    readBlobData = new byte[bytes.Length + length];
                                    Array.Copy(bytes, 0, readBlobData, 0, bytes.Length);
                                    Array.Copy(data, 0, readBlobData, bytes.Length, data.Length);
                                }
                                if (hciReplies.ObjTag != null)
                                {
                                    readBlobHandle      = (ushort)hciReplies.ObjTag;
                                    readBlobHandleValid = true;
                                    break;
                                }
                                else
                                {
                                    readBlobHandle      = 0;
                                    readBlobHandleValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }

                    case 23:
                        SendRspCallback(hciReplies, true);
                        break;

                    case 26:
                        if (readBlobData != null && readBlobHandleValid)
                        {
                            Dictionary <string, DataAttr> tmpAttrDict = new Dictionary <string, DataAttr>();
                            string   attrKey1     = attrUuidUtils.GetAttrKey(attReadBlobRsp.AttMsgHdr.ConnHandle, readBlobHandle);
                            DataAttr dataAttr1    = new DataAttr();
                            bool     dataChanged1 = false;
                            if (!attrDataUtils.GetDataAttr(ref dataAttr1, ref dataChanged1, attrKey1, "AttReadBlobRsp"))
                            {
                                flag = false;
                                break;
                            }

                            dataAttr1.Key        = attrKey1;
                            dataAttr1.ConnHandle = attReadBlobRsp.AttMsgHdr.ConnHandle;
                            dataAttr1.Handle     = readBlobHandle;
                            dataAttr1.Value      = devUtils.UnloadColonData(readBlobData, false);
                            if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr1, dataChanged1, attrKey1))
                            {
                                flag = false;
                                break;
                            }

                            string[] delimiterStrs = new string[2] {
                                " ", ":"
                            };
                            byte[] uuid = dataUtils.GetHexBytes(dataAttr1.Uuid, delimiterStrs);
                            if (uuid != null &&
                                uuid.Length > 1 &&
                                uuid[0] == 3 &&
                                uuid[1] == 40 &&
                                dataAttr1.Value.Length > 0)
                            {
                                byte[] value = dataUtils.GetHexBytes(dataAttr1.Value, delimiterStrs);
                                if (value.Length > 0)
                                {
                                    int  index   = 0;
                                    bool dataErr = false;
                                    dataAttr1.Properties = dataUtils.Unload8Bits(value, ref index, ref dataErr);
                                    if (dataAttr1.Properties == 0)
                                    {
                                        dataAttr1.PropertiesStr = string.Empty;
                                    }
                                    else
                                    {
                                        dataAttr1.PropertiesStr = devUtils.GetGattCharProperties(dataAttr1.Properties, true) + " 0x" + dataAttr1.Properties.ToString("X2");
                                        if (value.Length >= 5)
                                        {
                                            ushort   handle       = dataUtils.Unload16Bits(value, ref index, ref dataErr, false);
                                            ushort   connHandle   = attReadBlobRsp.AttMsgHdr.ConnHandle;
                                            string   attrKey2     = attrUuidUtils.GetAttrKey(connHandle, handle);
                                            DataAttr dataAttr2    = new DataAttr();
                                            bool     dataChanged2 = false;
                                            if (!attrDataUtils.GetDataAttr(ref dataAttr2, ref dataChanged2, attrKey2, "AttReadBlobRsp"))
                                            {
                                                flag = false;
                                                break;
                                            }

                                            dataAttr2.Key        = attrKey2;
                                            dataAttr2.ConnHandle = connHandle;
                                            dataAttr2.Handle     = handle;
                                            int    dataLength = value.Length - index;
                                            byte[] destData   = new byte[dataLength];
                                            dataUtils.UnloadDataBytes(value, dataLength, ref index, ref destData, ref dataErr);
                                            dataAttr2.Uuid          = devUtils.UnloadColonData(destData, false);
                                            dataAttr2.UuidHex       = dataUtils.GetStringFromBytes(destData, true);
                                            dataAttr2.Properties    = dataAttr1.Properties;
                                            dataAttr2.PropertiesStr = dataAttr1.PropertiesStr;
                                            dataAttr2.IndentLevel   = attrUuidUtils.GetIndentLevel(dataAttr2.UuidHex);
                                            dataAttr2.UuidDesc      = attrUuidUtils.GetUuidDesc(dataAttr2.UuidHex);
                                            dataAttr2.ValueDesc     = attrUuidUtils.GetUuidValueDesc(dataAttr2.UuidHex);
                                            dataAttr2.ForeColor     = attrUuidUtils.GetForegroundColor(dataAttr2.UuidHex);
                                            dataAttr2.BackColor     = attrUuidUtils.GetBackgroundColor(dataAttr2.UuidHex);
                                            dataAttr2.ValueDisplay  = attrUuidUtils.GetValueDsp(dataAttr2.UuidHex);
                                            dataAttr2.ValueEdit     = attrUuidUtils.GetValueEdit(dataAttr2.UuidHex);
                                            if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr2, dataChanged2, attrKey2))
                                            {
                                                flag = false;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                            {
                                flag = false;
                                break;
                            }
                        }
                        readBlobData   = null;
                        readBlobHandle = 0;
                        SendRspCallback(hciReplies, true);
                        break;

                    default:
                        flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadBlobRsp");
                        break;
                    }
                }
            }
            if (!flag && dataFound)
            {
                readBlobData   = null;
                readBlobHandle = 0;
                SendRspCallback(hciReplies, false);
            }
            return(flag);
        }
コード例 #25
0
ファイル: AttReadByGrpTypeRsp.cs プロジェクト: x893/BTool
        public bool GetATT_ReadByGrpTypeRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag = rspHdlrsUtils.CheckValidResponse(hciReplies);
            if (flag)
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_ReadByGrpTypeRsp readByGrpTypeRsp = hciLeExtEvent.AttReadByGrpTypeRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (readByGrpTypeRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                        case 0:
                            if (readByGrpTypeRsp.HandleData != null)
                            {
                                Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                                foreach (HCIReplies.HandleHandleData handleHandleData in readByGrpTypeRsp.HandleData)
                                {
                                    string attrKey1 = attrUuidUtils.GetAttrKey(readByGrpTypeRsp.AttMsgHdr.ConnHandle, handleHandleData.Handle1);
                                    DataAttr dataAttr1 = new DataAttr();
                                    bool dataChanged1 = false;
                                    if (!attrDataUtils.GetDataAttr(ref dataAttr1, ref dataChanged1, attrKey1, "AttReadByGrpTypeRsp"))
                                    {
                                        flag = false;
                                        break;
                                    }

                                    dataAttr1.Key = attrKey1;
                                    dataAttr1.ConnHandle = readByGrpTypeRsp.AttMsgHdr.ConnHandle;
                                    dataAttr1.Handle = handleHandleData.Handle1;
                                    dataAttr1.Value = devUtils.UnloadColonData(handleHandleData.Data, false);
                                    if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr1, dataChanged1, attrKey1))
                                    {
                                        flag = false;
                                        break;
                                    }

                                    if (handleHandleData.Handle2 != ushort.MaxValue)
                                    {
                                        if ((int)handleHandleData.Handle2 - (int)handleHandleData.Handle1 <= 0)
                                        {
                                            flag = false;
                                            break;
                                        }
                                        for (int index = handleHandleData.Handle1 + 1; index <= handleHandleData.Handle2; ++index)
                                        {
                                            string attrKey2 = attrUuidUtils.GetAttrKey(readByGrpTypeRsp.AttMsgHdr.ConnHandle, (ushort)index);
                                            DataAttr dataAttr2 = new DataAttr();
                                            bool dataChanged2 = false;
                                            if (!attrDataUtils.GetDataAttr(ref dataAttr2, ref dataChanged2, attrKey2, "AttReadByGrpTypeRsp"))
                                            {
                                                flag = false;
                                                break;
                                            }
                                            dataAttr2.Key = attrKey2;
                                            dataAttr2.ConnHandle = readByGrpTypeRsp.AttMsgHdr.ConnHandle;
                                            dataAttr2.Handle = (ushort)index;
                                            if (devForm.attrData.sendAutoCmds)
                                                sendCmds.SendGATT(new HCICmds.GATTCmds.GATT_ReadLongCharValue()
                                                {
                                                    connHandle = dataAttr2.ConnHandle,
                                                    handle = dataAttr2.Handle
                                                }, TxDataOut.CmdTypes.DiscUuidAndValues, null);
                                            if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr2, dataChanged2, attrKey2))
                                            {
                                                flag = false;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                        break;
                                }
                                if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                                    flag = false;
                            }
                            break;
                        case 23:
                        case 26:
                            SendRspCallback(hciReplies, true);
                            break;
                        default:
                            flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadByGrpTypeRsp");
                            break;
                    }
                }
            }
            if (!flag && dataFound)
                SendRspCallback(hciReplies, false);
            return flag;
        }
コード例 #26
0
ファイル: RspHandlersUtils.cs プロジェクト: x893/BTool
 public bool UnexpectedRspEventStatus(HCIReplies hciReplies, string moduleName)
 {
     return false;
 }
コード例 #27
0
ファイル: AttReadBlobRsp.cs プロジェクト: x893/BTool
        public bool GetATT_ReadBlobRsp(HCIReplies hciReplies, ref bool dataFound)
        {
            dataFound = false;
            bool flag;
            if (flag = rspHdlrsUtils.CheckValidResponse(hciReplies))
            {
                HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
                HCIReplies.HCI_LE_ExtEvent.ATT_ReadBlobRsp attReadBlobRsp = hciLeExtEvent.AttReadBlobRsp;
                HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
                if (attReadBlobRsp != null)
                {
                    dataFound = true;
                    switch (leExtEventHeader.EventStatus)
                    {
                        case 0:
                            if (attReadBlobRsp.Data != null)
                            {
                                int length = attReadBlobRsp.Data.Length;
                                byte[] data = attReadBlobRsp.Data;
                                if (length > 0)
                                {
                                    if (readBlobData == null)
                                    {
                                        readBlobData = new byte[length];
                                        readBlobData = data;
                                    }
                                    else
                                    {
                                        byte[] bytes = readBlobData;
                                        readBlobData = new byte[bytes.Length + length];
                                        Array.Copy(bytes, 0, readBlobData, 0, bytes.Length);
                                        Array.Copy(data, 0, readBlobData, bytes.Length, data.Length);
                                    }
                                    if (hciReplies.ObjTag != null)
                                    {
                                        readBlobHandle = (ushort)hciReplies.ObjTag;
                                        readBlobHandleValid = true;
                                        break;
                                    }
                                    else
                                    {
                                        readBlobHandle = 0;
                                        readBlobHandleValid = false;
                                        break;
                                    }
                                }
                                else
                                    break;
                            }
                            else
                                break;
                        case 23:
                            SendRspCallback(hciReplies, true);
                            break;
                        case 26:
                            if (readBlobData != null && readBlobHandleValid)
                            {
                                Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                                string attrKey1 = attrUuidUtils.GetAttrKey(attReadBlobRsp.AttMsgHdr.ConnHandle, readBlobHandle);
                                DataAttr dataAttr1 = new DataAttr();
                                bool dataChanged1 = false;
                                if (!attrDataUtils.GetDataAttr(ref dataAttr1, ref dataChanged1, attrKey1, "AttReadBlobRsp"))
                                {
                                    flag = false;
                                    break;
                                }

                                dataAttr1.Key = attrKey1;
                                dataAttr1.ConnHandle = attReadBlobRsp.AttMsgHdr.ConnHandle;
                                dataAttr1.Handle = readBlobHandle;
                                dataAttr1.Value = devUtils.UnloadColonData(readBlobData, false);
                                if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr1, dataChanged1, attrKey1))
                                {
                                    flag = false;
                                    break;
                                }

                                string[] delimiterStrs = new string[2] { " ", ":" };
                                byte[] uuid = dataUtils.GetHexBytes(dataAttr1.Uuid, delimiterStrs);
                                if (uuid != null
                                && uuid.Length > 1
                                && uuid[0] == 3
                                && uuid[1] == 40
                                && dataAttr1.Value.Length > 0)
                                {
                                    byte[] value = dataUtils.GetHexBytes(dataAttr1.Value, delimiterStrs);
                                    if (value.Length > 0)
                                    {
                                        int index = 0;
                                        bool dataErr = false;
                                        dataAttr1.Properties = dataUtils.Unload8Bits(value, ref index, ref dataErr);
                                        if (dataAttr1.Properties == 0)
                                        {
                                            dataAttr1.PropertiesStr = string.Empty;
                                        }
                                        else
                                        {
                                            dataAttr1.PropertiesStr = devUtils.GetGattCharProperties(dataAttr1.Properties, true) + " 0x" + dataAttr1.Properties.ToString("X2");
                                            if (value.Length >= 5)
                                            {
                                                ushort handle = dataUtils.Unload16Bits(value, ref index, ref dataErr, false);
                                                ushort connHandle = attReadBlobRsp.AttMsgHdr.ConnHandle;
                                                string attrKey2 = attrUuidUtils.GetAttrKey(connHandle, handle);
                                                DataAttr dataAttr2 = new DataAttr();
                                                bool dataChanged2 = false;
                                                if (!attrDataUtils.GetDataAttr(ref dataAttr2, ref dataChanged2, attrKey2, "AttReadBlobRsp"))
                                                {
                                                    flag = false;
                                                    break;
                                                }

                                                dataAttr2.Key = attrKey2;
                                                dataAttr2.ConnHandle = connHandle;
                                                dataAttr2.Handle = handle;
                                                int dataLength = value.Length - index;
                                                byte[] destData = new byte[dataLength];
                                                dataUtils.UnloadDataBytes(value, dataLength, ref index, ref destData, ref dataErr);
                                                dataAttr2.Uuid = devUtils.UnloadColonData(destData, false);
                                                dataAttr2.UuidHex = dataUtils.GetStringFromBytes(destData, true);
                                                dataAttr2.Properties = dataAttr1.Properties;
                                                dataAttr2.PropertiesStr = dataAttr1.PropertiesStr;
                                                dataAttr2.IndentLevel = attrUuidUtils.GetIndentLevel(dataAttr2.UuidHex);
                                                dataAttr2.UuidDesc = attrUuidUtils.GetUuidDesc(dataAttr2.UuidHex);
                                                dataAttr2.ValueDesc = attrUuidUtils.GetUuidValueDesc(dataAttr2.UuidHex);
                                                dataAttr2.ForeColor = attrUuidUtils.GetForegroundColor(dataAttr2.UuidHex);
                                                dataAttr2.BackColor = attrUuidUtils.GetBackgroundColor(dataAttr2.UuidHex);
                                                dataAttr2.ValueDisplay = attrUuidUtils.GetValueDsp(dataAttr2.UuidHex);
                                                dataAttr2.ValueEdit = attrUuidUtils.GetValueEdit(dataAttr2.UuidHex);
                                                if (!attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr2, dataChanged2, attrKey2))
                                                {
                                                    flag = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!attrDataUtils.UpdateAttrDict(tmpAttrDict))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            readBlobData = null;
                            readBlobHandle = 0;
                            SendRspCallback(hciReplies, true);
                            break;
                        default:
                            flag = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttReadBlobRsp");
                            break;
                    }
                }
            }
            if (!flag && dataFound)
            {
                readBlobData = null;
                readBlobHandle = 0;
                SendRspCallback(hciReplies, false);
            }
            return flag;
        }
コード例 #28
0
ファイル: RspHandlersUtils.cs プロジェクト: x893/BTool
 public bool CheckValidResponse(HCIReplies hciReplies)
 {
     if (hciReplies == null || hciReplies.HciLeExtEvent == null)
         return false;
     return true;
 }
コード例 #29
0
ファイル: AttFindInfoRsp.cs プロジェクト: x893/BTool
 public bool GetATT_FindInfoRsp(HCIReplies hciReplies, ref bool dataFound)
 {
     dataFound = false;
     bool success;
     if (success = rspHdlrsUtils.CheckValidResponse(hciReplies))
     {
         HCIReplies.HCI_LE_ExtEvent hciLeExtEvent = hciReplies.HciLeExtEvent;
         HCIReplies.HCI_LE_ExtEvent.ATT_FindInfoRsp attFindInfoRsp = hciLeExtEvent.AttFindInfoRsp;
         HCIReplies.LE_ExtEventHeader leExtEventHeader = hciLeExtEvent.Header;
         if (attFindInfoRsp != null)
         {
             dataFound = true;
             switch (leExtEventHeader.EventStatus)
             {
                 case (byte)0:
                     if (attFindInfoRsp.HandleData != null)
                     {
                         Dictionary<string, DataAttr> tmpAttrDict = new Dictionary<string, DataAttr>();
                         foreach (HCIReplies.HandleData handleData in attFindInfoRsp.HandleData)
                         {
                             string attrKey = m_attrUuidUtils.GetAttrKey(attFindInfoRsp.AttMsgHdr.ConnHandle, handleData.Handle);
                             DataAttr dataAttr = new DataAttr();
                             bool dataChanged = false;
                             if (!m_attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, attrKey, "AttFindInfoRsp"))
                             {
                                 success = false;
                                 break;
                             }
                             else
                             {
                                 dataAttr.Key = attrKey;
                                 dataAttr.ConnHandle = attFindInfoRsp.AttMsgHdr.ConnHandle;
                                 dataAttr.Handle = handleData.Handle;
                                 dataAttr.Uuid = m_deviceFormUtils.UnloadColonData(handleData.Data, false);
                                 dataAttr.UuidHex = m_dataUtils.GetStringFromBytes(handleData.Data, true);
                                 dataAttr.IndentLevel = m_attrUuidUtils.GetIndentLevel(dataAttr.UuidHex);
                                 dataAttr.UuidDesc = m_attrUuidUtils.GetUuidDesc(dataAttr.UuidHex);
                                 dataAttr.ValueDesc = m_attrUuidUtils.GetUuidValueDesc(dataAttr.UuidHex);
                                 dataAttr.ForeColor = m_attrUuidUtils.GetForegroundColor(dataAttr.UuidHex);
                                 dataAttr.BackColor = m_attrUuidUtils.GetBackgroundColor(dataAttr.UuidHex);
                                 dataAttr.ValueDisplay = m_attrUuidUtils.GetValueDsp(dataAttr.UuidHex);
                                 dataAttr.ValueEdit = m_attrUuidUtils.GetValueEdit(dataAttr.UuidHex);
                                 if (m_deviceForm.attrData.sendAutoCmds || hciReplies.CmdType == TxDataOut.CmdTypes.DiscUuidAndValues)
                                     m_sendCmds.SendGATT(new HCICmds.GATTCmds.GATT_ReadLongCharValue()
                                     {
                                         connHandle = dataAttr.ConnHandle,
                                         handle = dataAttr.Handle
                                     }, TxDataOut.CmdTypes.DiscUuidAndValues, (SendCmds.SendCmdResult)null);
                                 if (!m_attrDataUtils.UpdateTmpAttrDict(ref tmpAttrDict, dataAttr, dataChanged, attrKey))
                                 {
                                     success = false;
                                     break;
                                 }
                             }
                         }
                         if (!m_attrDataUtils.UpdateAttrDict(tmpAttrDict))
                         {
                             success = false;
                             break;
                         }
                         else
                             break;
                     }
                     else
                         break;
                 case (byte)23:
                 case (byte)26:
                     SendRspCallback(hciReplies, true);
                     break;
                 default:
                     success = rspHdlrsUtils.UnexpectedRspEventStatus(hciReplies, "AttFindInfoRsp");
                     break;
             }
         }
     }
     if (!success && dataFound)
         SendRspCallback(hciReplies, false);
     return success;
 }
コード例 #30
0
        public void GetRspData(RxDataIn rxDataIn, HCIStopWait.StopWaitEvent stopWaitEvent)
        {
            int  index1  = 0;
            bool dataErr = false;
            int  num1    = 0;

            try
            {
                HCIReplies hciReplies = new HCIReplies();
                hciReplies.ObjTag  = null;
                hciReplies.CmdType = TxDataOut.CmdTypes.General;
                if (stopWaitEvent != null)
                {
                    hciReplies.ObjTag  = stopWaitEvent.Tag;
                    hciReplies.CmdType = stopWaitEvent.CmdType;
                }
                switch (rxDataIn.CmdOpcode)
                {
                case byte.MaxValue:
                    byte num2 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                    if (dataErr)
                    {
                        break;
                    }
                    hciReplies.HciLeExtEvent = new HCIReplies.HCI_LE_ExtEvent();
                    hciReplies.HciLeExtEvent.Header.EventCode   = rxDataIn.EventOpcode;
                    hciReplies.HciLeExtEvent.Header.EventStatus = num2;
                    ushort num3 = rxDataIn.EventOpcode;
                    if (num3 <= 1171U)
                    {
                        if (num3 <= 1153U)
                        {
                            return;
                        }
                        else if (num3 == 1163 || num3 == 1171)
                        {
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (num3 <= 1408U)
                    {
                        switch (num3)
                        {
                        case 1281:
                            hciReplies.HciLeExtEvent.AttErrorRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ErrorRsp();
                            if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttErrorRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            byte num4 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttErrorRsp.ReqOpCode = num4;
                            hciReplies.HciLeExtEvent.AttErrorRsp.Handle    = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttErrorRsp.ErrorCode = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1282:
                            return;

                        case 1283:
                            return;

                        case 1284:
                            return;

                        case 1285:
                            hciReplies.HciLeExtEvent.AttFindInfoRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_FindInfoRsp();
                            if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttFindInfoRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttFindInfoRsp.Format = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            int uuidLength = m_deviceUtils.GetUuidLength(hciReplies.HciLeExtEvent.AttFindInfoRsp.Format, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            int dataLength1  = uuidLength + 2;
                            int totalLength1 = (int)rxDataIn.Length - index1;
                            hciReplies.HciLeExtEvent.AttFindInfoRsp.HandleData = new List <HCIReplies.HandleData>();
                            m_deviceUtils.UnloadHandleValueData(rxDataIn.Data, ref index1, totalLength1, dataLength1, ref dataErr, "Uuid", ref hciReplies.HciLeExtEvent.AttFindInfoRsp.HandleData);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1286:
                            return;

                        case 1287:
                            hciReplies.HciLeExtEvent.AttFindByTypeValueRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_FindByTypeValueRsp();
                            int num5;
                            if ((num5 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            if (num5 >= 2)
                            {
                                int length = num5 / 2;
                                hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.Handle = new ushort[length];
                                for (int index2 = 0; index2 < length && !dataErr; ++index2)
                                {
                                    hciReplies.HciLeExtEvent.AttFindByTypeValueRsp.Handle[index2] = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                                    if (dataErr)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1288:
                            return;

                        case 1289:
                            hciReplies.HciLeExtEvent.AttReadByTypeRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadByTypeRsp();
                            int num6;
                            if ((num6 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByTypeRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            int dataLength2 = (int)m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttReadByTypeRsp.Length = (byte)dataLength2;
                            int totalLength2 = num6 - 1;
                            if (dataLength2 == 0)
                            {
                                return;
                            }
                            string handleStr = string.Empty;
                            string valueStr  = string.Empty;
                            hciReplies.HciLeExtEvent.AttReadByTypeRsp.HandleData = new List <HCIReplies.HandleData>();
                            m_deviceUtils.UnloadHandleValueData(rxDataIn.Data, ref index1, totalLength2, dataLength2, ref handleStr, ref valueStr, ref dataErr, "Data", ref hciReplies.HciLeExtEvent.AttReadByTypeRsp.HandleData);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1290:
                            return;

                        case 1291:
                            hciReplies.HciLeExtEvent.AttReadRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadRsp();
                            int length1;
                            if ((length1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttReadRsp.Data = new byte[length1];
                            for (int index2 = 0; index2 < length1 && !dataErr; ++index2)
                            {
                                hciReplies.HciLeExtEvent.AttReadRsp.Data[index2] = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            }
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1292:
                            return;

                        case 1293:
                            hciReplies.HciLeExtEvent.AttReadBlobRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadBlobRsp();
                            int length2 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadBlobRsp.AttMsgHdr);
                            if (dataErr)
                            {
                                return;
                            }
                            if (length2 > 0)
                            {
                                hciReplies.HciLeExtEvent.AttReadBlobRsp.Data = new byte[length2];
                                for (int index2 = 0; index2 < length2 && !dataErr; ++index2)
                                {
                                    hciReplies.HciLeExtEvent.AttReadBlobRsp.Data[index2] = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                                }
                            }
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1294:
                            return;

                        case 1295:
                            return;

                        case 1296:
                            return;

                        case 1297:
                            hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ReadByGrpTypeRsp();
                            if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.AttMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            byte num7 = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.Length = num7;
                            if ((int)num7 == 0)
                            {
                                return;
                            }
                            int dataLength3  = (int)num7;
                            int totalLength3 = (int)rxDataIn.Length - 3 - index1 + 1;
                            hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.HandleData = new List <HCIReplies.HandleHandleData>();
                            m_deviceUtils.UnloadHandleHandleValueData(rxDataIn.Data, ref index1, totalLength3, dataLength3, ref dataErr, ref hciReplies.HciLeExtEvent.AttReadByGrpTypeRsp.HandleData);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1298:
                            return;

                        case 1299:
                            hciReplies.HciLeExtEvent.AttWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_WriteRsp();
                            if ((num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttWriteRsp.attMsgHdr)) == 0 || dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1300:
                            return;

                        case 1301:
                            return;

                        case 1302:
                            return;

                        case 1303:
                            hciReplies.HciLeExtEvent.AttPrepareWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_PrepareWriteRsp();
                            num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttPrepareWriteRsp.AttMsgHdr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Offset = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttPrepareWriteRsp.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1304:
                            return;

                        case 1305:
                            hciReplies.HciLeExtEvent.AttExecuteWriteRsp = new HCIReplies.HCI_LE_ExtEvent.ATT_ExecuteWriteRsp();
                            num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttExecuteWriteRsp.AttMsgHdr);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1306:
                            return;

                        case 1307:
                            hciReplies.HciLeExtEvent.AttHandleValueNotification = new HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueNotification();
                            num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttHandleValueNotification.AttMsgHdr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttHandleValueNotification.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttHandleValueNotification.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1308:
                            return;

                        case 1309:
                            hciReplies.HciLeExtEvent.AttHandleValueIndication = new HCIReplies.HCI_LE_ExtEvent.ATT_HandleValueIndication();
                            num1 = (int)UnloadAttMsgHeader(ref rxDataIn.Data, ref index1, ref dataErr, ref hciReplies.HciLeExtEvent.AttHandleValueIndication.AttMsgHdr);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttHandleValueIndication.Handle = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.AttHandleValueIndication.Value = m_deviceUtils.UnloadColonData(rxDataIn.Data, ref index1, rxDataIn.Data.Length - index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        case 1310:
                            return;

                        case 1408:
                            return;

                        default:
                            return;
                        }
                    }
                    else
                    {
                        switch (num3)
                        {
                        case 1536:
                        case 1537:
                        case 1538:
                        case 1539:
                        case 1540:
                        case 1541:
                        case 1542:
                        case 1543:
                        case 1544:
                        case 1545:
                        case 1546:
                        case 1547:
                        case 1548:
                        case 1549:
                        case 1550:
                        case 1551:
                            return;

                        case 1663:
                            hciReplies.HciLeExtEvent.GapHciCmdStat           = new HCIReplies.HCI_LE_ExtEvent.GAP_HCI_ExtentionCommandStatus();
                            hciReplies.HciLeExtEvent.GapHciCmdStat.CmdOpCode = m_dataUtils.Unload16Bits(rxDataIn.Data, ref index1, ref dataErr, false);
                            if (dataErr)
                            {
                                return;
                            }
                            hciReplies.HciLeExtEvent.GapHciCmdStat.DataLength = m_dataUtils.Unload8Bits(rxDataIn.Data, ref index1, ref dataErr);
                            if (dataErr)
                            {
                                return;
                            }
                            ushort num8 = hciReplies.HciLeExtEvent.GapHciCmdStat.CmdOpCode;
                            if ((uint)num8 <= 64918U)
                            {
                                if ((uint)num8 <= 64658U)
                                {
                                    if ((int)num8 == 64650 || (int)num8 == 64658)
                                    {
                                        return;
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    switch (num8)
                                    {
                                    case 64778:
                                    case 64779:
                                    case 64780:
                                    case 64781:
                                    case 64786:
                                    case 64787:
                                    case 64790:
                                    case 64791:
                                    case 64792:
                                    case 64793:
                                    case 64902:
                                    case 64912:
                                    case 64908:
                                    case 64914:
                                    case 64918:
                                        m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                                        return;

                                    case 64900:
                                    case 64904:
                                    case 64906:
                                        break;

                                    default:
                                        return;
                                    }
                                }
                            }
                            else if (num8 <= 64962U)
                            {
                                if (num8 != 64946U)
                                {
                                    return;
                                }
                            }
                            else
                            {
                                return;
                            }
                            m_deviceForm.threadMgr.rspDataIn.DataQueue.AddQTail(hciReplies);
                            return;

                        default:
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Get Response Data Problem.\n" + ex.Message + "\nRxDataInRspData\n");
            }
        }