Use from obniz-noble

noble is an open source BLE stack library created for Nodejs.

We support BLE with obniz.js, and we also publish the obniz-noble project.
obniz-noble allows remote operation of BLE gateways with obnizOS, while retaining the normal noble program. (The only difference from official noble is that you need to use obniz-noble and obnizID).

Installation

In the case of Nodejs

If it's Nodejs, install obniz-noble instead of noble.

npm install obniz-noble

Then we instantiate the noble using obnizID.

var obnizNoble = require('obniz-noble')
var noble = obnizNoble("OBNIZ_ID_HERE")  // or  var noble = obnizNoble("OBNIZ_ID_HERE", {obnizOptions})

In the case of a browser

If you are using a browser, take the following Script and instantiate it.

<script src="https://unpkg.com/obniz-noble/obniz-noble.js" crossorigin="anonymous"></script>
<script>
  var noble = obnizNoble("OBNIZ_ID_HERE")
</script>

Example program (scan)

The following is a sample code when the BLE scan is performed most easily.

noble.startScanning(); // any service UUID, no duplicates

noble.on('discover', function(peripheral) {
  console.log('Found device with local name: ' + peripheral.advertisement.localName);
  console.log('advertising the following service uuid\'s: ' + peripheral.advertisement.serviceUuids);
  console.log();
});

To learn how to use noble, please visit the official noble website or obniz-noble. For more information about connections, services, and characteristics, please follow the noble official operating instructions.

Github