コード例 #1
0
        public BTdevice(ref logging lg)
        {
            log = lg;
            try
            {
                preparePSWMD0C();
#if USE_SSAPI
                BTpower btPower = new BTpower();
                if (btPower.IsBluetoothOn() == false)
                {
                    log.WriteLog("BT power is OFF, trying to switch ON...");
                    btPower.TurnOnBluetooth();
                    if (btPower.IsBluetoothOn() == false)
                    {
                        log.WriteLog("BT power switch ON failed");
                    }
                    else
                    {
                        log.WriteLog("BT power is now ON");
                    }
                }
                else
                {
                    log.WriteLog("BT power was ON, no change");
                }

                //btPower.Dispose();
#endif
                _deviceUtility = new DeviceUtility();
                _deviceUtility.Initialize(xmlFileName);
            }
            catch (DeviceUtilityException ex)
            {
                log.WriteLog("DeviceUtilityException in BTdevice(): " + ex.Message);
                _deviceUtility = null;
            }
            catch (Exception ex)
            {
                log.WriteLog("Exception in BTdevice(): " + ex.Message);
                _deviceUtility = null;
            }
            log.WriteLog("BTdevice() OK");
        }
コード例 #2
0
ファイル: BTdevice.cs プロジェクト: hjgode/setbtscanner
        public BTdevice(ref logging lg)
        {
            log = lg;
            try
            {
                preparePSWMD0C();
#if USE_SSAPI 
                BTpower btPower = new BTpower();
                if (btPower.IsBluetoothOn() == false)
                {
                    log.WriteLog("BT power is OFF, trying to switch ON...");
                    btPower.TurnOnBluetooth();
                    if (btPower.IsBluetoothOn() == false)
                        log.WriteLog("BT power switch ON failed");
                    else
                        log.WriteLog("BT power is now ON");
                }
                else
                    log.WriteLog("BT power was ON, no change");
                
                //btPower.Dispose();
#endif
                _deviceUtility = new DeviceUtility();
                _deviceUtility.Initialize(xmlFileName);
            }
            catch (DeviceUtilityException ex)
            {
                log.WriteLog("DeviceUtilityException in BTdevice(): " + ex.Message);
                _deviceUtility = null;
            }
            catch (Exception ex)
            {
                log.WriteLog("Exception in BTdevice(): " + ex.Message);
                _deviceUtility = null;
            }
            log.WriteLog("BTdevice() OK");

        }