Esempio n. 1
0
 public AttrDataItemForm(DeviceForm deviceForm)
 {
     InitializeComponent();
     devForm = deviceForm;
     sendCmds = new SendCmds(deviceForm);
     attrDataUtils = new AttrDataUtils(deviceForm);
 }
Esempio n. 2
0
 public AttReadByGrpTypeRsp(DeviceForm deviceForm)
 {
     devForm = deviceForm;
     attrUuidUtils = new AttrUuidUtils();
     attrDataUtils = new AttrDataUtils(deviceForm);
     sendCmds = new SendCmds(deviceForm);
 }
Esempio n. 3
0
 public AttFindInfoRsp(DeviceForm deviceForm)
 {
     m_deviceForm = deviceForm;
     m_sendCmds = new SendCmds(deviceForm);
     m_attrUuidUtils = new AttrUuidUtils();
     m_attrDataUtils = new AttrDataUtils(deviceForm);
 }
Esempio n. 4
0
 public AttributesForm(DeviceForm deviceForm)
 {
     InitializeComponent();
     devForm = deviceForm;
     attrDataUtils = new AttrDataUtils(deviceForm);
     sendCmds = new SendCmds(deviceForm);
     ResetSort();
     devForm.threadMgr.rspDataIn.RspDataInChangedCallback = new RspDataInThread.RspDataInChangedDelegate(RspDataInChanged);
     lvAttributes_MouseUtils.MouseSingleClickCallback = new MouseUtils.MouseSingleClickDelegate(lvAttributes_MouseSingleClick);
     lvAttributes_MouseUtils.MouseDoubleClickCallback = new MouseUtils.MouseDoubleClickDelegate(lvAttributes_MouseDoubleClick);
     lvAttributes.MouseUp += new MouseEventHandler(lvAttributes_MouseUtils.MouseClick_MouseUp);
     chKey.Width = 0;
     ClearAll();
     tsmiRestoreDefaultColumnWidths_Click(null, EventArgs.Empty);
 }
Esempio n. 5
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;
 }
Esempio n. 6
0
 public bool SendATT(HCICmds.ATTCmds.ATT_WriteReq cmd, SendCmds.SendCmdResult callback)
 {
     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.signature, ref dataErr)
         && !m_dataUtils.Load8Bits(ref data, ref index, (byte)cmd.command, 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, TxDataOut.CmdTypes.General, cmd.handle, callback);
         if (dataErr)
             success = HandleDataError(cmd.cmdName);
     }
     catch (Exception ex)
     {
         success = HandleException(cmd.cmdName, ex.Message);
     }
     return success;
 }
Esempio n. 7
0
 private void TransmitCmd(string cmdName, ushort cmdOpcode, byte[] data, TxDataOut.CmdTypes cmdType, object tag, SendCmds.SendCmdResult callback)
 {
     m_deviceForm.threadMgr.txDataOut.dataQ.AddQTail(
         new TxDataOut()
         {
             CmdName = cmdName,
             CmdOpcode = cmdOpcode,
             Data = data,
             CmdType = cmdType,
             Tag = tag,
             Callback = callback
         });
 }
Esempio n. 8
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;
 }
Esempio n. 9
0
        public DeviceForm()
        {
            devInfo.DevForm = this;
            connectInfo.BDA = "00:00:00:00:00:00";
            connectInfo.Handle = 0;
            connectInfo.AddrType = 0;
            disconnectInfo.BDA = "00:00:00:00:00:00";
            disconnectInfo.Handle = 0;
            disconnectInfo.AddrType = 0;
            Connections.Clear();
            commMgr.InitCommManager();
            msgLogForm = new MsgLogForm(this);
            commSelectForm = new CommSelectForm();

            InitializeComponent();

            Text = FormMain.ProgramTitle + FormMain.ProgramVersion;
            threadMgr = new ThreadMgr(this);
            sendCmds = new SendCmds(this);
            attrData.sendAutoCmds = false;
            attributesForm = new AttributesForm(this);
            devTabsForm = new DeviceTabsForm(this);

            LoadUserInitializeValues();
            LoadUserSettings();

            sendCmds.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);

            threadMgr.txDataOut.DeviceTxDataCallback = new DeviceForm.DeviceTxDataDelegate(DeviceTxData);
            threadMgr.txDataOut.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);
            threadMgr.rxDataIn.DeviceRxDataCallback = new DeviceForm.DeviceRxDataDelegate(DeviceRxData);
            threadMgr.rxTxMgr.HandleRxTxMessageCallback = new DeviceForm.HandleRxTxMessageDelegate(HandleRxTxMessage);

            dspTxCmds.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);
            dspTxCmds.DisplayMsgTimeCallback = new DeviceForm.DisplayMsgTimeDelegate(DisplayMsgTime);
            attributesForm.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);
            msgLogForm.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);
            devTabsForm.DisplayMsgCallback = new DeviceForm.DisplayMsgDelegate(DisplayMsg);

            threadMgr.Init(this);

            msgLogForm.TopLevel = false;
            msgLogForm.Parent = plLog;
            msgLogForm.Visible = true;
            msgLogForm.Dock = DockStyle.Fill;
            msgLogForm.ControlBox = false;
            msgLogForm.ShowIcon = false;
            msgLogForm.FormBorderStyle = FormBorderStyle.None;
            msgLogForm.StartPosition = FormStartPosition.Manual;
            msgLogForm.Show();

            devTabsForm.TopLevel = false;
            devTabsForm.Parent = plUserTabs;
            devTabsForm.Visible = true;
            devTabsForm.Dock = DockStyle.Fill;
            devTabsForm.ControlBox = false;
            devTabsForm.ShowIcon = false;
            devTabsForm.FormBorderStyle = FormBorderStyle.None;
            devTabsForm.StartPosition = FormStartPosition.Manual;
            devTabsForm.Show();

            attributesForm.TopLevel = false;
            attributesForm.Parent = plAttributes;
            attributesForm.Visible = true;
            attributesForm.Dock = DockStyle.Fill;
            attributesForm.ControlBox = false;
            attributesForm.ShowIcon = false;
            attributesForm.FormBorderStyle = FormBorderStyle.None;
            attributesForm.StartPosition = FormStartPosition.Manual;
            attributesForm.Show();
        }