zhb

ZHBLE

iOS Bluetooth capsulation

Showing:

Popularity

Downloads/wk

0

GitHub Stars

55

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

0

License

MIT

Categories

Readme

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 nameFunction and usage
ZHBLECentralEquipment as the relevant attributes and operations on the Central side, for example: initialize Central, scanned, connect, retrieve equipment.
ZHBLEPeripheralPeripheral-side operations such as: discovery service and features, listening, reading and writing, and so on.
ZHBLEPeripheralManagerDevice as a Peripheral-side operations such as initialization of CBPeripheralManager, radio, adding services and send data.
ZHBLEStoredPeripheralsEquipment local cache operations
ZHBLEManagerFast access to recently connected devices
ZHBLEBlocksAll Block definitio

Usage

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100