Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于项目的实现 #1

Open
Da-lez opened this issue Sep 1, 2021 · 1 comment
Open

关于项目的实现 #1

Da-lez opened this issue Sep 1, 2021 · 1 comment

Comments

@Da-lez
Copy link

Da-lez commented Sep 1, 2021

项目中是如何确定监听的服务和特征订阅类型的?

@Da-lez Da-lez changed the title 关于项目封装的问题 关于项目的实现 Sep 1, 2021
@arsize
Copy link
Owner

arsize commented Sep 2, 2021

项目中是如何确定监听的服务和特征订阅类型的?

_getCharacteristics这个函数获取特征值,_notifyBLECharacteristicValueChange进行订阅,如果你想问的是如何确定serviceId,那么有两种方式,
1.如我项目这样,serviceId是硬件设备提供的唯一编码,可以提前写进代码里面;
2.如果serviceId不确定,你可以用deviceId在_onBluetoothFound_promise函数中嗅探设备时,遍历设备服务数组,里面会有一个服务拥有主key(isPrimary:true),相应的serviceId就是你所需要的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants