SDL中文论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 5661|回复: 0
打印 上一主题 下一主题

[Discuss] cybl10161编程

[复制链接]

149

主题

331

帖子

2445

积分

版主

Rank: 7Rank: 7Rank: 7

积分
2445
跳转到指定楼层
楼主
发表于 2016-6-20 17:06:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 ancientcc 于 2016-8-4 16:16 编辑

如何省电
一、必须要让cpu进入睡眠模式
cybl10161内部有一套唤醒流程,它大概是这样的:1)firmware要求cpu进入睡眠,一旦进入睡眠后会停止执行firmware代码。2)在设定的间隔(广播时/连接时,在“GAP Settings”设置)后被自动唤醒,继续执行firmware代码。3)firmware又执行步骤1,如此不断重复。
cypress提供了进入睡眠的标准代码(CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP)、CySysPmDeepSleep()、CySysPmSleep()),见firmware中的LowPowerImplementation函数。

二、CyBle_L2capLeConnectionParamUpdateRequest
为什么要调用这函数,看这贴子:Reducing connection interval from the default 30ms。如果不调用它,那在iOS平台,无法做到在已连接时更省电。以下摘抄该贴主要部分。
  1. I know the default connection interval for CoreBluetooth is 30 ms. I've read couple of articles that claim they can reduce it 30 ms > by changing the min and max of the interval. I didn't see any explanation of how they were changing the parameters of it? I am assuming this is all in the iOS end.
  2. ................
  3. Andswer:
  4. There is no API on iOS for a app as master (using CBCentralManager) to modify the initial Connection Parameters when connecting to a peripheral.

  5. However, the slave can suggest new connection parameters using a L2CAP Connection Parameter Update Request (see Bluetooth 4.0 specification, Volume 3, Part A, Section 4.20), which iOS will accept if they are reasonable (see Bluetooth Accessory Design Guidelines for Apple Products section 3.6 “Connection Parameters”)......
复制代码

要注意iOS能接受的参数(GAP_CONN_UPDATE_PARAM)范围要比标准的小,具体写在Bluetooth Accessory Design Guidelines for Apple Products section 3.6 “Connection Parameters”,以下是截图。


不要在firmware一检测到连接就调用这函数,如果用了较大间隔时间,一旦调用后,在iOS平台,接下的蓝牙请求、应答会变得非常慢。为此要把这函数放在set_utc_time(启动测温的最后一条命令)之后。注:测试下来Android好像不会变慢。

如何设置MAC地址
设置MAC地址包括两件事,一是以着最快速度用同一个firmware烧出不同MAC地址,二是在广播包发出MAC地址。

一、以着最快速度用同一个firmware烧出不同MAC地址
这个还在试验中,以下是想到的方法,是否可行还要等到时验证。
  • 找到cyBle_discoveryParam.directAddr这个变量在hex文件中位置。
  • 设置烧写器参数,烧写完一芯片后,已加载的hex文件directAddr对应位置的值自动增1。


二、在广播包发出MAC地址
BLE没有规定要在广播包发MAC地址,发出纯粹就是为了解决iOS不能得到MAC地址问题。

由于广播包中存储MAC地址的变量和系统存放MAC地址的变量不是同一个,这意味着,一旦须要改MAC地址,那么这两个变量都要改!这就会导致出两变量不同步问题。那要如何解决?既然没法改系统存放MAC地址的变量,那想到的就是让firmware能自动改掉广播包中存储MAC地址的变量。以下是采用的方法,具体参考update_advertisement_mac_addr()。
  1. firmware一启动就根据cyBle_discoveryParam.directAddr改掉cyBle_discoveryData.advData。
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|丽谷软件|libsdl.cn

GMT+8, 2025-5-2 03:48 , Processed in 0.051177 second(s), 22 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表