KRBle 1.2.1

KRBle 1.2.1

测试测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2015 年 8 月

Kalvar Lin 维护。



KRBle 1.2.1

屏幕截图

ScanHome   Central   Peripheral

Podfile

platform :ios, '7.0'
pod "KRBle", "~> 1.2.1"

如何开始

KRBle 实现了低能耗蓝牙 (BLE) 并模拟 SPP 大数据 (例如:图像 / 2,000 字),中心和外围设备可以相互交换大数据,总结来说,您可以轻松使用此项目构建您的 BLE 应用程序。

#import "BLECentral.h"

- (void)viewDidLoad
{
    [super viewDidLoad];

    __weak typeof(self) _weakSelf = self;

    _bleCentral = [BLECentral sharedInstance];

    //Scanning interval gap holder.
    [_bleCentral setScanIntervalHandler:^CGFloat
    {
        /*
         * @ 設定每 x 秒為 Scanning 的區間範圍
         *   - 每 x 秒進一次 centralManager:didDisconnectPeripheral:error: 的 Delegate
         *   - 每 x 秒才進 foundPeripheralHandler
         *   - <= 0.0f 秒為不限制 ( Default )
         */
        return 0.0f;
    }];

    //Find out peripheral will enter this block
    [_bleCentral setFoundPeripheralHandler:^(CBCentralManager *centralManager, CBPeripheral *peripheral, NSDictionary *advertisementData, NSInteger rssi)
    {
        if( ![_weakSelf.peripherals containsObject:peripheral] )
        {
            [_weakSelf.peripherals addObject:peripheral];
            dispatch_async(dispatch_get_main_queue(), ^{
                [_weakSelf.tableView reloadData];
            });
        }
    }];
}

-(void)scanMethods
{
    /*
     * @ Scan Methods
     */
    //Unlimit scanning, iPhone will be scanning 8 times per 1 sec.
    [_bleCentral startScan];

    //Limits scanning interval, may it can save some power waste.
    [_bleCentral startScanInterval:5.0f continueInterval:10.0f];

    //Scanning before timeout
    [_bleCentral startScanTimeout:2.0f];

    //Scan for limit-services.
    [_bleCentral startScanForServices:@[[CBUUID UUIDWithString:@"FFA0"]]];
}

-(void)stopScan
{
    [_bleCentral stopScan];
}

// More information please see the source code, by the way, I'm living in Taiwan, 
// so the source code remarks almost Chinese language.
// If you have any questions or never know the remarks talking about, 
// just ask me or create an issue to exchange the conversation, I'll so glad to give you a hand.

版本

V1.2.1

许可证

MIT.

备注

分享是世界上最重要的是的。