lousoperscopimaligni
Member
Is there any way to replicate this function in b4a?
it's a simple function that allows me to start a scan of available bluetooth devices
it's a simple function that allows me to start a scan of available bluetooth devices
function Scan:
function Scan() {
$("#out").html("");
$(".mybutton").addClass("hide");
$("#scan").addClass("hide");
$("#refresh").removeClass("hide");
eva = "";
log('Getting existing permitted Bluetooth devices...');
$("#out").html("...wait please");
var myService = uid_service;
navigator.bluetooth.requestDevice({
// filters: [myFilters] // you can't use filters and acceptAllDevices together
optionalServices: [myService],
acceptAllDevices: true
}).then(function (device) {
$("#out").html("device found :-) ...wait...");
myDevice = device;
console.log(device);
return device.gatt.connect();
}).then(function (server) {
$("#out").html("device connected :-) ...wait...");
return server.getPrimaryService(myService);
}).then(function (service) {
$("#out").html("service found :-)");
_service = service;
$(".mybutton").removeClass("hide");
}).catch(function (err) {
$("#out").html("Errore:" + err);
});
}