Code Monkey home page Code Monkey logo

ng-cordova-bluetoothle's Introduction

ng-cordova-bluetoothle

This wraps the Bluetooth Low Energy Phonegap Plugin by Rand Dusing in AngularJS code so it can be used more easily in AngularJS mobile applications.

Issues

Please only create issues that are directly related to ng-cordova-bluetoothle! If it's not an Angular/Javascript issue, create the issue in the cordova-plugin-bluetoothle repo!

Installation

  • Install the Bluetooth LE Plugin: cordova plugin add cordova-plugin-bluetoothle
  • Install the Angular Wrapper: bower install git://github.com/randdusing/ng-cordova-bluetoothle.git#master

Example App

An example app has been created using the Ionic Framework to demonstrate the functionality. To install the example app, follow the steps below:

  • Create a new Ionic Project: ionic start test tabs
  • Install the Bluetooth LE plugin: cordova plugin add cordova-plugin-bluetoothle
  • Install the Angular Wrapper: bower install git://github.com/randdusing/ng-cordova-bluetoothle.git#master
  • Install crypto-js library if using examples: bower install js-md5
  • Add contents from /example to /www of the Cordova project, replacing if necessary
  • Build and run the Cordova project

Example Usage

A few examples, but the example app is your best resource.

Initialize

  $cordovaBluetoothLE.initialize({request:true}).then(null,
    function(obj) {
      //Handle errors
    },
    function(obj) {
      //Handle successes
    }
  );

Initialize uses the notify callback to keep track of changes in the Bluetooth state (on/off).

Scan

  $cordovaBluetoothLE.startScan({services:[]}).then(null,
    function(obj) {
      //Handle errors
      console.log(obj.message);
    },
    function(obj) {
      if (obj.status == "scanResult")
      {
        //Device found
      }
      else if (obj.status == "scanStarted")
      {
        //Scan started
      }
    }
  );

Scan uses the notify callback as well since multiple scanned devices may be returned.

Connect

  $cordovaBluetoothLE.connect({address:"ABCDEFG"}).then(null,
    function(obj) {
      //Handle errors
      console.log(obj.message);
    },
    function(obj) {
      if (obj.status == "connected") {
        //Device connected
      } else {
        //Device disconnected, handle this unexpected disconnect
      }
    }
  );

Connect uses the notify callback as well since the connection state may change. See useResolve option below for resolve vs notify.

Available Functions

For details on each function, please visit https://github.com/randdusing/cordova-plugin-bluetoothle. A few methods require you wait for notify rather than resolve since the callback may be called multiple times: intialize, startScan, connect, reconnect, disconnect, subscribe. Enable and disable only wait for error since the "success" is returned to the initialize

  • $cordovaBluetoothLE.initialize(params).then(null, error, success);
  • $cordovaBluetoothLE.enable().then(null, error); Android
  • $cordovaBluetoothLE.disable().then(null, error); Android
  • $cordovaBluetoothLE.startScan(params).then(null, error, success);
  • $cordovaBluetoothLE.stopScan().then(success, error);
  • $cordovaBluetoothLE.retrieveConnected(params).then(success, error);
  • $cordovaBluetoothLE.bond(params).then(null, error, success);
  • $cordovaBluetoothLE.unbond(params).then(success, error);
  • $cordovaBluetoothLE.connect(params).then(null, error, success);
  • $cordovaBluetoothLE.reconnect(params).then(null, error, success);
  • $cordovaBluetoothLE.disconnect(params).then(success, error);
  • $cordovaBluetoothLE.close(params).then(success, error);
  • $cordovaBluetoothLE.discover(params).then(success, error);
  • $cordovaBluetoothLE.services(params).then(success, error); iOS
  • $cordovaBluetoothLE.characteristics(params).then(success, error); iOS
  • $cordovaBluetoothLE.descriptors(params).then(success, error); iOS
  • $cordovaBluetoothLE.read(params).then(success, error);
  • $cordovaBluetoothLE.subscribe(params).then(null, error, success);
  • $cordovaBluetoothLE.unsubscribe(params).then(success, error);
  • $cordovaBluetoothLE.write(params).then(success, error);
  • $cordovaBluetoothLE.writeQ(params).then(success, error);
  • $cordovaBluetoothLE.readDescriptor(params).then(success, error);
  • $cordovaBluetoothLE.writeDescriptor(params).then(success, error);
  • $cordovaBluetoothLE.rssi(params).then(success, error);
  • $cordovaBluetoothLE.mtu(params).then(success, error); Android
  • $cordovaBluetoothLE.requestConnectionPriority(params).then(success, error); Android
  • $cordovaBluetoothLE.isInitialized(params).then(success);
  • $cordovaBluetoothLE.isEnabled(params).then(success);
  • $cordovaBluetoothLE.isScanning(params).then(success);
  • $cordovaBluetoothLE.isBonded(params).then(success);
  • $cordovaBluetoothLE.wasConnected(params).then(success, error);
  • $cordovaBluetoothLE.isConnected(params).then(success, error);
  • $cordovaBluetoothLE.isDiscovered(params).then(success, error);
  • $cordovaBluetoothLE.hasPermission().then(success, error); Android 6.0+
  • $cordovaBluetoothLE.requestPermission().then(success, error); Android 6.0+
  • $cordovaBluetoothLE.isLocationEnabled().then(success, error); Android 6.0+
  • $cordovaBluetoothLE.requestLocation().then(success, error); Android 6.0+
  • $cordovaBluetoothLE.initializePeripheral(params).then(success, error);
  • $cordovaBluetoothLE.addService(params).then(success, error);
  • $cordovaBluetoothLE.removeService(params).then(success, error);
  • $cordovaBluetoothLE.removeAllServices().then(success, error);
  • $cordovaBluetoothLE.startAdvertising().then(success, error);
  • $cordovaBluetoothLE.stopAdvertising().then(success, error);
  • $cordovaBluetoothLE.isAdvertising().then(success, error);
  • $cordovaBluetoothLE.respond(params).then(success, error);
  • $cordovaBluetoothLE.notify(params).then(success, error);
  • $cordovaBluetoothLE.encodedStringToBytes(encodedString);
  • $cordovaBluetoothLE.bytesToEncodedString(bytes);
  • $cordovaBluetoothLE.stringToBytes(string);
  • $cordovaBluetoothLE.bytesToString(bytes);

Options

  • useResolve - If true, forces connect and reconnect to resolve the promise rather than using notify.
  • timeout - If set, the operation will timeout with an error after X milliseconds. Available on connect, reconnect, discover, services, characteristics, descriptors, read, subscribe, unsubscribe, write, readDescriptor, writeDescriptor, rssi, mtu, requestConnectionPriority.
  • scanTimeout - On a successful scan start, automatically stop the scan after X milliseconds.
  • subscribeTimeout - On a successful subscribe, automatically unsubscribe after X milliseconds.

Examples

Some examples are provided to help demonstrate different common scenarios. Looking for more examples? Let me know!

  • Throughput (Central) - Transfers a file to another device running Throughput (Peripheral). Make sure to start the Throughput (Peripheral) test first.
  • Throughput (Peripheral) - Receives a file from another device running Throughput (Central).
  • Read All - Scans for first available device, connects to it, discovers it, iterates through all characteristics and reads them, disconnects and finally closes. This provides a good example of promise chains.

Queueing Operations

Example of how you could queue up three read operations.

  $cordovaBluetoothLE.read(params1).then(function() { //Read 1
    return $cordovaBluetoothLE.read(params2); //Read 2
  }).then(function() {
    return $cordovaBluetoothLE.read(params3); //Read 3
  }).catch(function(err) {
    console.log(err); //Catch any errors
  });

Have a question or found a bug?

Open an issue.

Resources

AngularJS - http://www.angularjs.org

Apache Cordova - http://cordova.apache.org

License and Source

The code that powers the 'build generation' is a carbon copy (with minimal changes) of Nic Raboy's ngCordovaBeacon project. As of the Fork, it was licensed under the MIT license; The Cordova Wrapper was written by myself, and my employer and I retain the copyright for that; but this project is also licensed under the MIT License.

If you want to follow more of Nic's work, his blog is located here. If you want to know more about me or Jewelbots, you can follow Jewelbots on twitter, our Ink, or me.

Contributing

Rand Dusing - Primary author of the Cordova Bluetooth LE Plugin. You can contact me via: [email protected], Facebook, LinkedIn or Twitter.

ng-cordova-bluetoothle's People

Contributors

d33d33 avatar gortok avatar randdusing avatar zekenie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-cordova-bluetoothle's Issues

Error: Operation unsupported

I´m having this error in Log when I try to connect:

Initialize Error:
{"error": "unsupported", "message" : "Operation unsupported"}

I´m using Motorola Moto X with Android version 6.0

I added in my config.xml:

 <plugin name="BluetoothLePlugin" value="com.randdusing.bluetoothle.BluetoothLePlugin" /> 

My AndroidManifest.xml I have Bluetooth Permissions:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

I´m trying to connecto to HC-05 or stick n find (ibeacons) by bluetooth with phonegap/ionic/cordova project. Someone can help me with a working example?

Trigger callback after scanTimeout

Hi there,

It seems that using the scanTimeout parameter with startScan does stop the scan after the given time (I checked this using isScanning with angular's built in $timeout), but it seems that no callback is triggered when stopScan is called automatically after the timeout. Is this the expected behavior? Is there a way to trigger a callback without using the $timeout service (as this kind of defeats the purpose of the scanTimeout parameter, right?)?

Thanks in advance for the help and for the awesome angular wrapper of a great plugin!

No devices returned

I've implemented the code on the example app. Code provided below:

$ionicPlatform.ready().then(function () {
      $cordovaBluetoothLE.initialize({request:true}).then(null,
      function(obj) {
        //Handle errors
      },
      function(obj) {
        var params = {
          services:[],
          allowDuplicates: false
          //scanTimeout: 15000,
        };

        if (window.cordova) {
          params.scanMode = bluetoothle.SCAN_MODE_LOW_POWER;
          params.matchMode = bluetoothle.MATCH_MODE_STICKY;
          params.matchNum = bluetoothle.MATCH_NUM_ONE_ADVERTISEMENT;
          //params.callbackType = bluetoothle.CALLBACK_TYPE_FIRST_MATCH;
        }

        console.log("Start Scan : " + JSON.stringify(params));

        $cordovaBluetoothLE.startScan(params).then(function(obj) {
          console.log("Start Scan Auto Stop : " + JSON.stringify(obj));
        }, function(obj) {
          console.log("Start Scan Error : " + JSON.stringify(obj));
        }, function(obj) {
          console.log("Start Scan Success : " + JSON.stringify(obj));

          $scope.device = obj;
          addDevice(obj);
        });
      });
    });

But upon scanning, I'm only getting this result.

Start Scan Success : {"status":"scanStarted"}

Thanks!

Notify function

Hi ! i can't get notification from my bluetooth device.
can you post an example ?
thanks.

Read Long Characteristic

Hi,
as graduation project, i'm developing an hybrid application for the monitoring of vital parameter, which requires Bluetooth Low Energy.
I'm using ng-cordova-bluetoothle plugin and all the methods that I have used so far are working.
Now I want to read the frame from the BLE card to plot charts, but I have a problem, the frame length is 100bytes and I found that the maximum that can be read is 22bytes. have you any idea how I can use the read() to read this frame? is that even possible ?
thank you,

No main in package.json

Hey there,

For some reason I'm having trouble requiring the module with webpack. I think its because there's no main field in the package.json. I'm going to send a PR to add one with a version bump.

Read function not workind

Hi I'm using an Bluetooth from Adrafuit(Bluefruit). I can write without problem from my Android phone but I can't read anything form bluefruit. I just got errors(Unable to read).

Adafruit bluefruit https://learn.adafruit.com/introducing-adafruit-ble-bluetooth-low-energy-friend/uart-service

I use the example code adapted to a simple application without modification.

I have noticed something very simple, it takes a moment to write and displays "Success" or "Errors". But to read almost immediately displays "Error"

This is my test project https://github.com/wifixcort/BlueTest

Thanks for help

Cordova BluetoothLE Detects only mac laptop no other devices?

I was trying to figure out how BLE works. Tried to go through your plugin have followed all the steps mentioned in document. Build for android using windows everything is working great till now.

  • Initialize my device.
  • Enable/Disable my device bluetooth.

But when i used to startScan it only detects my Mac laptop even if my all other devices are enabled. I wanna know

  • How the app scan for all the bluetooth devices?
  • What should i have to pass in params of startScan show that it detects all the devices?

scan return only mac

when I use scan function in response I received only mac address, but I need the uuid of device

Scan code


$scope.scan = function(){
    $cordovaBluetoothLE.initialize({request:true}).then(null, function(obj) {
      console.log("error " + JSON.stringify(obj));
    }, function(obj) {
      console.log("ok " + JSON.stringify(obj));
    });

    var params = {
      services:[],
      allowDuplicates: false,
      scanTimeout: 1000,
    };

    if (window.cordova) {
      params.scanMode = bluetoothle.SCAN_MODE_LOW_POWER;
      params.matchMode = bluetoothle.MATCH_MODE_STICKY;
      params.matchNum = bluetoothle.MATCH_NUM_ONE_ADVERTISEMENT;
      //params.callbackType = bluetoothle.CALLBACK_TYPE_FIRST_MATCH;
    }

    console.log("Start Scan : " + JSON.stringify(params));

    $cordovaBluetoothLE.startScan(params).then(function(obj) {
      console.log("Start Scan Auto Stop : " + JSON.stringify(obj));
    }, function(obj) {
      console.log("Start Scan Error : " + JSON.stringify(obj));
    }, function(obj) {
      console.log("Start Scan Success : " + JSON.stringify(obj));
      console.log($cordovaBluetoothLE.stringToBytes(obj.address));
    });

  }

console response

...
Start Scan Success : {"address":"CF:BC:E4:1B:B1:A8","name":"EST","rssi":-76,"advertisement":"AgEGGv9MAAIVuUB/MPX4Rm6v+SVVa1f+bQABAAKvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","status":"scanResult"}
...

How to create Multiconnection with multiple ble devices ?

Hi Randdusing,
Thanks for the great plugin and example app.
I am creating an ionic application using your plugin which will be able to scan ,connect,discover and read the characteristics of glucometer and oximeter which are present within the range. so i need to implement multiconnection with multiple services along with monitoring of the characteristics value through subscription and notification.Currently I am able to read only one device at a time.It would be great if you can provide some inputs or examples.

read method misbehave when a response of bigger size has been received

Hi.

I'm trying to build an app using this library. More specifically, I want to call a specific function within a specified interval time. So to do this I'm using the following code:

vm.startExperimentLoop = function() {
       vm.myCall = $interval( loop, 5000);        
};


vm.apiStop = function(){
	$interval.cancel(vm.myCall);
}

function loop(){
	getTemp();
}

function getTemp(){
	return bleReadgetTemp()
	.then (function(response){
		response = atob(response.value);
		debugWrite("Response@getTemp: " + response + "\n");
		if(response.status){
			// Do nothing
		} else {
			// Stop the loop :p
		}
		return response;
	})
	.catch( function(error){
		console.log("getTemp");
	})
}

function bleReadgetTemp(){
	var service_id = '12ab';
	var characteristic_id = '31cd';

	var params = {
	        address: $stateParams.address,
	        service: service_id,
	        characteristic: characteristic_id,
	};

	return $cordovaBluetoothLE.read(params);
} 

The bluetooth peripheral is running nodeJS with bleno library and on this specific read request returns an object like {"temp": 2455555555}. As long the value of temp attribute has 10 or less digits everything work as expected. If I put one more digit and make them 11 in total, the $interval function seems not to be work and sends read requests continuously to the peripheral.

Any idea why this could happen?

Initialize Issue

Need to rethink initialize since Disable will "complete" the promise.

Plugin not connected to android phone

Hi all, I am using this plugin for connecting embedded device. before that I want to check it with 2 mobiles. But it is not even finding my mobile device..

What should be the format of the uuid string in the service and characteristic in a write request?

Hi I am trying to send a message to a BLE node using GATT connection. I am able to establish a connection but I am not able to send a message. This is the error I am facing,
Write Error :
{"error":"service","message":"Service not found","address":"C2:A7:51:2C:F2:37","name":"ble-Micro"}
My request looks like this,

$scope.write =function() {
            var params = {
                         address:"C2:A7:51:2C:F1:47", 
                         service:"713d0000-503e-4c75-ba94-3148f18d941e", 
                         characteristic: "713d0003-503e-4c75-ba94-3148f18d941e", 
                         value:"hello world", 
                         timeout: 3000
                       };
            console.log("Write : " + JSON.stringify(params));

            $cordovaBluetoothLE.write(params).then(function(obj) {
              console.log("Write Success : " + JSON.stringify(obj));
            }, function(obj) {
              console.log("Write Error : " + JSON.stringify(obj));
            });
 };

Any kind of help is appreciated.

Confusion regarding target SDK 23 and android 4.3

I'm not sure how to interpret the minimum requirements:

Android 4.3 or higher, Android Cordova library 5.0.0 or higher, target Android API 23 or higher

How is it possible to build an app using API 23 for a phone running Android 4.3?
Isn't the API tied to the Android version, i.e. API 23 for 6.0? (or 22 for 5.1.1 in my case)
My reference is simply the Android SDK Manager which list the build tools categorised as Android 6.0 (API 23) etc.
This confuses me (mainly because I'm completely new to mobile development).

I've tried setting <preference name="android-targetSdkVersion" value="23"/> and
<preference name="android-minSdkVersion" value="23"/> in the config.xml file, which result in apk install errors when deploying to the device.

unable to get devices.

Hi i am using this plugin and its working fine for initialize , but i start scan , no devices .

$rootScope.startScan = function() {
     var params = {
     services:[],
     allowDuplicates: false,
   //scanTimeout: 15000,
  };

if (window.cordova) {
  params.scanMode = bluetoothle.SCAN_MODE_LOW_POWER;
  params.matchMode = bluetoothle.MATCH_MODE_STICKY;
  params.matchNum = bluetoothle.MATCH_NUM_ONE_ADVERTISEMENT;
  //params.callbackType = bluetoothle.CALLBACK_TYPE_FIRST_MATCH;
}

Log.add("Start Scan : " + JSON.stringify(params));

$cordovaBluetoothLE.startScan(params).then(function(obj) {
  Log.add("Start Scan Auto Stop : " + JSON.stringify(obj));
}, function(obj) {
  Log.add("Start Scan Error : " + JSON.stringify(obj));
}, function(obj) {
  Log.add("Start Scan Success : " + JSON.stringify(obj));

  addDevice(obj);
});

};

Can't seem to get scan results on Nexus 5

I'm running this example just fine, on the surface everything seems to work just fine. Init works, enable/disable works, scan starts and stops, getting connected devices works just fine.

My problem is that scan results are not returning to the callback. I can see through logcat that the scan is successfully finding the device I'm trying to connect to (TI SensorTag), but the app does not record any found devices.

Do you know what could be the problem?

I've not modified the code in any way.

Scan stopped without finding any devices

Hello, I follow Example App steps and app start fine but when I use "Read All" example I get this log:

Initializing...
Finding device
Read All Error: "Scan stopped without finding any devices"

I run example in a "Moto E" (Android 4.4).
I have "Moto G (Android 4.4)" and "Nexus 4 (Android 5)" with bluetooth activated and visible.
If I use Android bluetooth search option it find 2 devices.
I use Android SDK 23 and I have location enabled and permission.

Is Location Enabled Success : {"isLocationEnabled":true}
as Permission Success : {"hasPermission":true}

Any help?

Updated

Sorry this mobile devices don't be BLE devices.
I use this plugin https://github.com/don/BluetoothSerial#discoverunpaired and it works.

respond() to a status writeRequested not work

Hi everyone!

I'm trying to respond to a 'writeRequested' state with the respond() method, but I see that it doesn't work as expected.

I need to reply to the device that made the writeRequest with a 'received' message.

This is the code that proves:

`if (status.status == "writeRequested") {

  if (
    status.service == "1234" &&
    status.characteristic == "D6D95414-516C-4DCF-B5CF-3BB1A560AF0F"
  ) {
    this.bluetoothle
      .respond({
        address: status.address,
        requestId: status.requestId,
        value: btoa('Recived message in tablet!') // encode base64
      })
      .then((data) => {
        console.log(data);
      })
      .catch((err) => {
        console.log(err);
      });
    this.recivedMessages.push(atob(status.value)); // decode base64
    this.cdr.detectChanges();
    console.log(atob(status.value));
  }

}`

When i debug the code, i see that the respond() method have success status, but the message is not visible in the other device.

writeRequested

NOTE: when i use the same method to respond 'readRequested' status works fine

Like this:

`if (status.status == "readRequested") {

  if (
    status.service == "1234" &&
    status.characteristic == "D6D95414-516C-4DCF-B5CF-3BB1A560AF0F"
  ) {
    this.bluetoothle
      .respond({
        address: status.address,
        requestId: status.requestId,
        value: btoa('Hello from tablet!')
      })
      .then((data) => {
        console.log(data);
      })
      .catch((err) => {
        console.log(err);
      });
  }

}`

This is the code of my writeRequest method:

`writeRequest(devAddress:string, messageS:string){

this.bluetoothle.write({
  address: devAddress,
  service: "1337",
  characteristic:"99AD1F53-0DC6-4D84-85CF-33CBE47C6EF8",
  value: btoa(messageS),
  type: ""
})
.then((resp)=>{
  console.log('RESPONSE from writeRequest', resp);
})
.catch((err)=>{
  console.log('ERROR IN writeRequest:', err);
})

}`

Is there an error in my implementation? Any idea how to solve it?

Of course, thank you for your time and kindness!

Best regards,
marcui :)

Missing template files?

Where are these located:
type=text/ng-template id=home.html
type=text/ng-template id=device.html
type=text/ng-template id=service.html
type=text/ng-template id=characteristic.html

android.bluetooth.BluetoothAdapter.getBluetoothLeAdvertiser()' on a null object reference

Running the example app on android using cordova run android, I get the following error when trying to advertise in peripheral mode:

Start Advertising Error : "Attempt to invoke virtual method
'android.bluetooth.le.BluetoothLeAdvertiser 
android.bluetooth.BluetoothAdapter.getBluetoothLeAdvertiser()' 
on a null object reference"

The devices I tried running on is both a Samsung Galaxy S6 mini, LG Nexus 5X and Huawei Ascend P7. Same error.
I have tried re-adding the plugin. initializePeripheral + addService works fine, but when triggering startAdvertising, I get the error. See the console.log file attached.
I have a question more: where is the characteristic "1234" (default for addService, i guess?) set within the code?
I have another question (note: my knowledge of BLE is still limited, so excuse me if the question seem dumb, obvious or a non-issue); what is the BLE profile that is used? Is it one supported by Apple, or do I have to get a MFi license when releasing the app to the App Store?
Thanks!
PS: I also attached the project.
console.log.zip
https://www.dropbox.com/s/67lut57hpe4mfec/test.zip?dl=0

Edit:
Bluetooth is of course enabled and at least the Nexus 5X device should support advertising.
I just stumbled on your suggested solution to remove

 || !bluetoothAdapter.isMultipleAdvertisementSupported()

But unfortunately this didn't resolve it for me.

Can't get example app to work

Hi Rand,
for some reason I can't get your example app to work. It shows the "Central role" screen only, but I'm sure I've previously seen the footer with "Peripherals" & "Log" as well. Also, non of the buttons triggers an action. I'm working on Android. Any guess what I've might done wrong?

Thanks,
Jens

screen shot 2016-03-14 at 09 53 20

operation unsupported

cordova bluetoothle all operation return this error:
error:{
"error":"unsupported","message":"operation unsupported"
}
what is soluction

Start advertising not working iOS

Hi All,

I'm trying to start advertising but I not able to receive callback, no error returned either from Safari Ispector either xCode inside the obj-c the plugin...

I'm testing it in iPhone 6 (iOs 9,3) and iPhone 5s (iOs 9.3.3)

I've tried a lot of times, the scan method work perfectly....

And another question... what is the diffrence between bluetoothle.initialize and initializePeripheral???


  .service('$lbeservice', function ($config, $http, $cordovaBluetoothLE) {
    return {

      uuid: null,

      init: function (uuid) {

        this.uuid = uuid;

        $this = this;

        $cordovaBluetoothLE.initialize({"request": true}).then(null,
          function(obj) {
            alert("ERRORE");
          },
          function(obj) {
            alert("INIT SUCCESS");
            $this.broadcast();
          }
        );
      },


      broadcast: function(){

        var params = {
          services: [this.uuid ],
          service: this.uuid
         };

        $cordovaBluetoothLE.startAdvertising(params).then(
          function(obj) {
            alert("START ADVERTISING SUCCESS: " + JSON.stringify(obj));
          },
          function(obj) {
            alert("START ADVERTISING ERROR: " + JSON.stringify(obj));
        });
      }


    };
  })

Many Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.