r***@163.com
r***@163.com
  • 发布:2017-12-27 18:04
  • 更新:2017-12-27 18:04
  • 阅读:1415

native.js 实现蓝牙BLE扫描回调参数怎么使用

分类:Native.js

var mScanCallback = plus.android.implements("android.bluetooth.BluetoothAdapter$LeScanCallback", {

            "onLeScan": function(device, rssi, scanRecord) {  

                if(device != null) {  
                    $('.list').css('display','flex');  
                    console.log("mScanCallback");  
                    /*var BluetoothDevice = plus.android.importClass("android.bluetooth.BluetoothDevice");  
                    device = new BluetoothDevice();*/  
                    var li = document.createElement('li');  
                    li.setAttribute('class', 'list_item');  
                    var p1 = document.createElement("span");  
                    p1.appendChild(document.createTextNode('名称:' + device.getName()));  
                    var p2 = document.createElement("span");  
                    p2.appendChild(document.createTextNode('地址:' + device.getAddress()));  
                    var p3 = document.createElement("span");  
                    p3.appendChild(document.createTextNode('信号:' + rssi));  
                    li.appendChild(p1);  
                    li.appendChild(p2);  
                    li.appendChild(p3);  
                    deviceList.appendChild(li);  

                }  

            }  

        });  

直接使用device.getName() 会报错,方法未定义。

2017-12-27 18:04 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复