ssb-mobile-bluetooth-manager
Advanced tools
Comparing version 1.1.0 to 1.1.1
27
index.js
@@ -27,3 +27,3 @@ const net = require('net'); | ||
const nearbyDevicesSource = Pushable(); | ||
let awaitingDevicesCb = null; | ||
@@ -122,6 +122,8 @@ function connect(bluetoothAddress, cb) { | ||
nearbyDevicesSource.push({ | ||
var nearBy = { | ||
lastUpdate: currentTime, | ||
discovered: arguments.devices | ||
}) | ||
} | ||
awaitingDevicesCb(null, nearBy); | ||
} | ||
@@ -188,6 +190,20 @@ | ||
function nearbyDevices() { | ||
return nearbyDevicesSource; | ||
function getLatestNearbyDevices(cb) { | ||
awaitingDevicesCb = cb; | ||
refreshNearbyDevices(); | ||
} | ||
function nearbyDevices(refreshInterval) { | ||
return pull( | ||
pull.infinite(), | ||
pull.asyncMap((next, cb) => { | ||
setTimeout(() => { | ||
getLatestNearbyDevices(cb) | ||
}, refreshInterval) | ||
}) | ||
) | ||
} | ||
function makeDeviceDiscoverable(forTime) { | ||
@@ -210,3 +226,2 @@ console.log("Making device discoverable"); | ||
listenForIncomingConnections, | ||
refreshNearbyDevices, | ||
nearbyDevices, | ||
@@ -213,0 +228,0 @@ makeDeviceDiscoverable |
{ | ||
"name": "ssb-mobile-bluetooth-manager", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A module for managing bluetooth connections over a react native bridge.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
7667
166