iOS 的蓝牙分为Central和Periphera
这里介绍Periphera
代码:
#define readwriteCharacteristicUUID @"abcd"
#define ServiceUUID1 @"50BD367B-6B17-4E81-B6E9-F62016F26E7B"
#define LocalNameKey @"my ble"
遵守协议<CBPeripheralManagerDelegate>
@property(nonatomic,strong)CBPeripheralManager *myperipheralManager;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.myperipheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
}
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
NSLog(@"%ld",(long)peripheral.state);
switch (peripheral.state) {