BTool.AttReadByGrpTypeRsp.GetATT_ReadByGrpTypeRsp C# (CSharp) Méthode

GetATT_ReadByGrpTypeRsp() public méthode

public GetATT_ReadByGrpTypeRsp ( HCIReplies hciReplies, bool &dataFound ) : bool
hciReplies HCIReplies
dataFound bool
Résultat bool
        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;
        }

Usage Example

Exemple #1
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);
        }