Bluetooth 4.0 mio alpha watch 心率监护应用 2
16lz
2021-01-26
刚鼓捣好第一个版本,比在android上开发ble简单多了,android主要是底层ble芯片不统一,ti的nordic的,所以没有官方的sdk,分别找htc或者三星的ae,他们会发给你sdk,但是大部分产品又没有ble,太乱了。
apple就标准了,
第一步 scan: startscanforUUID (heartrate 是0x180D),第一篇文章中提到ble的信息一直是广播的,和之前版本不一致,所以ios自己的系统里没有心率计也没关系;
第二步 connect: connect Peripherial;
第三步 找service: discoverService;
第四步 找characterist;
第五步 注册更新:
- [peripheralreadValueForCharacteristic:aChar];
- [peripheralsetNotifyValue:YESforCharacteristic:aChar];
- NSLog(@"FoundaHeartRateMeasurementCharacteristic");
该程序基于apple的core bluetooth framework (https://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/_index.html),参考了他的temperature 和 mac heart rate 的sample code,添加了disconnect和重新发现的功能,值得注意的地方是:
- service=[[[LeHeartRateNotificationServicealloc]initWithPeripheral:peripheralcontroller:peripheralDelegate]autorelease];
- // 该代码在disconnect,再重新连接的时候有问题,需要手动释放service,并在clearDevices时候release
- service=[[LeHeartRateNotificationServicealloc]initWithPeripheral:peripheralcontroller:peripheralDelegate];
代码还在更新中,如有需要,请联系我。
后续会发布到apple store, 大家可以测试下。
更多相关文章
- repo详解与如何更改manifest快速获取和复用AOSP代码
- Android高手进阶教程(二十六)之---Android超仿Path菜单的实现!
- android intent的跳转,页面传值
- Cocos2dx 3.x在Android下多线程加载问题(thread exiting, not ye
- 解决Android(安卓)Studio 新建导入项目时死掉
- 菜鸟的安卓实习之路----关于EditText的最大长度maxLength和密码
- Visual Studio 跨平台开发实战--- Hello Xamarin! [Visual Studi
- Android(安卓)优秀源码收集方式
- Android(安卓)MVP模式 入门