Giter Site home page Giter Site logo

miband-api's Introduction

MiBand-API

小米手环 iOS API. 当前 API 基于固件版本 v1.0.6.3 (手机手环 iOS 客户端 v1.0.16)。

使用

工程中添加CoreBluetooth.framework,引入MiBand文件夹,#import "MiBand.h"

self.centralManager = [MBCentralManager sharedCentralManager];
__weak typeof(self) this = self;
[self.centralManager scanForMiBandWithBlock:^(MBPeripheral *miband, NSNumber *RSSI, NSError *error) {
    [this.centralManager stopScan];
    [this.centralManager connectPeripheral:miband withResultBlock:^(MBPeripheral *peripheral, NSError *error) {
        MBUserInfoModel *me = ...
        [peripheral bindingWithUser:me withBlock:^(NSError *error) {
            //连接成功
        }];
    }];
}];

步数

// 获取当前总步数
__weak typeof(self) this = self;
[self.peripheral readRealtimeStepsWithBlock:^(NSUInteger steps, NSError *error) {
    this.realtimeStepsLabel.text = [NSString stringWithFormat:@"%tu", steps];
}];

// 实时更新步数
[self.peripheral subscribeRealtimeStepsWithBlock:^(NSUInteger steps, NSError *error) {
    this.realtimeStepsLabel.text = [NSString stringWithFormat:@"%tu", steps];
}];

睡眠

// Todo

设置

//查找手环
[self.peripheral sendNotificationWithType:MBNotificationTypeNormal withBlock:^(NSError *error) {
}];

//目标设定
[self.peripheral setGoalSteps:8000 withBlock:^(NSError *error) {
}];

//指示灯颜色
[self.peripheral setColorWithRed:6 green:0 blue:0 blink:YES withBlock:^(NSError *error) {
}];

//佩戴方式
[self.peripheral setWearPosition:MBWearPositionLeft withBlock:^(NSError *error) {
}];

//来电提醒
[self.peripheral setCallRemindInterval:10 withBlock:^(NSError *error) {
}];

感谢

虽然通过 hook CBCentralManagerCBPeripheral 基本上获取了所有的蓝牙指令,但是部分指令的意义及解析还是不太清楚,感谢stormlukeMili-iOS 让我对各指令的意义有了参考,同时大部分的实现都直接拿来或参考了Mili-iOS。

希望喜欢折腾的小伙伴们一起贡献代码,Thanks。 本人已入 Apple Watch, 小米手环已出,后面应该不会再维护该项目。如有兴趣,自行 Fork 代码。

miband-api's People

Contributors

tracy-e avatar stormluke avatar

Watchers

Qinwen Shi avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.