文章目录
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];