简体   繁体   English

蓝牙LE Scan Android

[英]Bluetooth LE Scan Android

So I am making this app right now on android basically what it does, It scans the area for a Bluetooth device with a sequence of letter's that it starts with but the last four letters constantly change, also you cant connect to this device either. 因此,我现在基本上就在android上制作此应用程序,它会在蓝牙设备的区域中扫描以字母开头的序列,但后四个字母会不断变化,您也无法连接到该设备。 So I just do a scan and look for the device and if it finds it, it shows in my list and then I read the last four letters and convert them into a double. 因此,我只是进行扫描并查找设备,如果找到该设备,它将显示在我的列表中,然后阅读最后四个字母并将它们转换为双精度字母。 What I want to do is have Bluetooth start as soon as the app loads up and then keep scanning the hole time so I can get the last four numbers as they go up and they go down. 我想做的是在应用程序加载后立即启动蓝牙,然后继续扫描空闲时间,这样我就可以在它们上升和下降时获得最后四个数字。

How can I do this? 我怎样才能做到这一点?

This can be done if you use advertisement data or scan response data. 如果您使用广告数据或扫描响应数据,则可以完成此操作。 so your application has to run in central as well as in other peripheral devices. 因此,您的应用程序必须在中央以及其他外围设备中运行。 The peripheral devices has to advertise with advertisement data ( with a unique string and variable part). 外围设备必须使用广告数据(具有唯一的字符串和可变部分)进行广告。 the advertisement data can be read by the central. 广告数据可以由中央读取。 Alternatively if you have the possibility to make the advertisement scannable, the advertisement data contains the fixed part (unique number/string) to identify the device and scan response data can be used to get the required number. 或者,如果您有可能使广告可扫描,则广告数据包含固定部分(唯一的数字/字符串)以标识设备,并且扫描响应数据可用于获取所需的编号。 note that the advertisement data and scan response data need to be set by custom application. 注意,广告数据和扫描响应数据需要由自定义应用程序设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM