예제 #1
0
 private void OnConnectResult(CSR_BLE_CONNECT_RESULT cr)
 {
     CurDevInfo.ConnHandle = cr.connectHandle;
     CsrBleDll.CsrBleClientDiscoverDatabase(cr.connectHandle);
     IsConnected = true;
     OnUpdateBleConnectEvent("蓝牙连接:" + CurDevInfo);
 }
예제 #2
0
        public bool BleSwitchMode()
        {
            if (!IsConnected)
            {
                Error("BleWriteChar when no device is connect!");
            }

            //switch (mode)
            //{
            //    case XcobraDataMode.NORMAL:
            //        _curServiceUuid = XIM_NORMAL_SERVICE;
            //        break;
            //    //case XcobraDataMode.BLOBS:
            //    //    _curServiceUuid = XIM_BLOBS_SERVICE;
            //    //    break;
            //    case XcobraDataMode.CALIB:
            //        _curServiceUuid = XIM_IMU_RAW_SERVICE;
            //        break;
            //    case XcobraDataMode.BATTERY:
            //        _curServiceUuid = XIM_BATTERY_SERVICE;
            //        break;

            //    default:
            //        return true;

            //}

            if (CurDevInfo != null)
            {
                CsrBleDll.CsrBleClientDiscoverDatabase(CurDevInfo.ConnHandle);

                if (_dbDiscoverEvent.WaitOne(8000))
                {
                    OnLogEvent("BleSwitchMode Success!");
                    return(true);
                }
            }

            OnLogEvent("BleSwitchMode Fail!");
            return(false);
        }
예제 #3
0
        private void OnHostConnectResult(CSR_BLE_CONNECT_RESULT conn)
        {
            var gattDevice = GattConnectDevices.Last();

            if (conn.result == 0)
            {
                gattDevice.Handle    = conn.connectHandle;
                gattDevice.Connected = true;

                CsrBleDll.CsrBleClientDiscoverDatabase(conn.connectHandle);
                Debug("[CSR]:OnHostConnectResult Success");
                OnDeviceConnectEvent("蓝牙连接 SUCCESS:" + gattDevice.Address);
            }
            else
            {
                gattDevice.Connected = false;
                Debug("[CSR]:OnHostConnectResult Fail");
                OnDeviceConnectEvent("蓝牙连接 FAIL:" + gattDevice.Address);
            }

            _connectEvent.Set();
        }