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 安卓手机蓝牙工具显示

在这里插入图片描述

在这里插入图片描述

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