nativescript classic bluetooth native android api

Viewed 540

this is my first question, i'm trying to realize an app with nativescript that will communicate with classic bluetooth devices. at the beginning i've tried the well known EddyVerbruggen/nativescript-bluetooth nativescript plugin, but this works only with BLE devices, i can turn on the bluetooth interface but i can't see no bluetooth devices around me.

i've read many pages about android and native api: https://developer.android.com/guide/topics/connectivity/bluetooth.html#SettingUp

http://www.londatiga.net/it/programming/android/how-to-programmatically-scan-or-discover-android-bluetooth-device/

and many others, so is there a way to integrate native android bluetooth api in nativescript? someone of you could help me?

this is my function, at the onDiscovered i ahave no results:

exports.bt = function () {    
    bluetooth.isBluetoothEnabled().then(
        function (enabled) {
            console.log("Enabled? " + enabled);
            if (!enabled) {
                bluetooth.enable().then(
                    function(enabled) {
                        console.log("active: "+ enabled);
                        bluetooth.startScanning({
                            serviceUUIDs: [],
                            seconds: 10,
                            onDiscovered: function (peripheral) {
                                console.log("Periperhal found with UUID: " + peripheral.UUID);
                            }
                        }).then(function () {
                            console.log("scanning complete ");
                            console.log("Periperhal found with UUID: " + peripheral.UUID);
                        }, function (err) {
                            console.log("error while scanning: " + err);
                        });
                    }
                );
            }
        }
    );
};

thanks in advance

**EDIT

this library works only with BLE devices

0 Answers
Related