通过SPP配置文件的GATT可以进行蓝牙通信吗? [英] GATT over SPP profile for bluetooth communication?

查看:400
本文介绍了通过SPP配置文件的GATT可以进行蓝牙通信吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我困惑了好几天.

在开始实现该功能时,我使用了 GATT配置文件 用于BLE蓝牙通信.

In the beginning when I was implementing the functionality, I used GATT profile for BLE bluetooth communication.

然后我想到了 BluetoothSocket .这将使用SPP配置文件进行蓝牙通信.

Then I came up with BluetoothSocket. This uses the SPP profile for bluetooth communication.

有提到:

最常见的蓝牙插座类型是RFCOMM,即RFCOMM Android API支持. RFCOMM是面向连接的, 通过蓝牙进行流传输.它也被称为串行 端口配置文件(SPP).

The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).

我的要求是-

1)扫描并使用BLE蓝牙将我的android设备与黑匣子连接.

1) To scan and then connect my android device with the Black Box using BLE bluetooth.

2)然后开始通讯.字节将在两者之间发送.

2) Then initiate communication. The bytes will be sent between both.

有什么想法吗?

推荐答案

在您提到的用例中,BLE可能是最好的选择.这是蓝牙4.0功能,而SPP是2.1功能.我将尝试列出使用BLE和与SPP进行比较的优缺点.

In the use case that you have mentioned BLE is probably your best bet. This is a Bluetooth 4.0 feature, while SPP is a 2.1 feature. I will try and list out the pros and cons to using BLE with a comparison with SPP.

    BLE是低能耗.与SPP相比,它将需要更少的能量.
  • BLE更快地建立了SPP的连接,因此您的响应将更快.
  • 仅当您要传输少量数据时,BLE才是好的,一旦开始传输大量数据,您会发现SPP是更好的选择.
  • BLE is low energy. It is going to require less energy compared to SPP.
  • BLE is much faster to establish the connection the SPP, so your responses will be much faster.
  • BLE is good only if you want to transfer small amounts of data, once you start transferring large amounts of data, you will find that SPP is a much better candidate.

话虽这么说,您的处理方式如下: 您将使用BluetoothAdapter获取对BluetoothDevice的引用,然后将其用于通过connectGatt获取BluetoothGatt.如果要使用BLE,则不会使用BluetoothSocket.使用此BluetoothGatt对象,您可以连接到设备并读取/写入特征.

With this being said, the way you would go about it is in the following way: You will use the BluetoothAdapter to get a reference to a BluetoothDevice, which you will then use to get BluetoothGatt using connectGatt. You will not use BluetoothSocket if you want to use BLE. Using this BluetoothGatt object you can connect to the device and read/write characteristics.

这篇关于通过SPP配置文件的GATT可以进行蓝牙通信吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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