Open MuraliKrishnaDev opened 8 years ago
Usually this means the plugin was installed wrong or it's being accessed before deviceready event is fired.
Hi,
I tried after device ready event,I am using visul studio 2015 and cordova 5.4.0 is installed,
The following is the code,
<!DOCTYPE html>
```(function () { "use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
document.getElementById('click').addEventListener('click', BluetoothConnection, false);
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
};
function BluetoothConnection() { try { //cordova.plugins.BluetoothStatus.initPlugin();
debugger
//cordova.plugins.BluetoothStatus.enableBT();
bluetoothle.initialize(function success() { }, function fail() { alert('error'); }, {
"request": true,
"statusReceiver": false
});
bluetoothle.requestPermission(function success() { }, function fail() { alert('error per'); });
bluetoothle.startScan(function listHandler(scan) {
alert(JSON.stringify(scan))
}, function fail() { alert('error scanr'); }, {
"services": [
"180D",
"180F"
],
"allowDuplicates": true,
"scanMode": bluetoothle.SCAN_MODE_LOW_LATENCY,
"matchMode": bluetoothle.MATCH_MODE_AGGRESSIVE,
"matchNum": bluetoothle.MATCH_NUM_MAX_ADVERTISEMENT,
"callbackType": bluetoothle.CALLBACK_TYPE_ALL_MATCHES,
});
} catch (e) {
debugger;
throw e;
}
}
)();
Still I am getting same error,Please help me regarding this
Thanks and regards, Murali
Hi, I get the same error too. I want to get the bluetooth list by scaning in app. Bluetooth is initialized and enabled,then by startScan function no device could be found. Actual I have turned on bluetooth of another phone(android 4.4).
Please help me or give some suggestion. Thx.
Bluetooth version of two phones is 4.0+, support bluetoothle.
@MuraliKrishnaDev Try calling the scan in the initialize callback @ZengYJ One of the devices must be advertising itself as a Bluetooth LE device. You can try using an app like LightBlue to emulate common BLE devices like heart rate monitors.
How to advertise itself as a buletooth le device? Phone A which my app is installed on, acts as server, and phone B which bluetooth is on. Could you give my some details. Thx
Currently the plugin only supports the central role. You'll need to use something like LightBlue to emulate BLE devices on the other phone.
I get it . THX.
@ZengYJ If you have a spare iOS device, you can use 4.0.0-dev branch of the plugin to advertise the device as a peripheral.
@MuraliKrishnaDev Are you still having issues?
Hi, Still I am getting the issue, Regards,Murali Date: Wed, 9 Mar 2016 10:25:13 -0800 From: notifications@github.com To: cordova-plugin-bluetoothle@noreply.github.com CC: muralikrishnadev.u@hotmail.com Subject: Re: [cordova-plugin-bluetoothle] Getting error while bluetoothle.startScan (#244)
@MuraliKrishnaDev Are you still having issues?
— Reply to this email directly or view it on GitHub.
@MuraliKrishnaDev Can you try using the Ionic based example in the plugin's Angular wrapper? This should confirm if it's a coding issue or phone issue.
@MuraliKrishnaDev
Are you running the application from an Android phone? You can't run this plugin on a windows desktop.
You should first try the Angular Wrapper. If that doesn't work try the following steps:
npm install -g cordova
cordova create "myapp"
cordova platform add android
cordova plugin add cordova-plugin-bluetoothle
cordova build android
Hi,
I am getting error while bluetoothle.startScan, Error is bluetoothle is not found,
Please guide me in this regard,
Thanks and regards, Murali