コード例 #1
0
ファイル: NXTLocator.java プロジェクト: lego-line/lejos
  public void inquiryCompleted(int discType) {
    if (remote == null) {
      mDisplay.setCurrent(vorForm);
      // Wait until the canvas appears...
      // For Nokia it is not the same?
      while (mDisplay.getCurrent() != vorForm) ;
      messages.insert("No NXT Brick found", messages.size());
    } else {
      try {
        remoteName = remote.getFriendlyName(false);
        messages.insert("Connecting to " + remoteName + "\n", messages.size());
      } catch (IOException ioe) {
        System.out.println("error retrieving friendly name");
      }

      try {
        // int[] attrs = {0x100}; // default attribute set plus service name
        UUID[] uuids = new UUID[] {new UUID(SERIALID)}; // Serial port service
        // agent.searchServices(attrs, uuids, remote, this);
        agent.searchServices(null, uuids, remote, this);
      } catch (BluetoothStateException bse) {
        System.out.println("service search failed");
      }
    }
  }
コード例 #2
0
ファイル: NXTLocator.java プロジェクト: lego-line/lejos
 public void findNXT() {
   if (local != null) {
     // place the device in inquiry mode
     try {
       agent.startInquiry(DiscoveryAgent.GIAC, this);
       messages.insert("Searching for NXT Brick\n", messages.size());
     } catch (BluetoothStateException bse) {
       System.out.println("inquiry couldn't be started");
     }
   } else {
     messages.insert("Bluetooth is off or this device doesn't support JSR82\n", messages.size());
   }
 }
コード例 #3
0
ファイル: NXTLocator.java プロジェクト: lego-line/lejos
  public NXTLocator(Display d) {
    mDisplay = d;
    messages = new TextBox("NXT Status", "Welcome!\n", 8192, TextField.ANY);
    mDisplay.setCurrent(messages);

    // retrieve the local Bluetooth device object
    try {
      local = LocalDevice.getLocalDevice();
      agent = local.getDiscoveryAgent();
    } catch (BluetoothStateException bse) {
      messages.insert("no device found\n", messages.size());
    }
  }
コード例 #4
0
ファイル: NXTLocator.java プロジェクト: lego-line/lejos
 public void serviceSearchCompleted(int transID, int respCode) {
   if (respCode == DiscoveryListener.SERVICE_SEARCH_COMPLETED) {
     // !! This code must be divorced from NXTLocator
     canvas = new RemoteCanvas(remoteURL);
     mDisplay.setCurrent(canvas);
   } else {
     mDisplay.setCurrent(vorForm);
     while (mDisplay.getCurrent() != vorForm) ;
     switch (respCode) {
       case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
         messages.insert("Error: Service search terminated", messages.size());
         break;
       case DiscoveryListener.SERVICE_SEARCH_ERROR:
         messages.insert("Error: Service search error", messages.size());
         break;
       case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
         messages.insert("Error: Service search no records", messages.size());
         break;
       case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
         messages.insert("Error: Service search device not reachable", messages.size());
         break;
     }
   }
 }
コード例 #5
0
ファイル: OxportMIDlet.java プロジェクト: BGCX261/znos-git
  public void commandAction(Command c, Displayable s) {
    if (c == exitCom) {
      destroyApp(true);
      notifyDestroyed();

    } else if (c == initCom) {
      if (ox == null) {
        textBox.insert("Exportando...\n", textBox.size());
        ox = new Oxport();
        ox.start();
      }
    } else if (c == playCom) {
      if ((ox == null) || (ox.getOServer() == null)) addtext("Playground need a OServer running");
      else {
        if (playground == null) playground = new PlayGround(this);
        display.setCurrent(playground);
      }
    } else {
    }
  }
コード例 #6
0
ファイル: OxportMIDlet.java プロジェクト: BGCX261/znos-git
 public static void addtext(String text) {
   if (textBox != null) textBox.insert(text + "\n", textBox.size());
 }