Ejemplo n.º 1
0
 public bool SendATT(HCICmds.ATTCmds.ATT_ExchangeMTUReq cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.clientRxMTU, ref dataErr, false))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 2
0
 public bool SendGATT(HCICmds.GATTCmds.GATT_ReliableWrites cmd)
 {
     bool success = true;
     try
     {
         if (cmd.numRequests > 5)
         {
             m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Value Entry '{0}'\nValid Range Is 1 to {1}\n", cmd.numRequests, 5));
             return false;
         }
         else
         {
             int num1 = 0;
             SendCmds.Element[] elementArray = new SendCmds.Element[5];
             if ((int)cmd.numRequests > 0)
             {
                 for (int index = 0; index < (int)cmd.numRequests; ++index)
                 {
                     int num2 = num1 + 1 + 2 + 2;
                     elementArray[index].temp = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.writeElement[index].value, 16);
                     if (elementArray[index].temp == null)
                     {
                         DisplayInvalidValue(cmd.writeElement[index].value);
                         return false;
                     }
                     else
                         num1 = num2 + elementArray[index].temp.Length;
                 }
             }
             byte dataLength = (byte)((uint)cmd.dataLength + (uint)num1);
             byte[] data = new byte[(int)dataLength + 4];
             int index1 = 0;
             bool dataErr = false;
             if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index1, 1, cmd.opCodeValue, dataLength)
             && !m_dataUtils.Load16Bits(ref data, ref index1, cmd.connHandle, ref dataErr, false)
             && !m_dataUtils.Load8Bits(ref data, ref index1, cmd.numRequests, ref dataErr))
             {
                 if (cmd.numRequests > 0)
                 {
                     for (int index2 = 0; index2 < (int)cmd.numRequests; ++index2)
                     {
                         cmd.writeElement[index2].valueLen = (byte)elementArray[index2].temp.Length;
                         if (!m_dataUtils.Load8Bits(ref data, ref index1, cmd.writeElement[index2].valueLen, ref dataErr))
                         {
                             if (!m_dataUtils.Load16Bits(ref data, ref index1, cmd.writeElement[index2].handle, ref dataErr, false))
                             {
                                 if (!m_dataUtils.Load16Bits(ref data, ref index1, cmd.writeElement[index2].offset, ref dataErr, false))
                                 {
                                     if (cmd.writeElement[index2].valueLen > 0)
                                     {
                                         if (m_dataUtils.LoadDataBytes(ref data, ref index1, elementArray[index2].temp, ref dataErr))
                                             break;
                                     }
                                 }
                                 else
                                     break;
                             }
                             else
                                 break;
                         }
                         else
                             break;
                     }
                 }
                 if (!dataErr)
                     TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
             }
             if (dataErr)
                 success = HandleDataError(cmd.cmdName);
         }
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 3
0
 public void SetGapAuthCompleteInfo(HCICmds.GAPEvts.GAP_AuthenticationComplete obj)
 {
     lastGAP_AuthenticationComplete = obj;
     string str1 = string.Empty;
     string str2 = !GetAuthenticationEnabled() ? "FALSE" : "TRUE";
     lastAuthStr = str2;
     string str3 = string.Empty;
     tbLongTermKeyData.Text = string.Format("Authenticated Bond: {0:S}\r\n", str2);
     string str4 = string.Format("Long-Term Key:\r\n{0:S}\r\n", obj.devSecInfo_LTK);
     TextBox textBox1 = tbLongTermKeyData;
     string str5 = textBox1.Text + str4;
     textBox1.Text = str5;
     string str6 = string.Format("LTK Diversifier: 0x{0:X}\r\n", obj.devSecInfo_DIV);
     TextBox textBox2 = tbLongTermKeyData;
     string str7 = textBox2.Text + str6;
     textBox2.Text = str7;
     string str8 = string.Format("LTK Random: {0:S}\r\n", obj.devSecInfo_RAND);
     TextBox textBox3 = tbLongTermKeyData;
     string str9 = textBox3.Text + str8;
     textBox3.Text = str9;
     string str10 = string.Format("Identity Info BD Address: {0:S}", obj.idInfo_BdAddr);
     TextBox textBox4 = tbLongTermKeyData;
     string str11 = textBox4.Text + str10;
     textBox4.Text = str11;
     PairBondUserInputControl();
 }
Ejemplo n.º 4
0
        public bool SendGAP(HCICmds.GAPCmds.GAP_UpdateAdvertisingData cmd)
        {
            bool success = true;
            try
            {
                byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.advertData, 16);
                if (sourceData == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Advert Data Entry.\n '{0}' \nFormat Is  00:00....\n", cmd.advertData));
                    return false;
                }

                byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
                byte[] data = new byte[dataLength + 4];
                int index = 0;
                bool dataErr = false;
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
                && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.adType, ref dataErr))
                {
                    cmd.dataLen = (byte)sourceData.Length;
                    if (!m_dataUtils.Load8Bits(ref data, ref index, cmd.dataLen, ref dataErr)
                    && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                        TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
                }
                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 5
0
        public bool SendGAP(HCICmds.GAPCmds.GAP_DeviceDiscoveryRequest obj)
        {
            bool success = true;
            try
            {
                byte dataLength = obj.dataLength;
                byte[] data = new byte[(int)dataLength + 4];
                int index = 0;
                bool dataErr = false;
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, obj.opCodeValue, dataLength)
                && !m_dataUtils.Load8Bits(ref data, ref index, (byte)obj.mode, ref dataErr)
                && !m_dataUtils.Load8Bits(ref data, ref index, (byte)obj.activeScan, ref dataErr)
                && !m_dataUtils.Load8Bits(ref data, ref index, (byte)obj.whiteList, ref dataErr))
                    TransmitCmd(obj.cmdName, obj.opCodeValue, data);

                if (dataErr)
                    success = HandleDataError(obj.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(obj.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 6
0
        public bool SendGAP(HCICmds.GAPCmds.GAP_DeviceInit cmd)
        {
            bool success = true;
            try
            {
                byte[] s_IRK = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.irk, 16);
                if (s_IRK == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid IRK Value Entry '{0}'\nFormat Is 00:00....\n", cmd.irk));
                    return false;
                }

                byte[] s_CSRK = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.csrk, 16);
                if (s_CSRK == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid CSRK Value Entry '{0}'\nFormat Is 00:00....\n", cmd.csrk));
                    return false;
                }

                byte dataLength = (byte)(cmd.dataLength + s_IRK.Length + s_CSRK.Length);
                byte[] data = new byte[dataLength + 4];
                int index = 0;
                bool dataErr = false;
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength))
                {
                    byte bits = 0;
                    if (cmd.broadcasterProfileRole == HCICmds.GAP_EnableDisable.Enable)
                        bits |= 1;
                    if (cmd.observerProfileRole == HCICmds.GAP_EnableDisable.Enable)
                        bits |= 2;
                    if (cmd.peripheralProfileRole == HCICmds.GAP_EnableDisable.Enable)
                        bits |= 4;
                    if (cmd.centralProfileRole == HCICmds.GAP_EnableDisable.Enable)
                        bits |= 8;
                    if (!m_dataUtils.Load8Bits(ref data, ref index, bits, ref dataErr)
                    && !m_dataUtils.Load8Bits(ref data, ref index, cmd.maxScanResponses, ref dataErr))
                    {
                        if (s_IRK.Length == 16)
                        {
                            if (!m_dataUtils.LoadDataBytes(ref data, ref index, s_IRK, ref dataErr))
                            {
                                if (s_CSRK.Length == 16)
                                {
                                    if (!m_dataUtils.LoadDataBytes(ref data, ref index, s_CSRK, ref dataErr)
                                    && !m_dataUtils.Load32Bits(ref data, ref index, cmd.signCounter, ref dataErr, false))
                                        TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
                                }
                                else
                                {
                                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid CSRK Data Length = {0:D} \nLength must be {1:D}\n", s_CSRK.Length, 16));
                                    return false;
                                }
                            }
                        }
                        else
                        {
                            m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid IRK Data Length = {0:D} \nLength must be {1:D}\n", s_IRK.Length, 16));
                            return false;
                        }
                    }
                }
                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 7
0
 public bool SendATT(HCICmds.ATTCmds.ATT_ReadByGrpTypeRsp cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.dataList, 16);
         if (sourceData == null)
         {
             m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Data List Entry.\n '{0}'\nFormat Is 00:00...\n", cmd.dataList));
             return false;
         }
         byte dataLength = (byte)((uint)cmd.dataLength + (uint)sourceData.Length);
         byte[] data = new byte[(int)dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false))
         {
             cmd.length = (byte)sourceData.Length;
             if (!m_dataUtils.Load8Bits(ref data, ref index, cmd.length, ref dataErr)
             && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                 TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         }
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 8
0
 public bool SendHCIExt(HCICmds.HCIExtCmds.HCIExt_SetBDADDR cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2BDA_LSBMSB(cmd.bleDevAddr);
         byte dataLength = cmd.dataLength;
         if (sourceData != null)
             dataLength += (byte)sourceData.Length;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 9
0
 public bool SendHCIExt(HCICmds.HCIExtCmds.HCIExt_PER cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.perTestCommand, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 10
0
 public bool SendGATT(HCICmds.GATTCmds.GATT_AddAttribute cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.uuid, 16);
         if (sourceData == null)
         {
             DisplayInvalidUUIDEntry(cmd.uuid);
             return false;
         }
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr)
         && !m_dataUtils.Load8Bits(ref data, ref index, cmd.permissions, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 11
0
        public bool SendHCIExt(HCICmds.HCIExtCmds.HCIExt_SetLocalSupportedFeatures cmd)
        {
            bool success = true;
            try
            {
                byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.localFeatures, 16);
                if (sourceData == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Local Features Entry.\n '{0}'\nFormat Is 00:00....\n", cmd.localFeatures));
                    return false;
                }

                byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
                byte[] data = new byte[dataLength + 4];
                int index = 0;
                bool dataErr = false;
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength))
                {
                    if (sourceData.Length == 8)
                    {
                        if (!m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                            TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
                    }
                    else
                    {
                        m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Local Features Length = {0:D} \nLength must be {1:D}\n", sourceData.Length, 8));
                        return false;
                    }
                }
                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 12
0
 public bool SendGATT(HCICmds.GATTCmds.GATT_AddService obj)
 {
     bool success = true;
     try
     {
         byte dataLength = obj.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, obj.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, (ushort)obj.uuid, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, obj.numAttrs, ref dataErr, false))
             TransmitCmd(obj.cmdName, obj.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(obj.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(obj.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 13
0
 public bool SendGATT(HCICmds.GATTCmds.GATT_WriteCharDesc cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.value, 16);
         if (sourceData == null)
         {
             DisplayInvalidValue(cmd.value);
             return false;
         }
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.offset, ref dataErr, false)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data, TxDataOut.CmdTypes.General);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 14
0
 public bool SendATT(HCICmds.ATTCmds.ATT_FindByTypeValueRsp cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.handlesInfo, 16);
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 15
0
        public bool SendATT(HCICmds.ATTCmds.ATT_ReadMultiReq cmd)
        {
            bool success = true;
            try
            {
                ushort[] numArray = m_deviceFormUtils.String2UInt16_LSBMSB(cmd.handles, 16);
                bool dataErr = false;
                if (numArray != null && numArray.Length > 1)
                {
                    byte dataLength = (byte)(cmd.dataLength + (numArray.Length * 2));
                    byte[] data = new byte[dataLength + 4];
                    int index1 = 0;
                    if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index1, 1, cmd.opCodeValue, dataLength))
                    {
                        if (!m_dataUtils.Load16Bits(ref data, ref index1, cmd.connHandle, ref dataErr, false))
                        {
                            for (int index2 = 0; index2 < numArray.Length; ++index2)
                            {
                                m_dataUtils.Load16Bits(ref data, ref index1, numArray[index2], ref dataErr, false);
                                if (dataErr)
                                    break;
                            }
                            TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
                        }
                    }
                }
                else if (numArray == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Invalid Characteristic Value Handle(s)\nFormat: 0x0001;0x0002\n");
                }
                else if (numArray.Length < 2)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Need More Than One Characteristic Value Handle\nFormat: 0x0001;0x0002\n");
                }

                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 16
0
 public bool SendHCIOther(HCICmds.HCIOtherCmds.HCIOther_LEClearWhiteList cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 17
0
 public bool SendATT(HCICmds.ATTCmds.ATT_ReadByGrpTypeReq cmd, TxDataOut.CmdTypes cmdType)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.groupType, 16);
         if (sourceData == null)
         {
             m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Group Type Entry.\n '{0}'\nFormat Is Either 00:00 or 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00\n", cmd.groupType));
             return false;
         }
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.startHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.endHandle, ref dataErr, false)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data, cmdType);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 18
0
        public bool SendHCIOther(HCICmds.HCIOtherCmds.HCIOther_LERemoveDeviceFromWhiteList cmd)
        {
            bool success = true;
            try
            {
                byte[] sourceData = m_deviceFormUtils.String2BDA_LSBMSB(cmd.devAddr);
                if (sourceData == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Addr Value Entry.\n '{0}'\nFormat Is  00:00....\n", cmd.devAddr));
                    return false;
                }

                byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
                byte[] data = new byte[dataLength + 4];
                int index = 0;
                bool dataErr = false;
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
                && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.addrType, ref dataErr))
                {
                    if (sourceData.Length == 6)
                    {
                        if (!m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                            TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
                    }
                    else
                    {
                        m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Address Length = {0:D} \nLength must be {1:D}\n", sourceData.Length, 6));
                        return false;
                    }
                }
                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 19
0
 public bool SendATT(HCICmds.ATTCmds.ATT_ExecuteWriteReq cmd, SendCmds.SendCmdResult callback)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.flags, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data, callback);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 20
0
 public bool SendHCIOther(HCICmds.HCIOtherCmds.HCIOther_LEConnectionUpdate cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.handle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connInterval, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connIntervalMax, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connLatency, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connTimeout, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.minimumLength, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.maximumLength, ref dataErr, false))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 21
0
 public bool SendATT(HCICmds.ATTCmds.ATT_HandleValueIndication cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.value, 16);
         if (sourceData == null)
         {
             DisplayInvalidAttributeValue(cmd.value);
             return false;
         }
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.authenticated, ref dataErr)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.handle, ref dataErr, false)
         && !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 22
0
 public bool SendL2CAP(HCICmds.L2CAPCmds.L2CAP_ConnParamUpdateReq cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.intervalMin, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.intervalMax, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.slaveLatency, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.timeoutMultiplier, ref dataErr, false))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 23
0
 public bool SendGAP(HCICmds.GAPCmds.GAP_ConfigDeviceAddr cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] numArray = new byte[6];
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.addrType, ref dataErr))
         {
             byte[] sourceData = m_deviceFormUtils.String2BDA_LSBMSB(cmd.addr);
             if (sourceData != null)
             {
                 if (!m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                     TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
             }
             else
                 success = false;
         }
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 24
0
        public bool SendMISC(HCICmds.MISCCmds.MISC_GenericCommand cmd)
        {
            bool success = true;
            try
            {
                byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.data, 16);
                if (sourceData == null)
                {
                    DisplayInvalidData(cmd.data);
                    return false;
                }

                cmd.dataLength = (byte)sourceData.Length;
                byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
                byte[] data = new byte[dataLength + 4];
                int index = 0;
                bool dataErr = false;
                ushort num;
                try
                {
                    num = Convert.ToUInt16((cmd.opCode).ToString(), 16);
                }
                catch (Exception ex)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid OpCode Entry.\n '{0}'\nFormat Is 0x0000.\n\n{1}\n", cmd.opCode.ToString(), ex.Message));
                    return false;
                }
                if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, num, dataLength))
                {
                    if (sourceData.Length == 0 || !m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                        TransmitCmd(cmd.cmdName, num, data);
                }

                if (dataErr)
                    success = HandleDataError(cmd.cmdName);
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 25
0
 public bool SendGAP(HCICmds.GAPCmds.GAP_MakeDiscoverable cmd)
 {
     bool success = true;
     try
     {
         byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.initiatorAddr, 16);
         if (sourceData == null)
         {
             m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Initiator Address Value Entry.\n '{0}'\nFormat Is  00:00....\n", cmd.initiatorAddr));
             return false;
         }
         byte dataLength = (byte)(cmd.dataLength + sourceData.Length);
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.eventType, ref dataErr)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.initiatorAddrType, ref dataErr))
         {
             if (sourceData.Length == 6)
             {
                 if (!m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr)
                 && !m_dataUtils.Load8Bits(ref data, ref index, cmd.channelMap, ref dataErr)
                 && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.filterPolicy, ref dataErr))
                     TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
             }
             else
             {
                 m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Initiator's Address Length = {0:D} \nLength must be {1:D}", sourceData.Length, 6));
                 return false;
             }
         }
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 26
0
        public bool SendMISC(HCICmds.MISCCmds.MISC_RawTxMessage cmd)
        {
            bool success = true;
            try
            {
                bool dataErr = false;
                byte[] sourceData = m_deviceFormUtils.String2Bytes_LSBMSB(cmd.message, 16);
                if (sourceData == null)
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Invalid Message Entry.\n '{0}'\nFormat Is  00:00....\n", cmd.message));
                    return false;
                }

                byte[] data = new byte[cmd.dataLength + sourceData.Length];
                int index = 0;
                if (sourceData.Length >= 4)
                {
                    if (!m_dataUtils.LoadDataBytes(ref data, ref index, sourceData, ref dataErr))
                    {
                        ushort cmdOpcode = (ushort)(m_dataUtils.SetByte16(data[1], 0) + m_dataUtils.SetByte16(data[2], 1));
                        TransmitCmd(cmd.cmdName, cmdOpcode, data);
                    }
                    if (dataErr)
                        success = HandleDataError(cmd.cmdName);
                }
                else
                {
                    m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Raw Tx Message Length = {0:D} \nLength must be greater or equal to {1:D}\n", sourceData.Length, 4));
                    return false;
                }
            }
            catch (Exception ex)
            {
                success = HandleException(cmd.cmdName, ex.Message);
            }
            return success;
        }
Ejemplo n.º 27
0
 public bool SendGAP(HCICmds.GAPCmds.GAP_EndDiscoverable cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[(int)dataLength + 4];
         int index = 0;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 28
0
 public bool SendUTIL(HCICmds.UTILCmds.UTIL_NVRead cmd)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load8Bits(ref data, ref index, cmd.nvId, ref dataErr)
         && !m_dataUtils.Load8Bits(ref data, ref index, cmd.nvDataLen, ref dataErr))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Ejemplo n.º 29
0
 public void UsePasskeySecurity(HCICmds.GAP_UiOutput state)
 {
     if (state == HCICmds.GAP_UiOutput.DONT_DISPLAY_PASSCODE)
         tbPasskey.PasswordChar = '*';
     else
         tbPasskey.PasswordChar = char.MinValue;
 }
Ejemplo n.º 30
0
 public bool SendGATT(HCICmds.GATTCmds.GATT_ReadLongCharValue cmd, TxDataOut.CmdTypes cmdType, SendCmds.SendCmdResult callback)
 {
     bool success = true;
     try
     {
         byte dataLength = cmd.dataLength;
         byte[] data = new byte[dataLength + 4];
         int index = 0;
         bool dataErr = false;
         if (m_deviceFormUtils.LoadMsgHeader(ref data, ref index, 1, cmd.opCodeValue, dataLength)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.connHandle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.handle, ref dataErr, false)
         && !m_dataUtils.Load16Bits(ref data, ref index, cmd.offset, ref dataErr, false))
             TransmitCmd(cmd.cmdName, cmd.opCodeValue, data, cmdType, cmd.handle, callback);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }