如何正确使用UUID.fromString方法? [英] How to correctly use UUID.fromString method?

查看:1198
本文介绍了如何正确使用UUID.fromString方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取/写入以下ble特性:

I am trying to read/write these ble characteristics:

现在,我正在尝试阅读 AA01 *

Right now, I'm trying to read AA01*

我正在使用要使用此库

这是我的代码:

private void connectToSensorTag(RxBleDevice rxBleDevice) {
    rxBleDevice.establishConnection(getApplicationContext(), false)
            .doOnError(new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    int i = 0;
                }
            })
            .flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(UUID.fromString("AA01*")))
            .subscribe(new Subscriber<byte[]>() {
                @Override
                public void onCompleted() {
                    int i = 0;
                }

                @Override
                public void onError(Throwable e) {
                    int i = 0;
                }

                @Override
                public void onNext(byte[] bytes) {
                    int i = 0;
                }
            });

我收到此错误:


java.lang.IllegalArgumentException:无效的UUID:AA01 *

java.lang.IllegalArgumentException: Invalid UUID: AA01*

我还尝试了这个类似的问题,但没有任何效果。相同的错误。

I also tried the solutions from this similar question but nothing works. Same error.

推荐答案

在BLE规范中,有两种UUID。

In the BLE specification there are two kinds of UUIDs.


  • 完全合格的128位长,通常分配给BLE设备的特定供应商以实现非标准功能:
    UUID.fromString ( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx);

还完全限定(但由标准定义)的UUID具有相同的前缀和后缀: UUID.fromString( F000xxxx-0451-4000-B000-000000000000);
其中 xxxx 是填写您从SensorTag规范获得的四个字符的地方。为了方便起见,通常使用四个字符的标识符来引用标准UUID。

Also fully qualified (but defined by standard) UUIDs which have the same prefix and postfix: UUID.fromString("F000xxxx-0451-4000-B000-000000000000"); where xxxx is the place to fill the four characters you get from the SensorTag specification. For convenience the standard UUIDs are usually referenced with the four characters identifier.

另外,如果您要处理SensorTag,设备,您可以检出今年在MCE ^ 3会议上显示的图书馆演示应用程序:

Additionally if you're dealing with a SensorTag device you can checkout the library demo application that was shown on MCE^3 conference this year:

演讲: https://www.youtube.com/watch?v=0aKfUGCxUDM

演示应用程序存储库: https://github.com/dariuszseweryn/2016_MCE_Demo_RxAndroidBLE

The demo application repository: https://github.com/dariuszseweryn/2016_MCE_Demo_RxAndroidBLE

我希望能对您有所帮助。

I hope that will help you.

最好的问候。

这篇关于如何正确使用UUID.fromString方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆