Methods

public

connectToClosestSensor(scanTime, callbackFun, disconnectFun)

Connect to nearest IoT Sensor device.

Example

iotsensor.connectToClosestSensor(
	3000, // Scan for 3000 ms
	function()
	{
		// Connected and device is ready
	},
	function(error)
	{
		console.log('Disconnect error ' + error);
	}
);

Parameters

Name Type Optional Description

scanTime

integer

 

Time (in ms) to scan for nearby IoT Sensors (optional, default 2 seconds)

callbackFun

function()

 

Callback called when connected and device is initalized

disconnectFun

function()

 

Callback called when connection is lost (optional)

public

connectToDevice(device, callbackFun, disconnectFun)

Connect to an IoT Sensor device

Example

iotsensor.connectToDevice(
	device,
	function()
	{
		// Connected and device is ready
	},
	function(error)
	{
		console.log('Disconnect error ' + error);
	}
);

Parameters

Name Type Optional Description

device

evothings.easyble.EasyBLEDevice

 

A evothings.easyble.device object

callbackFun

function()

 

Callback called when connected and device is initialized

disconnectFun

function()

 

Callback called when connection is lost (optional)

public

disableAllSensors()

RAW and SFL. Implementation of evothings.iotsensor.instance#disableAllSensors

Example

iotsensor.disableAllSensors();
public

disconnectDevice()

Disconnect from the connect device

Example

iotsensor.disconnectDevice();
public

isIoTSensor(device) → boolean

Determine if a BLE device is a IoT Sensor.
Checks the general case using the advertised name.
Specific implementation is added for SFL and RAW.

Example

if(iotsensor.isIoTSensor(device))
{
	// connect to device
}

Parameter

Name Type Optional Description

device

evothings.easyble.EasyBLEDevice

 

easyble device object

Returns

boolean 

public

startScanningForDevices(callbackFun)

Start a manual scan for physical devices.
This process can be automated by using connectToClosestSensor(scanTime, callbackFun, disconnectFun)
The device (evothings.easyble.EasyBLEDevice) that is found is passed to callbackFun and can be used to inspect device fields to determine properties such as RSSI, name etc.
You can call isIoTSensor(device) to determine if this is an IoT sensor. To connect, call connectToDevice(device, callbackFun, disconnectFun).

Example

iotsensor.startScanningForDevices(
	function(device)
	{
		console.log('Device found: ' + device.name + ' RSSI: ' + device.rssi);
		if(iotsensor.isIoTSensor(device))
		{
			// We have an IoT Sensor, let's connect!
			iotsensor.connectToDevice(
				device,
				function()
				{
					// Connected and device is ready
				},
				function(error)
				{
					console.log('Disconnect error ' + error);
				}
			);
		}
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with found device: callbackFun(device).

public

stopScanningForDevices()

Stop scanning for physical devices and call statusCallback with STOPPED_SCANNING message.

Example

iotsensor.stopScanningForDevices();