android上的Nativescript bluetooth只是发现了一些设备,而且进展缓慢

android上的Nativescript bluetooth只是发现了一些设备,而且进展缓慢,android,bluetooth,nativescript,nativescript-plugin,Android,Bluetooth,Nativescript,Nativescript Plugin,我目前正在开发一个手机应用程序,使用nativescript和bluetooth(我对这两种技术都很陌生),我在发现附近正在被发现的设备时遇到了问题。在另一个手机应用程序上,许多设备被发现的速度非常快,然而,在我的应用程序上,只发现其他应用程序发现的设备的一个子集,而且发现速度也较慢。所以我的主要问题是,是什么导致我的应用程序只发现我周围的一些设备,而不发现其他设备?其次,为什么发现它们的速度很慢?或者有什么简单的方法来诊断这个问题 这是我的代码 import { Component, OnIn

我目前正在开发一个手机应用程序,使用nativescript和bluetooth(我对这两种技术都很陌生),我在发现附近正在被发现的设备时遇到了问题。在另一个手机应用程序上,许多设备被发现的速度非常快,然而,在我的应用程序上,只发现其他应用程序发现的设备的一个子集,而且发现速度也较慢。所以我的主要问题是,是什么导致我的应用程序只发现我周围的一些设备,而不发现其他设备?其次,为什么发现它们的速度很慢?或者有什么简单的方法来诊断这个问题

这是我的代码

import { Component, OnInit } from "@angular/core";
import { ListViewEventData, RadListView } from "nativescript-ui-listview";
import { Device } from "../shared/device.model";
var bluetooth = require('nativescript-bluetooth');



//var bluetooth = require("nativescript-bluetooth");

@Component({
    selector: "Home",
    moduleId: module.id,
    templateUrl: "./home.component.html",
    styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
    deviceList: Array<Device> = [];
    isLoading = false;
    listLoaded = true;

    constructor() {

    }

    onTapCell(name): void{
        alert(name);
        return;
    }

    ngOnInit(): void{
        console.log(bluetooth.isBluetoothEnabled().then(
            function(enabled){
                console.log("enabled " + enabled);
            }
        ));
        var t = this.deviceList;
        setTimeout( 
            function(){
                bluetooth.startScanning({
                    serviceUUIDs: [],
                    seconds : 120,
                    onDiscovered: function(peripheral){
                        console.log(peripheral.UUID);
                        console.log(peripheral.RSSI);
                        peripheral.RSSI += 128;
                        t.push(peripheral);
                    },
                    onScanFailed: function(){

                    } 

                });
            },
            125*1000
        )


    }
}
从“@angular/core”导入{Component,OnInit};
从“nativescript ui listview”导入{ListViewEventData,RadListView};
从“./shared/Device.model”导入{Device};
var bluetooth=require('nativescript-bluetooth');
//var bluetooth=require(“nativescript蓝牙”);
@组成部分({
选择器:“主页”,
moduleId:module.id,
templateUrl:“./home.component.html”,
样式URL:['./home.component.css']
})
导出类HomeComponent实现OnInit{
deviceList:Array=[];
isLoading=false;
listLoaded=true;
构造函数(){
}
onTapCell(名称):void{
警报(名称);
返回;
}
ngOnInit():void{
console.log(bluetooth.isBluetoothEnabled()。然后(
功能(已启用){
console.log(“已启用”+已启用);
}
));
var t=此设备列表;
设置超时(
函数(){
bluetooth.startScanning({
serviceUUIDs:[],
秒:120,
发现:功能(外围设备){
console.log(peripheral.UUID);
console.log(peripheral.RSSI);
外围设备RSSI+=128;
t、 推(外设);
},
OnScan失败:函数(){
} 
});
},
125*1000
)
}
}
我的系统:安卓8,motoZ2

谢谢,
Issiah

@Katherine是和否,事实证明它使用了低能量蓝牙(bluetooth LE),这将无法与使用高功率蓝牙的旧设备向后兼容。另外,如果我没记错的话(请不要引用我的话),库不会处理从设备接收到的初始信号,我认为创建者在git repo中有一个TODO,这也可以解释为什么它的速度很慢。这里有到repo github.com/eddyverbruggen/nativescript-bluetooth的链接。注意:本机android库应具有向后兼容的蓝牙。

您好。你找到解决办法了吗?我也面临同样的问题!是和否,事实证明它使用的是低能量蓝牙(bluetooth LE),这与使用高功率蓝牙的旧设备不向后兼容。另外,如果我没记错的话(请不要引用我的话),库不会处理从设备接收到的初始信号,我认为创建者在git repo中有一个TODO,这也可以解释为什么它的速度很慢。这里有一个到回购协议的链接。注意:本机android库应具有向后兼容的蓝牙。