Latest 0.0.3
Homepage https://github.com/developerXiong/CYBleManager
License MIT
Platforms ios 8.0
Dependencies iOSDFULibrary
Authors

CYBleManager 中文

About bluetooth library, contains connection, data transceiver, OTA.

Version
Carthage compatible

Installation

For Cocoapods:

  • Create/Update your Podfile with the following contents

    target 'YourProjectName' do
        use_frameworks!
        pod 'CYBleManager'
    end
  • Install dependencies

    pod install
    pod update
  • Import the library to any of your classes by using @import CYBleManager and begin working on your project

For Carthage:

  • Update your Cartfile with the following contents

    github "developerXiong/CYBleManagerLibrary",
    github "NordicSemiconductor/IOS-Pods-DFU-Library"
  • run the command:

    carthage update
  • Carthage will build the CYBleManagerLibrary, iOSDFULibrary.framework and Zip.framework files in Carthag/Build/, you may now copy all those files to your project and use the library

Usage

  • scanning ble

    [[CYBleManager manager] startScan:10 services:nil isFilter:YES result:^(NSArray<CBPeripheral *> *peripherals) {
        // your code
    
    }];
  • connect ble

    [[CYBleManager manager] connectBle:peripheral timeout:10];
  • disconnect ble

    [[CYBleManager manager] disconnectBle:peripheral];
  • moniter ble connect state

    [CYBleManager manager] moniterBleConnectState:^(CYBleManagerConnectState state) {
        // your code
    
    }];
  • receive data

    [[CYBleManager manager] writeStringValue:value toCharacter:character back:^(NSData *data) {
        // your code
    
    }];
    [[CYBleManager manager] readValueForCharacteristic:character back:^(NSData *data) {
        // your code
    }];
  • OTA

    [[CYBleManager manager] startScan:10 services:@[[CBUUID UUIDWithString:@"FE59"]] isFilter:NO result:^(NSArray<CBPeripheral *> *peripherals) {
        CBPeripheral *peripheral = peripherals[0];
        [[CYBleManager manager] firmwareUpdateWithDFUPeripheral:peripheral filePath:filePath response:^(NSString *message, CYDFUState state) {
            // your code
    
        } progress:^(NSInteger part, NSInteger totalPart, NSInteger progress) {
            // your code
    
        }];
    }]

Latest podspec

{
    "name": "CYBleManager",
    "version": "0.0.3",
    "summary": "About Bluetooth framework.",
    "description": "Using Block to write a Bluetooth connection, data transceiver, OTA and other functions of the framework.",
    "homepage": "https://github.com/developerXiong/CYBleManager",
    "license": "MIT",
    "authors": {
        "xiongcy": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/developerXiong/CYBleManager.git"
    },
    "source_files": "CYBleManager/*.{h,m}",
    "dependencies": {
        "iOSDFULibrary": []
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This