Commit 1029702b authored by 刘俊宏's avatar 刘俊宏

Removing BabyBluetooth

parent 6b7b45a4
......@@ -7,7 +7,7 @@
<key>GeliBusinessPlatform.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>18</integer>
<integer>22</integer>
</dict>
</dict>
</dict>
......
......@@ -24,6 +24,5 @@ pod 'RealmSwift'
pod 'SnapKit'
pod 'LGButton'
pod 'WYAutoLayout'
pod 'BabyBluetooth'
pod 'SVProgressHUD'
end
PODS:
- Alamofire (4.9.1)
- BabyBluetooth (0.7.0)
- CryptoSwift (1.3.0)
- Dollar (9.0.0)
- ESTabBarController-swift (2.8.0)
......@@ -47,7 +46,6 @@ PODS:
DEPENDENCIES:
- Alamofire
- BabyBluetooth
- CryptoSwift
- Dollar
- ESTabBarController-swift
......@@ -71,7 +69,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- Alamofire
- BabyBluetooth
- CryptoSwift
- Dollar
- ESTabBarController-swift
......@@ -95,7 +92,6 @@ SPEC REPOS:
SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
BabyBluetooth: d50758aecf24d4a0ab9271d69f0f116d6bee51c9
CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211
Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c
ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136
......@@ -117,6 +113,6 @@ SPEC CHECKSUMS:
ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73
WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb
PODFILE CHECKSUM: 5362542ba7b343b78bf3e0ee7359bad79d3db6ae
PODFILE CHECKSUM: 3835497c93adf93b9ea2d02d860992e134d8f3b0
COCOAPODS: 1.9.1
This diff is collapsed.
This diff is collapsed.
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 的block定义和储存
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyOptions.h"
//设备状态改变的委托
typedef void (^BBCentralManagerDidUpdateStateBlock)(CBCentralManager *central);
//找到设备的委托
typedef void (^BBDiscoverPeripheralsBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI);
//连接设备成功的block
typedef void (^BBConnectedPeripheralBlock)(CBCentralManager *central,CBPeripheral *peripheral);
//连接设备失败的block
typedef void (^BBFailToConnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
//断开设备连接的bock
typedef void (^BBDisconnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
//找到服务的block
typedef void (^BBDiscoverServicesBlock)(CBPeripheral *peripheral,NSError *error);
//找到Characteristics的block
typedef void (^BBDiscoverCharacteristicsBlock)(CBPeripheral *peripheral,CBService *service,NSError *error);
//更新(获取)Characteristics的value的block
typedef void (^BBReadValueForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error);
//获取Characteristics的名称
typedef void (^BBDiscoverDescriptorsForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error);
//获取Descriptors的值
typedef void (^BBReadValueForDescriptorsBlock)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error);
//babyBluettooth cancelScanBlock方法调用后的回调
typedef void (^BBCancelScanBlock)(CBCentralManager *centralManager);
//babyBluettooth cancelAllPeripheralsConnection 方法调用后的回调
typedef void (^BBCancelAllPeripheralsConnectionBlock)(CBCentralManager *centralManager);
typedef void (^BBDidWriteValueForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
typedef void (^BBDidWriteValueForDescriptorBlock)(CBDescriptor *descriptor,NSError *error);
typedef void (^BBDidUpdateNotificationStateForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
typedef void (^BBDidReadRSSIBlock)(NSNumber *RSSI,NSError *error);
typedef void (^BBDidDiscoverIncludedServicesForServiceBlock)(CBService *service,NSError *error);
typedef void (^BBDidUpdateNameBlock)(CBPeripheral *peripheral);
typedef void (^BBDidModifyServicesBlock)(CBPeripheral *peripheral,NSArray *invalidatedServices);
//peripheral model
typedef void (^BBPeripheralModelDidUpdateState)(CBPeripheralManager *peripheral);
typedef void (^BBPeripheralModelDidAddService)(CBPeripheralManager *peripheral,CBService *service,NSError *error);
typedef void (^BBPeripheralModelDidStartAdvertising)(CBPeripheralManager *peripheral,NSError *error);
typedef void (^BBPeripheralModelDidReceiveReadRequest)(CBPeripheralManager *peripheral,CBATTRequest *request);
typedef void (^BBPeripheralModelDidReceiveWriteRequests)(CBPeripheralManager *peripheral,NSArray *requests);
typedef void (^BBPeripheralModelDidSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
typedef void (^BBPeripheralModelDidUnSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
@interface BabyCallback : NSObject
#pragma mark - callback block
//设备状态改变的委托
@property (nonatomic, copy) BBCentralManagerDidUpdateStateBlock blockOnCentralManagerDidUpdateState;
//发现peripherals
@property (nonatomic, copy) BBDiscoverPeripheralsBlock blockOnDiscoverPeripherals;
//连接callback
@property (nonatomic, copy) BBConnectedPeripheralBlock blockOnConnectedPeripheral;
//连接设备失败的block
@property (nonatomic, copy) BBFailToConnectBlock blockOnFailToConnect;
//断开设备连接的bock
@property (nonatomic, copy) BBDisconnectBlock blockOnDisconnect;
//发现services
@property (nonatomic, copy) BBDiscoverServicesBlock blockOnDiscoverServices;
//发现Characteristics
@property (nonatomic, copy) BBDiscoverCharacteristicsBlock blockOnDiscoverCharacteristics;
//发现更新Characteristics的
@property (nonatomic, copy) BBReadValueForCharacteristicBlock blockOnReadValueForCharacteristic;
//获取Characteristics的名称
@property (nonatomic, copy) BBDiscoverDescriptorsForCharacteristicBlock blockOnDiscoverDescriptorsForCharacteristic;
//获取Descriptors的值
@property (nonatomic,copy) BBReadValueForDescriptorsBlock blockOnReadValueForDescriptors;
@property (nonatomic, copy) BBDidWriteValueForCharacteristicBlock blockOnDidWriteValueForCharacteristic;
@property (nonatomic, copy) BBDidWriteValueForDescriptorBlock blockOnDidWriteValueForDescriptor;
@property (nonatomic, copy) BBDidUpdateNotificationStateForCharacteristicBlock blockOnDidUpdateNotificationStateForCharacteristic;
@property (nonatomic, copy) BBDidReadRSSIBlock blockOnDidReadRSSI;
@property (nonatomic, copy) BBDidDiscoverIncludedServicesForServiceBlock blockOnDidDiscoverIncludedServicesForService;
@property (nonatomic, copy) BBDidUpdateNameBlock blockOnDidUpdateName;
@property (nonatomic, copy) BBDidModifyServicesBlock blockOnDidModifyServices;
//babyBluettooth stopScan方法调用后的回调
@property(nonatomic,copy) BBCancelScanBlock blockOnCancelScan;
//babyBluettooth stopConnectAllPerihperals 方法调用后的回调
@property(nonatomic,copy) BBCancelAllPeripheralsConnectionBlock blockOnCancelAllPeripheralsConnection;
//babyBluettooth 蓝牙使用的参数参数
@property(nonatomic,strong) BabyOptions *babyOptions;
#pragma mark - 过滤器Filter
//发现peripherals规则
@property (nonatomic, copy) BOOL (^filterOnDiscoverPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
//连接peripherals规则
@property (nonatomic, copy) BOOL (^filterOnconnectToPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
#pragma mark - peripheral model
//peripheral model
@property (nonatomic, copy) BBPeripheralModelDidUpdateState blockOnPeripheralModelDidUpdateState;
@property (nonatomic, copy) BBPeripheralModelDidAddService blockOnPeripheralModelDidAddService;
@property (nonatomic, copy) BBPeripheralModelDidStartAdvertising blockOnPeripheralModelDidStartAdvertising;
@property (nonatomic, copy) BBPeripheralModelDidReceiveReadRequest blockOnPeripheralModelDidReceiveReadRequest;
@property (nonatomic, copy) BBPeripheralModelDidReceiveWriteRequests blockOnPeripheralModelDidReceiveWriteRequests;
@property (nonatomic, copy) BBPeripheralModelDidSubscribeToCharacteristic blockOnPeripheralModelDidSubscribeToCharacteristic;
@property (nonatomic, copy) BBPeripheralModelDidUnSubscribeToCharacteristic blockOnPeripheralModelDidUnSubscribeToCharacteristic;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyCallback.h"
@implementation BabyCallback
- (instancetype)init {
self = [super init];
if (self) {
[self setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
if (![peripheralName isEqualToString:@""]) {
return YES;
}
return NO;
}];
[self setFilterOnconnectToPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
if (![peripheralName isEqualToString:@""]) {
return YES;
}
return NO;
}];
}
return self;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 蓝牙中心模式实现类
*/
// Created by 刘彦玮 on 15/7/30.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyToy.h"
#import "BabySpeaker.h"
#import "BabyDefine.h"
@interface BabyCentralManager : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate> {
@public
//方法是否处理
BOOL needScanForPeripherals;//是否扫描Peripherals
BOOL needConnectPeripheral;//是否连接Peripherals
BOOL needDiscoverServices;//是否发现Services
BOOL needDiscoverCharacteristics;//是否获取Characteristics
BOOL needReadValueForCharacteristic;//是否获取(更新)Characteristics的值
BOOL needDiscoverDescriptorsForCharacteristic;//是否获取Characteristics的描述
BOOL needReadValueForDescriptors;//是否获取Descriptors的值
//一次性处理
BOOL oneReadValueForDescriptors;
//方法执行时间
int executeTime;
NSTimer *connectTimer;
//pocket
NSMutableDictionary *pocket;
//主设备
CBCentralManager *centralManager;
//回叫方法
BabySpeaker *babySpeaker;
@private
//已经连接的设备
NSMutableArray *connectedPeripherals;
//已经连接的设备
NSMutableArray *discoverPeripherals;
//需要自动重连的外设
NSMutableArray *reConnectPeripherals;
}
//扫描Peripherals
- (void)scanPeripherals;
//连接Peripherals
- (void)connectToPeripheral:(CBPeripheral *)peripheral;
//断开设备连接
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
//断开所有已连接的设备
- (void)cancelAllPeripheralsConnection;
//停止扫描
- (void)cancelScan;
//获取当前连接的peripherals
- (NSArray *)findConnectedPeripherals;
//获取当前连接的peripheral
- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
/**
sometimes ever,sometimes never. 相聚有时,后会无期
this is center with peripheral's story
**/
//sometimes ever:添加断开重连接的设备
- (void)sometimes_ever:(CBPeripheral *)peripheral ;
//sometimes never:删除需要重连接的设备
- (void)sometimes_never:(CBPeripheral *)peripheral ;
@end
This diff is collapsed.
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 预定义一些库的执行行为和配置
*/
// Created by 刘彦玮 on 6/4/19.
// Copyright © 2016年 liuyanwei. All rights reserved.
//
#import <Foundation/Foundation.h>
# pragma mark - baby 行为定义
//Baby if show log 是否打印日志,默认1:打印 ,0:不打印
#define KBABY_IS_SHOW_LOG 1
//CBcentralManager等待设备打开次数
# define KBABY_CENTRAL_MANAGER_INIT_WAIT_TIMES 5
//CBcentralManager等待设备打开间隔时间
# define KBABY_CENTRAL_MANAGER_INIT_WAIT_SECOND 2.0
//BabyRhythm默认心跳时间间隔
#define KBABYRHYTHM_BEATS_DEFAULT_INTERVAL 3;
//Baby默认链式方法channel名称
#define KBABY_DETAULT_CHANNEL @"babyDefault"
# pragma mark - baby通知
//蓝牙系统通知
//centralManager status did change notification
#define BabyNotificationAtCentralManagerDidUpdateState @"BabyNotificationAtCentralManagerDidUpdateState"
//did discover peripheral notification
#define BabyNotificationAtDidDiscoverPeripheral @"BabyNotificationAtDidDiscoverPeripheral"
//did connection peripheral notification
#define BabyNotificationAtDidConnectPeripheral @"BabyNotificationAtDidConnectPeripheral"
//did filed connect peripheral notification
#define BabyNotificationAtDidFailToConnectPeripheral @"BabyNotificationAtDidFailToConnectPeripheral"
//did disconnect peripheral notification
#define BabyNotificationAtDidDisconnectPeripheral @"BabyNotificationAtDidDisconnectPeripheral"
//did discover service notification
#define BabyNotificationAtDidDiscoverServices @"BabyNotificationAtDidDiscoverServices"
//did discover characteristics notification
#define BabyNotificationAtDidDiscoverCharacteristicsForService @"BabyNotificationAtDidDiscoverCharacteristicsForService"
//did read or notify characteristic when received value notification
#define BabyNotificationAtDidUpdateValueForCharacteristic @"BabyNotificationAtDidUpdateValueForCharacteristic"
//did write characteristic and response value notification
#define BabyNotificationAtDidWriteValueForCharacteristic @"BabyNotificationAtDidWriteValueForCharacteristic"
//did change characteristis notify status notification
#define BabyNotificationAtDidUpdateNotificationStateForCharacteristic @"BabyNotificationAtDidUpdateNotificationStateForCharacteristic"
//did read rssi and receiced value notification
#define BabyNotificationAtDidReadRSSI @"BabyNotificationAtDidReadRSSI"
//蓝牙扩展通知
// did centralManager enable notification
#define BabyNotificationAtCentralManagerEnable @"BabyNotificationAtCentralManagerEnable"
# pragma mark - baby 定义的方法
//Baby log
#define BabyLog(fmt, ...) if(KBABY_IS_SHOW_LOG) { NSLog(fmt,##__VA_ARGS__); }
@interface BabyDefine : NSObject
@end
//
// BabyBlueDefine.m
// BabyTestProject
//
// Created by xuanyan.lyw on 16/4/19.
// Copyright © 2016年 liuyanwei. All rights reserved.
//
#import "BabyDefine.h"
@implementation BabyDefine
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 封装蓝牙外设模式的运行时参数,可以实现后台模式,重复接收广播,查找service参数,查找characteristic参数
*/
// Created by 刘彦玮 on 15/9/27.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabyOptions : NSObject
#pragma mark - 属性
/*!
* 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
* @param An optional dictionary specifying options for the scan.
* @see centralManager:scanForPeripheralsWithServices
* @seealso CBCentralManagerScanOptionAllowDuplicatesKey :忽略同一个Peripheral端的多个发现事件被聚合成一个发现事件
* @seealso CBCentralManagerScanOptionSolicitedServiceUUIDsKey
*/
@property (nonatomic, copy) NSDictionary *scanForPeripheralsWithOptions;
/*!
* 连接设备的参数
* @method connectPeripheral:options:
* @param An optional dictionary specifying connection behavior options.
* @see centralManager:didConnectPeripheral:
* @see centralManager:didFailToConnectPeripheral:error:
* @seealso CBConnectPeripheralOptionNotifyOnConnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnDisconnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnNotificationKey
*/
@property (nonatomic, copy) NSDictionary *connectPeripheralWithOptions;
/*!
* 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
*@param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.
*@see centralManager:scanForPeripheralsWithServices
*/
@property (nonatomic, copy) NSArray *scanForPeripheralsWithServices;
// [peripheral discoverServices:self.discoverWithServices];
@property (nonatomic, copy) NSArray *discoverWithServices;
// [peripheral discoverCharacteristics:self.discoverWithCharacteristics forService:service];
@property (nonatomic, copy) NSArray *discoverWithCharacteristics;
#pragma mark - 构造方法
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions;
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
@end
//
// BabyClothes.m
// BabyBluetoothAppDemo
//
// Created by 刘彦玮 on 15/9/27.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import "BabyOptions.h"
@implementation BabyOptions
- (instancetype)init {
self = [super init];
if (self) {
_scanForPeripheralsWithOptions = nil;
_connectPeripheralWithOptions = nil;
_scanForPeripheralsWithServices = nil;
_discoverWithServices = nil;
_discoverWithCharacteristics = nil;
}
return self;
}
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
{
self = [super init];
if (self) {
[self setScanForPeripheralsWithOptions:scanForPeripheralsWithOptions];
[self setConnectPeripheralWithOptions:connectPeripheralWithOptions];
}
return self;
}
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics
{
self = [self initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions];
if (self) {
[self setScanForPeripheralsWithServices:scanForPeripheralsWithServices];
[self setDiscoverWithServices:discoverWithServices];
[self setDiscoverWithCharacteristics:discoverWithCharacteristics];
}
return self;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 蓝牙外设模式实现类
*/
// Created by 刘彦玮 on 15/12/12.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyToy.h"
#import "BabySpeaker.h"
@interface BabyPeripheralManager : NSObject<CBPeripheralManagerDelegate> {
@public
//回叫方法
BabySpeaker *babySpeaker;
}
/**
添加服务
*/
- (BabyPeripheralManager *(^)(NSArray *array))addServices;
/**
启动广播
*/
- (BabyPeripheralManager *(^)())startAdvertising;
//外设管理器
@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
@property (nonatomic, copy) NSString *localName;
@property (nonatomic, strong) NSMutableArray *services;
@end
/**
* 构造Characteristic,并加入service
* service:CBService
* param`ter for properties :option 'r' | 'w' | 'n' or combination
* r CBCharacteristicPropertyRead
* w CBCharacteristicPropertyWrite
* n CBCharacteristicPropertyNotify
* default value is rw Read-Write
* paramter for descriptor:be uesd descriptor for characteristic
*/
void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor);
/**
* 构造一个包含初始值的Characteristic,并加入service,包含了初值的characteristic必须设置permissions和properties都为只读
* make characteristic then add to service, a static characteristic mean it has a initial value .according apple rule, it must set properties and permissions to CBCharacteristicPropertyRead and CBAttributePermissionsReadable
*/
void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data);
/**
生成CBService
*/
CBMutableService* makeCBService(NSString *UUID);
/**
生成UUID
*/
NSString* genUUID();
//
// BabyPeripheralManager.m
// BluetoothStubOnIOS
//
// Created by 刘彦玮 on 15/12/12.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import "BabyPeripheralManager.h"
#import "BabyDefine.h"
#define callbackBlock(...) if ([[babySpeaker callback] __VA_ARGS__]) [[babySpeaker callback] __VA_ARGS__ ]
@implementation BabyPeripheralManager {
int PERIPHERAL_MANAGER_INIT_WAIT_TIMES;
int didAddServices;
NSTimer *addServiceTask;
}
- (instancetype)init {
self = [super init];
if (self) {
_localName = @"baby-default-name";
_peripheralManager = [[CBPeripheralManager alloc]initWithDelegate:self queue:nil options:nil];
}
return self;
}
- (BabyPeripheralManager *(^)())startAdvertising {
return ^BabyPeripheralManager *() {
if ([self canStartAdvertising]) {
PERIPHERAL_MANAGER_INIT_WAIT_TIMES = 0;
NSMutableArray *UUIDS = [NSMutableArray array];
for (CBMutableService *s in _services) {
[UUIDS addObject:s.UUID];
}
//启动广播
[_peripheralManager startAdvertising:
@{
CBAdvertisementDataServiceUUIDsKey : UUIDS
,CBAdvertisementDataLocalNameKey : _localName
}];
}
else {
PERIPHERAL_MANAGER_INIT_WAIT_TIMES++;
if (PERIPHERAL_MANAGER_INIT_WAIT_TIMES > 5) {
BabyLog(@">>>error: 第%d次等待peripheralManager打开任然失败,请检查蓝牙设备是否可用",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
}
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.startAdvertising();
});
BabyLog(@">>> 第%d次等待peripheralManager打开",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
}
return self;
};
}
- (BOOL)canStartAdvertising {
if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
return NO;
}
if (didAddServices != _services.count) {
return NO;
}
return YES;
}
- (BOOL)isPoweredOn {
if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
return NO;
}
return YES;
}
- (BabyPeripheralManager *(^)(NSArray *array))addServices {
return ^BabyPeripheralManager*(NSArray *array) {
_services = [NSMutableArray arrayWithArray:array];
[self addServicesToPeripheral];
return self;
};
}
- (void)addServicesToPeripheral {
if ([self isPoweredOn]) {
for (CBMutableService *s in _services) {
[_peripheralManager addService:s];
}
}
else {
[addServiceTask setFireDate:[NSDate distantPast]];
addServiceTask = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(addServicesToPeripheral) userInfo:nil repeats:NO];
}
}
#pragma mark - peripheralManager delegate
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
switch (peripheral.state) {
case CBPeripheralManagerStateUnknown:
BabyLog(@">>>CBPeripheralManagerStateUnknown");
break;
case CBPeripheralManagerStateResetting:
BabyLog(@">>>CBPeripheralManagerStateResetting");
break;
case CBPeripheralManagerStateUnsupported:
BabyLog(@">>>CBPeripheralManagerStateUnsupported");
break;
case CBPeripheralManagerStateUnauthorized:
BabyLog(@">>>CBPeripheralManagerStateUnauthorized");
break;
case CBPeripheralManagerStatePoweredOff:
BabyLog(@">>>CBPeripheralManagerStatePoweredOff");
break;
case CBPeripheralManagerStatePoweredOn:
BabyLog(@">>>CBPeripheralManagerStatePoweredOn");
//发送centralManagerDidUpdateState通知
[[NSNotificationCenter defaultCenter]postNotificationName:@"CBPeripheralManagerStatePoweredOn" object:nil];
break;
default:
break;
}
// if([babySpeaker callback] blockOnPeripheralModelDidUpdateState) {
// [currChannel blockOnCancelScan](centralManager);
// }
callbackBlock(blockOnPeripheralModelDidUpdateState)(peripheral);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(NSError *)error {
didAddServices++;
callbackBlock(blockOnPeripheralModelDidAddService)(peripheral,service,error);
}
- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error {
callbackBlock(blockOnPeripheralModelDidStartAdvertising)(peripheral,error);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
callbackBlock(blockOnPeripheralModelDidReceiveReadRequest)(peripheral, request);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests {
callbackBlock(blockOnPeripheralModelDidReceiveWriteRequests)(peripheral,requests);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic {
callbackBlock(blockOnPeripheralModelDidSubscribeToCharacteristic)(peripheral,central,characteristic);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic {
callbackBlock(blockOnPeripheralModelDidUnSubscribeToCharacteristic)(peripheral,central,characteristic);
}
@end
void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor) {
//paramter for properties
CBCharacteristicProperties prop = 0x00;
if ([properties containsString:@"r"]) {
prop = prop | CBCharacteristicPropertyRead;
}
if ([properties containsString:@"w"]) {
prop = prop | CBCharacteristicPropertyWrite;
}
if ([properties containsString:@"n"]) {
prop = prop | CBCharacteristicPropertyNotify;
}
if (properties == nil || [properties isEqualToString:@""]) {
prop = CBCharacteristicPropertyRead | CBCharacteristicPropertyWrite;
}
CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:prop value:nil permissions:CBAttributePermissionsReadable | CBAttributePermissionsWriteable];
//paramter for descriptor
if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
//c设置description对应的haracteristics字段描述
CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
[c setDescriptors:@[desc]];
}
if (!service.characteristics) {
service.characteristics = @[];
}
NSMutableArray *cs = [service.characteristics mutableCopy];
[cs addObject:c];
service.characteristics = [cs copy];
}
void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data) {
CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:CBCharacteristicPropertyRead value:data permissions:CBAttributePermissionsReadable];
//paramter for descriptor
if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
//c设置description对应的haracteristics字段描述
CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
[c setDescriptors:@[desc]];
}
if (!service.characteristics) {
service.characteristics = @[];
}
NSMutableArray *cs = [service.characteristics mutableCopy];
[cs addObject:c];
service.characteristics = [cs copy];
}
CBMutableService* makeCBService(NSString *UUID)
{
CBMutableService *s = [[CBMutableService alloc]initWithType:[CBUUID UUIDWithString:UUID] primary:YES];
return s;
}
NSString * genUUID()
{
CFUUIDRef uuid_ref = CFUUIDCreate(NULL);
CFStringRef uuid_string_ref= CFUUIDCreateString(NULL, uuid_ref);
CFRelease(uuid_ref);
NSString *uuid = [NSString stringWithString:(__bridge NSString*)uuid_string_ref];
CFRelease(uuid_string_ref);
return uuid;
}
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth Rhythm用于检测蓝牙的任务执行情况,处理复杂的蓝牙流程操作
*/
//
// Created by ZTELiuyw on 15/9/15.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BabyDefine.h"
@interface BabyRhythm : NSObject
typedef void (^BBBeatsBreakBlock)(BabyRhythm *bry);
typedef void (^BBBeatsOverBlock)(BabyRhythm *bry);
//timer for beats
@property (nonatomic, strong) NSTimer *beatsTimer;
//beat interval
@property NSInteger beatsInterval;
#pragma mark beats
//心跳
- (void)beats;
//主动中断心跳
- (void)beatsBreak;
//结束心跳,结束后会进入BlockOnBeatOver,并且结束后再不会在触发BlockOnBeatBreak
- (void)beatsOver;
//恢复心跳,beatsOver操作后可以使用beatsRestart恢复心跳,恢复后又可以进入BlockOnBeatBreak方法
- (void)beatsRestart;
//心跳中断的委托
- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block;
//心跳结束的委托
- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block;
@end
//
// BabyBeats.m
// BabyBluetoothAppDemo
//
// Created by ZTELiuyw on 15/9/15.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyRhythm.h"
#import "BabyDefine.h"
@implementation BabyRhythm {
BOOL isOver;
BBBeatsBreakBlock blockOnBeatBreak;
BBBeatsOverBlock blockOnBeatOver;
}
- (instancetype)init {
self = [super init];
if (self) {
//beatsInterval
_beatsInterval = KBABYRHYTHM_BEATS_DEFAULT_INTERVAL;
}
return self;
}
- (void)beats {
if (isOver) {
BabyLog(@">>>beats isOver");
return;
}
BabyLog(@">>>beats at :%@",[NSDate date]);
if (self.beatsTimer) {
[self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
}
else {
self.beatsTimer = [NSTimer timerWithTimeInterval:self.beatsInterval target:self selector:@selector(beatsBreak) userInfo:nil repeats:YES];
[self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
[[NSRunLoop currentRunLoop] addTimer:self.beatsTimer forMode:NSRunLoopCommonModes];
}
}
- (void)beatsBreak {
BabyLog(@">>>beatsBreak :%@",[NSDate date]);
[self.beatsTimer setFireDate:[NSDate distantFuture]];
if (blockOnBeatBreak) {
blockOnBeatBreak(self);
}
}
- (void)beatsOver {
BabyLog(@">>>beatsOver :%@",[NSDate date]);
[self.beatsTimer setFireDate:[NSDate distantFuture]];
isOver = YES;
if (blockOnBeatOver) {
blockOnBeatOver(self);
}
}
- (void)beatsRestart {
BabyLog(@">>>beatsRestart :%@",[NSDate date]);
isOver = NO;
[self beats];
}
- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block {
blockOnBeatBreak = block;
}
- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block {
blockOnBeatOver = block;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth block查找和channel切换
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyCallback.h"
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabySpeaker : NSObject
- (BabyCallback *)callback;
- (BabyCallback *)callbackOnCurrChannel;
- (BabyCallback *)callbackOnChnnel:(NSString *)channel;
- (BabyCallback *)callbackOnChnnel:(NSString *)channel
createWhenNotExist:(BOOL)createWhenNotExist;
//切换频道
- (void)switchChannel:(NSString *)channel;
//添加到notify list
- (void)addNotifyCallback:(CBCharacteristic *)c
withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block;
//添加到notify list
- (void)removeNotifyCallback:(CBCharacteristic *)c;
//获取notify list
- (NSMutableDictionary *)notifyCallBackList;
//获取notityBlock
- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabySpeaker.h"
#import "BabyDefine.h"
typedef NS_ENUM(NSUInteger, BabySpeakerType) {
BabySpeakerTypeDiscoverPeripherals,
BabySpeakerTypeConnectedPeripheral,
BabySpeakerTypeDiscoverPeripheralsFailToConnect,
BabySpeakerTypeDiscoverPeripheralsDisconnect,
BabySpeakerTypeDiscoverPeripheralsDiscoverServices,
BabySpeakerTypeDiscoverPeripheralsDiscoverCharacteristics,
BabySpeakerTypeDiscoverPeripheralsReadValueForCharacteristic,
BabySpeakerTypeDiscoverPeripheralsDiscoverDescriptorsForCharacteristic,
BabySpeakerTypeDiscoverPeripheralsReadValueForDescriptorsBlock
};
@implementation BabySpeaker {
//所有委托频道
NSMutableDictionary *channels;
//当前委托频道
NSString *currChannel;
//notifyList
NSMutableDictionary *notifyList;
}
- (instancetype)init {
self = [super init];
if (self) {
BabyCallback *defaultCallback = [[BabyCallback alloc]init];
notifyList = [[NSMutableDictionary alloc]init];
channels = [[NSMutableDictionary alloc]init];
currChannel = KBABY_DETAULT_CHANNEL;
[channels setObject:defaultCallback forKey:KBABY_DETAULT_CHANNEL];
}
return self;
}
- (BabyCallback *)callback {
return [channels objectForKey:KBABY_DETAULT_CHANNEL];
}
- (BabyCallback *)callbackOnCurrChannel {
return [self callbackOnChnnel:currChannel];
}
- (BabyCallback *)callbackOnChnnel:(NSString *)channel {
if (!channel) {
[self callback];
}
return [channels objectForKey:channel];
}
- (BabyCallback *)callbackOnChnnel:(NSString *)channel
createWhenNotExist:(BOOL)createWhenNotExist {
BabyCallback *callback = [channels objectForKey:channel];
if (!callback && createWhenNotExist) {
callback = [[BabyCallback alloc]init];
[channels setObject:callback forKey:channel];
}
return callback;
}
- (void)switchChannel:(NSString *)channel {
if (channel) {
if ([self callbackOnChnnel:channel]) {
currChannel = channel;
BabyLog(@">>>已切换到%@",channel);
}
else {
BabyLog(@">>>所要切换的channel不存在");
}
}
else {
currChannel = KBABY_DETAULT_CHANNEL;
BabyLog(@">>>已切换到默认频道");
}
}
//添加到notify list
- (void)addNotifyCallback:(CBCharacteristic *)c
withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block {
[notifyList setObject:block forKey:c.UUID.description];
}
//添加到notify list
- (void)removeNotifyCallback:(CBCharacteristic *)c {
[notifyList removeObjectForKey:c.UUID.description];
}
//获取notify list
- (NSMutableDictionary *)notifyCallBackList {
return notifyList;
}
//获取notityBlock
- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c {
return [notifyList objectForKey:c.UUID.description];
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 工具类
*/
// Created by 刘彦玮 on 15/8/1.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabyToy : NSObject
//十六进制转换为普通字符串的。
+ (NSString *)ConvertHexStringToString:(NSString *)hexString;
//普通字符串转换为十六进制
+ (NSString *)ConvertStringToHexString:(NSString *)string;
//int转data
+(NSData *)ConvertIntToData:(int)i;
//data转int
+(int)ConvertDataToInt:(NSData *)data;
//十六进制转换为普通字符串的。
+ (NSData *)ConvertHexStringToData:(NSString *)hexString;
//根据UUIDString查找CBCharacteristic
+(CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
UUIDString:(NSString *)UUIDString;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/8/1.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyToy.h"
@implementation BabyToy
//十六进制转换为普通字符串的。
+ (NSString *)ConvertHexStringToString:(NSString *)hexString {
char *myBuffer = (char *)malloc((int)[hexString length] / 2 + 1);
bzero(myBuffer, [hexString length] / 2 + 1);
for (int i = 0; i < [hexString length] - 1; i += 2) {
unsigned int anInt;
NSString * hexCharStr = [hexString substringWithRange:NSMakeRange(i, 2)];
NSScanner *scanner = [[NSScanner alloc] initWithString:hexCharStr];
[scanner scanHexInt:&anInt];
myBuffer[i / 2] = (char)anInt;
}
NSString *unicodeString = [NSString stringWithCString:myBuffer encoding:4];
// BabyLog(@"===字符串===%@",unicodeString);
return unicodeString;
}
//普通字符串转换为十六进制
+ (NSString *)ConvertStringToHexString:(NSString *)string {
NSData *myD = [string dataUsingEncoding:NSUTF8StringEncoding];
Byte *bytes = (Byte *)[myD bytes];
//下面是Byte 转换为16进制。
NSString *hexStr=@"";
for (int i=0;i<[myD length];i++) {
NSString *newHexStr = [NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
if ([newHexStr length]==1) {
hexStr = [NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
}
else{
hexStr = [NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
}
}
return hexStr;
}
//int转data
+ (NSData *)ConvertIntToData:(int)i {
NSData *data = [NSData dataWithBytes: &i length: sizeof(i)];
return data;
}
//data转int
+ (int)ConvertDataToInt:(NSData *)data {
int i;
[data getBytes:&i length:sizeof(i)];
return i;
}
//十六进制转换为普通字符串的。
+ (NSData *)ConvertHexStringToData:(NSString *)hexString {
NSData *data = [[BabyToy ConvertHexStringToString:hexString] dataUsingEncoding:NSUTF8StringEncoding];
return data;
}
//根据UUIDString查找CBCharacteristic
+ (CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
UUIDString:(NSString *)UUIDString {
for (CBService *s in services) {
for (CBCharacteristic *c in s.characteristics) {
if ([c.UUID.UUIDString isEqualToString:UUIDString]) {
return c;
}
}
}
return nil;
}
@end
The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
![](http://images.jumppo.com/uploads/BabyBluetooth_logo.png)
The easiest way to use Bluetooth (BLE )in ios,even bady can use. 简单易用的蓝牙库,基于CoreBluetooth的封装,并兼容ios和mac osx.
**为什么使用它?**
- 1:基于原生CoreBluetooth框架封装的轻量级的开源库,可以帮你更简单地使用CoreBluetooth API。
- 2:CoreBluetooth所有方法都是通过委托完成,代码冗余且顺序凌乱。BabyBluetooth使用block方法,可以重新按照功能和顺序组织代码,并提供许多方法减少蓝牙开发过程中的代码量。
- 3:链式方法体,代码更简洁、优雅。
- 4:通过channel切换区分委托调用,并方便切换
- 5:便利的工具方法
- 6:完善的文档,且项目处于活跃状态,不断的更新中
- 7:github上star最多的纯Bluetooth类库
- 8:包含多种类型的demo和ios蓝牙开发教程
- 9:同时支持蓝牙设备中心模式和外设模式(central model and peripheral model)
当前版本 0.6.0
详细文档请参考wiki The full documentation of the project is available on its wiki.
# [english readme link,please click it!](https://github.com/coolnameismy/BabyBluetooth/blob/master/README_en.md)
# Table Of Contents
* [QuickExample](#user-content-QuickExample)
* [如何安装](#如何安装)
* [如何使用](#如何使用)
* [示例程序说明](#示例程序说明)
* [兼容性](#兼容性)
* [后期更新](#后期更新)
* [蓝牙学习资源](#蓝牙学习资源)
* [期待](#期待)
# QuickExample
## 中心模式 central model
> app作为中心,连接其他BLE4.0外设
```objc
//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;
-(void)viewDidLoad {
[super viewDidLoad];
//初始化BabyBluetooth 蓝牙库
baby = [BabyBluetooth shareBabyBluetooth];
//设置蓝牙委托
[self babyDelegate];
//设置委托后直接可以使用,无需等待CBCentralManagerStatePoweredOn状态
baby.scanForPeripherals().begin();
}
//设置蓝牙委托
-(void)babyDelegate{
//设置扫描到设备的委托
[baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
NSLog(@"搜索到了设备:%@",peripheral.name);
}];
//过滤器
//设置查找设备的过滤器
[baby setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
//最常用的场景是查找某一个前缀开头的设备 most common usage is discover for peripheral that name has common prefix
//if ([peripheralName hasPrefix:@"Pxxxx"] ) {
// return YES;
//}
//return NO;
//设置查找规则是名称大于1 , the search rule is peripheral.name length > 1
if (peripheralName.length >1) {
return YES;
}
return NO;
}];
//.......
}
```
更多蓝牙操作方法和委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
中心模式使用示例请参考:[BabyBluetoothAppDemo](https://github.com/coolnameismy//BabyBluetoothExamples/BabyBluetoothAppDemo)
## 外设模式 peripheral model
> app模拟一个,BLE4.0外设,可以被其他设备连接和使用
模拟一个有2个service和6个characteristic的外设
````objc
//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;
-(void)viewDidLoad {
[super viewDidLoad];
//配置第一个服务s1
CBMutableService *s1 = makeCBService(@"FFF0");
//配置s1的3个characteristic
makeCharacteristicToService(s1, @"FFF1", @"r", @"hello1");//读
makeCharacteristicToService(s1, @"FFF2", @"w", @"hello2");//写
makeCharacteristicToService(s1, genUUID(), @"rw", @"hello3");//可读写,uuid自动生成
makeCharacteristicToService(s1, @"FFF4", nil, @"hello4");//默认读写字段
makeCharacteristicToService(s1, @"FFF5", @"n", @"hello5");//notify字段
//配置第一个服务s2
CBMutableService *s2 = makeCBService(@"FFE0");
makeStaticCharacteristicToService(s2, genUUID(), @"hello6", [@"a" dataUsingEncoding:NSUTF8StringEncoding]);//一个含初值的字段,该字段权限只能是只读
//实例化baby
baby = [BabyBluetooth shareBabyBluetooth];
//配置委托
[self babyDelegate];
//启动外设
baby.bePeripheral().addServices(@[s1,s2]).startAdvertising();
}
//设置蓝牙外设模式的委托
-(void)babyDelegate{
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnPeripheralManagerDidUpdateState:^(CBPeripheralManager *peripheral) {
NSLog(@"PeripheralManager trun status code: %ld",(long)peripheral.state);
}];
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnDidStartAdvertising:^(CBPeripheralManager *peripheral, NSError *error) {
NSLog(@"didStartAdvertising !!!");
}];
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnDidAddService:^(CBPeripheralManager *peripheral, CBService *service, NSError *error) {
NSLog(@"Did Add Service uuid: %@ ",service.UUID);
}];
//.....
}
````
更多蓝牙外设模式委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
中心模式使用示例请参考:[BluetoothStubOnIOS](https://github.com/coolnameismy//BabyBluetoothExamples/BluetoothStubOnIOS)
# 如何安装
##1 手动安装
step1:将项目Classes/objc 文件夹中的文件直接拖入你的项目中即可
step2:导入.h文件
````objc
#import "BabyBluetooth.h"
````
##2 cocoapods
step1:add the following line to your Podfile:
````
pod 'BabyBluetooth','~> 0.6.0'
````
step2:导入.h文件
````objc
#import "BabyBluetooth.h"
````
# 如何使用
[用法请见wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
# 示例程序说明
**BabyBluetoothExamples/BabyBluetoothAppDemo** :一个类似lightblue的程序,蓝牙操作全部使用BabyBluetooth完成。
功能:
- 1:扫描周围设备
- 2:连接设备,扫描设备的全部services和characteristic
- 3:显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value
- 4:写0x01到characteristic
- 5:订阅/取消订阅 characteristic的notify
**BabyBluetoothExamples/BluetoothStubOnIOS** : 一个iOS程序,启动后会用手机模拟一个外设,提供2个服务和若干characteristic。
该程序作为Babybluetooth 外设模式使用的示例程序
**BabyBluetoothExamples/BabyBluetoothOSDemo** :一个mac os程序,因为os和ios的蓝牙底层方法都一样,所以BabyBluetooth可以ios/os通用。但是os程序有个好处就是直接可以在mac上跑蓝牙设备,不像ios,必须要真机才能跑蓝牙设备。所以不能真机调试时可以使用os尝试蓝牙库的使用。
功能:
- 1:扫描周围设备、连接设备、显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value的委托设置,并使用nslog打印信息。
**BabyBluetoothExamples/BluetoothStubOnOSX** :一个mac os程序,该程序可以作为蓝牙外设使用,解决学习蓝牙时没有外设可用的囧境,并且可以作为peripheral model模式的学习示例。改程序用swift编码。
功能:
- 1:作为蓝牙外设使用,可以被发现,连接,读写,订阅
- 2:提供1个service,包含了3个characteristic,分别具有读、读写、订阅功能
# 兼容性
- 蓝牙4.0,也叫做ble,ios6以上和iPhone4s以上可以自由使用
- os和ios通用
- 蓝牙设备相关程序必须使用真机才能运行。如果不能使用真机调试的情况,可以使用os程序调试蓝牙。可以参考示例程序中的BabyBluetoothOSDemo
- 本项目和示例程序是使用ios 8.3开发,使用者可以自行降版本,但必须大于6.0
# 后期更新
- 优化babyBluetooch的子类类名
- 增加对Carthage Install的支持
- swift版本开发
已经更新的版本说明,请在wiki中查看
# 蓝牙学习资源
> 温馨提示:零基础做蓝牙开发很困难,所以就算使用babybluetooth降低了代码量,仍然任很有必要花上几天时间把蓝牙的基础概念弄明白后才开始动手~
- [ios蓝牙开发(一)蓝牙相关基础知识](http://liuyanwei.jumppo.com/2015/07/17/ios-BLE-1.html)
- [ios蓝牙开发(二)蓝牙中心模式的ios代码实现](http://liuyanwei.jumppo.com/2015/08/14/ios-BLE-2.html)
- [ios蓝牙开发(三)app作为外设被连接的实现](http://liuyanwei.jumppo.com/2015/09/07/ios-BLE-3.html)
- [ios蓝牙开发(四)BabyBluetooth蓝牙库介绍](http://liuyanwei.jumppo.com/2015/09/11/ios-BLE-4.html)
- 暂未完成-ios蓝牙开发(五)BabyBluetooth实现原理
- 待定...
- [官方CoreBuetooth支持页](https://developer.apple.com/bluetooth)
- [Bluetooth Accessory Design Guidelines for Apple Products](https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf)
qq交流群4: 313084771
qq交流群3:530142592(满)
qq交流群2:168756967(满)
qq交流群1:426603940(满)
# 期待
- 蓝牙库写起来很辛苦,不要忘记点击右上角小星星star和[follow](https://github.com/coolnameismy)支持一下~
- 如果在使用过程中遇到BUG,或发现功能不够用,希望你能Issues我,谢谢
- 期待大家也能一起为BabyBluetooth输出代码,这里我只是给BabyBluetooth开了个头,他可以增加和优化的地方还是非常多。也期待和大家在Pull Requests一起学习,交流,成长。
PODS:
- Alamofire (4.9.1)
- BabyBluetooth (0.7.0)
- CryptoSwift (1.3.0)
- Dollar (9.0.0)
- ESTabBarController-swift (2.8.0)
......@@ -47,7 +46,6 @@ PODS:
DEPENDENCIES:
- Alamofire
- BabyBluetooth
- CryptoSwift
- Dollar
- ESTabBarController-swift
......@@ -71,7 +69,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- Alamofire
- BabyBluetooth
- CryptoSwift
- Dollar
- ESTabBarController-swift
......@@ -95,7 +92,6 @@ SPEC REPOS:
SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
BabyBluetooth: d50758aecf24d4a0ab9271d69f0f116d6bee51c9
CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211
Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c
ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136
......@@ -117,6 +113,6 @@ SPEC CHECKSUMS:
ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73
WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb
PODFILE CHECKSUM: 5362542ba7b343b78bf3e0ee7359bad79d3db6ae
PODFILE CHECKSUM: 3835497c93adf93b9ea2d02d860992e134d8f3b0
COCOAPODS: 1.9.1
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "25A41AE5E52F6C0CE6354B9305FD89EE"
BuildableName = "BabyBluetooth.framework"
BlueprintName = "BabyBluetooth"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -7,15 +7,15 @@
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3F83465BA81F6E581B3A431642D2992E"
BuildableName = "ESTabBarController-swift.framework"
BuildableName = "ESTabBarController_swift.framework"
BlueprintName = "ESTabBarController-swift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
......@@ -23,14 +23,15 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......@@ -38,17 +39,14 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
......@@ -7,15 +7,15 @@
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "21FA543DECED4F6DC91853F5E1518EB3"
BuildableName = "Pods-GeliBusinessPlatform.framework"
BuildableName = "Pods_GeliBusinessPlatform.framework"
BlueprintName = "Pods-GeliBusinessPlatform"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
......@@ -23,14 +23,15 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......@@ -38,17 +39,14 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
......@@ -7,15 +7,15 @@
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0B00B2C167CD783351BD1D00BD5AD1F8"
BuildableName = "ReachabilitySwift.framework"
BuildableName = "Reachability.framework"
BlueprintName = "ReachabilitySwift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
......@@ -23,14 +23,15 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......@@ -38,17 +39,14 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
......@@ -8,116 +8,155 @@
<dict>
<key>isShown</key>
<false/>
</dict>
<key>BabyBluetooth.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>CryptoSwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Dollar.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>ESTabBarController-swift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>Hue.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>4</integer>
</dict>
<key>IQKeyboardManagerSwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
</dict>
<key>Kingfisher.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>6</integer>
</dict>
<key>LGButton.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>7</integer>
</dict>
<key>MJRefresh.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>8</integer>
</dict>
<key>ObjectMapper.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>9</integer>
</dict>
<key>Pods-GeliBusinessPlatform.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>10</integer>
</dict>
<key>ReachabilitySwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>11</integer>
</dict>
<key>Realm.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>12</integer>
</dict>
<key>RealmSwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>13</integer>
</dict>
<key>SVProgressHUD.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>16</integer>
</dict>
<key>SkeletonView.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>14</integer>
</dict>
<key>SnapKit.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>15</integer>
</dict>
<key>SwiftDate.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>17</integer>
</dict>
<key>SwifterSwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>18</integer>
</dict>
<key>SwiftyJSON.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>19</integer>
</dict>
<key>ViewAnimator.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>20</integer>
</dict>
<key>WYAutoLayout.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>21</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.7.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
#import <Foundation/Foundation.h>
@interface PodsDummy_BabyBluetooth : NSObject
@end
@implementation PodsDummy_BabyBluetooth
@end
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "BabyBluetooth.h"
#import "BabyCallback.h"
#import "BabyCentralManager.h"
#import "BabyDefine.h"
#import "BabyOptions.h"
#import "BabyPeripheralManager.h"
#import "BabyRhythm.h"
#import "BabySpeaker.h"
#import "BabyToy.h"
FOUNDATION_EXPORT double BabyBluetoothVersionNumber;
FOUNDATION_EXPORT const unsigned char BabyBluetoothVersionString[];
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/BabyBluetooth
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module BabyBluetooth {
umbrella header "BabyBluetooth-umbrella.h"
export *
module * { export * }
}
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/BabyBluetooth
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
......@@ -24,32 +24,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## BabyBluetooth
The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## CryptoSwift
Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin.krzyzanowski@gmail.com>
......
......@@ -41,38 +41,6 @@ THE SOFTWARE.
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>BabyBluetooth</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (C) 2014-2017 Marcin Krzyżanowski &lt;marcin.krzyzanowski@gmail.com&gt;
......
${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh
${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework
${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework
${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework
${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework
${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework
......
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BabyBluetooth.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework
......
${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh
${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework
${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework
${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework
${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework
${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework
......
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BabyBluetooth.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework
......
......@@ -198,7 +198,6 @@ fi
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
install_framework "${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework"
install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework"
......@@ -222,7 +221,6 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
install_framework "${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework"
install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment