Git Product home page Git Product logo

ble's Introduction

@nativescript-community/ble

Downloads per month NPM Version

Connect to and interact with Bluetooth LE peripherals.


Table of Contents

Installation

Run the following command from the root of your project:

ns plugin add @nativescript-community/ble

API

Want to dive in quickly? Check out the demo app! Otherwise, mix and match these functions as you see fit:

Prerequisites

Discovery

Connectivity

Interaction

Debugging

isBluetoothEnabled

Reports if bluetooth is enabled.

// require the plugin
import { Bluetooth } from '@nativescript-community/ble';
var bluetooth = new Bluetooth();

bluetooth.isBluetoothEnabled().then(
  function(enabled) {
    console.log("Enabled? " + enabled);
  }
);

Permissions (Android)

On Android >= 6 and < 12 you need to request permissions to be able to interact with a Bluetooth peripheral (when the app is in the background) when targeting API level 23+. You need BLUETOOTH and ACCESS_FINE_LOCATION. You should read the doc here

On android >= 12 you need new permissions. You should read the doc here Note that for BLUETOOTH and BLUETOOTH_ADMIN you don't require runtime permission; adding those to AndroidManifest.xml suffices.

Note that hasLocationPermission will return true when:

  • You're running this on iOS, or
  • You're targeting an API level lower than 23, or
  • You're using a device running Android < 6, or
  • You've already granted permission.
bluetooth.hasLocationPermission().then(
  function(granted) {
    // if this is 'false' you probably want to call 'requestLocationPermission' now
    console.log("Has Location Permission? " + granted);
  }
);

requestLocationPermission

Since plugin version 1.2.0 the startScanning function will handle this internally so it's no longer mandatory to add permission checks to your code.

// if no permission was granted previously this will open a user consent screen
bluetooth.requestLocationPermission().then(
  function(granted) {
    console.log("Location permission requested, user granted? " + granted);
  }
);

enable (Android only)

The promise will be rejected on iOS

// This turns bluetooth on, will return false if the user denied the request.
bluetooth.enable().then(
  function(enabled) {
    // use Bluetooth features if enabled is true 
  }
);

startScanning

A few of the optional params require a bit of explanation:

seconds

Scanning for peripherals drains the battery quickly, so you better not scan any longer than necessary. If a peripheral is in range and not engaged in another connection it usually pops up in under a second. If you don't pass in a number of seconds you will need to manually call stopScanning.

avoidDuplicates

Set this to true if you don't want duplicates with the same serviceUUID reported in "onDiscovered" callback. If true, only the first discovered peripheral with the same serviceUUID will be reported.

skipPermissionCheck

Set this to true if you don't want the plugin to check (and request) the required Bluetooth permissions. Particularly useful if you're running this function on a non-UI thread (ie. a Worker). Relevant on Android only.

filters

It's inefficient to scan for all available Bluetooth peripherals and have them report all services they offer. Moreover on Android if we don't use filters we must have location permissions and have GPS enabled

If you're only interested in finding a heartrate peripheral for instance, pass in service UUID '180d' like this: filters: [{serviceUUID:'180d'}]. If you add 2 or more (comma separated) services then only peripherals supporting ALL those services will match.

Note that UUID's are ALWAYS strings; don't pass integers.

onDiscovered

While scanning the plugin will immediately report back uniquely discovered peripherals.

This function will receive an object representing the peripheral which contains these properties (and types):

  • UUID: string
  • name: string
  • RSSI: number (relative signal strength, can be used for distance measurement)
  • services?: (optional - this is set once connected to the peripheral)
  • manufacturerId?: number (optional)
  • advertismentData?: { localName?:string manufacturerData?: ArrayBuffer; serviceUUIDs?: string[]; txPowerLevel?:number, flags?:number } (optional)
bluetooth.startScanning({
  filters: [{serviceUUID:'180d'}],
  seconds: 4,
  onDiscovered: function (peripheral) {
  	console.log("Periperhal found with UUID: " + peripheral.UUID);
  }
}).then(function() {
  console.log("scanning complete");
}, function (err) {
  console.log("error while scanning: " + err);
});

stopScanning

At any time during a scan, being one where you passed in a number or seconds or not, you can stop the scan by calling this function.

You may for instance want to stop scanning when the peripheral you found in startScanning's onDiscovered callback matches your criteria.

bluetooth.stopScanning().then(function() {
  console.log("scanning stopped");
});

connect

Pass in the UUID of the peripheral you want to connect to and once a connection has been established the onConnected callback function will be invoked. This callback will received the peripheral object as before, but it's now enriched with a services property. An example of the returned peripheral object could be:

  peripheral: {
    UUID: '3424-542-4534-53454',
    name: 'Polar P7 Heartrate Monitor',
    RSSI: '-57',
    services: [{    
      UUID: '180d',
      name: 'Heartrate service',
      characteristics: [{
        UUID: '34534-54353-234324-343',
        name: 'Heartrate characteristic',
        properties: {
          read: true,
          write: false,
          writeWithoutResponse: false,
          notify: true
        }
      }]
    }]
  }

Here's the connect function in action with an implementation of onConnected that simply dumps the entire peripheral object to the console:

bluetooth.connect({
  UUID: '04343-23445-45243-423434',
  onConnected: function (peripheral) {
  	console.log("Periperhal connected with UUID: " + peripheral.UUID);

  	// the peripheral object now has a list of available services:
  	peripheral.services.forEach(function(service) {
  	  console.log("service found: " + JSON.stringify(service));
   });
  },
  onDisconnected: function (peripheral) {
  	console.log("Periperhal disconnected with UUID: " + peripheral.UUID);
  }
});

Also note that onDisconnected function: if you try to interact with the peripheral after this event you risk crashing your app.

disconnect

Once done interacting with the peripheral be a good citizen and disconnect. This will allow other applications establishing a connection.

bluetooth.disconnect({
  UUID: '34234-5453-4453-54545'
}).then(function() {
  console.log("disconnected successfully");
}, function (err) {
  // in this case you're probably best off treating this as a disconnected peripheral though
  console.log("disconnection error: " + err);
});

read

If a peripheral has a service that has a characteristic where properties.read is true then you can call the read function to retrieve the current state (value) of the characteristic.

The promise will receive an object like this:

{
  value: <ArrayBuffer>, // an ArrayBuffer which you can use to decode (see example below)
  ios: <72>, // the platform-specific binary value of the characteristic: NSData (iOS), byte[] (Android)
  android: <72>, // the platform-specific binary value of the characteristic: NSData (iOS), byte[] (Android)
  characteristicUUID: '434234-234234-234234-434'
}

Armed with this knowledge, let's invoke the read function:

bluetooth.read({
  peripheralUUID: '34234-5453-4453-54545',
  serviceUUID: '180d',
  characteristicUUID: '3434-45234-34324-2343'
}).then(function(result) {
  // fi. a heartrate monitor value (Uint8) can be retrieved like this:
  var data = new Uint8Array(result.value);
  console.log("Your heartrate is: " + data[1] + " bpm");  
}, function (err) {
  console.log("read error: " + err);
});

write

If a peripheral has a service that has a characteristic where properties.write is true then you can call the write function to update the current state (value) of the characteristic.

The value may be a string or any array type value. If you pass a string you should pass the encoding too

bluetooth.write({
  peripheralUUID: '34134-5453-4453-54545',
  serviceUUID: '180e',
  characteristicUUID: '3424-45234-34324-2343',
  value: [1]
}).then(function(result) {
  console.log("value written");
}, function (err) {
  console.log("write error: " + err);
});

writeWithoutResponse

Same API as write, except that when the promise is invoked the value has not been written yet; it has only been requested to be written an no response will be received when it has.

startNotifying

If a peripheral has a service that has a characteristic where properties.notify is true then you can call the startNotifying function to retrieve the value changes of the characteristic.

Usage is very much like read, but the result won't be sent to the promise, but to the onNotify callback function you pass in. This is because multiple notifications can be received and a promise can only resolve once. The value of the object sent to onNotify is the same as the one you get in the promise of read.

bluetooth.startNotifying({
  peripheralUUID: '34234-5453-4453-54545',
  serviceUUID: '180d',
  characteristicUUID: '3434-45234-34324-2343',
  onNotify: function (result) {
    // see the read example for how to decode ArrayBuffers
	console.log("read: " + JSON.stringify(result));
  }  
}).then(function() {
  console.log("subscribed for notifications");
});

stopNotifying

Enough is enough. When you're no longer interested in the values the peripheral is sending you do this:

bluetooth.stopNotifying({
  peripheralUUID: '34234-5453-4453-54545',
  serviceUUID: '180d',
  characteristicUUID: '3434-45234-34324-2343'
}).then(function() {
  console.log("unsubscribed for notifications");
}, function (err) {
  console.log("unsubscribe error: " + err);
});

Examples:

  • Basic
    • A basic example showing that overriding N gestures works, even in modals

Demos and Development

Repo Setup

The repo uses submodules. If you did not clone with --recursive then you need to call

git submodule update --init

The package manager used to install and link dependencies must be pnpm or yarn. npm wont work.

To develop and test: if you use yarn then run yarn if you use pnpm then run pnpm i

Interactive Menu:

To start the interactive menu, run npm start (or yarn start or pnpm start). This will list all of the commonly used scripts.

Build

npm run build.all

WARNING: it seems yarn build.all wont always work (not finding binaries in node_modules/.bin) which is why the doc explicitly uses npm run

Demos

npm run demo.[ng|react|svelte|vue].[ios|android]

npm run demo.svelte.ios # Example

Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in demo-[ng|react|svelte|vue] Instead you work in demo-snippets/[ng|react|svelte|vue] You can start from the install.ts of each flavor to see how to register new demos

Contributing

Update repo

You can update the repo files quite easily

First update the submodules

npm run update

Then commit the changes Then update common files

npm run sync

Then you can run yarn|pnpm, commit changed files if any

Update readme

npm run readme

Update doc

npm run doc

Publish

The publishing is completely handled by lerna (you can add -- --bump major to force a major release) Simply run

npm run publish

modifying submodules

The repo uses https:// for submodules which means you won't be able to push directly into the submodules. One easy solution is t modify ~/.gitconfig and add

[url "ssh://[email protected]/"]
	pushInsteadOf = https://github.com/

Questions

If you have any questions/issues/comments please feel free to create an issue or start a conversation in the NativeScript Community Discord.

Demos and Development

Repo Setup

The repo uses submodules. If you did not clone with --recursive then you need to call

git submodule update --init

The package manager used to install and link dependencies must be pnpm or yarn. npm wont work.

To develop and test: if you use yarn then run yarn if you use pnpm then run pnpm i

Interactive Menu:

To start the interactive menu, run npm start (or yarn start or pnpm start). This will list all of the commonly used scripts.

Build

npm run build.all

WARNING: it seems yarn build.all wont always work (not finding binaries in node_modules/.bin) which is why the doc explicitly uses npm run

Demos

npm run demo.[ng|react|svelte|vue].[ios|android]

npm run demo.svelte.ios # Example

Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in demo-[ng|react|svelte|vue] Instead you work in demo-snippets/[ng|react|svelte|vue] You can start from the install.ts of each flavor to see how to register new demos

Contributing

Update repo

You can update the repo files quite easily

First update the submodules

npm run update

Then commit the changes Then update common files

npm run sync

Then you can run yarn|pnpm, commit changed files if any

Update readme

npm run readme

Update doc

npm run doc

Publish

The publishing is completely handled by lerna (you can add -- --bump major to force a major release) Simply run

npm run publish

modifying submodules

The repo uses https:// for submodules which means you won't be able to push directly into the submodules. One easy solution is t modify ~/.gitconfig and add

[url "ssh://[email protected]/"]
	pushInsteadOf = https://github.com/

Questions

If you have any questions/issues/comments please feel free to create an issue or start a conversation in the NativeScript Community Discord.

ble's People

Contributors

aaayushsingh avatar bapowell avatar bradmartin avatar catchabus avatar dbenninger avatar eddyverbruggen avatar facetious avatar farfromrefug avatar iesrbt avatar ivanzorcic avatar keerl avatar prabudevarrajan avatar rynop avatar sebawita avatar sebj54 avatar secreto31126 avatar sis0k0 avatar softwaregravy avatar springltd avatar t4deon avatar two-bridges avatar xinthose 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

ble's Issues

NullPointerException in Android when used with Workers

Hello, I have successfully Integrated this library in my demo project. It works as expected for connecting, writing, reading etc.

Then I tried to pull all the code into worker thread as In Android, we put BLE communication code into background thread.

Here's my implementation:

require("globals");
var bluetooth = require("nativescript-bluetooth");

global.onmessage = function (msg) {
if (msg.data == "START") {
  bluetooth.startScanning({
//.....properies & call back goes here
});
}
}

But it gives following error in Worker thread

JS: Error in Bluetooth.startScanning: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object reference
JS:     android.support.v4.content.ContextCompat.checkSelfPermission(ContextCompat.java:453)
JS:     com.tns.Runtime.WorkerGlobalOnMessageCallback(Native Method)
JS:     com.tns.Runtime.access$400(Runtime.java:33)
JS:     com.tns.Runtime$WorkerThreadHandler.handleMessage(Runtime.java:233)
JS:     android.os.Handler.dispatchMessage(Handler.java:102)
JS:     android.os.Looper.loop(Looper.java:158)
JS:     android.os.HandlerThread.run(HandlerThread.java:61)

So am I missing something or currently there is no support for Worker Threads?

value of WriteOptions missing

in bluetooth.d.ts is the value missing in interface WriteOptions.
Currently, it is:
export interface WriteOptions extends CRUDOptions {}

But it needs to be:
export interface WriteOptions extends CRUDOptions {
value: any;
}

I would push the change to a new branch but I'm not authorized to do so.
It would be great if you could apply the change. Thanks in advance.

Update interface while searching device

Hello,
I couldn't figure out how to update view while searching device.
Here is my code
searching device function:

app.component.ts

log: string = "Start test";
startScanning() {
        ble.startScanning({
            serviceUUIDs: [],
            seconds: 5,
            onDiscovered: (peripheral) => {
                if (peripheral.name == "SWING") {
                    this.stopScanning();
                    this.updateLog(`Device Name: ${peripheral.name}`); //Update view
                }
        }).then(() => {
            this.updateLog("scanning completed");
        }, (err) => {
            console.error(`Error on scanning: ${err}`);
        })
    }

app.component.html

 <TextView text="{{ log }}" editable="false"></TextView>

While it scanning, it won't update the log to the view before 5 seconds which finishes the ble.startScanning.
I believe that I do not fully understand RxJs (Promise) functionality, so I couldn't figure out this issue.

Thank you.

Use this module for peripheral devices?

Hi,

First of all, thank you for this great module!

I'm new to BLE sphere, so sorry if my wish is out of scope: is there any chance to extend this plugin to peripheral devices? I successfully exchanged data between my macbook as a peripheral (thanks to Bleno nodejs module) and my phone as a central (thanks to guess who...), now I would like to go to phone-phone interactions.

Thanks again,

Sébastien

Bluetooth.startNotifying() returns immediately

This is similar to issue #62.

startNotifying() calls gatt.writeDescriptor() then calls resolve() right away. I think it should wait and call resolve() from onDescriptorWrite() instead.

The case I have is a Blood Pressure device that only starts sending data after you start listening to two different characteristics. This requires two calls to Bluetooth.startNotifying(), but the second one fails unless you wait for the first one to call onDescriptorWrite()

ios: isBluetoothEnabled returns false even bluetooth is on

I have had situations where isBluetoothEnabled() returns false even phone bluetooth is on.

Switching bluetooth off and on does not help. Restarting phone does not help.

Tested with version 1.1.2 & 1.1.3.

Problem has occurred with iPhone 5s & 6s.

Uint8Array as write value doesn't work on Android 6.0.1

When I try to pass the value as an Uint8Array to call writeWithoutResponse function, the command doesn't seem to be processed correctly.
However the same value presented as a string works fine.

Here is an example (the commented out line is for the code that works):

bluetooth.writeWithoutResponse({
	serviceUUID: this.serviceUUID,
	characteristicUUID: this.characteristicUUID,
	peripheralUUID: this.deviceUUID,
	// value: '0x71,0x20,0x40'
	value: new Uint8Array([0x71, 0x20, 0x40])
})

When I tried to manually adapt the steps of Bluetooth._encodeValue to copy the contents of my Uint8Array - like below - then the instruction seems to be processed just fine.

  var result = Array.create("byte", parts.length);

  for (var i=0; i<val.length; i++) {
    result[i] = val[i];
  }
  return result;

Am I using the Uint8Array in a wrong way? This is the way I am used to use it with Web Bluetooth ;)

onConnected callback not called on iOS

Hej, I'm writing a plugin which utilizes nativescript-bluetooth and I ran into an issue on iOS, where the onConnected callback is not triggered after the connection to a peripheral is established. About 20 seconds after the connections is established the peripheral is disconnected. The same behavior appears with the demo app.

iOS Versions tested: 10.1.1, 10.3.1
Xcode Version: 8.3.3

Here's the console log of the demo app:

CONSOLE LOG file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:239:16: ----- delegate centralManager:didDiscoverPeripheral: BOT @ -35
CONSOLE LOG file:///app/main-view-model.js:41:16: !!&&&&***** Clicked item with index 0
CONSOLE LOG file:///app/main-view-model.js:43:16: --- peri selected: 77571063-AFD5-4F8D-BE5E-E0A108938FF4
CONSOLE LOG file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:426:20: Connecting to peripheral with UUID: 77571063-AFD5-4F8D-BE5E-E0A108938FF4
CONSOLE LOG file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:264:16: ----- delegate centralManager:didConnectPeripheral: <CBPeripheral: 0x1702ea280, identifier = 77571063-AFD5-4F8D-BE5E-E0A108938FF4, name = BOT, state = connected>
CONSOLE LOG file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:268:16: ----- delegate centralManager:didConnectPeripheral: cached perio: <CBPeripheral: 0x1702ea280, identifier = 77571063-AFD5-4F8D-BE5E-E0A108938FF4, name = BOT, state = connected>
CONSOLE LOG file:///app/tns_modules/nativescript-bluetooth/bluetooth.js:275:16: ----- delegate centralManager:didConnectPeripheral, let's discover service

The demo app was build with following versions:

node: 6.10.1
nativescript: 3.1.3
tns-core-modules: 3.1.1
tns-android: 3.1.1
tns-ios: 3.1.0 

In my plugin I've tested this with nativescript-bluetooth version 1.1.6 and 1.2.0
Here's a part of the package.json:

{
  ...
  "nativescript": {
    "platforms": {
      "android": "3.0.0",
      "ios": "3.0.0"
    }
  },
  ...
  "dependencies": {
    "nativescript-bluetooth": "1.1.6",
    "nativescript-platform": "^1.1.1",
    "nativescript-zip": "^1.3.2"
  },
  "devDependencies": {
    "tns-core-modules": "~3.0.0",
    "tns-platform-declarations": "^3.0.1",
    "typescript": "~2.2.1",
    "prompt": "~1.0.0",
    "rimraf": "~2.5.0"
  }
}

The app in which I'm using my plugin was build with:

node: 6.10.1
nativescript: 3.1.3
tns-core-modules: 3.0.1
tns-android: 3.0.0
tns-ios: 3.0.1

The console log is identical to the log of the demo app (except the lines of the view-model of course).

On Android everything is working fine.

Any idea how to solve this? Could version conflicts be the cause?
Thanks in advance!

Bluetooth Hands Free Profile

Can I use this lib to connect a Headset or something to my App, or do I need a different approach to archive that?

I am really new to Bluetooth.

Thanks in advance.

serviceUUID and characteristicUUIDunknown

hello,

i have got a HM-10 BLE device, when i connect i have no services in the peripheral properties, i just need to send a character like "a" or "b", how can I make it works?
this is the scancallback result:

Lollipop+ scanCallback result: {"type":"scanResult","UUID":"50:8C:B1:6A:7C:AB","name":"HMSoft","RSSI":-71,"
state":"disconnected","advertisement":"AgEGCf9ITVCMsWp8qwcWALAAAAAAAwLg/wIKAAcJSE1Tb2Z0AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAA=","manufacturerId":19784,"manufacturerData":{}}

i have found on this site these services:
http://blog.blecentral.com/2015/05/05/hm-10-peripheral/
Service UUID: 0000ffe0-0000-1000-8000-00805f9b34fb) that enables bidirectional communication between the module and any other central device that connects to it. The service defines a single characteristic (Characteristic UUID: 0000ffe1-0000-1000-8000-00805f9b34fb)
so if I try to connect and write the ascii for "a" I have this result:
Connecting to peripheral with UUID: 50:8C:B1:6A:7C:AB
JS: ------- _MyGattCallback.onConnectionStateChange, status: 0, new state: 2
JS: ---- discovering services..
JS: ------- _MyGattCallback.onConnectionStateChange, status: 8, new state: 0
JS: ----- invoking disc cb
JS: Periperhal disconnected with UUID: 50:8C:B1:6A:7C:AB

someone have ever worked with this device? where am i wrong?

thank you

NativeScript Angular Support?

Hello,

I am looking for a way to use this plugin on an app built with NativeScript Angular, but it seems very tricky to me. I suppose that it's definitely possible. Has anyone done it successfully?

Android write value as it is

Hi
I am making an android app which is communicating with a "Health monitor".

To access raw data notification service I need to write a specific string (password) to a characteristic.

The issue comes at "Bluetooth._encodeValue" method, which sees what value is a string without "x" and it returns null.

I added extra argument "passRaw" to the write method in my local copy and everything works just fine.
I wonder, is there is any other way to write a string?

that my solution:

 bluetooth.write({
            peripheralUUID: peripheral.UUID,
            serviceUUID: service.UUID,
            characteristicUUID: characteristic.UUID,
            value: pass,
            passRaw: true

and bluetooth.android.js:693

var val = arg.passRaw ? arg.value : Bluetooth._encodeValue(arg.value);

Structure of peripheral object seems to differ between iOS and Android

On iOS, from what I see in the code, a "peripheral" object appears to have the structure

{
    UUID: ...,
    name: ...,
    RSSI: ...,
    state: ...
}

while on Android I see

{
    type: ...,
    RSSI: ...,
    device: {
        name: ...,
        address: ...
    },
    advertisement: ...
}

where UUID and address appear to be used synonymous in regard to consecutive actions like service discovery.

I would expect the structure to be identical regardless of OS.

getAdapter return null, use of a promise to init Bluetooth.

I'm starting to study the plugin for use of Bluetooth.

Unfortunately I discovered that the tablet I have does not have bluetooth, so when I initialize the plugin I get an exception, since the getAdapter function returns null.

Given this I would suggest that this plugin's start point would be a 'Promise' something like:

Bluetooth.init = function() {
  return new Promise(function(resolve, reject) { 
      var bluetoothManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.BLUETOOTH_SERVICE);
      adapter = bluetoothManager.getAdapter();
      if(adapter === null) {
         reject("this device not have bluetooth!");
         return;
       }
       //......
  });
}; 

And this initialization was controlled by the application, so we would have access to the 'then' and 'cath' functions to take some action so the application did not break.

Bluetooth enabled failing

I've tried adding this plugin to an iOS app for an iPad (9.3.5) and whenever I run isBlueToothEnabled(), I get back false. I then installed the demo app https://github.com/EddyVerbruggen/nativescript-bluetooth-demo on the same device and am getting that it is not enabled there as well. My bluetooth is definitely enabled and it works as I am able to pair with a device using a different app (not one I developed).

iOS - advertising data

Currently raw advertising data is available only on android.

A short googling showed me, that iOS do not provide raw advertising data, but it is possible to get at least:
CBAdvertisementDataManufacturerDataKey
CBAdvertisementDataServiceDataKey
(https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManagerDelegate_Protocol/#//apple_ref/doc/constant_group/Advertisement_Data_Retrieval_Keys)

I want to start a discussion here about how nativescript-bluetooth API can look, to allow accessing adv data on iOS.

1st tought:
just add manufacturerData and serviceData properties to onDiscovered callback, so on android we will have:

{
  ...,
  advertisement: String,
  manufacturerData: String,
  serviceData: String
}

and on iOS

{
  ...,
  manufacturerData: String,
  serviceData: String
}

Application which I want to implement with {N} and {N}-bluetooth should use manufacturerData to update device state (like ON/OFF) without connection.

Android startNotifying questions

Just wondering..

About line 780:
console.log("Characteristic " + characteristicUUID + " does not have NOTIFY or INDICATE property set");

shouldn't it rather be:
reject("Characteristic " + characteristicUUID + " does not have NOTIFY or INDICATE property set");
return;

About lines 770, 771:
reject("Set notification failed for " + characteristicUUID);
return;

It seems some peripheral do no provide the descriptor even though they announce the characteristic is notifiable in the properties array. Does it make sense to instead do:

bluetoothGattDescriptor=new android.bluetooth.BluetoothGattDescriptor(clientCharacteristicConfigId, android.bluetooth.BluetoothGattDescriptor.PERMISSION_WRITE);
bluetoothGattCharacteristic.addDescriptor(bluetoothGattDescriptor);
console.log("BluetoothGattDescriptor created...")

At least that allowed me to be notified ;-)

Anyway, thanks for your plugin!

startScanning with serviceUUIDs doesn't return any values

I am using an Android 6.0.1 device (Samsung S6 edge+) and NativeScript 2.5.

I am trying to use startScanning function with serviceUUIDs parameter? However I don’t seem to be able to make it to work.
Whenever I provide serviceUUIDs I get 0 results

bluetooth.startScanning({
	seconds: 3,
	serviceUUIDs: ['ffe5'],
	// serviceUUIDs: ['0000ffe5-0000-1000-8000-00805f9b34fb'],
	onDiscovered: (peripheral: Peripheral) => {
		console.log(`UUID: ${peripheral.UUID} name: ${peripheral.name}`)
	}
})

I am certain that my device has a ffe5 service, as this is the service I use for sending instructions to it.

However when I use the same serviceUUIDs with web bluetooth in a web project it seems to work. So I assume that my serviceUUIDs are correct.

I’ve tried to use both a short notation serviceUUIDs: ['ffe5'] and a long one serviceUUIDs: ['0000ffe5-0000-1000-8000-00805f9b34fb'] neither seems to work

Background Support

Hi Eddy,

For a project I am doing, I need to enable background BLE updates. On Android, you seem to just create a generic background service and then pass the ble updates into in - here but for ios it seems to require authorizing the Bluetooth updates to persist in the background - Docs

I had hoped to create a generic background-service plugin, but the ios approach seems to make that difficult, so I wondered if you wanted to add background support to your app? I am more than happy to help. Alternatively, I could make a separate plugin. Let me know what you think would be best.

Develop and Use the plugin with Sony Xperia C SDK 4.2.2

Hello

I have a Xperia C that empowered with an Android Jelly Beans MR 1 (SDK 17 - 4.2.2) and with Bluetooth.

However the nativescript-bluetooth plugin does not work with it because of the SDK 4.2.2, I would like to study the implementation of such functionality in a retroactive way to make the plugin compatible with these phones, in Brazil there are many Bluetooth-enabled phones but versions of the previous SDK 4.3.

What do they suggest as a starting point, I tried to search about the use of the NativeScript-core-modules / Utils getService () function but I did not find enough material.

Grateful.
ps: See #42

ServiceUUID for BT data logger and humidity sensor

Hello,

I am trying to get sensor data from the below Bluetooth data logger.
https://www.bluemaestro.com/product/tempo-disc-temperature-humidity-data-logger/
https://www.bluemaestro.com/wp-content/uploads/2016/10/Temperature-Humidity-Data-Logger-Commands-API.pdf

It has this BT Chipset I believe.
http://infocenter.nordicsemi.com/pdf/nRF52832_PB_v1.4.pdf

Using the Nativescript Bluetooth Demo app I can see the Datalogger and connect to it, but it doesn't seem to read any characteristic data from the BT device. It only has 1 service which has a Notify and Write characteristics.

You have mentioned reading data from a Heartrate ServiceUUID but how can one get the logged data from this BlueMaestro tempo disc?

BlueMaestro has a utility app for ios that can read the data from the data loggers. It also has an SDK to develop upon, but it is native iOS code and I would like to develop in Nativescript using your plugin :)
App called BlueMaestro Tempo Utility
SDK: https://github.com/BlueMaestro/IOS-Tempo-Utility-App-SDK/blob/master/README.md

Any help or guidance would be greatly appreciated.

Many thanks,
Brian

Provide a way to toggle console logging.

Hello,

I have an app that produces a ton of bluetooth traffic (it's transferring a devices firmware over bluetooth) and on ios, the console actually completely freezes and detaches due to excessive console logging. I've tested disabling console logging in bluetooth.android.js and bluetooth.ios.js and have seen the issue disappear.

I can see how console logging could be useful, but we should provide a way to either enable or disable it.

Would you be accepting to a pull request with some way to toggle debug output on or off?

Crashlytics issues

I use Crashlytics and am getting the following two crash reports. I've attached the full stack trace for both. I'm not able to get to the bottom of what could cause this.


_Fatal Exception: com.tns.NativeScriptException:
Calling js method run failed

TypeError: Cannot read property 'stopScan' of null
File: "file:///data/data/za.co.digitlab.GFConnect/files/app/tns_modules/nativescript-bluetooth/bluetooth.js, line: 478, column: 45_


_Fatal Exception: com.tns.NativeScriptException:
Calling js method onServicesDiscovered failed

TypeError: Cannot read property 'onConnected' of undefined
File: "file:///data/data/za.co.digitlab.GFConnect/files/app/tns_modules/nativescript-bluetooth/bluetooth.js, line: 257, column: 17_

za.co.digitlab.gfconnect_issue_1_crash_59E919A3031500011E5F0FFAB83B7D8C_f8b36b5ab51811e78fd856847afe9799_0_v2.txt
za.co.digitlab.gfconnect_issue_1_crash_59E8A30A00F6000125FDF227511FBFCE_0b68a7cab51811e78fd856847afe9799_0_v2.txt

Should NSData be an ArrayBuffer?

I am starting to do more work with my BLE-to-serial adapter. When I catch the notify event, I am expecting binary data. My return type appears to be NSData. Should this be marshaled to an ArrayBuffer? I'm not sure what is the best way to handle binary data on the iOS side.

Not detecting any devices

I've been testing the plugin for a while on my app for my phone that's running Android 6.0, but I haven't been able to get it to show that it can detect the bluetooth devices in my vicinity (my laptop).

  • I made sure to request permission to use location
  • I made sure bluetooth is enabled
  • no other bluetooth devices are connected to the phone
  • initiated scan, defined a callback to be called when onDiscovered happens
  • added a .then() clause with a callback to see if perhaps after the scan something would come up out of th bluetooth._connections object. None.

👐

writeWithoutResponse() returns too quickly on Android

I used your Cordova plugin to talk to a AnD BLE scale with success.

Now porting the app over to NativeScript and using this plugin.

Ran into a problem on Android using writeWithoutResponse(). The old plugin waited for onCharacteristicWrite() to be called before calling the success callback. This plugin returns immediately.

Now when starting another BLE call after writeWithoutResponse() returns it fails.

I changed writeWithoutResponse() to use the same logic as write(), setting the onWritePromise, and it all works perfectly.

Callback for every adv packet

There can be a use case in which app can be interested in all adv packets.

I propose adding a new, optional callback to bluetooth.startScanning:

let scanningOptions = {
  onScanResult: (peripheral) => {...}, //event name is to be discussed
  onDiscovered: (peripheral) => {...},
  seconds: 0
}

bluetooth.startScanning(scanningOptions);

This way the app can f.e.:

  • maintain currently visible devices list and show their RSSI "in realtime"
  • for now on Android only: update found device presentation basing on adv manufactured data

Subscribing to characteristic changes question

Is there a way to subscribe to changes to a characteristic? I'm working with a NFC device that reads tags that is communicating with my app over bluetooth and am attempting to setup a stream where my app will continuously read tag data being sent by the NFC device.

Right now I have it setup so I'm just continuously doing reads (using the .read w/ the peripheral id, service id, and characteristic id) at a really small interval (10 milliseconds) and am getting empty data: {"type":"read","characteristicUUID":"CACC07FF-FFFF-4C48-8FAE-A9EF71B75E26","valueRaw":{},"value":{}} and converting value to a Uint8Array as in one of the examples gets me:{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0}

I know my write commands are working and that the NFC device is transmitting the tag data due to visual cues on the device, so I'm just struggling to get the data read properly and I'm wondering if the issue is because of these random-interval-reads as opposed to a subscription

Device not detected

When I try to run the demo app in my phone "Redmi Note 3" Android version "6.0.1", I am not able to detect any other device, provided both the location and bluetooth are enabled in all the devices. Kindly help.

Incorrect Characteristics being read ?

I have a Bluetooth module which is broadcasting a custom BLE service. I have been using the LightBlue iOS app to debug. This is showing the results I expect:
enter image description here
However, when using your plugin and then your demo app, I have found it is showing a different service on the exact same service, on the same device. Why is this?

See below:
enter image description here

Enable Bluetooth directly from app.

Right now, this only supports checking if Bluetooth is enabled or not. It'd be great if it allowed turning on Bluetooth from within the application. This way, the user wouldn't have to do it manually.

onNotify never calls its callback

Hello, I'm writing the bluetooth communication part of an app with several other people, and I've been struggling for quite some time now so that's why I'm opening this issue here hoping someone can help !

I'm connecting to a peripheral that has a UART over BLE service, so I'm subscribing to notifications on the TX characteric of the UART service (and the logs correctly reports that notify is TRUE) but when I write values on the RX characteristic, I never receive anything while I should be receiving something (I'm sending an HEX command that works perfectly in native android code or also on cordova...).

Here is how I subscribe to notifications (notifications subscription works as I said earlier as I'm correctly seeing in the console JS: --- notifying - this is on Android, but works also on iOS):

public subscribeTXnotification = function () {
    //Subscribe to TX notifications
    console.log("----- Starting TX subscription");
    bluetooth.startNotifying({
      peripheralUUID: this.connectedPeripheral.UUID,
      serviceUUID: this.uartService,
      characteristicUUID: this.txUuid,
      onNotify: this.onData
    }).then(function() {
      console.log("----------- subscribed for notifications of TX Channel");
    });
  }

and the onData callback is here:

public onData = function (data) {
    console.log("read: ", JSON.stringify(data));
  }

You should note that I'm coding using TypeScript and those functions are part of a class.

Example of write call is here:

bluetooth.write(
  {
    peripheralUUID: that.connectedPeripheral.UUID,
    serviceUUID: that.uartService,
    characteristicUUID: that.rxUuid,
    value: '0xAA0400002955', //AA010400C555
  }
).then(
  function(result) {
    console.log("Done: ", JSON.stringify(result));
  },
  function (err) {
    dialogs.alert({
      title: "Whoops!",
      message: err,
      okButtonText: "Hmmkay"
    });
  }
);

Also, I tried on both iOS and Android and I get the same behaviors. Write works without printing any errors in the console but I never receive anything.

onDiscovered returning empty peripheral object

Hello,
I'm trying to implement this plugin in an app using typescript. I used the demo example to see how it working, but when I call my startScanning method, onDiscovered returns an empty peripheral object... no idea why.

here is my code:

bluetooth.startScanning(
  {
    serviceUUIDs: [], // pass an empty array to scan for all services
    seconds: 4, // passing in seconds makes the plugin stop scanning after <seconds> seconds
    onDiscovered: function (peripheral) {
      var obsp = new Observable(peripheral);
      console.log(peripheral);
      that.observablePeripheralArray.push(obsp);
      console.log("final len: ", that.observablePeripheralArray.length);
      console.log(that.observablePeripheralArray);

    }
  }
)

and here is the log:

JS: ---- Lollipop+ scanCallback result: {"type":"scanResult","UUID":"E8:41:48:A7:4C:E7","name":"GIL#B914AF7329C428D4","RSSI":-100,"state":"disconnected","advertisement":"FQlHSUwjQjkxNEFGNzMyOUM0MjhENAIBBQMDDxgRB57K3CQO5angk/OjtQEAQG4AAAAAAAAAAAAAAAAAAAA="}
JS: [object Object]
JS: final len:  1
JS: Observable

Thanks

Android 4.4.2 cannot connect

Hi,

I'm trying to figure out why I cannot connect to my thermal printer on android (ios is working fine). I can scan and get uuid just fine, but on intent of connecting it's just get stuck and thats it, no timeouts nothing. Device is Samsung S3

I tried playing with minSdk and it is set to 21 (tried 17, 19). Just to be sure printer is working I downloaded "Bluetooth Printer" app from the store, and I see the same uuid and can make test print so I asume everything is ok with ble printer.

I started digging and I found several issues related with "who gets first to connect" or something like that. My debugging took me to connectGatt() method, and my printer shows blue light pointgin that maybe device is connected, but services are never returned, so sending something to write gives gatt.getService error.

Thanks

bluetooth not detect devices

hi, i've read the other topic about bluetooth detecting problems, but i still can't resolve it, i'm new in nativescript and mobile programming, this is my discovering function, it works until the enable function, then the
onDiscovered: function (peripheral) { console.log("Periperhal found with UUID: " + peripheral.UUID); }

don't return nothing,
where am i wrong?
exports.bt = function () { bluetooth.isBluetoothEnabled().then( function (enabled) { console.log("Enabled? " + enabled); if (!enabled) { bluetooth.enable().then( function(enabled) { console.log("attivato "+ 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); }); } ); } } ); };
thank you for your help

Can't seem to access observablearray from within ondiscovered function

Hi Eddy

Pretty new to this.
Using typescript.

Here is an excerpt of my code.

import { Observable, fromObject } from "data/observable";
import { ObservableArray }  from "data/observable-array";

import bluetooth = require('nativescript-bluetooth');

let addressList = ["disable", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"];


@Component({
    selector: "ns-items",
    moduleId: module.id,
    templateUrl: "items.component.html",
    styleUrls: ["items-common.css"]
})

//hi
export class ItemsComponent implements OnInit {
    items: Item[];
    public addresses: Array<string>;
    pobjects: ObservableArray<object>;
    hello: string;
    
    // This pattern makes use of Angular’s dependency injection implementation to inject an instance of the ItemService service into this class. 
    // Angular knows about this service because it is included in your app’s main NgModule, defined in app.module.ts.
    constructor(private itemService: ItemService) {
        this.addresses = [];
        for (let i = 0; i < addressList.length; i++) {
            this.addresses.push(addressList[i]);
        }
        this.pobjects = new ObservableArray();
    }

    public onchange(args) {
    }

    public getUUID() {

        //this.pobjects.push(4);
        //console.log(this.pobjects.getItem(0));
        console.log(this.hello);   
        bluetooth.startScanning({
            serviceUUIDs: [],
            seconds: 4,
            onDiscovered: function(peripheral) {
                console.log("Peripheral found with UUID: "+ peripheral.UUID);                       
            }
        }).then(function(){
            console.log("scanning complete");
        }, function(err) {
            console.log("error while scanning: "+err);
        })
    }

The problem is in the following area:
Whenever a button is pressed getUUID is called which starts scanning.
What I want to do is push peripherals found into my pobjects observable array
But whenever I put this.pobjects.push(fromObject(peripherals)) into ondiscovered: function(peripheral) it seems to not recognise the object with the following error

JS ERROR typeError: undefined is not an object (evaluating 'this.pobjects.push')

What am I doing wrong?

public getUUID() {

        //this.pobjects.push(4);
        //console.log(this.pobjects.getItem(0));
        console.log(this.hello);   
        bluetooth.startScanning({
            serviceUUIDs: [],
            seconds: 4,
            onDiscovered: function(peripheral) {
                console.log("Peripheral found with UUID: "+ peripheral.UUID);                       
            }
        }).then(function(){
            console.log("scanning complete");
        }, function(err) {
            console.log("error while scanning: "+err);
        })
    }

Adroid 6 - check if location service is enabled

On Android 6, user have to enable location service (Settings -> Location -> On) to make this plugin (And all BLE depended apps) working.

If we have hasCoarseLocationPermission and requestCoarseLocationPermission methods, then, there should be also similar methods for location service.

Or at least it will be good to make a note about this in readme :)

Difference between IOS and Android on connected

Hi,

I get diffent result when Perihicals are connected:
It works perfectly in IOS ("UUID":"E2E4278A-056A-4B22-947D-37010C1FE970"),
but on android ("UUID":"00:1E:C0:2F:EC:03") i get different UUID's. It does not seems logic???

IOS:
Peripheral connected: {"UUID":"E2E4278A-056A-4B22-947D-37010C1FE970","name":"Omega","state":"connected","services":[{"UUID":"12345678-9012-3456-7890-1234567890EE","name":{},"characteristics":[{"UUID":"12345678-9012-3456-7890-123456789000","name":{},"value":null,"properties":{"broadcast":false,"read":true,"broadcast2":false,"read2":true,"write":false,"writeWithoutResponse":true,"notify":true,"indicate":false,"authenticatedSignedWrites":false,"extendedProperties":false,"notifyEncryptionRequired":false,"indicateEncryptionRequired":false},"isNotifying":false},{"UUID":"12345678-9012-3456-7890-123456789001","name":{},"value":"SQE=","properties":{"broadcast":false,"read":false,"broadcast2":false,"read2":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"authenticatedSignedWrites":false,"extendedProperties":false,"notifyEncryptionRequired":false,"indicateEncryptionRequired":false},"isNotifying":false},{"UUID":"12345678-9012-3456-7890-123456789002","name":{},"value":"gQA4AaA5AAAA","properties":{"broadcast":false,"read":false,"broadcast2":false,"read2":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"authenticatedSignedWrites":false,"extendedProperties":false,"notifyEncryptionRequired":false,"indicateEncryptionRequired":false},"isNotifying":false},{"UUID":"12345678-9012-3456-7890-123456789003","name":{},"value":"hwGg","properties":{"broadcast":false,"read":false,"broadcast2":false,"read2":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"authenticatedSignedWrites":false,"extendedProperties":false,"notifyEncryptionRequired":false,"indicateEncryptionRequired":false},"isNotifying":false},{"UUID":"12345678-9012-3456-7890-123456789004","name":{},"value":null,"properties":{"broadcast":false,"read":false,"broadcast2":false,"read2":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"authenticatedSignedWrites":false,"extendedProperties":false,"notifyEncryptionRequired":false,"indicateEncryptionRequired":false},"isNotifying":false}]}]}

Android:
Peripheral connected: {"UUID":"00:1E:C0:2F:EC:03","name":"Omega","state":"connected","services":[{"UUID":"1800","characteristics":[{"UUID":"2a00","name":"2a00","properties":{"read":true,"write":true,"writeWithoutResponse":false,"notify":false,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[]},{"UUID":"2a01","name":"2a01","properties":{"read":true,"write":false,"writeWithoutResponse":false,"notify":false,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[]},{"UUID":"2a04","name":"2a04","properties":{"read":true,"write":false,"writeWithoutResponse":false,"notify":false,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[]}]},{"UUID":"1801","characteristics":[]},{"UUID":"12345678-9012-3456-7890-1234567890ee","characteristics":[{"UUID":"12345678-9012-3456-7890-123456789000","name":"12345678-9012-3456-7890-123456789000","properties":{"read":true,"write":false,"writeWithoutResponse":true,"notify":true,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[{"UUID":"2902","value":null}]},{"UUID":"12345678-9012-3456-7890-123456789001","name":"12345678-9012-3456-7890-123456789001","properties":{"read":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[{"UUID":"2902","value":null}]},{"UUID":"12345678-9012-3456-7890-123456789002","name":"12345678-9012-3456-7890-123456789002","properties":{"read":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[{"UUID":"2902","value":null}]},{"UUID":"12345678-9012-3456-7890-123456789003","name":"12345678-9012-3456-7890-123456789003","properties":{"read":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[{"UUID":"2902","value":null}]},{"UUID":"12345678-9012-3456-7890-123456789004","name":"12345678-9012-3456-7890-123456789004","properties":{"read":false,"write":false,"writeWithoutResponse":false,"notify":true,"indicate":false,"broadcast":false,"authenticatedSignedWrites":false,"extendedProperties":false},"descriptors":[{"UUID":"2902","value":null}]}]}]}

"----- Invoking disc cb" explosion

Once in a while when I try to connect my device to a BLE peripheral (my laptopt, in my case) following the "Connecting" state message, I get an explosion of messages in the format ----- Invoking disc cb which causes the app to freeze. This can also happen when I intentionally disconnect my peripheral from my device, but it's mostly bothering when it happens during the connecting state.

The message seems to originate from here:
https://github.com/EddyVerbruggen/nativescript-bluetooth/blob/81b8ae455e45fa2e2009b7b48e54aff800b1d9f6/bluetooth.android.js#L457

Better Android permission handling

When starting scanning, check for permission, request it, then scan. That last bit is not possible at the moment.

This will make it no longer required for developers to check permissions themselves.

Polling for bluetooth state?

If the user has bluetooth switched off, do we have to poll until the user switches on bluetooth or is there any other way?

Android 5+: Bluetooth.startScanning scanFilters don't work

When passing a service UUID to startScanning() for use as scan filter, no peripheral is found.
This is reproducible on at least two different BT LE capable devices with differing variants of Android 6.

it is probably due to known issues in the BT LE implementation of Android 5/6 as mentioned here: EddyVerbruggen/nativescript-bluetooth-demo#4

In fact I had the same problem when trying this myself some time ago with NativeScript as well as with native Android code (then testing on Android 5.1), following different examples from the web, and at some point decided to rather build a workaround.

I'd be happy if some in-deep Android developer would prove me wrong.
Otherwise, to make startScanning() work as expected and fully cross platform, the only reliable solution seems to be scanning for all devices on Android 5+, doing the filtering as an afterwork in the callback's onScanResult() and from there call onDiscovery() conditionally.

The alternative would be leaving that check to the app developer. But this would violate the cross platform idea and may well result in similar bug reports in the future.

Estimote Beacons, iBeacons

I am attempting to use this module to detect Estimote beacons. The main issue I'm having is with the optional params of the StartScanning function.

bluetooth.startScanning({
serviceUUIDs: [],
seconds: 4,
onDiscovered: function (peripheral) {
console.log("Periperhal found with UUID: " + peripheral.UUID);
}
})

Estimote beacons don't have a serviceUUID, at least none that I could find after looking around. So, I'm not sure how to go about filtering the beacons from the other bluetooth devices being detected by the scanner and I'm not sure how to go about identifying individual beacons.

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.