我对BLE稍微熟悉,我在使用继承的代码时遇到了一些问题.所以应用程序的工作原理如下:
我面临的问题是,配对几次(它变化)后,手机无法发现设备,因此阻止用户配对.
我正在使用GattServer连接客户端设备,我正在重置服务,如下所示:
public void resetBluetoothGattServer() {
Log.i(TAG," resetBluetoothGattServer: bluetoothGattServer: "+ bluetoothGattServer);
if (bluetoothGattServer != null) {
if(!bluetoothGattServer.getServices().isEmpty()){
Log.i(TAG," resetBluetoothGattServer: clearing services on bluetooth Gatt Server");
bluetoothGattServer.clearServices();
}
Log.i(TAG," resetBluetoothGattServer: closing bluetoothGattServer");
bluetoothGattServer.close();
}
bluetoothGattServer = openGattServer();
}
Run Code Online (Sandbox Code Playgroud)
重新启动手机,关闭蓝牙,然后重新打开,卸载和安装应用程序将无法解决问题.唯一的解决方案是从Android应用程序管理器上的蓝牙共享应用程序中清除缓存.
这篇文章如何在不使用缓存的情况下以编程方式强制在Android上强制蓝牙低能耗服务发现地址来解决类似的问题,但由于我们没有使用BluetoothGatt来连接它,因此没有合适的解决方案.也不会重构整个继承的代码.
我问你是否有办法使用BluetoothGattServer以编程方式清除缓存.
android bluetooth clear-cache bluetooth-lowenergy bluetooth-peripheral
我正在编写一个通过BLE连接到物理设备的Android应用程序.Android应用程序将充当外围角色,而设备是中心.设备I/O功能也设置为NoInputNoOutput(ble_cmd_sm_set_parameters(0, 8, sm_io_capability_noinputnooutput))
建立连接的流程是:
bluetoothManager.openGattServer()Sent Pairing Request: AuthReq与Secure Connection Flag = 1后者Secure Connection Flag = 0有关(有关安全连接标志的更多信息,请参阅蓝牙配对第4部分)当从Android Studio logcat读取输出时(如果是三星设备),我得到这些日志:
01-31 15:21:53.322 D/BluetoothAdapter: isSecureModeEnabled
01-31 15:21:53.322 D/BtConfig.SecureMode: isSecureModeOn:false
01-31 15:21:53.325 D/BluetoothAdapter: STATE_ON
01-31 15:21:53.325 D/BluetoothLeAdvertiser: start advertising
不确定SecureMode是否与我们提到的SecureConnection相同.
据我所知,配对是BLE Secure Connections,采用JustWorks模式.但似乎并非所有的Android设备都支持它(你能否确认一下我的想法?).或者,我们如何强制后一个设备也有配对对话框?
一个重要的是,我有一个具有相同连接流和相同物理设备的iOS应用程序,它确实显示了配对对话框.
android bluetooth bluetooth-lowenergy bluetooth-peripheral pairing
开发了一个应用程序,它充当外围设备并与其他设备连接(仅限中央).
它在具有操作系统版本6.0的设备中运行良好,但在Nougat 7.0中遇到了一些问题.
我收集了一些日志,在开发者选项中启用"Bluetooth HCI snoop log".
收集的日志:
W/bt_btm: btm_sec_disconnect : reason=19
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btm: btm_sec_send_hci_disconnect: handle:0x41, reason=0x13
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btif: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=7 connected=0 conn_id=7 reason=0x0016
W/bt_btif: bta_dm_bl_change_cback : reason=22
W/bt_btif: bta_dm_bl_change_cback : reason=22
W/bt_btm: btm_sec_disconnected
W/bt_btif: conn.link_down.is_removed : 0
D/BtGatt.GattService: onClientConnected() serverIf: 6, connId=6, address=00:16:A4:13:1E:48, connected=false
W/bt_btif: btif_dm_upstreams_cback ev: BTA_DM_LINK_DOWN_EVT
W/bt_btif: BTA_DM_LINK_DOWN_EVT. …Run Code Online (Sandbox Code Playgroud) android bluetooth disconnection bluetooth-peripheral pairing
更新:
Qt版本:5.11
平台:Raspberry pi 3
操作系统:Rasbpian
我将linux Qt BLE应用程序连接到IOS中央设备。它在大多数情况下都能正常工作,但有时会因以下错误而崩溃
qt.bluetooth.bluez:void QBluetoothSocketPrivate :: __ q_readNotify()29错误:-1“资源暂时不可用”
这是代码和基础方案。
我有一个运行Qt 5.11的raspberrypi,我创建了一个BLE低能耗外围设备,该设备连接到IOS应用并发送和接收数据。
声明:
QLowEnergyCharacteristicData ReadCharacteristicData,
WriteCharactersiticData,
ConnectivityData,
TrackerData_Data;
QLowEnergyCharacteristic charas;
QLowEnergyDescriptorData ReadCharacteristicDesc,
WriteCharactersiticDesc,
ConnectivityDesc,
TrackerDesc;
QLowEnergyServiceData serviceData;
QScopedPointer<QLowEnergyController> leController;
QScopedPointer<QLowEnergyService> service;
Run Code Online (Sandbox Code Playgroud)
服务初始化:
Here I am initializing bluetooth service
//! [Advertising Data]
advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
advertisingData.setLocalName("Atlas360Dev");
advertisingData.setServices(QList<QBluetoothUuid>()<<QBluetoothUuid::Atlas);
// For IOS its readonly and for Atlas its write only
ReadCharacteristicData.setUuid(QBluetoothUuid::ReadCharacteristic);
ReadCharacteristicData.setProperties(QLowEnergyCharacteristic::Notify);
ReadCharacteristicDesc.setUuid(QBluetoothUuid::ClientCharacteristicConfiguration);
ReadCharacteristicDesc.setValue(QByteArray(2,0));
ReadCharacteristicData.addDescriptor(ReadCharacteristicDesc);
// For IOS its write only characteristic and for Atlas its read only
WriteCharactersiticData.setUuid(QBluetoothUuid::WriteCharacteristic);
WriteCharactersiticData.setProperties(QLowEnergyCharacteristic::Write …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Linux计算机上创建低功耗蓝牙外围设备(目标是通过蓝牙从iPhone发送数据)。即时通讯目前使用的工具hciconfig,hcitool和hcidump。
我当前的实验是播发带有特定UUID的服务,iOS CoreBluetooth库将使用该服务。(注意:我不是要创建iBeacon)。
现在,实际上就像困扰我的一个命令一样简单。
hcitool -i hci0 cmd 0x08 0x0008 15 02 01 1a 11 07 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50
Run Code Online (Sandbox Code Playgroud)
我认为应该执行以下操作:
0x1a:标志值:
bit 0 (OFF) LE Limited Discoverable Mode
bit 1 (ON) LE General Discoverable Mode
bit 2 (OFF) BR/EDR Not Supported
bit 3 (ON) Simultaneous LE and BR/EDR to Same Device Capable (controller)
bit 4 (ON) …Run Code Online (Sandbox Code Playgroud)如果有的话,拥有多个 BLE 的价值是services什么?与只是将所有characteristics服务都放在一项服务中?
我正在从我们自己制造的(外围)设备构建一个 BLE 接口。我正在使用该STMicro BlueNRG-ms芯片。我的第一个原型使用了 9 个characteristics,在 4 个中组织得很好services。现在编写它的应用程序方面,我发现单独的服务只会创建更多UUID我必须映射的 s,并且似乎并没有真正增加任何价值。这 9 个特征都是独一无二的,所以我没有从单独的服务中获得任何真正需要的命名空间。
我有简单的任务来编写连接和添加2个Android设备之间的通信的应用程序.我发现了什么?Android BLE不支持"外围"角色.
1)所以这意味着我无法通过特殊的UUID连接一个Android"中央"设备与另一个"外围"Android设备?这是正确的吗?
2)如果无法通过BLE连接2台Android设备,为什么我们在Android上需要BLE?要将Android与iOS连接?
3)Android设备如何与手表配合使用?