Giter VIP home page Giter VIP logo

linkedge-core-sdk-nodejs's Introduction

Link IoT Edge Core SDK for Node.js

The package allows developers to write functions on Function Compute using JavaScript, which running within Link IoT Edge.

Installation

npm install linkedge-core-sdk

or you can copy this project directly to your function's node_modules directory.

Althrough the library is built into Link IoT Edge, we recommand that you install it locally as it improves the development experience, especially when developing with IDE.

Example

Here is a examle demonstrates publishing messages to a topic.

const leSdk = require('linkedge-core-sdk');

const iotData = new leSdk.IoTData();
const message = {
  topic: '/hello/world',
  payload: 'Hello World! Sent from Link IoT Edge using Node.js.',
};
iotData.publish(message, (err) => {
  if (err) console.log(err);
});

APIs


IoTData.publish(params, callback)

Publishes messages.

The parameters are:

  • params: params object,which contains:
    • topic: {String} (Required) the topic name to be published.
    • payload: {String|Buffer} (Required) the message payload in string or in binary.
  • callback(err): a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error.

IoTData.getThingProperties(params, callback)

Obtains specific properties of a thing.

The parameters are:

  • params: params object,which contains:
    • productKey: {String} (Required) the productKey of the target thing from which to get properties.
    • deviceName: {String} (Required) the deviceName of the target thing from which to get properties.
    • payload: {Array} (Required) a list of keys that specifies the properties to be obtained.
  • callback(err, data): a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error and the second parameter as the result object.

IoTData.setThingProperties(params, callback)

Updates the properties of a thing.

The parameters are:

  • params: params object,which contains:
    • productKey: {String} (Required) the productKey of the target thing to which to set properties.
    • deviceName: {String} (Required) the deviceName of the target thing to which to set properties.
    • payload: {Object} (Required) a object consisting of keys and values that specifies the properties to be updated.
  • callback(err): a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error.

IoTData.callThingService(params, callback)

Calls a specific service of a thing.

The parameters are:

  • params: params object,which contains:
    • productKey: {String} (Required) the productKey of the target thing of which to call a service.
    • deviceName: {String} (Required) the deviceName of the target thing of which to call a service.
    • service: {String} (Required) the name of the service to be called.
    • payload: {String|Buffer} a optional string or binary in JSON that you provided to the service as arguments.
    • callback(err, [data]): a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error and the second parameter as the result object.

IoTData.getThingsWithTags(params, callback)

Obtains a list of thing objects, each of which being with all given tags.

The parameters are:

  • params: params object,which contains:
    • payload: {Array} (Required) a list of tag that consisting of {key: value}.
  • callback: a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error and the second parameter as a list of thing objects.

FCClient.invokeFunction(params, callback)

Invokes a specific function.

The parameters are:

  • params: params object,which contains:
    • functionId: {String} (Required) the id of the function to be invoked. Function name is not supported currently.
    • invocaionType: {String} a optional type of the invocation, may be Sync or Async. It will be Sync if not specified.
    • invokerContext: {String} a optional invoker-specific information to the invoked function. The invoker information will be passed into the function, and can be choosed through context variable. It must be base64-encoded.
    • payload: {String|Buffer} a optional string or binary data that you want to provide to the function as input.
  • callback: a callback function for receiving result, which follows the standard JS practice of setting the first parameter as an error and the second parameter as the result object.

License

Apache 2.0

linkedge-core-sdk-nodejs's People

Contributors

feil0n9wan9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.