当前位置: 首页>>代码示例>>Java>>正文


Java LocalDevice.getLocalDevice方法代码示例

本文整理汇总了Java中javax.bluetooth.LocalDevice.getLocalDevice方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDevice.getLocalDevice方法的具体用法?Java LocalDevice.getLocalDevice怎么用?Java LocalDevice.getLocalDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.bluetooth.LocalDevice的用法示例。


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

示例1: sendBluetoothMessage

import javax.bluetooth.LocalDevice; //导入方法依赖的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.LocalDevice; //导入方法依赖的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: initDevicePairingBluetooth

import javax.bluetooth.LocalDevice; //导入方法依赖的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

示例4: main

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public static void main(String args[]) {
    try {
        LocalDevice local = LocalDevice.getLocalDevice();
        System.out.println("Server Started:\n"
                + local.getBluetoothAddress()
                + "\n" + local.getFriendlyName());

        rfcommserver ff = new rfcommserver();
        while (true) {
            ff.startserver();
        } //while
    }  //try
    catch (Exception e) {
        System.err.print(e.toString());
    }
}
 
开发者ID:Blaubot,项目名称:Blaubot,代码行数:17,代码来源:rfcommserver.java

示例5: start

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public boolean start() throws IOException {
	// Initialise the Bluetooth stack
	try {
		localDevice = LocalDevice.getLocalDevice();
	} catch(UnsatisfiedLinkError e) {
		// On Linux the user may need to install libbluetooth-dev
		if(OsUtils.isLinux())
			callback.showMessage("BLUETOOTH_INSTALL_LIBS");
		return false;
	}
	if(LOG.isLoggable(INFO))
		LOG.info("Local address " + localDevice.getBluetoothAddress());
	running = true;
	bind();
	return true;
}
 
开发者ID:kiggundu,项目名称:briar,代码行数:17,代码来源:BluetoothPlugin.java

示例6: MonitoringThreadImpl

import javax.bluetooth.LocalDevice; //导入方法依赖的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: init

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
/**
 * Process the search/download requests.
 */
public void init() {

    try {
        // create/get a local device and discovery agent
        LocalDevice localDevice = LocalDevice.getLocalDevice();
        discoveryAgent = localDevice.getDiscoveryAgent();
    } catch (Exception e) {
        eventListener.errorOccured("Can't initialize bluetooth: ", e);
        System.err.println("Can't initialize bluetooth: " + e);
    }

    // initialize some optimization variables
    uuidSet = new UUID[2];

    // ok, we are interesting in btspp services only
    uuidSet[0] = new UUID(0x1101);

    // and only known ones, that allows pictures
    uuidSet[1] = SERVER_UUID;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:BluetoothClient.java

示例8: startServiceSearch

import javax.bluetooth.LocalDevice; //导入方法依赖的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

示例9: BluetoothServer

import javax.bluetooth.LocalDevice; //导入方法依赖的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: start

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public void start() {
    try {
        localDevice = LocalDevice.getLocalDevice();
        address = Bluetooth
                .formatAddress(localDevice.getBluetoothAddress());
        try {
            if (!localDevice.setDiscoverable(DiscoveryAgent.GIAC)) {
                logger.debug("Could not set discoverable to GIAC");
            }
        } catch (Throwable sd) {
            logger.debug("Could not set discoverable to GIAC", sd);
        }
        thread = new BluetoothServerThread();
        thread.setName("BluetoothMouseMoveServer");
        thread.start();
        bluetoothSupported = true;
    } catch (Throwable t) {
        logger.debug("Bluetooth not supported due to {}", t.toString());
    }
}
 
开发者ID:devbury,项目名称:mkRemote,代码行数:21,代码来源:BluetoothMouseMoveServer.java

示例11: startInquiry

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
/**
 * Start device inquiry. Your application call this method to start inquiry.
 * @param mode int one of DiscoveryAgent.GIAC or DiscoveryAgent.LIAC
 * @param serviceUUIDs UUID[]
 */
public void startInquiry(int mode, UUID[] serviceUUIDs) {
	try {
		this.discoveryMode = mode;
		this.serviceUUIDs = serviceUUIDs;

		// clear previous values first
		devices.removeAllElements();
		deviceClasses.removeAllElements();

		//
		// initialize the JABWT stack
		device = LocalDevice.getLocalDevice(); // obtain reference to singleton
		device.setDiscoverable(DiscoveryAgent.GIAC); // set Discover Mode
		agent = device.getDiscoveryAgent(); // obtain reference to singleton


		boolean result = agent.startInquiry(mode, this.listener = new Listener());

		// update screen with "Please Wait" message
		remotedeviceui.setMsg("[Please Wait...]");

	} catch (BluetoothStateException e) {
		e.printStackTrace();
	}

}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:32,代码来源:BLUElet.java

示例12: start

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public void start() {
    try {
        localDevice = LocalDevice.getLocalDevice();
        address = Bluetooth
                .formatAddress(localDevice.getBluetoothAddress());
        logger.debug("Bluetooth stack type is {}",
                LocalDevice.getProperty("bluecove.stack"));
        logger.debug("Bluetooth name {}", localDevice.getFriendlyName());
        logger.debug("Bluetooth address {}", address);
        logger.debug("Bluetooth API Version {}",
                LocalDevice.getProperty("bluetooth.api.version"));
        try {
            if (!localDevice.setDiscoverable(DiscoveryAgent.GIAC)) {
                logger.debug("Could not set discoverable to GIAC");
            }
        } catch (Throwable sd) {
            logger.debug("Could not set discoverable to GIAC", sd);
        }

        thread = new BluetoothServerThread();
        thread.setName("BluetoothServer");
        thread.start();
        bluetoothSupported = true;
    } catch (Throwable t) {
        logger.debug("Bluetooth not supported due to {}", t.toString());
    }
}
 
开发者ID:devbury,项目名称:mkRemote,代码行数:28,代码来源:BluetoothServer.java

示例13: main

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    
    //display local device address and name
    LocalDevice localDevice = LocalDevice.getLocalDevice();
    System.out.println("Address: "+localDevice.getBluetoothAddress());
    System.out.println("Name: "+localDevice.getFriendlyName());
    
    BTServer BTCommand=new BTServer();
    BTCommand.startServer();
    
}
 
开发者ID:siracoj,项目名称:BluetoothRecord,代码行数:12,代码来源:ServerCommand.java

示例14: getMoteFinder

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
/**
 * Returns the <code>WiimoteFinder</code> instance.
 * 
 * @return WiimoteFinder
 */
public static MoteFinder getMoteFinder() {
	try {
		// disable PSM minimum flag because the wiimote has a PSM below 0x1001
		System.setProperty(BlueCoveConfigProperties.PROPERTY_JSR_82_PSM_MINIMUM_OFF, "true");

		SingletonHolder.INSTANCE.localDevice = LocalDevice.getLocalDevice();
		SingletonHolder.INSTANCE.discoveryAgent = SingletonHolder.INSTANCE.localDevice.getDiscoveryAgent();
		return SingletonHolder.INSTANCE;
	} catch (BluetoothStateException ex) {
		throw new RuntimeException(ex);
	}
}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:18,代码来源:MoteFinder.java

示例15: Main

import javax.bluetooth.LocalDevice; //导入方法依赖的package包/类
public Main(){
    mainContainer = new ScreensController(this);
    mainContainer.loadScreen("ChatScreen","ChatScreen.fxml");
    mainContainer.loadScreen("StartScreen","StartScreen.fxml");
    mainContainer.loadScreen("LoadingScreen","LoadingScreen.fxml");
    mainContainer.loadScreen("ServerListScreen","ServerListScreen.fxml");
    mainContainer.setScreen("StartScreen");

    try {
        LocalDevice localDevice = LocalDevice.getLocalDevice();
        myName = localDevice.getFriendlyName();
    } catch (BluetoothStateException e) {
        e.printStackTrace();
    }
}
 
开发者ID:arminkz,项目名称:BluetoothChat,代码行数:16,代码来源:Main.java


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