JavaScript BlinkUp version 0.3.2
blinkupSDK module.
- Source:
Classes
Members
(static) NetworkConfig
NetworkConfig class constructor for imp network configuration
- Source:
(static) NetworkProxy
NetworkProxy class constructor for routing imp traffic through a proxy
- Source:
(static) pollTimeout
Max time to poll for a device after flash in whole seconds
- Source:
(static) preventFastFlashing
If true, prevents the default behavior where a faster flasher is used on mobile devices
- Source:
(static) progressCallback
During the flashing process this function is called with the progress percentage.
Setting this property will override the default progress bar behaviour.
Care should be taken when creating the callback as any screen updates may cause
the BlinkUp to fail on various devices. The SDK will call this method on each
percentage point change in progress regardless of FPS.
- Source:
Example
var blinkup = require('blinkup/blinkupSDK');
blinkup.progressCallback = function (progress) {
// Perform a very fast ui update.
// object.style = 'translateZ(0) scale(' + progress / 100.0 + ',1)'
};
(static) StaticAddressing
StaticAddressing class constructor for static addressing
- Source:
Methods
(static) getConfigId(apiKey, existingPlanId, environment, callback)
Get a ConfigId from the Electric Imp API.
Parameters:
Name | Type | Description |
---|---|---|
apiKey |
string | Your apiKey from Electric Imp |
existingPlanId |
string | For production environment, existing Id previously generated by Electric Imp, or null to auto-generate a new plan Id. |
environment |
string | `production` environment |
callback |
module:blinkupSDK~getConfigIdCompletion | Called on completion |
- Source:
Example
var blinkup = require('blinkup/blinkupSDK');
blinkup.getConfigId('myElectricImpAPIKey', null, 'production', function (err, configId) {
if (err) {
// Handle error
} else {
// The configId has been retrieved.
// Generally it should be passed to the startNetworkFlash function
var theConfigId = configId;
}
});
(static) pollForDeviceInfo(configId, callback)
Polls the Electric Imp server to gather information about the recently flashed
device.
Parameters:
Name | Type | Description |
---|---|---|
configId |
module:blinkupSDK~ConfigId | The ConfigId used during present |
callback |
module:blinkupSDK~pollForDeviceInfoCompletion | Callback function for after device has been polled |
- Source:
Example
var blinkup = require('blinkup/blinkupSDK');
blinkup.pollForDeviceInfo (configId, function(err, deviceInfo) {
if (err) {
// Handle error
// (device rejected or server connection timed out)
} else if (deviceInfo) {
// Do something with deviceInfo data
}
});
(static) progressCallbackWillOccurr(overrideFPSopt) → {Boolean}
Evaluate if the default progressCallback function will update the progress
bar. If the progressCalback has been manually set the returned value isn't
valid.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
overrideFPS |
Number |
<optional> |
FPS if you will be overridding the default fps |
- Source:
Returns:
true if the default progress callback function will update the
progress bar, false otherwise.
- Type
- Boolean
(static) startDisconnectFlash(options, callback)
Starts the BlinkUp disconnect process by targeting the BU-canvas element in the DOM.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | Flashing parameters {fps: [10-60] (default:60 mobile, 20 browser)} |
callback |
callback | Callback function for after the BlinkUp flash finishes (no parameters) |
- Source:
Example
var blinkup = require('blinkup/blinkupSDK');
blinkup.startDisconnectFlash({}, function () {
// Hide the canvas and progress bar now that BlinkUp is complete
// hideFlashingElements();
});
(static) startNetworkFlash(configId, networkConfig, Flashing, callback)
Starts the BlinkUp flash process by targeting the BU-canvas element in the DOM.
Parameters:
Name | Type | Description |
---|---|---|
configId |
module:blinkupSDK~ConfigId | The ConfigId with token, planId, apiKey, and type (retrieved by getConfigId) |
networkConfig |
module:blinkupSDK~NetworkConfig | The network configuration for the wireless network to use |
Flashing |
Object | parameters {fps: [10-60] (default:60 mobile, 20 browser)} |
callback |
callback | Callback function for after the BlinkUp flash finishes (with success parameter) |
- Source:
Example
var blinkup = require('blinkup/blinkupSDK');
// configId, networkConfig created elsewhere
var options = {
};
blinkup.startNetworkFlash(configId, networkConfig, options, function () {
// Hide the canvas and progress bar now that BlinkUp is complete
// hideFlashingElements();
// Show status of device polling
// setInstruction('Gathering device data (' + blinkup.pollTimeout + 's max)');
// document.getElementById('status').style.display = 'block';
// showPolling();
// Poll the device for results of the BlinkUp process
// getDeviceStatus(configId);
});
(static) stopFlash()
Cancel any active BlinkUp flashing
- Source:
(static) stopPolling()
Cancel any active Device Polling
- Source:
Type Definitions
getConfigIdCompletion(error, configId)
Callback used by getConfigId.
Parameters:
Name | Type | Description |
---|---|---|
error |
string | Specifies error, null on success |
configId |
module:blinkupSDK~ConfigId | ConfigId object containing token and planId information returned by API (null on failure) |
- Source:
pollForDeviceInfoCompletion(error, data)
Callback used by pollForDeviceInfo.
Parameters:
Name | Type | Description |
---|---|---|
error |
string | Specifies error, null on success |
data |
module:blinkupSDK~DeviceInfo | Device information for successfully Blinked Up device (null on failure) |
- Source: