
Version 1.0
Updated on 15 January 2024
This /IOTCONNECT™ NodeJS SDK package will show you how to install and run
the firmware file.
Date | Name | Download |
---|---|---|
15 January 2024 | NodeJS SDK V1.0 | Download![]() |
Getting started
Prerequisites
Before you install and run the firmware file, we recommend to check with
the following setup requirements:
- NodeJs : Node.js supported version v8.x and above
- Npm : NPM is compatible with the node version
Installation
- you can clone the full sample source code from this repository given
at the Download link. - Or run the “git clone –branch master-std-21 https://github.com/avnet-iotconnect/iotc-node-sdk.git” at the terminal/command prompt to get the full SDK file.
-
To install the required libraries use the below command:– Goto SDK “iotc-node-sdk” directory path using terminal/Command
prompt– cd iotc-node-sdk– npm install (Install prerequisite nodejs library)– npm install iotconnect-sdk (Install the ‘iotconnect-sdk’ package
in nodejs library) -
Using terminal/command prompt goto sample folder– cd sample
-
You can take the firmware file from the above location and update
the following details– Prerequisite input data as explained in the usage section as below– Update sensor attributes according to added in iotconnect cloud
platform– If your device is secure then need to configure the x.509
certificate path as like sdkOptions given below otherwise leave as
it is.
Run
configured device detail)
experience to test the sdk)
Explanation
To initialize the SDK object, you need to import the below SDK package
var SDKClient = require('iotconnect-sdk');
Prerequisite configuration
string cpId = "<Your cpId>";
string uniqueId = "<Your UniqueID>";
string env = "<your env>";
string sId = "<Your SID>";
string platform = "<Your platform>"
- cpId : It need to get from the /IOTCONNECT™ platform
“Settings->Key Vault”. - uniqueId : Your device uniqueId
- env : It need to get from the /IOTCONNECT™ platform
“Settings->Key Vault”. - SId : It is the company code. You can get it from the
/IOTCONNECT™ UI portal “Settings -> Key Vault -> SDK Identities
-> select language DotNet and Version 1.0” - platform : It is either aws or az
Notes: Set either SID or CPID, As any one of it will be optional.
SdkOptions
SdkOptions is for the SDK configuration and need to parse in SDK object
initialize call. You need to manage the below onfiguration as per your
device authentications.
var sdkOptions = {
"certificate" : { //For SSL CA signed and SelfSigned authorized device only
"SSLKeyPath" : "<< SystemPath >>/device.key",
"SSLCertPath" : "<< SystemPath >>/device.pem",
"SSLCaPath" : "<< SystemPath >>/rootCA.pem"
},
"offlineStorage": {
"disabled": false, //default value = false, false = store data, true = not store data
"availSpaceInMb": 1, //size in MB, Default value = unlimted
"fileCount": 5 // Default value = 1
},
"discoveryUrl" : "https://discovery.iotconnect.io", // Mandatory parameter to get device details
// "debug" : true, // Private setting, false(default) = Don't show log, true = Show log
"devicePK": "", // For Symmetric Key Auth type support
"skipValidation": false, // false(default) = Do validation, true = skip validation
"keepalive": "", // Integer value only
"dpsInfo": { // For TPM device only
"scopeId": "",
"globalEndpoint": ""
},
"cpId" : cpId,
"env" : env,
"pf": pf
}
Notes:
sdkOptions is a mandatory parameter for sdk object initialize call.
Certificate
It indicated to define the path of the certificate file. Mandatory for
X.509 device CA signed and self-signed authentication type only.
- SSLKeyPath: your device key
- SSLCertPath: your device certificate
- SSLCaPath : Root CA certificate
Windows + Linux OS: Use “/” forward slash (Example: Windows: “E:/folder1/folder2/certificate”,
Linux: “/home/folder1/folder2/certificate)
OfflineStorage
Define the configuration related to the offline data storage.
- disabled : false = offline data storing, true = not storing offline data
- availSpaceInMb : Define the file size of offline data which should be in (MB)
- fileCount : Number of files need to create for offline data
DiscoveryUrl
- discoveryUrl : “Your Discovery Url”
DevicePrimarykey
get it from the /IOTCONNECT™ UI portal “Device -> Select device ->
info(Tab) -> Connection Info -> Device Connection”
- devicePrimaryKey : “<DevicePrimaryKey>”