ios藍牙掃描指定的設備

0.蘋果官方文檔

  [myCentralManager scanForPeripheralsWithServices:nil options:nil];

If you specify nil for the first parameter, the central manager returns all discovered peripherals, regardless of their supported services. In a real app, you typically specify an array of CBUUID objects, each of which represents the universally unique identifier (UUID) of a service that a peripheral is advertising. When you specify an array of service UUIDs, the central manager returns only peripherals that advertise those services, allowing you to scan only for devices that you may be interested in.

如果爲第一個參數指定nil,則中央管理器將返回所有發現的外圍設備,不管它們支持哪些服務。在實際應用程序中,通常指定一個CBUUID對象數組,其中每個對象表示外圍設備正在廣告的服務的通用惟一標識符(UUID)。當您指定一個服務uuid數組時,中央管理器只返回宣傳這些服務的外圍設備,允許您只掃描您可能感興趣的設備。

文檔連接

1.掃描廣播的service UUIDs是2803或是CB00的設備

 NSString *str = @"2803";
    CBUUID *uuid = [CBUUID UUIDWithString:str];
    NSString *str1 = @"CB00";
    CBUUID *uuid1 = [CBUUID UUIDWithString:str1];
     [_myCentralManager scanForPeripheralsWithServices:@[uuid,uuid1] options:nil];

在這裏插入圖片描述

在這裏插入圖片描述

2.掃描廣播的service UUIDs是2803的設備

在這裏插入圖片描述

2.1 蘋果手機藍牙工具顯示

在這裏插入圖片描述

2.2 安卓手機藍牙工具顯示

在這裏插入圖片描述

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章