Package javax.bluetooth

Examples of javax.bluetooth.RemoteDevice


   */
  public static List<Node> knownNodes() {
    List<Node> nodes = new ArrayList<Node>();
    Enumeration deviceEnumeration = Bluetooth.getKnownDevicesList().elements();
    while (deviceEnumeration.hasMoreElements()) {
      RemoteDevice device = (RemoteDevice)deviceEnumeration.nextElement();
      nodes.add(new Node(device));
    }
    return nodes;
  }
View Full Code Here


        if (devList.size() > 0)
        {
            String[] names = new String[devList.size()];
            for (int i = 0; i < devList.size(); i++)
            {
                RemoteDevice btrd = ((RemoteDevice) devList.elementAt(i));
                names[i] = btrd.getFriendlyName(false);
            }
            TextMenu searchMenu = new TextMenu(names, 1);
            TextMenu subMenu = new TextMenu(new String[]{"Pair"}, 4);
            int selected;
            do
            {
                newScreen("Found");
                ind.setIOMode(Indicators.IO_NONE);
                selected = getSelection(searchMenu, 0);
                if (selected >= 0)
                {
                    RemoteDevice btrd = ((RemoteDevice) devList.elementAt(selected));
                    newScreen();
                    LCD.drawString(names[selected], 0, 1);
                    LCD.drawString(btrd.getBluetoothAddress(), 0, 2);
                    int subSelection = getSelection(subMenu, 0);
                    if (subSelection == 0)
                    {
                        newScreen("Pairing");
                        Bluetooth.addDevice(btrd);
                        byte[] tempPin =
                        {
                            '0', '0', '0', '0'
                        };
                        byte[] pin = enterNumber(4, "PIN for " + btrd.getFriendlyName(false), tempPin); // !! Assuming 4 length
                        if (pin == null) break;
                        LCD.drawString("Please wait...", 0, 6);
                        BTConnection connection = Bluetooth.connect(btrd.getDeviceAddr(), 0, pin);
                        // Indicate Success or failure:
                        if (connection != null)
                        {
                            LCD.drawString("Paired!      ", 0, 6);
                            connection.close();
View Full Code Here

        if (devList.size() > 0)
        {
            String[] names = new String[devList.size()];
            for (int i = 0; i < devList.size(); i++)
            {
                RemoteDevice btrd = ((RemoteDevice) devList.elementAt(i));
                names[i] = btrd.getFriendlyName(false);
            }

            TextMenu deviceMenu = new TextMenu(names, 1);
            TextMenu subMenu = new TextMenu(new String[] {"Remove"}, 6);
            int selected;
            do
            {
                newScreen();
                selected = getSelection(deviceMenu, 0);
                if (selected >= 0)
                {
                    newScreen();
                    RemoteDevice btrd = ((RemoteDevice) devList.elementAt(selected));
                    LCD.drawString(btrd.getFriendlyName(false), 0, 2);
                    LCD.drawString(btrd.getBluetoothAddress(), 0, 3);
                    for (int i = 0; i < 4; i++)
                        LCD.drawInt(btrd.getDeviceClass()[i], 3, i * 4, 4);
                    int subSelection = getSelection(subMenu, 0);
                    if (subSelection == 0)
                    {
                        Bluetooth.removeDevice(btrd);
                        break;
View Full Code Here

            return connect(stringToAddress(target), mode, pin);
        else
        {
            // We have a device name. Try and locate it in the list of known
            // devices
            RemoteDevice dev = getKnownDevice(target);
            if (dev != null)
                // Found a match connect to it
                return connect(stringToAddress(dev.getBluetoothAddress()), mode, pin);
            return null;
        }
    }
View Full Code Here

      int state = RS_CMD;
      byte[] device = new byte[ADDRESS_LEN];
      byte[] devclass = new byte[4];
      byte[] name = new byte[NAME_LEN];
      Vector retVec = new Vector(1);
      RemoteDevice curDevice;
      cmdStart();
      cmdInit(MSG_DUMP_LIST, 1, 0, 0);
      while (cmdWait(RS_REPLY, state, MSG_ANY, TO_LONG) >= 0)
      {
        state = RS_WAIT;
        if (replyBuf[1] == MSG_LIST_ITEM)
        {
          System.arraycopy(replyBuf, 2, device, 0, ADDRESS_LEN);
                    System.arraycopy(replyBuf, 9, name, 0, NAME_LEN);
          System.arraycopy(replyBuf, 25, devclass, 0, 4);
          curDevice = new RemoteDevice(nameToString(name), addressToString(device), devclass);
          //1 RConsole.print("got name " + curDevice.getFriendlyName() + "\n");
          retVec.addElement(curDevice);
        }
        else if (replyBuf[1] == MSG_LIST_DUMP_STOPPED)
          break;
View Full Code Here

   * (those who have been paired before) into the BTDevice Object.
   * @param fName Friendly-Name of the device
   * @return BTDevice Object or null, if not found.
   */
  public static RemoteDevice getKnownDevice(String fName) {
    RemoteDevice btd = null;
    //look the name up in List of Known Devices
    Vector devList = getKnownDevicesList();
    if (devList.size() > 0) {
      for (int i = 0; i < devList.size(); i++) {
        btd = (RemoteDevice) devList.elementAt(i);
        if (btd.getFriendlyName(false).equals(fName)) {
          return btd;
        }
      }
    }
    return null;
View Full Code Here

          int codRecord = (retCod[0] << 8) + retCod[1];
          codRecord = (codRecord << 8) + retCod[2];
          codRecord = (codRecord << 8) + retCod[3];
         
          final DeviceClass deviceClass = new DeviceClass(codRecord);
          final RemoteDevice rd = new RemoteDevice(nameToString(name), addressToString(device), retCod);
         
          // Spawn a separate thread to notify in case doesn't return immediately:
          Thread t = new Thread() {
            public void run() {
              // Make sure only one notify thread is running at a time using notifyToken
View Full Code Here

        {
          System.arraycopy(replyBuf, 2, device, 0, ADDRESS_LEN);
                    System.arraycopy(replyBuf, 9, name, 0, NAME_LEN);
          System.arraycopy(replyBuf, 25, retCod, 0, 4);
          // add the Element to the Vector List
          retVec.addElement(new RemoteDevice(nameToString(name), addressToString(device), retCod));
        }
        else if (replyBuf[1] == MSG_INQUIRY_STOPPED)
        {
          cmdComplete();
          // Fill in the names 
          for (int i = 0; i < retVec.size(); i++) {
            RemoteDevice btrd = ((RemoteDevice) retVec.elementAt(i));
            String s = btrd.getFriendlyName(false);
            if (s.length() == 0) {
              String nm = lookupName(btrd.getDeviceAddr());
              btrd.setFriendlyName(nm);
            }
          }
          return retVec;
        }
      }
View Full Code Here

            // Create a data template that will format the model data as an
            // array of Fields
            final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
                public Field[] getDataFields(final int modelRowIndex) {
                    final RemoteDevice _remoteDevice =
                            (RemoteDevice) _model.getRow(modelRowIndex);

                    final Field[] fields =
                            { new LabelField(_remoteDevice.toString(),
                                    Field.NON_FOCUSABLE) };
                    return fields;
                }
            };
View Full Code Here

                _statusField = new RichTextField();
                ClientScreen.this.add(_statusField);
                try {
                    final UUID[] uuidSet = { new UUID(_uuid) };
                    final int[] attrSet = { 0x0100 };
                    final RemoteDevice _remoteDevice =
                            (RemoteDevice) _model.getRow(_view
                                    .getRowNumberWithFocus());
                    _discoveryAgent.searchServices(attrSet, uuidSet,
                            _remoteDevice, ClientScreen.this);
                } catch (final BluetoothStateException bse) {
View Full Code Here

TOP

Related Classes of javax.bluetooth.RemoteDevice

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.