简体   繁体   English

使用 cordova-ble-plugin 更改 BLE 设备名称

[英]Change BLE device name using cordova-ble-plugin

I am using corodova-ble-plugin ( https://github.com/don/cordova-plugin-ble-central ) with my ionic 4 project and I wanted to know if its possible to change the bluetooth device name with this plugin.我在 ionic 4 项目中使用 corodova-ble-plugin ( https://github.com/don/cordova-plugin-ble-central ),我想知道是否可以使用此插件更改蓝牙设备名称。 I searched the ble plugin documentation and did not find anything.我搜索了 ble 插件文档,但没有找到任何东西。 But have anyone done such thing with an ionic app before without native android dev?但是,在没有本机 android dev 之前,有人用离子应用程序做过这样的事情吗?

** Update ** ** 更新 **

I was able to find the characteristics that has to be passed using the write method to set the name of the device.我能够找到必须使用 write 方法传递的特征来设置设备的名称。 But the passed value has to be a array buffer type and not string.但是传递的值必须是数组缓冲区类型而不是字符串。 So I used the string to array buffer npm package, its passing the write value when I checked in the android studio console but in the device it shows up with symbols instead and not the actual name.因此,我将字符串用于数组缓冲区 npm package,当我在 android 工作室控制台中检查时,它传递了写入值,但在设备中它显示的是符号而不是实际名称。 What would be going wrong here?这里会出什么问题?

I'm not an expert in Cordova but it looks like this plugin doesn't allow what you're looking for.我不是 Cordova 的专家,但看起来这个插件不允许您查找的内容。 The good news is if you change the name of the device using native code, it should work.好消息是,如果您使用本机代码更改设备的名称,它应该可以工作。

BluetoothAdapter.getDefaultAdapter().setName("myDeviceName");

You can use that in your MainActivity.您可以在 MainActivity 中使用它。

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

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