Android 10中的蓝牙串行功能是否发生了变化? [英] Did something change with Bluetooth Serial in Android 10?

查看:65
本文介绍了Android 10中的蓝牙串行功能是否发生了变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android 10上的Google Pixel 3a XL,它无法使用蓝牙2.0与蓝牙SPP模块建立良好的蓝牙串行连接.但是,我可以使用蓝牙1.2连接到模块.我无法确定这是否与所有Android 10或Pixel 3系列产品有关.

I have a Google Pixel 3a XL on Android 10 that is unable to make a good Bluetooth serial connection to a Bluetooth SPP module using Bluetooth 2.0. However, I can connect to a module with Bluetooth 1.2. I haven't been able to determine if this is related to all of Android 10, or something specific to the Pixel 3 line.

我正在尝试通过蓝牙从GPS接收器获取GPS位置数据.当我尝试使用 createInsecureRfcommSocketToServiceRecord()建立连接时,串行连接实际上会出现1-5秒.我确实从GPS接收器中获取了一些数据,但是缺少很多数据块.然后,数据停止流动.除了我的应用程序外,我还用其他几个蓝牙串行终端程序进行了测试,它们都具有相同的结果-我得到了一些数据,然后停止了.

I'm trying to get GPS position data from a GPS receiver via Bluetooth. When I try to bring up a connection using createInsecureRfcommSocketToServiceRecord(), the serial connection actually comes up for 1-5 seconds. I do get some data from the GPS receiver, however there are chunks missing. Then the data stops flowing. In addition to my app, I have tested this with several other Bluetooth serial terminal programs, and they all have the same results - I get some data, then it stops.

我可以将同一蓝牙模块与运行Android 9的其他Android设备一起使用,并且效果很好.我也可以从Windows连接到该蓝牙模块,它也可以正常工作.

I can use this same Bluetooth module with a different Android device running Android 9 and it works great. I can also connect to this Bluetooth module from Windows and it too works fine.

我还有一个较旧的蓝牙模块(运行Bluetooth v1.2),令人惊讶的是它实际上可以与Pixel一起正常工作.

I have a second Bluetooth module that is older (runs Bluetooth v1.2) and surprisingly it actually works fine with the Pixel.

是否有人在Android 10上看到过蓝牙串口问题?

Has anyone else seen issues with Serial over Bluetooth on Android 10?

推荐答案

Android 10发生的变化是,除了权限之外,您还需要启用位置才能连接到某些BLE设备.我不确定这是否对您有帮助,但是可以让您了解当前遇到的问题.

Something that changed with Android 10 is that you need to have your location enabled besides the permission in order to connect to some BLE devices. I'm not sure if this will help you, but can give you some light regarding the issue you're having.

某些电话,蓝牙,Wi-Fi API需要FINE位置许可如果您的应用定位到Android 10或更高版本,则它必须具有ACCESS_FINE_LOCATION权限,才能在Wi-Fi,Wi-Fi Aware或Bluetooth API中使用多种方法.以下各节列出了受影响的类和方法."

"Some telephony, Bluetooth, Wi-Fi APIs require FINE location permission If your app targets Android 10 or higher, it must have the ACCESS_FINE_LOCATION permission in order to use several methods within the Wi-Fi, Wi-Fi Aware, or Bluetooth APIs. The following sections list the affected classes and methods."

https://developer.android.com/about/versions/10/privacy/changes

这篇关于Android 10中的蓝牙串行功能是否发生了变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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