• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BluetoothStateException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.bluetooth.BluetoothStateException的典型用法代码示例。如果您正苦于以下问题:Java BluetoothStateException类的具体用法?Java BluetoothStateException怎么用?Java BluetoothStateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BluetoothStateException类属于javax.bluetooth包,在下文中一共展示了BluetoothStateException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendBluetoothMessage

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
/**
 * if bluetooth connection is available, <code>sendBluetoothMessage()</code> run <code>sendReciveMessageThread()</code>.
 * Else, checks if Bluetooth is activated and chooses if close connection or wait again
 */
void sendBluetoothMessage() {
    if (connectionIsAvaible) {
        if (outStream != null) {
            if (sendReciveMessageThread.isInterrupted()) {
                messageThreadExecutor.execute(sendReciveMessageThread);
                System.out.println("thread creato e avviato");
                sendBluetoothMessage();
            } else {
                sendReciveMessageThread.interrupt();
                messageThreadExecutor.execute(sendReciveMessageThread);
            }
        }
    } else {
        try {
            if (LocalDevice.getLocalDevice() != null && !LocalDevice.getLocalDevice().getFriendlyName().equals("null"))
                System.out.println("connessione non stabilita " + LocalDevice.getLocalDevice().getFriendlyName());
            else {
                closeConnection();
            }
        } catch (BluetoothStateException | NullPointerException e) {
            e.printStackTrace();
            closeConnection();
        }
    }
}
 
开发者ID:andrea9293,项目名称:pcstatus,代码行数:30,代码来源:BluetoothSPPServer.java


示例2: getLocalAddress

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private Optional<String> getLocalAddress() {
	try {
		final LocalDevice localDevice = LocalDevice.getLocalDevice();

		// Insert colons into the address because android needs them
		final StringBuilder addressBuilder = new StringBuilder();
		final String originalAddress = localDevice.getBluetoothAddress();
		for (int i = 0; i < originalAddress.length(); i++) {
			addressBuilder.append(originalAddress.charAt(i));
			if (i > 0 && i < originalAddress.length() - 1 && i % 2 != 0) addressBuilder.append(':');
		}

		return Optional.of(addressBuilder.toString());
	} catch (BluetoothStateException e) {
		logger.error("Failed to access local bluetooth device to fetch its address. Ensure the "
				+ "system's bluetooth service is started with \"sudo systemctl start bluetooth\" "
				+ "and the bluetooth stack is on in the system settings", e);
		return Optional.empty();
	}
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:21,代码来源:BluetoothServer.java


示例3: correspondingTo

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
public CoronataException correspondingTo(BluetoothStateException cause) {
	String errorMsg = cause.getMessage().toLowerCase();

	if (errorMsg.contains("librar") && errorMsg.contains("not available")) {
		return problemLoadingLibraries(cause);

	} else if (errorMsg.contains("device is not available") ||
			errorMsg.contains("stack not detected")) {
		return bluetoothAdapterIsOff(cause);

	} else if (errorMsg.contains("device is not ready")) {
		return deviceIsNotReady(cause);

	} else {
		return unexpectedError(cause);
	}
}
 
开发者ID:awvalenti,项目名称:bauhinia,代码行数:18,代码来源:BlueCoveExceptionFactory.java


示例4: initDevicePairingBluetooth

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
public BluetoothPairingInformation initDevicePairingBluetooth()
		throws BluetoothStateException, InterruptedException {
	// This is the first time we are going to touch the Bluetooth API so we
	// should attach our logger to the com.intel.bluetooth logging
	appendBluetoothLogging();

	// Make bluetooth device discoverbale!
	LocalDevice local = LocalDevice.getLocalDevice();
	try {
		local.setDiscoverable(DiscoveryAgent.GIAC);
	} catch (BluetoothStateException e) {
		logger.debug(
				"PanboxClient : initDevicePairingBluetooth : First try to set discoverable failed. Will try again in 1sec.");
		Thread.sleep(1000);
		local.setDiscoverable(DiscoveryAgent.GIAC);
	}

	// setting LocalDevice is only need for Linux, since on Windows we
	// bluecove only supports one device!
	BluetoothPairingInformation info = new BluetoothPairingInformation(local);
	extendPairingInformation(info);
	return info;
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:24,代码来源:PanboxClient.java


示例5: actionPerformed

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	try {
		BluetoothPairingInformation pInfo = client
				.initDevicePairingBluetooth();
		if (pInfo != null) {
			new PairNewDeviceDialog(clientGuiFrame, client, pInfo);
		} else {
			logger.info("AddDeviceBluetoothActionListener : Bluetooth device pairing aborted!");
		}
	} catch (BluetoothStateException | InterruptedException ex) {
		if (ex.getMessage().contains("Device is not available") || ex.getMessage().contains("BluetoothStack not detected")) {
			JOptionPane
					.showMessageDialog(
							clientGuiFrame,
							bundle.getString("AddDeviceBluetoothActionListener.noDevice.Message"),
							bundle.getString("error"),
							JOptionPane.ERROR_MESSAGE);
		}
		logger.error(
				"AddDeviceBluetoothActionListener : Bluetooth device exited with exception: ",
				ex);
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:25,代码来源:AddDeviceBluetoothActionListener.java


示例6: MonitoringThreadImpl

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
/**
 * Creates a new instance.
 * 
 */
MonitoringThreadImpl() throws BluetoothException
{
    super("Bluetooth Monitoring"); //$NON-NLS-1$
    try
    {
        this.localDevice = LocalDevice.getLocalDevice();
    }
    catch (BluetoothStateException e)
    {
        throw new BluetoothException(e.getMessage());
    }

    this.localAddress = localDevice.getBluetoothAddress();
    this.localName = localDevice.getFriendlyName();
    this.discoveryAgent = localDevice.getDiscoveryAgent();

    logger.debug("LocalAdress: " + localAddress + ", Name: " + localName); //$NON-NLS-1$ //$NON-NLS-2$
    
    this.monitoringListeners = new ArrayList();
    this.discoveryInProgress = false;
    this.pass = 0;
}
 
开发者ID:rhamnett,项目名称:dazzl,代码行数:27,代码来源:MonitoringThreadImpl.java


示例7: startServiceSearch

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
/**
 * 
 * This method is used to re-establish a connection to a device when we have the address.  
 *
 * @param address The address to the device
 */
public void startServiceSearch(String address){
    // Connects to a remote device with the given address     
    RemoteDeviceInstance remoteDevice = new RemoteDeviceInstance(address);
    try{
        localDevice = LocalDevice.getLocalDevice();   
        agent = localDevice.getDiscoveryAgent();
        uuids[0] = new UUID(uuidString, false);
        servicesFound = new Vector();
        devicesFound = new Vector();
        agent.searchServices(attributes,uuids,remoteDevice,this);
    }catch(BluetoothStateException bse) {
        log.logException("BluetoothServiceDiscovery.startServiceSearch()",bse, false);
        // throw bse;
    }
}
 
开发者ID:meisamhe,项目名称:GPLshared,代码行数:22,代码来源:BluetoothServiceDiscovery.java


示例8: searchService

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
public int searchService(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev,
        DiscoveryListener discListener) throws BluetoothStateException,
        IllegalArgumentException {

    if (DEBUG) {
        System.out.println("- serviceSearcher: initializing");
    }
    initialize(attrSet, uuidSet, btDev);

    if (discListener == null) {
        throw new NullPointerException("DiscoveryListener is null");
    }
    this.discListener = discListener;

    return start();
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:17,代码来源:ServiceSearcher.java


示例9: BluetoothServer

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private BluetoothServer() {
	clients = new ConcurrentHashMap<Integer, BluetoothClient>();
	try {
		device = LocalDevice.getLocalDevice();
		if (device != null) {
			if (!LocalDevice.isPowerOn()) {
				System.out.println("Device power is off. Turn it on!");
				System.exit(1);
			}
		} else {
			System.out.println("No device");
			System.exit(1);
		}
	} catch (BluetoothStateException e) {
		System.out.println(e.getMessage());
		System.exit(1);

	}
}
 
开发者ID:golvmopp,项目名称:BGSEP,代码行数:20,代码来源:BluetoothServer.java


示例10: loadNativeLibraries

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
static void loadNativeLibraries(BluetoothStack stack) throws BluetoothStateException {
	// Check is libraries already loaded
	try {
		if ((UtilsJavaSE.canCallNotLoadedNativeMethod) && (stack.isNativeCodeLoaded())) {
			return;
		}
	} catch (Error e) {
		// We caught UnsatisfiedLinkError
	}
	LibraryInformation[] libs = stack.requireNativeLibraries();
	if ((libs == null) || (libs.length == 0)) {
		// No native libs for this stack
		return;
	}
	for (int i = 0; i < libs.length; i++) {
		Class c = libs[i].stackClass;
		if (c == null) {
			c = stack.getClass();
		}
		if (!NativeLibLoader.isAvailable(libs[i].libraryName, c)) {
			throw new BluetoothStateException("BlueCove library " + libs[i].libraryName + " not available");
		}
	}
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:25,代码来源:BlueCoveImpl.java


示例11: getBluetoothStack

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
/**
 * Applications should not used this function.
 *
 * @return current BluetoothStack implementation
 * @throws BluetoothStateException
 *             when BluetoothStack not detected. If one connected the hardware later, BlueCove would be able to
 *             recover and start correctly
 * @exception Error
 *                if called from outside of BlueCove internal code.
 */
public synchronized BluetoothStack getBluetoothStack() throws BluetoothStateException {
	Utils.isLegalAPICall(fqcnSet);
	BluetoothStackHolder sh = currentStackHolder(false);
	if ((sh != null) && (sh.bluetoothStack != null)) {
		return sh.bluetoothStack;
	} else if ((sh == null) && (threadStack != null)) {
		throw new BluetoothStateException("No BluetoothStack or Adapter for current thread");
	}

	BluetoothStack stack;
	if (accessControlContext == null) {
		stack = detectStack();
	} else {
		stack = detectStackPrivileged();
	}
	return stack;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:28,代码来源:BlueCoveImpl.java


示例12: startInquiry

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
/**
 * Start DeviceInquiry and wait for startException or deviceInquiryStartedCallback
 */
static boolean startInquiry(BluetoothStack stack, DeviceInquiryRunnable inquiryRunnable, int accessCode,
		DiscoveryListener listener) throws BluetoothStateException {
	DeviceInquiryThread t = (new DeviceInquiryThread(stack, inquiryRunnable, accessCode, listener));
	// In case the BTStack hangs, exit JVM anyway
	UtilsJavaSE.threadSetDaemon(t);
	synchronized (t.inquiryStartedEvent) {
		t.start();
		while (!t.started && !t.terminated) {
			try {
				t.inquiryStartedEvent.wait();
			} catch (InterruptedException e) {
				return false;
			}
			if (t.startException != null) {
				throw t.startException;
			}
		}
	}
	DebugLog.debug("startInquiry return", t.started);
	return t.started;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:25,代码来源:DeviceInquiryThread.java


示例13: run

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
public void run() {
	int respCode = DiscoveryListener.SERVICE_SEARCH_ERROR;
	try {
		BlueCoveImpl.setThreadBluetoothStack(stack);
		respCode = serachRunnable.runSearchServices(this, attrSet, uuidSet, device, listener);
	} catch (BluetoothStateException e) {
		startException = e;
		return;
	} finally {
		finished = true;
		unregisterThread();
		synchronized (serviceSearchStartedEvent) {
			serviceSearchStartedEvent.notifyAll();
		}
		DebugLog.debug("runSearchServices ends", getTransID());
		if (started) {
			Utils.j2meUsagePatternDellay();
			listener.serviceSearchCompleted(getTransID(), respCode);
		}
	}
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:22,代码来源:SearchServicesThread.java


示例14: deviceDiscovered

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
@Override
public void deviceDiscovered(RemoteDevice device, DeviceClass deviceClass) {
	UUID[] uuids = new UUID[] {new UUID(uuid, false)};
	// Try to discover the services associated with the UUID
	try {
		discoveryAgent.searchServices(null, uuids, device, this);
		searches.incrementAndGet();
	} catch (BluetoothStateException e) {
		if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:12,代码来源:InvitationListener.java


示例15: makeDeviceDiscoverable

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private void makeDeviceDiscoverable() {
	// Try to make the device discoverable (requires root on Linux)
	try {
		localDevice.setDiscoverable(GIAC);
	} catch (BluetoothStateException e) {
		if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:9,代码来源:BluetoothPlugin.java


示例16: discoverDevices

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private void discoverDevices() throws BluetoothStateException {
    foundDevices = new ArrayList<>();
    agent.startInquiry(DiscoveryAgent.GIAC, getDiscoveryListener());
    try {
        synchronized (LOCK) {
            LOCK.wait();
        }
    } catch (InterruptedException e) {
        LOGGER.error("Error when discoverDevices().", e);
        fireBluetooothEvent(new ErrorEvent(e, this));
    }
}
 
开发者ID:vkorecky,项目名称:bluetooth-client-hc06,代码行数:13,代码来源:BluetoothScanThread.java


示例17: discoverServices

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private void discoverServices(RFCommBluetoothDevice device) throws BluetoothStateException {
    this.tempDevice = device;
    agent.searchServices(null, uuidSet, this.tempDevice.getRemoteDevice(), getDiscoveryListener());
    try {
        synchronized (LOCK) {
            LOCK.wait();
        }
    } catch (InterruptedException e) {
        LOGGER.error("Error when discoverServices().", e);
        fireBluetooothEvent(new ErrorEvent(e, this));
    }
}
 
开发者ID:vkorecky,项目名称:bluetooth-client-hc06,代码行数:13,代码来源:BluetoothScanThread.java


示例18: CoronataException

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
private CoronataException
		problemLoadingLibraries(BluetoothStateException cause) {
	return new CoronataException(cause,
			"Unable to load required libraries for BlueCove.\n" +
			"\tCheck if the requirements described here were met:" +
			" http://www.bluecove.org/bluecove-gpl/index.html\n" +
			"\tTry installing one of these packages:" +
			" libbluetooth-dev (Ubuntu)," +
			" bluez-libs-devel (Fedora), bluez-devel (openSUSE)\n" +
			"");
}
 
开发者ID:awvalenti,项目名称:bauhinia,代码行数:12,代码来源:BlueCoveExceptionFactory.java


示例19: run

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
@Override
State run() {
	try {
		BlueCoveLibraryFacade blueCoveLib = new BlueCoveLibraryFacade();
		leObserver.searchStarted(false);
		return states.startInquiry(blueCoveLib);

	} catch (BluetoothStateException e) {
		return states.bluetoothException(e);
	}
}
 
开发者ID:awvalenti,项目名称:bauhinia,代码行数:12,代码来源:LoadLibraryState.java


示例20: BluetoothExceptionState

import javax.bluetooth.BluetoothStateException; //导入依赖的package包/类
BluetoothExceptionState(StateFactory states,
		CoronataLifecycleEventsObserver leObserver,
		BluetoothStateException exception) {
	this.states = states;
	this.leObserver = leObserver;
	this.exception = exception;
}
 
开发者ID:awvalenti,项目名称:bauhinia,代码行数:8,代码来源:BluetoothExceptionState.java



注:本文中的javax.bluetooth.BluetoothStateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FabricMySQLConnection类代码示例发布时间:2022-05-21
下一篇:
Java BlockSnapshot类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap