Package javax.bluetooth

Examples of javax.bluetooth.LocalDevice


   * @return A Node identifying the local device.
   */
  public static Node localNode() {
    if (localNode == null) {
      try {
        LocalDevice device = LocalDevice.getLocalDevice();
        localNode = new Node(device);
      } catch (BluetoothStateException e) {
        System.out.println("Bluetooth state exception.");
      }
    }
View Full Code Here


  }

  public Node localNodeNonStatic() {
    if (localNode == null) {
      try {
        LocalDevice device = LocalDevice.getLocalDevice();
        localNode = new Node(device);
      } catch (BluetoothStateException e) {
        System.out.println("Bluetooth state exception.");
      }
    }
View Full Code Here

   * @return Information about a device with the given name.
   */
  protected static Object deviceFromName(String name) {
    if (name == null) return null;
    try {
      LocalDevice localDevice = LocalDevice.getLocalDevice();
      if (localDevice.getFriendlyName() == name) {
        return localDevice;
      }
    } catch (BluetoothStateException e) {
      System.out.println("Bluetooth state exception.");
    }
View Full Code Here

   * @return A Node identifying the local device.
   */
  public static Node localNode() {
    if (localNode == null) {
      try {
        LocalDevice device = LocalDevice.getLocalDevice();
        localNode = new Node(device);
      } catch (BluetoothStateException e) {
        System.out.println("Bluetooth state exception.");
      }
    }
View Full Code Here

   * @return Information about a device with the given name.
   */
  protected static Object deviceFromName(String name) {
    if (name == null) return null;
    try {
      LocalDevice localDevice = LocalDevice.getLocalDevice();
      if (localDevice.getFriendlyName() == name) {
        return localDevice;
      }
    } catch (BluetoothStateException e) {
      System.out.println("Bluetooth state exception.");
    }
View Full Code Here

        }));
        addMenuItem(infoScreen);

        try {
            // Make the device discoverable
            final LocalDevice device = LocalDevice.getLocalDevice();

            // Store the current mode so it can be restored later
            final int mode = device.getDiscoverable();
            if (mode != DiscoveryAgent.GIAC) {
                device.setDiscoverable(DiscoveryAgent.GIAC);
            }
            switch (_uuid) {
            case BluetoothJSR82Demo.SPP_UUID:
                final SPPServerThread sppThread = new SPPServerThread();
                sppThread.start();
View Full Code Here

                StreamConnection connection = null;
                DataOutputStream os = null;
                DataInputStream is = null;
                try {
                    final UUID uuid = new UUID(_uuid);
                    final LocalDevice local = LocalDevice.getLocalDevice();
                    updateStatus("[SERVER] Device Address: "
                            + local.getBluetoothAddress());
                    updateStatus("[SERVER] Device Name: "
                            + local.getFriendlyName());
                    updateStatus("[SERVER] Listening for Client...");

                    // Open a connection and wait for client requests
                    final StreamConnectionNotifier service =
                            (StreamConnectionNotifier) Connector
View Full Code Here

        public void run() {
            try {
                L2CAPConnection connection = null;
                try {
                    final UUID uuid = new UUID(_uuid);
                    final LocalDevice local = LocalDevice.getLocalDevice();
                    updateStatus("[SERVER] Device Address: "
                            + local.getBluetoothAddress());
                    updateStatus("[SERVER] Device Name: "
                            + local.getFriendlyName());
                    updateStatus("[SERVER] Listening for Client...");

                    // Open a connection and wait for client requests
                    final L2CAPConnectionNotifier service =
                            (L2CAPConnectionNotifier) Connector
View Full Code Here

         * @see java.lang.Runnable#run()
         */
        public void run() {
            try {
                final UUID uuid = new UUID(_uuid);
                final LocalDevice local = LocalDevice.getLocalDevice();
                updateStatus("[SERVER] Device Address: "
                        + local.getBluetoothAddress());
                updateStatus("[SERVER] Device Name: " + local.getFriendlyName());

                // Open a connection and wait for client requests
                final SessionNotifier sessionNotifier =
                        (SessionNotifier) Connector.open("btgoep://localhost:"
                                + uuid + ";name=" + SERVICE_NAME_OPP);
View Full Code Here

     * Assembles a text string containing the device's bluetooth information
     *
     * @return String containing the device's bluetooth information
     */
    private String generateBluetoothString() {
        LocalDevice lc;

        try {
            // Get the LocalDevice
            lc = LocalDevice.getLocalDevice();
        } catch (final Exception ex) {
            return "Failed to initialize Bluetooth";
        }

        final StringBuffer sb = new StringBuffer();

        // Get the device's Bluetooth address
        sb.append("Bluetooth Address: ");
        sb.append(lc.getBluetoothAddress());
        sb.append('\n');

        // Get the device's Bluetooth friendly name
        sb.append("Bluetooth friendly name: ");
        sb.append(lc.getFriendlyName());
        sb.append('\n');

        // Get the device's discovery mode
        sb.append("Discovery Mode: ");

        switch (lc.getDiscoverable()) {
        case DiscoveryAgent.GIAC:
            sb.append("General/Unlimited Inquiry Access");
            break;

        case DiscoveryAgent.LIAC:
View Full Code Here

TOP

Related Classes of javax.bluetooth.LocalDevice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.