I am currently working on a phone app, using nativescript and bluetooth(both of which I am very new to) and I am having an issue with discovering nearby devices being discovered. On another phone app many devices are discovered very fast, however, on my app only discovers a subset of those that are discovered by other app and they discovered slower as well. So my primary question is what could cause my app only discovers some of the devices around me and not others? Also, secondarily why is it slow to discover them? Or perhaps any easy ways to diagnose the problem?
Also here's my code...
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
)
}
}
My system: Android 8, motoZ2
Thanks, Issiah