Latest 0.0.1
Homepage https://github.com/dwanghello/Bluetooth
License MIT
Platforms ios 8.0
Dependencies Masonry
Frameworks Foundation, UIKit, CoreBluetooth
Authors

DWBluetooth


简化蓝牙使用


CocoaPods

platform :ios, '8.0'
pod 'DWBluetooth'

第一步

导入封装完成文件:DWBlueTooth文件夹,导入CoreBluetooth.framework库

第二步

在需要使用蓝牙的地方引入头文件
#import "DWBlueTooth.h"

第三步

使用DWBlueTooth
进行初始化
shareBluetooth = [DWBlueTooth dw_sharedManager];

设置UUID
 //读服务/写服务/读特征/写特征
NSArray *arrayUUID = @[@"18F0",@"18F0",@"2AF0",@"2AF1"];

开始搜索蓝牙设备
[shareBluetooth dw_startSetUUID:arrayUUID EqualToString:@"只搜索此名称的蓝牙"];

获取蓝牙的基本信息
[shareBluetooth dw_GetStateStr:^(NSString *stateStr) {
      //获取当前蓝牙状态---开启/关闭
      DWLog(@"%@",stateStr);

} newBlueTooths:^(NSMutableDictionary *newBlueTooths) {

    扫描到的蓝牙数组回调
    DWLog(@"%@",newBlueTooths);

    }

}];

连接蓝牙
[shareBluetooth dw_ConnectPeripheral:activePeripheral];//蓝牙设备

连接成功或失败
[shareBluetooth dw_GetconnectOK:^(CBCentralManager *connectOKManager, CBPeripheral *connectOKPeripheral)
{

} error:^(NSError *error) {

    //断开连接

} peripheralDiscover:^(CBPeripheral *peripheralDiscover) {

    //连接成功

} allMessage:^(CBPeripheral *allMessagePeripheral, CBService *allMessageService) {

}];

写入数据
[shareBluetooth dw_WriteTo:activePeripheral Value:[SendData start]];

Latest podspec

{
    "name": "DWBlueTooth",
    "version": "0.0.1",
    "summary": "A role in OC language bluetooth framework.",
    "description": "The library will use the bluetooth has carried on the comprehensive package, let you can be done with the least amount of code to function",
    "homepage": "https://github.com/dwanghello/Bluetooth",
    "license": "MIT",
    "authors": {
        "dwanghello": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/dwanghello/Bluetooth.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "Bluetooth",
        "Bluetooth/Bluetooth/DWBlueTooth/**/*.{h,m}"
    ],
    "frameworks": [
        "Foundation",
        "UIKit",
        "CoreBluetooth"
    ],
    "xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2"
    },
    "dependencies": {
        "Masonry": []
    }
}

Pin It on Pinterest

Share This