繁体   English   中英

您如何在Android事物中为蓝牙服务命名?

[英]how would you give name to bluetooth service in android things?

我在android事物中创建了一个简单的服务以使用Bluetooth BLE。当我尝试使用NRF connect应用程序对其进行测试时,它会显示为“未知服务”。我想命名为“ Speed Service”。该怎么办?

private BluetoothAdapter bluetoothAdapter = null;
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

void ChangeDeviceName(){
                Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress());
                bluetoothAdapter.setName("NewDeviceName");
                Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress());
            }

参考: 更改Android蓝牙设备名称

希望这种情况与您相似。

这是由您使用的扫描应用程序(不一定是Android Things设备)控制的因素。 蓝牙LE不会通过无线方式发送诸如“服务名称”之类的元数据。 服务仅通过其UUID进行标识。 如果您的设备实现标准服务UUID之一,则类似NRF Connect的扫描仪应用程序可能会识别并显示服务类型。

再举一个例子,我们的Bluetooth GATT Server示例通过使用Bluetooth SIG为该服务采用的UUID来实现标准的当前时间服务。

暂无
暂无

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

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