I am making an algorithm for access to Bluetooth Classic devices in which I get from an instance obtained directly from an Android service a collection of type java.util.Set, I need to interact in this collection to get the properties of the objects there present and build a new Array , according to an entity model built in NativeScript with the JavaScript language.
In what way should such an interest be performed in NativeScript using the JavaScript language?
Here is the code suggested below so you can get a sense of what I want to do:
Bluetooth.getBoundedDevices = function(){
java.util.Set<android.bluetooth.BluetoothDevice> pairedDevices = adapter.getBondedDevices();
var obArrayDevices = new ObservableArray();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (deviceAndroid of pairedDevices.toArray([{}])) {
var device = new Observable({
type: 'scanResult',
UUID: deviceAndroid.getAddress(),
name: deviceAndroid.getName(),
RSSI: 0,
state: 'disconnected'
});
console.log("dispositivo Encontrado:");
console.dir(device);
obArrayDevices.add(device);
}
}
return obArrayDevices;
}