如何在 Android 4.X 中使用 Broadcom BLE SDK (SMART 4.0)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11311947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:53:17  来源:igfitidea点击:

How to use Broadcom BLE SDK (SMART 4.0) in Android 4.X

androidbluetoothbluetooth-lowenergy

提问by sdespont

I am trying to develop a BLE bluetooth (SMART) application for Android.

我正在尝试为 Android 开发一个 BLE 蓝牙(SMART)应用程序。

I managed to download the Broadcom BLE SDK, install through the Android SDK Manager as explained on the web site and download the projects examples.

我设法下载了Broadcom BLE SDK,按照网站上的说明通过 Android SDK Manager 安装并下载了项目示例

When I tried to push one of the examples into my tests phones (HTC One S, HTC One X both with Bluetooth BLE feature), I am facing the following issue:

当我尝试将其中一个示例推送到我的测试手机(HTC One S、HTC One X 均具有蓝牙 BLE 功能)时,我面临以下问题:

INSTALL_FAILED_MISSING_SHARED_LIBRARY

Is there any possibility to include the broadcom library described in the AndroidManifest.xml file ? <uses-library android:name="com.broadcom.bt.le" android:required="true"/>

是否有可能包含 AndroidManifest.xml 文件中描述的 Broadcom 库? <uses-library android:name="com.broadcom.bt.le" android:required="true"/>

Is someone managed to test the broadcom projects examples? And on which phone?

有人设法测试了 Broadcom 项目示例吗?在哪个手机上?

According to this post, a bug has been discovered on Samsung Galaxy S3, but I didn't find any information about HTC products.

根据这篇文章,在三星 Galaxy S3 上发现了一个错误,但我没有找到有关 HTC 产品的任何信息。



UPDATE : What a great news!!!

更新:真是个好消息!!!

Last Android version 4.3 (Jelly Bean) now support low-energy Bluetooth Smart accessories.

最新的 Android 版本 4.3 (Jelly Bean) 现在支持低功耗蓝牙智能配件。

http://www.android.com/about/jelly-bean/

http://www.android.com/about/jelly-bean/

https://developer.bluetooth.org/Pages/Bluetooth-Android-Developers.aspx

https://developer.bluetooth.org/Pages/Bluetooth-Android-Developers.aspx

Not sure that every phones will have an update (even the last HTC One M7 for example) but next phones will certainly embed this major release.

不确定每部手机都会有更新(即使是最后一款 HTC One M7),但下一部手机肯定会嵌入这个主要版本。

回答by idarwin

The problem is that if your phone doesn't have the .so file installed, this isn't going to help.

问题是,如果您的手机没有安装 .so 文件,这将无济于事。

And your device will only (as of this writing) have the .so file if Broadcom has blessed the device.

如果 Broadcom 已祝福设备,则您的设备将仅(在撰写本文时)具有 .so 文件。

For example, the latest official build (4.0.4) for the reasonably-new Samsung Galaxy Nexus does not.

例如,相当新的三星 Galaxy Nexus 的最新官方版本 (4.0.4) 没有。

For those that don't know, there are two different (incompatible) APIs for LOW-ENERGY Bluetooth (BtLE, now apparently called BT Smart). One is from Broadcom, and the other is from Motorola. Unsurprisingly, each only works on a phone that has that vendor's chips in it.

对于那些不知道的人,低能耗蓝牙(BtLE,现在显然称为 BT Smart)有两种不同(不兼容)的 API。一个来自博通,另一个来自摩托罗拉。不出所料,每个都只适用于装有该供应商芯片的手机。

This is a terrible, terrible situation, and Google REALLY needs to get moving on a solution or Android will become totally irrelevant in a little industry known as HEALTHCARE!!!!!

这是一个可怕的、可怕的情况,谷歌真的需要采取解决方案,否则 Android 将在一个被称为医疗保健的小行业中变得完全无关紧要!!!!!!

回答by Lance Nanek

The HTC One X and One S use a Qualcomm Bluetooth chip, not Broadcom. Therefore the Broadcom SDK would not be expected to work. There is an HTC BLE SDK that works with the HTC One X+, Droid DNA, and HTC One that you can sign up for the HTC BLE SDK here:
http://www.htcdev.com/devcenter/opensense-sdk/partner-apis/bluetooth-low-energy/

HTC One X 和 One S 使用高通蓝牙芯片,而不是博通。因此,预计 Broadcom SDK 将无法工作。有一个适用于 HTC One X+、Droid DNA 和 HTC One 的 HTC BLE SDK,您可以在此处注册 HTC BLE SDK:http:
//www.htcdev.com/devcenter/opensense-sdk/partner- apis/蓝牙低能耗/

回答by user2100730

Confirming BroadCom BLE stack works on HTC 1X+and cooperates with standard TI KeyFob Demo.

确认 BroadCom BLE 堆栈适用于HTC 1X+并与标准TI KeyFob Demo配合使用。

Seems like I'm making a dumb post, but I thought someone might be encouraged to keep going by an unequivocal statement of at least a tiny success.

似乎我在发一个愚蠢的帖子,但我认为有人可能会因为至少取得微小成功的明确声明而被鼓励继续前进。

BleFindMeClientreally does work on the HTC 1X+in conjunction with the TI CC2540-mini Keyfob aka KeyFobDemoin the TI distro.

BleFindMeClient与 TI 发行版中的 TI CC2540-mini Keyfob aka KeyFobDemo一起在HTC 1X+上确实可以工作。

I've never written an Andoid app., or code for the TI keyfob, so it took me a frustratingly long while to figure out how all the tools worked and how to configure them, but there was no real magic. For me, some of the other Android demos don't compile out the gate without some code tweaks, but that could just be my inexperience.

我从来没有写过 Andoid 应用程序,或者 TI 钥匙扣的代码,所以我花了很长时间才弄清楚所有工具是如何工作的以及如何配置它们,但没有真正的魔法。对我来说,其他一些 Android 演示在没有一些代码调整的情况下无法编译,但这可能只是我的经验不足。

http://youtu.be/cqWpjU7gJ2Q

http://youtu.be/cqWpjU7gJ2Q

On the other issue regarding getDeviceType(), here is a code fragment that works perfectly every time on the HTC 1x+. Hope this helps too.

关于getDeviceType()的另一个问题,这里有一段代码片段,每次在 HTC 1x+ 上都能完美运行。希望这也有帮助。

BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if ( BleAdapter.getDeviceType(device) == BleAdapter.DEVICE_TYPE_BLE ) {
    ...
}

回答by sdespont

Someone find the solution here.

有人在这里找到解决方案。

The three steps to do are :

要做的三个步骤是:

  1. Do not include in manifest file.

  2. In project PropertiesJava Build PathLibrariesAdd external jar, add broadcom ble jar.

  3. In project PropertiesJava Build PathOrder and Export, check the included jar in step 2.
  1. 不要包含在清单文件中。

  2. 在项目PropertiesJava Build PathLibraries→ 中Add external jar,添加 Broadcom ble jar。

  3. 在项目PropertiesJava Build Path→ 中Order and Export,检查步骤 2 中包含的 jar。

Finally, the Broadcom samples projects run, but crash after few seconds due to an unknown virtual method not implemented on HTC (.getDeviceType(), ...)!

最后,Broadcom 示例项目运行,但由于未在 HTC 上实现的未知虚拟方法(.getDeviceType(),...),几秒钟后崩溃!

回答by AAnkit

If any body writing a app depending on this SDK, there is one line I want to tell

如果有任何机构根据此 SDK 编写应用程序,我想告诉您一行

in DeviceDiscovery they call a method getDeviceType which is not defined anywhere in the entire Android JB codebase hence it crashes there only. so if are trying hard to remove the crash, just keep in mind you can not do it if it is crashing in device Discovery event.

在 DeviceDiscovery 中,他们调用了一个方法 getDeviceType,该方法未在整个 Android JB 代码库中的任何地方定义,因此它只会在那里崩溃。因此,如果正在努力消除崩溃,请记住,如果它在设备发现事件中崩溃,则无法执行此操作。

回答by Franck

It seems that something might be missing on the HTC phones as well. This error means that there is probably a layer of software missing (or malfunctioning) between the BLE hardware and the API. As for today I have only seen BLE kind of working on an the Motorola Razr but it seems to be limited to the heart rate profile (and it does not use the Broadcom API).

HTC 手机上似乎也缺少某些东西。此错误意味着 BLE 硬件和 API 之间可能存在一层软件缺失(或出现故障)。至于今天,我只看到 BLE 在摩托罗拉 Razr 上工作,但它似乎仅限于心率配置文件(并且它不使用 Broadcom API)。

回答by dljava

Just to clarify, only starting with these currently available HTC devices will you find BLE support: the HTC One X+, the HTC Droid DNA, and of course the HTC One and upcoming flagship devices. Note that as of 4.3, you should migrate to use the standard official Android BLE API, to support devices pre-4.3 you can use the HTC BLE API. See https://www.htcdev.com/devcenter/opensense-sdk/bluetooth-smartfor more info and sample code supporting both APIs.

澄清一下,只有从这些当前可用的 HTC 设备开始,您才能找到 BLE 支持:HTC One X+、HTC Droid DNA,当然还有 HTC One 和即将推出的旗舰设备。请注意,从 4.3 开始,您应该迁移到使用标准的官方 Android BLE API,为了支持 4.3 之前的设备,您可以使用 HTC BLE API。有关支持这两种 API 的更多信息和示例代码,请参阅https://www.htcdev.com/devcenter/opensense-sdk/bluetooth-smart

回答by sdespont

What a great news!!!

真是个好消息!!!

Last Android version 4.3 (Jelly Bean) now support low-energy Bluetooth Smart accessories.

最新的 Android 版本 4.3 (Jelly Bean) 现在支持低功耗蓝牙智能配件。

http://www.android.com/about/jelly-bean/

http://www.android.com/about/jelly-bean/

https://developer.bluetooth.org/Pages/Bluetooth-Android-Developers.aspx

https://developer.bluetooth.org/Pages/Bluetooth-Android-Developers.aspx

Not sure that every phones will have an update (even the last HTC One M7 for example) but next phones will certainly embed this major release.

不确定每部手机都会有更新(即使是最后一款 HTC One M7),但下一部手机肯定会嵌入这个主要版本。