繁体   English   中英

如何在Android 4.3中更改蓝牙低能耗设备的名称?

[英]How to change the name of bluetooth low energy device in Android 4.3?

我正在开发一个必须连接到Android 4.3上的蓝牙设备的应用程序。

我想通过Android应用程序更改CC2541 Keyfob的名称。

我试图使用0x2A00来获取设备名称服务,但是当我调用Device_Name函数时,它似乎无法正常工作。

Name_Service为空。

 private static final UUID Device_Name_UUID = UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb");
private static final UUID Write_UUID = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");



    public void Device_Name(){
        BluetoothGattService Name_Service = mBluetoothGatt.getService(Write_UUID );
        if(Name_Service == null) {
            Log.d(TAG, "Name_Service service not found!");
            return;
        }

        BluetoothGattCharacteristic DeviceName = Name_Service.getCharacteristic(Device_Name_UUID);
        if(DeviceName == null) {
            Log.d(TAG, "DeviceName charateristic not found!");
            return;
        }

    }


Log.v(TAG, "readCharacteristic(DeviceName) = " + mBluetoothGatt.readCharacteristic(DeviceName));

String i = "123";       
DeviceName.setValue(i);
Log.v(TAG, "writeCharacteristic(DeviceName) = " + mBluetoothGatt.writeCharacteristic(DeviceName));

我可以从BLE设备读取名称,但是当我使用mBluetoothGatt.readCharacteristic(DeviceName)时,它表明writeCharacteristic(DeviceName)为false。

有人尝试使用设备名称的UUID(0x2A00)将名称写入BLE设备吗?

您需要修改CC2541 keyfob的固件,以通过将以下代码添加到keyfobdemo.c中的KeyFobApp_Init()中来添加设备名称的写许可权:

uint8 devNamePermission = GATT_PERMIT_READ|GATT_PERMIT_WRITE; 
GGS_SetParameter( GGS_W_PERMIT_DEVICE_NAME_ATT, sizeof ( uint8 ), &devNamePermission );

参考: http : //processors.wiki.ti.com/index.php/CC2540_DeviceNameWrite

暂无
暂无

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

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