Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Intel® Technology Access SDK Developer Guide

$
0
0

October 2014
Rev 1.2

Intel Confidential

Revision History

RevisionRevision HistoryDate
1.0First external releaseAugust 8, 2014
1.1SDK updates aligned with Intel® Technology Access SW release 1.1September 2, 2014
1.2
  • Appendix A – Verifying Intel® TA installation
  • Initialization calls clarified
  • Appendix B - result.event.mode changed to result.mode in sample code
October, 2014

Contents

References and Links

DocumentLocation
Mashery API Key Generationhttps://inteltechnologyaccess.mashery.com
Intel® Validation Internet Portal (VIP)https://platformsw.intel.com
Mashery API Key Generation Instructions

OEMs: Refer to “Intel_TA_APIs_Getting_Started_Guide.pdf” document included in the latest Intel® TA SDK VIP kit: Intel_Technology_Access_SDK_[Intel® TA version number].zip

ISVs: Visit https://software.intel.com/en-us/intel-technology-access. Click on “SDK” tab, and then select the Mashery article.

SDK files for Intel® Technology Access

OEMs: The SDK files are located in the “Intel_Technology_Access_SDK for JavaScript* programming language.zip” file which is included in the latest Intel® TA SDK VIP kit: Intel_Technology_Access_SDK_[Intel® TA version number].zip

ISVs: Visit https://software.intel.com/en-us/intel-technology-access. Click on “SDK” tab, then select “Download the SDK”.

Software Download Site for Intel® Technology Access

OEMs: The software installer “Intel_Technology_Access_Software_[Intel® TA version number].exe” is included in the latest Intel® TA VIP kit: Intel_Technology_Access_[Intel® TA version number].zip

ISVs: Visit https://software.intel.com/en-us/intel-technology-access

Software Installation and Configuration Guide for Intel® Technology AccessRefer to the document “Intel_Technology_Access_Software_Install_Guide.pdf” which is included in the latest Intel® TA VIP kit Intel_Technology_Access_[Intel® TA version number].zip
Intel® Technology Access End User Legal Agreementhttps://software.intel.com/en-us/file/intel-ta-oem-isvpdf

Abstract

The JavaScript* SDK for Intel® Technology Access allows developers to quickly access Intel® Technology Access capabilities, such as the two-in-one sensor.

Introduction

Intel® Technology Access (Intel TA) is a set of REST APIs that enables applications to access platform technologies using web services.

With Intel TA, developers can now:

  • Take advantage of leading technologies built into platforms using web services
  • Access hardware capabilities to deliver a consistent user experience across multiple computing environments

Abstract

The JavaScript* SDK for Intel® Technology Access allows developers to quickly access Intel® Technology Access capabilities, such as the two-in-one sensor.

Target Audience

The target audience for this document is developers with a working knowledge of JavaScript*.

Hardware Requirements

Any Intel® Atom™ or 4th generation Intel® Core™ processor-based 2 in 1 systems

Operating Environments

  • Microsoft Windows* 7 OS (x86, x64) browsers
  • Microsoft Windows* 8 and 8.1 Modern OS (x86, x64) web application
  • Microsoft Windows* 8 and 8.1 Desktop OS (x86, x64) browsers
  • Supported browsers: Mozilla Firefox*, Microsoft Internet Explorer*, and Google Chrome*.

Getting Started

1. Register with Mashery.If not already registered, register with the Mashery API key service.  https://inteltechnologyaccess.mashery.com
2. Create an API key for your application.Please see Mashery API Key Generation Instructions in References and Links for detailed instructions on creating an API key.
3. Download and install Intel® Technology Access software.Refer to References and Links section for the download location.
4. Download SDK files.
  1. Download the SDK files which are part of “Intel_Technology_Access_SDK for JavaScript* programming language.zip ”
  2. Save the Intel® Technology Access JavaScript* SDK files to the local device.
Refer to References and Links section for the download location.
5. Add Intel® Technology Access SDK calls to your code.See Example usage of Intel® Technology Access SDK calls, and a full example in Appendix B: Full sample code invoking 2 in 1sensor.
6. Include a script source attribute in your HTML file.For example: <script src="js/intel-technologyaccess.js"></script>


Example usage of Intel® Technology Access (Intel® TA) SDK calls

Also see Appendix B for full sample code invoking.

Perform the following steps in order, beginning with Step 1.

  1. Refer to Intel TA SDK files relatively inside developer’s web page
    <script type="text/javascript" src="./ITA SDK/intel-technologyaccess.js"></script><script type="text/javascript" src="./ITA SDK/intel-2in1.js"></script>
  2. Set variables for the API key, Application name, and access tokens
    var settings = {"apiKey": "xyz123", //Enter your Mashery-generated API key here"applicationName": "FirstApp", // Replace with your app name here"applicationType": "web"
    };
    var RTN, RAT; // access tokens
  3. Call SDK using the API key and Application name settings
    This call initializes the core SDK which provides pairing and other core functionalities.
    var crHandler = intel.technologyaccess.sdk(settings);
  4. Create error pairing callback function
    var pairingErrorCallback = function(result) {
    	console.log(result.responseText);
    	$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Error: ' + result.responseText);
    };
  5. Create pairing callback function which retrieves the access token
    var pairingSuccessCallback = function(result) {
    	RAT = result.resourceAccessToken;
    	// Output.
    	$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Complete: ' + RAT);
  6. Create pairing progress callback function
    var pairingProgressCallback = function(result) {
    	RTN = result.id;
    	// Output.
    	$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Status: ' + result.status);
    };
  7. Create 2 in 1 callback function
    var get2in1ValueSuccessCallback = function(result) {
    	console.log(result);
    	$('#2in1Output').val($('#2in1Output').val() + 'n2in1 Mode: ' + result.mode);
    	}
  8. Create pairing request
    crHandler.PairDevice(["/sensors/2in1"], ["THIS"], pairingProgressCallback, pairingSuccessCallback, pairingErrorCallback);
    			});
  9. Create an object to access 2 in 1 sensor
    This call initializes specifically the 2 in 1 vertical of the SDK. This is only needed if the developer intends to use the 2 in 1 capabilities. 
    var twoinone = intel.technologyaccess.twoinone(settings);
  10. Retrieve mode of 2 in 1 sensor
    twoinone.GetValue(RAT, get2in1ValueSuccessCallback, get2in1ValueErrorCallback);
  11. Create Event listener via SDK Handler
    crHandler.CreateEventListener(RAT, "sensors", "2in1", sdkCreateEventListenerSuccessCallback, sdkCreateEventListenerErrorCallback);
  12. Poll 2in1 events for the above event listener via SDK handler
    crHandler.GetEvents(RAT, "sensors", "2in1", sdkListenerId, seqNumber, sdkGetEventsSuccessCallback, sdkGetEventsErrorCallback);
  13. Delete the Event listener via SDK handler
    crHandler.DeleteEventListener(RAT, "sensors", "2in1", sdkListenerId, sdkDeleteEventListenerSuccessCallback, sdkDeleteEventListenerErrorCallback);
  14. Create and poll for 2in1 events via SDK handler
    crHandler.PollEventListener(RAT, "sensors", "2in1", sdkPollEventsSuccessCallback, sdkPollEventsErrorCallback);
  15. Create and poll for 2in1 events via twoinone handler
    twoinone.Listen(RAT, twoInOneListenerSuccessCallback, twoInOneListenerErrorCallback);
  16. Deleting the 2in1 event listener via twoinone handler
    twoinone.DeleteListener(RAT, twoInOneListenerId, twoInOneDeleteListenerSuccessCallback, twoInOneDeleteListenerErrorCallback);

Intel® Technology Access SDK reference

Namespace intel

Variable NameDetails
errorCodes{Number} The type of error. Values include: NO_TOKEN(1), INVALID_METHOD_SEQUENCES(2), INTERNAL_ERROR(3), INVALID_PARAMETER(4), UNAUTHORIZED(5), SERVICE_ERROR(6).
FunctionSummary
public static object capability (object settings)Interface for interacting with the underlying TechnologyAccess REST 2-in-1 capability service calls.
public static object errorcodes()Utility object defining the various error codes.

Function Details: namespace intel

function capability

public static object capability(object settings)
Interface for interacting with the underlying TechnologyAccess REST 2 in 1 capability service calls.
Parameters:(object) settings - User configured settings. See intel.technologyaccess.sdk for details.
Returns:(object) Returns the capability object.

function errorcodes

public static object errorcodes()
Utility object defining the various error codes.
Returns:(object) Returns an object containing an enumeration of the public errors.

Namespace intel.technologyaccess.sdk (in intel-technologyaccess.js file)

Function

Summary
public static object sdk (object settings)Creates an instance of the Technology Access SDK object.
public string sdk.CreateEventListener (object RAT, string domain, string capability, function successCB, function errorCB)Creates a new event listener and starts polling for the provided capability.
public string sdk.DeleteEventListener (object RAT, string domain, string capability, string ID, function successCB, function errorCB)Deletes event listener.
public string sdk.GetEvents (object RAT, string domain, string capability, string ID, int seqnum, function successCB, function errorCB)Gets Events for the event listener.
public string sdk.PairDevice (array capabilities, array targets, function progressCB, function successCB, function errorCB)Initiates the pairing sequence for the provided capabilities on the supplied targets.
public string sdk.PollEventListener (object RAT, string domain, string capability, function successCB, function errorCB)Creates a new event listener and starts polling for the provided capability.

Function Details: namespace intel.technologyaccess.sdk (in intel-technlologyaccess.js file)

function sdk

public static object sdk(object settings)
Creates an instance of the Technology Access SDK object. Used to interact with the underlying REST service.
Parameters:(object) settings - User configured settings.
Required: apiKey.
Optional: pairingPollingDuration.
Returns:(object) SDK object for interacting with the underlying REST service.

function sdk.CreateEventListener

public string sdk.CreateEventListener(object RAT, string domain, string capability, function successCB, function errorCB)
Creates a new event listener and starts polling for the provided capability.
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(string) domain - Domain of requested capability
(string) capability - Capabilities to create listener for.
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

function sdk.DeleteEventListener

public string sdk.DeleteEventListener(object RAT, string domain, string capability, string ID, function successCB, function errorCB)
Deletes event listener
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(string) domain - Domain of requested capability
(string) capability - Capabilities to delete listener for.
(string) ID - ID of the listener
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

function sdk.GetEvents

public string sdk.GetEvents(object RAT, string domain, string capability, string ID, int seqnum, function successCB, function errorCB)
Gets Events for the event listener
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(string) domain - Domain of requested capability
(string) capability - Capabilities to create listener for.
(string) ID - ID of the listener
(int) seqnum - number in event sequence
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

function sdk.PairDevice

public string sdk.PairDevice(array capabilities, array targets, function progressCB, function successCB, function errorCB)
Initiates the pairing sequence for the provided capabilities on the supplied targets.
Parameters:(array) capabilities - Array of capabilities to request pairing for.
(array) targets - Array of targets to request pairing from.
(function) progressCB - Callback for monitoring the pairing process. Callback should accept a result parameter.
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.
function sdk. PollEventListenerpublic string sdk.PollEventListener(object RAT, string domain, string capability, function successCB, function errorCB)
Initiates the pairing sequence for the provided capabilities on the supplied targets.
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(string) domain - Domain of requested capability
(string) capability - Capabilities to create listener for.
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

Namespace intel.technologyaccess.twoinone (in intel-2in1.js file)

FunctionSummary
public static object capability (object settings)Interface for interacting with the underlying TechnologyAccess REST 2 in 1 capability service calls.
public string DeleteListener (object RAT, string ID, function successCB, function errorCB)Deletes a new event listener for 2in1.
public object GetValue (object RAT, function successCB, function errorCB)Retrieves the current value of the 2 in 1 capability.
public string Listen (object RAT, function progressCB, function errorCB)Creates a new event listener for 2in1 and starts polling.

Function Details: namespace intel.technologyaccess.twoinone (in intel-2in1.js file)

function Capability

public static object capability(object settings)
Interface for interacting with the underlying TechnologyAccess REST 2 in 1 capability service calls.
Parameters:(object) settings - User configured settings. See intel.technologyaccess.sdk for details.
Returns:(object) Returns the capability object.

function DeleteListener

public string DeleteListener(object RAT, string ID, function successCB, function errorCB)
Deletes a new event listener for 2in1.
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(string) ID - ID of the listener
(function) successCB - Callback called to track progress. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

function GetValue

public object GetValue(object RAT, function successCB, function errorCB)
Retrieves the current value of the 2 in 1 capability.
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(function) successCB - Callback called on success. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

Function Listen

public string Listen(object RAT, function progressCB, function errorCB)
Creates a new event listener for 2in1 and starts polling.
Parameters:(object) RAT - A valid resource access token (RAT), obtained from the device pairing process.
(function) progressCB - Callback called to track progress. Callback should accept a result parameter.
(function) errorCB - Callback called in the event of an error. Callback should accept a result parameter.

Appendix A: Sample code verifying Intel® TA installation

// Sample PairDevice Usage

var RTN, RAT;
var settings = {
    "apiKey": "{API key}","applicationName": "{App name}","applicationType": "web"
};
var crHandler = intel.technologyaccess.sdk(settings);
// Error callback fired when pairing process fails.
var errorCallback = function(result) {
    // This is the function the developer would use to handle errors during the pairing process.
    // In the event IntelTA is unreachable this function will be called with a result object that indicates attempting to reach IntelTA timed out.
    // Output result to console.
    console.log(result);
};
// Success callback fired on successful device pairing.
var successCallback = function(result) {
    // This is the function the developer would use to handle a successful pairing process.
    // From here the application can retrieve the completed RAT and begin to utilize the capability services.
    RAT = result.resourceAccessToken;
    // Output result to console.
    console.log(result);
};
// Progress callback to get incremental updates on the pairing process.
var progressCallback = function(result) {
    // This is the function the developer would use to get incremental status updates of the pairing process.
    RTN = result.id;
    // Output result to console.
    console.log(result);
};
// Create pairing request.
crHandler.PairDevice(["/sensors/2in1"], ["THIS"], progressCallback, successCallback, errorCallback);

////////////////////////////////////////////////////////////////////////////////////
// Success and Intel TA Unreachable Responses
////////////////////////////////////////////////////////////////////////////////////
Successful PairDevice request:
In the event of a successful PairDevice request, the success callback provided during the PairDevice call will be executed and receive the following object as a parameter:
{
  "id": "9ed1q5sd","status": "ACCEPTED","resourceAccessToken": "{RAT}"
}
Failed PairDevice request:
In the event of a failed Pair Device request, the error callback provided during the PairDevice call will be executed and receive an object with the following structure as a parameter:

*Note: The specific error response object shown below is specifically for the case in which Intel TA was unable to be reached before timeout. This could be due to Intel TA not being installed, the service being stopped or another connectivity issue.
{
  "id": "{RTN}","status": "REJECTED","details": "TIMEOUT_CP","timeToLive": 0,"requestingAppId": "{API key}","requestingAppName": "{App name}","requestingIP": "{IP}","requestedCapabilities": ["/sensors/2in1"
  ],"requestedTargets": ["THIS"
  ]
}

Appendix B: Full sample code invoking 2 in 1 sensor

Before starting:

  1. Replace the value of the “apiKey” and “applicationName” variables below with the Mashery-generated API key and name.
  2. Create a folder named “ITA SDK” and copy the jquery.js and the downloaded ITA javascript files into that folder.

Notes: If using Windows* Internet Explorer, please ensure to use version 10 or later.

<!--
Copyright (C) 2014. Intel Corporation All Rights Reserved.

This sample source code, information and materials ("Material") contained herein is owned by Intel Corporation or its suppliers or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors. The Material contains proprietary information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright laws and treaty provisions. All use of or distribution of the Materials is solely and exclusively governed by the terms of the license agreement located at:  https://software.intel.com/en-us/file/intel-ta-oem-isvpdf. Unless otherwise agreed by Intel in writing, you may not remove or alter this notice or any other notice embedded in the Material by Intel or Intel’s suppliers or licensors in any way.
--><html><head><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><title>

			Intel(R) Technology Access Sample App
		</title><script src="./ITA SDK/jquery.min.js"></script><!--JavaScript SDK --><!-- Pointing to remote js files --><!--<script type="text/javascript" src="https://api.intel.com/reflector/sdk/js/dist/dev/intel-technologyaccess.js?api-key=xyz123"></script> <!--Enter your API key in place of xyz123--><!--<script type="text/javascript" src="https://api.intel.com/reflector/sdk/js/dist/dev/intel-2in1.js?api-key=xyz123"></script>--> <!-- Enter your API key in place of xyz123 --><!-- Pointing to local js files --><script type="text/javascript" src="./ITA SDK/intel-technologyaccess.js"></script><script type="text/javascript" src="./ITA SDK/intel-2in1.js"></script><!-- intel.technologyacces.sdk callbacks --><script type="text/javascript">
			var RTN, RAT;

			var sdkListenerId, seqNumber, twoInOneListenerId;

			var settings = {
				"apiKey": "xyz123", //Enter your API key here"applicationName": "FirstApp", // Enter your app name here"applicationType": "web"

			};

			//Get an handler for the 'intel.technologyaccess.sdk'
			var crHandler = intel.technologyaccess.sdk(settings);

			// Callbacks.
			var pairingErrorCallback = function(result) {
				console.log(result.responseText);
				$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Error: ' + result.responseText);
			};

			var pairingSuccessCallback = function(result) {
				RAT = result.resourceAccessToken;
				// Output.
				$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Complete: ' + RAT);

				/*Showing the hidden controls*/
				$('#twoInOneCalls').show();
				$('#sdkEventListeners').show();
			};

			var pairingProgressCallback = function(result) {
				RTN = result.id;
				// Output.
				$('#pairingOutput').val($('#pairingOutput').val() + 'nPairing Status: ' + result.status);
			};

			var sdkCreateEventListenerErrorCallback = function(result) {
				console.log(result.responseText);
				$('#sdkListenerOutput').val($('#sdkListenerOutput').val() + 'nCreateEventListener Error: ' + result.responseText);

			}


			var sdkCreateEventListenerSuccessCallback = function(result) {
				console.log(result);
				sdkListenerId = result.listenerId;
				seqNumber = result.seqNumber;
				$('#sdkListenerOutput').val($('#sdkListenerOutput').val() + 'nEvent Listener created successfullyn');
				$('#sdkListenerOutput').val($('#sdkListenerOutput').val() + 'nListener Id: ' + sdkListenerId + 'nSequence Number: ' + seqNumber);
			}

			var sdkDeleteEventListenerErrorCallback = function(result) {
				console.log(result.responseText);
				$('#deleteListenerOutput').val($('#deleteListenerOutput').val() + 'nDeleteEventListener Error: ' + result.responseText);

			}

			var sdkDeleteEventListenerSuccessCallback = function(result) {
				console.log(result);
				if(typeof sdkListenerId === 'undefined')
				{
					$('#deleteListenerOutput').val($('#deleteListenerOutput').val() + 'nThe listener id is not created. Please create the listener id by clicking on the CreateEventListener button');
				}
				else
				{
					$('#deleteListenerOutput').val($('#deleteListenerOutput').val() + 'nEvent Listener for ' + sdkListenerId + ' removed successfullyn');
					$('#deleteListenerOutput').val($('#deleteListenerOutput').val() + 'Status: ' + result.status + ' Message: ' + result.message);
				}

			}


			var sdkGetEventsErrorCallback = function(result) {
				console.log(result.responseText);
				$('#getEventsOutput').val($('#getEventsOutput').val() + 'nGetEvents Error: ' + result.responseText);
			}

			var sdkGetEventsSuccessCallback = function(result) {
				console.log(result);
				sdkListenerId = result.listenerId;

				$('#getEventsOutput').val($('#getEventsOutput').val() + 'nnListenerId: ' + sdkListenerId + 'n 2in1 mode: ' + result.event.mode);
			}

			var sdkPollEventsErrorCallback = function(result) {
				console.log(result.responseText);
				$('#pollEventsOutput').val($('#pollEventsOutput').val() + 'nPollEventListener Error: ' + result.responseText);
			}



			var sdkPollEventsSuccessCallback = function(result) {
				console.log(result);
				sdkListenerId = result.listenerId;

				$('#pollEventsOutput').val($('#pollEventsOutput').val() + 'nnListenerId: ' + sdkListenerId + 'n 2in1 mode: ' + result.event.mode);
			}</script><!-- intel.technologyaccess.twoinone callbacks --><script type="text/javascript">

			//Get an handler for the 'intel.technologyaccess.twoinone'
			var twoinone = intel.technologyaccess.twoinone(settings);

			var get2in1ValueErrorCallback = function(result) {
				console.log(result.responseText);
				$('#2in1Output').val($('#2in1Output').val() + result.responseText);
			}

			var get2in1ValueSuccessCallback = function(result) {
				console.log(result);
				$('#2in1Output').val($('#2in1Output').val() + 'n2in1 Mode: ' + result.mode);
			}

			var twoInOneListenerErrorCallback = function(result) {
				console.log(result.responseText);
				$('#2in1ListenerOutput').val($('#2in1ListenerOutput').val() + 'nListen Error:' + result.responseText);
			}

			var twoInOneListenerSuccessCallback = function(result) {
				console.log(result);
				twoInOneListenerId = result.listenerId;
				$('#2in1ListenerOutput').val($('#2in1ListenerOutput').val() + 'nnEvent Listener created successfullyn');
				$('#2in1ListenerOutput').val($('#2in1ListenerOutput').val() + 'nListener Id: ' + twoInOneListenerId + 'n2in1 mode: ' + result.event.mode);
			}

			var twoInOneDeleteListenerErrorCallback = function(result) {
				console.log(result);
				$('#2in1DeleteListenerOutput').val($('#2in1DeleteListenerOutput').val() + 'nDeleteListener Error: ' + result.responseText);
			}

			var twoInOneDeleteListenerSuccessCallback = function(result) {
				console.log(result);
				if(typeof twoInOneListenerId === 'undefined')
				{
					$('#2in1DeleteListenerOutput').val($('#2in1DeleteListenerOutput').val() + 'nThe listener id is not created. Please create the listener id by clicking on the CreateEventListener button');
				}
				else
				{
					$('#2in1DeleteListenerOutput').val($('#2in1DeleteListenerOutput').val() + 'nEvent Listener for ' + twoInOneListenerId + ' removed successfullyn');
					$('#2in1DeleteListenerOutput').val($('#2in1DeleteListenerOutput').val() + 'Status: ' + result.status + ' Message: ' + result.message);
				}
			}</script></head><body><h2>Intel(R) Technology Access Sample App</h2><fieldset id="sdkCalls"><legend>Demonstration of 'intel.technologyaccess.sdk' API calls</legend><fieldset id="sdkPairing"><legend>Pairing</legend><div><h3>Demonstration of Pairing (Initiates the pairing sequence for the provided capabilities on the supplied targets):</h3><div id="controls-container"><button id="begin-pairing-btn">Pair Device</button></div><div><textarea id="pairingOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div></fieldset><hr><fieldset id="sdkEventListeners"><legend>2in1 Event Listeners</legend><div><h3>Demonstration of 2in1 CreateEventListener through SDK handler (Creates a new event listener):</h3><div id="controls-container"><button id="Init-Listener-btn">Create 2in1 event listener</button></div><div><textarea id="sdkListenerOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div><div><h3>Demonstration of 2in1 GetEvents through SDK handler (Gets Events for the event listener that got created):</h3><div id="controls-container"><button id="getevents-btn">2in1 GetEvents</button></div><div><textarea id="getEventsOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div><div><h3>Demonstration of 2in1 DeleteEventListener through SDK handler (Deletes event listener):</h3><div id="controls-container"><button id="Delete-Listener-btn">Delete 2in1 event listener</button></div><div><textarea id="deleteListenerOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div><div><h3>Demonstration of 2in1 PollEventListener through SDK handler (Creates a new event listener and starts polling for the provided capability):</h3><div id="controls-container"><button id="pollevents-btn">2in1 PollEventListener</button></div><div><textarea id="pollEventsOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div></fieldset></fieldset><br/><br/><fieldset id="twoInOneCalls"><legend>Demonstration of 'intel.technologyaccess.twoinone' API calls</legend><div><h3>Demonstration of 2in1 Capability Access (Retrieves the current value of the 2in1 capability):</h3><div id="controls-container"><button id="get-2in1-value-btn">Get Sensor Value</button></div><div><textarea id="2in1Output" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div><div><h3>Demonstration of 2in1 Listener (Creates a new event listener for 2in1 and starts polling):</h3><div id="controls-container"><button id="get-2in1-listener-btn">2in1 Event Listener</button></div><div><textarea id="2in1ListenerOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div><div><h3>Demonstration of 2in1 DeleteEventListener (Deletes an new event listener for 2in1):</h3><div id="controls-container"><button id="get-2in1-deleteListener-btn">2in1 DeleteEventListener</button></div><div><textarea id="2in1DeleteListenerOutput" rows="10" style="background-color:#ccc; width:100%;" disabled="disabled">Output:</textarea></div></div></fieldset><!-- intel.technologyaccess.sdk Event handlers --><script type="text/javascript">

			function hideControls()
			{
				$('#twoInOneCalls').hide();
				$('#sdkEventListeners').hide();

			}

			/*Hiding Controls that are dependent on pairing to complete*/
			hideControls();

			$('#begin-pairing-btn').click(function(e) {
				e.preventDefault();
				// Output.
				$('#pairingOutput').val($('#pairingOutput').val() + 'nBeginning pairing...');
				// Create pairing request.
				crHandler.PairDevice(["/sensors/2in1"], ["THIS"], pairingProgressCallback, pairingSuccessCallback, pairingErrorCallback);
			});

			$('#Init-Listener-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					crHandler.CreateEventListener(RAT, "sensors", "2in1", sdkCreateEventListenerSuccessCallback, sdkCreateEventListenerErrorCallback);
				}
			});

			$('#getevents-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					crHandler.GetEvents(RAT, "sensors", "2in1", sdkListenerId, seqNumber, sdkGetEventsSuccessCallback, sdkGetEventsErrorCallback);
				}
			});

			$('#Delete-Listener-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					crHandler.DeleteEventListener(RAT, "sensors", "2in1", sdkListenerId, sdkDeleteEventListenerSuccessCallback, sdkDeleteEventListenerErrorCallback);
				}
			});


			$('#pollevents-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					crHandler.PollEventListener(RAT, "sensors", "2in1", sdkPollEventsSuccessCallback, sdkPollEventsErrorCallback);
				}
			});</script><!-- intel.technologyaccess.twoinone Event handlers --><script>

			$('#get-2in1-value-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					twoinone.GetValue(RAT, get2in1ValueSuccessCallback, get2in1ValueErrorCallback);
				}
			});

			$('#get-2in1-listener-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					twoinone.Listen(RAT, twoInOneListenerSuccessCallback, twoInOneListenerErrorCallback);
				}
			});

			$('#get-2in1-deleteListener-btn').click(function(e) {
				e.preventDefault();
				// If the RAT is set attempt to get meta data.
				if (RAT.length > 0) {
					// Get Meta Data.
					console.dir(e);
					twoinone.DeleteListener(RAT, twoInOneListenerId, twoInOneDeleteListenerSuccessCallback, twoInOneDeleteListenerErrorCallback);
				}
			});</script></body></html>

Appendix C: Troubleshooting

Q1. How can I see more status information on the SDK calls?
A1. Press “F12” in the browser and then click on the Network tab to display more status information.

Q2. How do I view the output of console.log()?
A2. Press “F12” in the browser and select “Console” in the debugger menu.

Q3. Pairing will not complete, despite following setup instructions carefully.
A3. Ensure that pop-up messages are enabled in your browser.

Legal Information

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

A "Mission Critical Application" is any application in which failure of the Intel Product could result, directly or indirectly, in personal injury or death. SHOULD YOU PURCHASE OR USE INTEL'S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION, YOU SHALL INDEMNIFY AND HOLD INTEL AND ITS SUBSIDIARIES, SUBCONTRACTORS AND AFFILIATES, AND THE DIRECTORS, OFFICERS, AND EMPLOYEES OF EACH, HARMLESS AGAINST ALL CLAIMS COSTS, DAMAGES, AND EXPENSES AND REASONABLE ATTORNEYS' FEES ARISING OUT OF, DIRECTLY OR INDIRECTLY, ANY CLAIM OF PRODUCT LIABILITY, PERSONAL INJURY, OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL APPLICATION, WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN, MANUFACTURE, OR WARNING OF THE INTEL PRODUCT OR ANY OF ITS PARTS.

Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined". Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.

The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or go to: http://www.intel.com/design/literature.htm.

All products, platforms, dates, and figures specified are preliminary based on current expectations, and are subject to change without notice. All dates specified are target dates, are provided for planning purposes only and are subject to change.

This document contains information on products in the design phase of development. Do not finalize a design with this information. Revised information will be published when the product is available. Verify with your local sales office that you have the latest datasheet before finalizing a design.

Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.

Windows is a registered trademark of Microsoft Corporation in the United States and other countries.

*Other names and brands may be claimed as the property of others.

Copyright © 2014 Intel Corporation. All rights reserved.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>