Latest 0.2.1
Homepage https://github.com/zhuozhuo/ZHBLE
License MIT
Platforms ios 7.0
Frameworks CoreBluetooth
Authors

ZHBLE

ZHBLE using Block callback methods, aimed at making the system CoreBluetooth library function is called simple.

Screenshot0    Screenshot1   

Chinese README LINK

Features

  • Based on the original CoreBluetooth, the callback function all packaged into Block mode, calls the associated function simplicity.。
  • Central and Peripheral side has packages。
  • Using the factory pattern and Block integration makes it easier for initialization and function calls.

Design Goals

simple and convenient to use Bluetooth。

Requirements

  • iOS 7.0+
  • ARC
  • CoreBluetooth.framework

Introduce

Class name Function and usage
ZHBLECentral Equipment as the relevant attributes and operations on the Central side, for example: initialize Central, scanned, connect, retrieve equipment.
ZHBLEPeripheral Peripheral-side operations such as: discovery service and features, listening, reading and writing, and so on.
ZHBLEPeripheralManager Device as a Peripheral-side operations such as initialization of CBPeripheralManager, radio, adding services and send data.
ZHBLEStoredPeripherals Equipment local cache operations
ZHBLEManager Fast access to recently connected devices
ZHBLEBlocks All Block definitio

Usage

CocoaPods (recommended)

pod 'ZHBLE'

Copy the folder ZHBLE to your project

Central

#import "ZHBLE.h"

self.central = [ZHBLECentral sharedZHBLECentral];

//Scan

[self.central scanPeripheralWithServices:uuids options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @(YES)} onUpdated:^(ZHBLEPeripheral *peripheral,NSDictionary *data){
   if (peripheral) {
       //Do Something
}}];

//Connection

[self.central connectPeripheral:peripheral options:nil onFinished:^(ZHBLEPeripheral *peripheral, NSError *error){
}];

Peripheral

#import "ZHBLE.h"

self.peripheralManager = [ZHBLEPeripheralManager sharedZHBLEPeripheralManager];

//Advertise
CBUUID *temUUID = [CBUUID UUIDWithString:@"902DD287-69BE-4ADD-AACF-AA3C24D83B66"];
NSArray *temUUIDArray = [NSArray arrayWithObjects:temUUID, nil];
NSDictionary *temServiceDic = @{CBAdvertisementDataServiceUUIDsKey:temUUIDArray};
[self.peripheralManager startAdvertising:temServiceDic onStarted:^(NSError *error){
}];

//Add Service
[self.peripheralManager addService:_transferService onFinish:^(CBService *service,NSError *error){
}];

License

This code is distributed under the terms and conditions of the MIT license.

Latest podspec

{
    "name": "ZHBLE",
    "version": "0.2.1",
    "summary": "ZHBLE Block way, aim to make call BlueTooth more simple.",
    "description": "* u65e8u5728u5febu6377u65b9u4fbfu7684u4f7fu7528u7cfbu7edfCoreBluetoothu5e93.n* u57fau4e8eu539fu751fCoreBluetooth,u56deu8c03u51fdu6570u5168u90e8u5c01u88c5u6210Blocku56deu8c03u65b9u5f0fuff0cu4f7fu8c03u7528u76f8u5173u51fdu6570u7b80u6d01u660eu4e86>u3002n* u8bbeu5907u4f5cu4e3aCentralu7aefu548cPeripheralu7aefu90fdu6709u5c01u88c5u3002n* u91c7u7528u5de5u5382u6a21u5f0fu548cBlocku65b9u6cd5u7ed3u5408u4f7fu5f97u521du59cbu5316u548cu51fdu6570u8c03u7528u66f4u5bb9u6613.",
    "homepage": "https://github.com/zhuozhuo/ZHBLE",
    "screenshots": [
        "http://ac-unmt7l5d.clouddn.com/a5ad110235345af7.png",
        "http://ac-unmt7l5d.clouddn.com/2eba95e19897014b.png"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mr.jiang": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/zhuozhuo/ZHBLE.git",
        "tag": "0.2.1"
    },
    "source_files": [
        "Classes",
        "Demo/ZHBLE/Classes/ZHBLE/*.{h,m}"
    ],
    "public_header_files": "Demo/ZHBLE/Classes/ZHBLE/*.h",
    "frameworks": "CoreBluetooth"
}

Pin It on Pinterest

Share This