JavaScript API - v1.2
window.Spacecode
. The
class Device is accessible from this
namespace. First create the device, then define the events
callbacks, and finally connect the device.
var _smartboard = new Spacecode.Device("192.168.1.50");
// Event Handling
_smartboard.on('connected', function()
{
_smartboard.requestScan();
});
_smartboard.on('scancompleted', function()
{
_smartboard.getLastInventory(function(inventory)
{
null
callback is passed as first parameter to improve
the readability of this example, but it is highly recommended to create one.
if(inventory != null)
{
console.log('Scan Completed: '+ inventory.getNumberTotal() +' tags scanned.');
_smartboard.startLightingTagsLed(null, inventory.getTagsAll());
}
});
});
_smartboard.on('lightingstarted', function(tagsNotLighted)
{
console.log('Lighting Started!');
tagsNotLighted.forEach(function(uid)
{
console.log(uid + ' not lighted');
});
});
'connected'
is raised (see above).
// Connect to the device
_smartboard.connect();
document
to stop the lighting process and
release the connection to the remote device.
Note: No callback is given to the method startLightingTagsLed,
to improve the readability of this example. It is highly recommended to create one.
// Stop the lighting process and Disconnect the device on KeyPress
document.onkeypress = function()
{
// "active" only if the device is connected
if(_smartboard.isConnected())
{
_smartboard.stopLightingTagsLed();
_smartboard.release();
document.onkeypress = null;
}
};
window.Spacecode
. The
class Device is accessible from this
namespace. First create the device, then define the events
callbacks, and finally connect the device.
var _smartboard = new Spacecode.Device("192.168.1.50");
// Event Handling
_smartboard.on('connected', function()
{
_smartboard.requestScan();
});
_smartboard.on('scancompleted', function()
{
_smartboard.getLastInventory(function(inventory)
{
if(inventory != null)
{
console.log('Scan Completed at '+ inventory.getCreationDate());
console.log(inventory.getNumberAdded() +' tags added');
console.log(inventory.getNumberPresent() +' tags already present');
console.log(inventory.getNumberRemoved() +' tags removed');
}
});
_smartboard.requestScan();
});
scancancelledbyhost
and scanfailed
.var onScanCancelledOrFailed = function()
{
console.log('Scan cancelled or failed.');
_smartboard.requestScan();
};
_smartboard.on('scancancelledbyhost', onScanCancelledOrFailed);
_smartboard.on('scanfailed', onScanCancelledOrFailed);
connected
is raised (see above).
// Connect to the device
_smartboard.connect();
document
to stop the lighting process and
release the connection to the remote device.
Note: No callback is given to the method startLightingTagsLed,
to improve the readability of this example. It is highly recommended to create one.
// Disconnect the device on KeyPress
document.onkeypress = function()
{
// "active" only if the device is connected
if(_smartboard.isConnected())
{
_smartboard.release();
document.onkeypress = null;
}
};