Example #1
0
        public void BleHostInitialize()
        {
            Task.Run(() =>
            {
                var transport = new CSR_BLE_TRANSPORT
                {
                    transportType   = (byte)CsrBleDefine.CSR_BLE_TRANSPORT_USB,
                    usbDeviceNumber = (byte)CsrBleDefine.CSR_BLE_DEFAULT_USB_DEVICE_NUMBER
                };

                if (CsrBleDll.CsrBleHostInit(false, null, ref transport) == 0)
                {
                    Error("[CSR]:CsrBleHostInit Fail!");
                    throw new InvalidOperationException("BleHostInit CsrBleHostInit Fail!");
                }

                if (!CsrBleDll.CsrBleHostStart(0))
                {
                    Error("[CSR]:CsrBleHostStart Fail!");
                    throw new InvalidOperationException("BleHostInit CsrBleHostStart Fail!");
                }

                Info("[CSR]:BleHostInitialize Success!");
                BleHostProcessMsg();
            });
        }
Example #2
0
        public void BleHostInitialize()
        {
            Task.Run(() =>
            {
                CSR_BLE_TRANSPORT transport = new CSR_BLE_TRANSPORT()
                {
                    transportType   = (byte)CsrBleDefine.CSR_BLE_TRANSPORT_USB,
                    usbDeviceNumber = (byte)CsrBleDefine.CSR_BLE_DEFAULT_USB_DEVICE_NUMBER,
                };

                if (CsrBleDll.CsrBleHostInit(false, null, ref transport) == 0)
                {
                    Error("Unable to initialize uEnergy Host.");
                    MessageBox.Show("蓝牙无法初始化!");
                    return;
                }

                if (!CsrBleDll.CsrBleHostStart(0))
                {
                    Error("Unable to start uEnergy Host.");
                    MessageBox.Show("蓝牙HOST无法开始!");
                    return;
                }

                Trace("BleHostInitialize");
                BleHostProcessMsg();
            });
        }