亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? servicefinder.java

?? Bluetooth echo between pc server and client
?? JAVA
字號:

// ServiceFinder.java
// Andrew Davison, ad@fivedots.coe.psu.ac.th, August 2005

/* Create a Bluetooth discovery agent, and carry out a devices
   search followed by services search.

   Each matching device must be a PC or phone.
   The devices are stored in deviceList.

   Each of the service searches are carried out sequentially, 
   one at a time.

   A matching service must have the same UUID as that specified in 
   UUIDStr, and the same service name as srchServiceName. It must 
   use the RFCOMM protocol.

   Each service record is stored along with its device name in the 
   serviceTable hashtable, using the device name as the 
   key, the service record as the value.

   At the end, the hashtable is passed to the midlet via the
   midlet's showServices() method.
*/

import java.io.*;
import java.util.*;
import javax.microedition.io.*;
import javax.bluetooth.*;


public class ServiceFinder implements DiscoveryListener
{
  private EchoClientMIDlet ecm;
  private String UUIDStr;           // the UUID of the desired service
  private String srchServiceName;   // the name of the desired service

  private DiscoveryAgent agent;

  // stores the remote devices found during the device search
  private Vector deviceList;

  /* table of matching services, stored as pairs of the form
     {device name, serviceRecord} */
  private Hashtable serviceTable;
  private boolean searchDone;



  public ServiceFinder(EchoClientMIDlet ecm, String uuid, String nm)
  // create a discovery agent then perform device and services search.
  {
    this.ecm = ecm;
    UUIDStr = uuid;
    srchServiceName = nm;

    try {   
      // get the discovery agent, by asking the local device
      LocalDevice local = LocalDevice.getLocalDevice();
      agent = local.getDiscoveryAgent();

      // initialize device search data structure
      deviceList = new Vector();

      // start the searches: devices first, services later
      ecm.setStatus("Searching for Devices...");
      System.out.println("Searching for Devices...");
      agent.startInquiry(DiscoveryAgent.GIAC, this);   // non-blocking
    }
    catch (Exception e) {
      System.out.println(e);
      ecm.searchError("Search Error");
    }
  } // end of ServiceFinder()


 // -------------------------- device search methods ---------------

  /* deviceDiscovered() and inquiryCompleted() are called 
     automatically during the device search initiated by the 
     DiscoveryAgent.startInquiry() call.
  */


  public void deviceDiscovered(RemoteDevice dev, DeviceClass cod)
  /* A matching device was found during the device search.
     Only store it if it's a PC or phone. */
  {
    System.out.println("Device Name: " +  getDeviceName(dev)); 

    int majorDC = cod.getMajorDeviceClass();
    int minorDC = cod.getMinorDeviceClass();   // not used in the code
    System.out.println("Major Device Class: " + majorDC + 
                     "; Minor Device Class: " + minorDC);
    
    // restrict matching device to PC or Phone
    if ((majorDC == 0x0100) || (majorDC == 0x0200))
      deviceList.addElement(dev);
    else
      System.out.println("Device not PC or phone, so rejected");
  } // end of deviceDiscovered()


  private String getDeviceName(RemoteDevice dev)
  /* Return the 'friendly' name of the device being examined,
     or "Device ??" */
  {
    String devName;
    try {
      devName = dev.getFriendlyName(false);  // false to reduce connections
    }
    catch (IOException e) 
    { devName = "Device ??";  }
    return devName;
  }  // end of getDeviceName()


  public void inquiryCompleted(int inqType)
  // device search has finished; start the services search
  {
    showInquiryCode(inqType);
    System.out.println("No. of Matching Devices: " + deviceList.size());

    // start the services search
    ecm.setStatus("Searching for Services...");
    searchForServices(deviceList, UUIDStr);
  } // end of inquiryCompleted()


  private void showInquiryCode(int inqCode)
  {
    if(inqCode == INQUIRY_COMPLETED)
      System.out.println("Device Search Completed");
    else if(inqCode == INQUIRY_TERMINATED)
      System.out.println("Device Search Terminated");
    else if(inqCode == INQUIRY_ERROR)
      System.out.println("Device Search Error");
    else 
      System.out.println("Unknown Device Search Status: " + inqCode); 
  }  // end of showResponseCode()


  // --------------------- service search methods --------------------
  

  private void searchForServices(Vector deviceList, String UUIDStr)
  /* Carry out service searches for all the matching devices, looking
     for the RFCOMM service with UUID == UUIDStr. Also check the
     service name.
  */
  {
    UUID[] uuids = new UUID[2];   // holds UUIDs used in the search

    /* Add the UUID for RFCOMM to make sure that the matching service
       support RFCOMM. */
    uuids[0] = new UUID(0x0003);

    // add the UUID for the service we're looking for
    uuids[1] = new UUID(UUIDStr, false);

    /* we want the search to retrieve the service name attribute,
       so we can check it against the service name we're looking for */
    int[] attrSet = {0x0100};

    // initialize service search data structure
    serviceTable = new Hashtable();

    // carry out a service search for each of the devices
    RemoteDevice dev;
    for (int i = 0; i < deviceList.size(); i++) {
      dev = (RemoteDevice) deviceList.elementAt(i);
      searchForService(dev, attrSet, uuids);
    }

    // tell the top-level MIDlet the result of the searches
    if (serviceTable.size() > 0)
      ecm.showServices(serviceTable);
    else
      ecm.searchError("No Matching Services Found");
  } // end of searchForServices()


  private void searchForService(RemoteDevice dev, int[] attrSet, 
                                                     UUID[] uuids)
  // search device for a service with the desired attribute and uuid values
  {
    System.out.println("Searching device: " + getDeviceName(dev));
    try {
      int trans = agent.searchServices(attrSet, uuids, dev, this); // non-blocking
      waitForSearchEnd(trans); 
    }
    catch (BluetoothStateException e) {
      System.out.println(e);
    }
  }  // end of searchForService()



  private void waitForSearchEnd(int trans)
  // wait for the current service search to finish
  {
    System.out.println("Waiting for trans ID " + trans + "...");
    searchDone = false;
    while (!searchDone) {
      synchronized (this) {
        try {
          this.wait();
        }
        catch (Exception e) {}
      }
    }
    System.out.println("Done");
  }  // end of waitForSearchEnd()


  /* servicesDiscovered() and serviceSearchCompleted() are called 
     automatically during a services search initiated by a
     DiscoveryAgent.searchServices() call. We call it from
     searchForService().
  */

  public void servicesDiscovered(int transID, ServiceRecord[] servRecords)
  /* Called when matching services are found on a device. 
     The service record is only stored if its name matches the one
     being searched for (srchServiceName).

     The service record is stored with the device name in the serviceTable
     hashtable, using the device name as the key, the service record as the
     value.
  */
  {
    for (int i=0; i < servRecords.length; i++) {
      if (servRecords[i] != null) {
        // get the service record's name
        DataElement servNameElem = servRecords[i].getAttributeValue(0x0100);
        String servName = (String)servNameElem.getValue();
        System.out.println("Name of Discovered Service: " + servName);

        if (servName.equals(srchServiceName)) {  // check the name
          RemoteDevice dev = servRecords[i].getHostDevice();
          serviceTable.put( getDeviceName(dev), servRecords[i]); // add to table
        }
      }
    }
  } // end of servicesDiscovered()


  public void serviceSearchCompleted(int transID, int respCode)
  // Called when the service search has finished
  {
    showResponseCode(transID, respCode);

    /* Wake up waitForSearchEnd() for this search, allowing the next
       services search to commence in searchForServices(). */
    searchDone = true;
    synchronized (this) {  
      this.notifyAll();  // wake up
    }
  } // end of serviceSearchCompleted()



  private void showResponseCode(int transID, int respCode)
  {
    System.out.print("Trans ID " + transID + ". ");

    if(respCode == SERVICE_SEARCH_ERROR)
      System.out.println("Service Search Error");
    else if(respCode == SERVICE_SEARCH_COMPLETED)
      System.out.println("Service Search Completed");
    else if(respCode == SERVICE_SEARCH_TERMINATED)
      System.out.println("Service Search Terminated");
    else if(respCode == SERVICE_SEARCH_NO_RECORDS)
      System.out.println("Service Search: No Records found");
    else if(respCode == SERVICE_SEARCH_DEVICE_NOT_REACHABLE)
      System.out.println("Service Search: Device Not Reachable");   
    else 
      System.out.println("Unknown Service Search Status: " + respCode); 
  }  // end of showResponseCode()


} // end of ServiceFinder class

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人手机电影网| 欧美区在线观看| 欧美日韩精品是欧美日韩精品| 91精品免费在线| 国产精品不卡视频| 日韩精品一级中文字幕精品视频免费观看 | 久久超碰97中文字幕| 95精品视频在线| 欧美大白屁股肥臀xxxxxx| **网站欧美大片在线观看| 久久精品国产999大香线蕉| 色哟哟精品一区| 中文字幕精品综合| 国产在线精品一区二区不卡了 | 精品久久久久久久久久久久包黑料| 国产精品福利一区| 国产精一品亚洲二区在线视频| 欧美日韩亚洲综合在线| 亚洲欧美日韩系列| 国产成人精品影院| 久久午夜色播影院免费高清| 奇米精品一区二区三区在线观看 | 国产亚洲人成网站| 喷水一区二区三区| 欧美精选午夜久久久乱码6080| 亚洲同性同志一二三专区| 国产盗摄一区二区| 久久久久国产精品麻豆ai换脸 | 福利一区福利二区| 国产视频911| 国产一区二区h| 精品国产乱码久久久久久老虎| 视频在线观看国产精品| 欧美精品九九99久久| 亚洲国产精品一区二区尤物区| 在线精品亚洲一区二区不卡| 亚洲视频一区在线| 99国产精品99久久久久久| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 97se亚洲国产综合自在线| 亚洲人精品午夜| 欧美午夜免费电影| 成人福利视频在线看| 国产日韩欧美麻豆| 不卡视频在线看| 亚洲精品水蜜桃| 欧美日韩视频在线一区二区| 首页亚洲欧美制服丝腿| 日韩欧美另类在线| 国产99久久久国产精品潘金| 国产精品乱子久久久久| 99国内精品久久| 亚洲一区二区三区在线看| 欧美乱熟臀69xxxxxx| 奇米影视一区二区三区| 久久无码av三级| 91小视频免费看| 午夜久久电影网| 精品国产乱码久久久久久牛牛| 国产一区二区伦理| 亚洲欧美成人一区二区三区| 制服视频三区第一页精品| 老司机精品视频线观看86| 国产精品色眯眯| 精品视频1区2区3区| 久久www免费人成看片高清| 中文字幕乱码久久午夜不卡 | 激情五月婷婷综合| 中文字幕欧美一| 欧美美女网站色| 欧美猛男男办公室激情| 国产凹凸在线观看一区二区| 亚洲永久精品大片| 久久久久久久网| 欧洲生活片亚洲生活在线观看| 麻豆精品久久久| 亚洲激情综合网| 久久综合五月天婷婷伊人| 色综合久久久久综合体桃花网| 久久精品国产精品亚洲红杏| 亚洲人成亚洲人成在线观看图片| 欧美午夜精品电影| 岛国av在线一区| 美女视频一区二区| 亚洲美女区一区| 久久精品视频一区| 91精品国产91久久久久久最新毛片| 福利91精品一区二区三区| 日韩av中文字幕一区二区三区| 国产精品国产三级国产专播品爱网| 欧美一区二区三区电影| 色成年激情久久综合| 国产乱码精品一区二区三区av| 亚洲成人黄色影院| 亚洲免费看黄网站| 国产清纯白嫩初高生在线观看91 | 亚洲激情一二三区| 国产精品欧美一区喷水| 精品久久国产97色综合| 在线不卡a资源高清| 色综合久久99| 99免费精品在线| 国产精品一卡二卡| 精品一区二区三区在线播放| 亚洲国产精品自拍| 亚洲伦理在线精品| 国产精品久久久久影视| 久久久久国色av免费看影院| 日韩欧美中文字幕一区| 91精品欧美久久久久久动漫| 91精品国产综合久久精品| 一本久道中文字幕精品亚洲嫩| 丰满亚洲少妇av| 国产**成人网毛片九色| 国产精品18久久久久| 国产麻豆精品视频| 国产一区二区成人久久免费影院| 美女网站色91| 韩国三级电影一区二区| 久久er99精品| 国产精品自拍三区| 岛国av在线一区| 99久久精品99国产精品| 97精品视频在线观看自产线路二| av在线综合网| 91激情五月电影| 欧美日韩精品电影| 欧美日韩国产一级片| 欧美精品久久一区二区三区| 91精品国产高清一区二区三区| 欧美一区二区三区不卡| 欧美精品一区视频| 国产免费观看久久| 亚洲精品午夜久久久| 五月天网站亚洲| 蜜臀av国产精品久久久久| 久久精品国产一区二区| 国产成人精品网址| 91免费看片在线观看| 欧美性色黄大片手机版| 日韩一区二区三区电影| 国产情人综合久久777777| 亚洲精品成人天堂一二三| 日本亚洲三级在线| 国产一本一道久久香蕉| 成人视屏免费看| 日本韩国欧美在线| 日韩欧美综合一区| 国产精品国模大尺度视频| 亚洲一二三四在线| 国产自产2019最新不卡| av一本久道久久综合久久鬼色| 欧美色爱综合网| 国产亚洲1区2区3区| 一区二区三区四区视频精品免费| 日韩中文字幕区一区有砖一区 | 成人18精品视频| 欧美老人xxxx18| 国产精品久久久99| 日韩av电影天堂| av一区二区三区四区| 欧美一级片免费看| 中文字幕一区二区三区蜜月| 五月天激情综合| 成人av在线资源网站| 欧美肥妇bbw| 亚洲欧美一区二区在线观看| 男女视频一区二区| 99久久99久久精品国产片果冻| 51精品久久久久久久蜜臀| 国产精品美女久久久久久久网站| 午夜激情一区二区三区| 99久久99久久精品国产片果冻 | 日韩精品高清不卡| 成人免费毛片a| 日韩欧美国产午夜精品| 亚洲一区视频在线| 99久久免费精品| 国产亚洲精品久| 精品一区二区日韩| 777午夜精品免费视频| 亚洲精品日韩一| 波多野结衣中文字幕一区二区三区| 欧美xxxxx裸体时装秀| 日韩国产在线一| 欧美优质美女网站| 亚洲免费在线电影| 成人综合激情网| 久久―日本道色综合久久| 久久99精品久久久久久久久久久久 | 欧美日韩亚洲丝袜制服| 一区二区三区 在线观看视频| 国产福利91精品| 久久久精品国产免大香伊| 老司机精品视频一区二区三区| 69久久99精品久久久久婷婷 | 国产精品美女www爽爽爽| 国产美女视频一区| 精品999在线播放| 激情偷乱视频一区二区三区|