简体   繁体   English

如何知道cordova中的蓝牙设备类型

[英]How to know the bluetooth device type in cordova

I am using a cordova plugin to display the list of all bluetooth device .我正在使用cordova插件来显示所有蓝牙设备的列表。 But I need to filter out all the devices which are printer.但我需要过滤掉所有打印机设备。 How can I do so ?我怎么能这样做? Is there anyway I can find the bluetooth device type by their mac address or name ?无论如何我可以通过他们的mac地址或名称找到蓝牙设备类型吗?

As given in the documentation you mentioned.如您提到的文档中所述。

var device_names = {};
var updateDeviceName = function (device) {
    device_names[device.address] = device.name;
};

// Add listener to receive newly found devices
networking.bluetooth.onDeviceAdded.addListener(updateDeviceName);

// With the listener in place, get the list of known devices
networking.bluetooth.getDevices(function (devices) {
    for (var i = 0; i < devices.length; i++) {
        updateDeviceName(devices[i]);
    }
});

// Now begin the discovery process.
networking.bluetooth.startDiscovery(function () {
    // Stop discovery after 30 seconds.
    setTimeout(function () {
        networking.bluetooth.stopDiscovery();
    }, 30000);
});

Check out here: Device information and discovery在此处查看: 设备信息和发现

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

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