GithubHelp home page GithubHelp logo

kii-mt7688-agent's Introduction

kii-mt7688-agent

Creating a build

webpack

The build artifacts will be stored in the dist/ directory.

Deploy

In the dist/ directory,

├── main.js              # main js file
├── package.json         # specifics of npm's package.json handling
└── resource
    ├── db.json          # configuration
    └── stateCache.json  # cache data

All we need are in the dist folder. Copy these files with their structure into the gateway.

Also We need to install some additional packages manually in the gateway.

npm install express
npm install jju
npm install [email protected]

or we can just use

npm install  # will install the depedencies set in the package.json

All of them can NOT be bundled into the dist.

User Access Token Generation

curl -X POST -H "Content-Type: application/json" -d '{
	"grant_type": "password",
	"username": {username},
	"password": {password}
}' "https://api-sg.kii.com/api/apps/{appID}/oauth2/token"

Configuration

Before serving the service, we have to configure resource/db.json first.

{
  "app": {
    "appID": "appID",
    "appKey": "appKey",
    "site": "https://api-sg.kii.com"
  },
  "user": {
    "ownerToken": "ownerToken",
    "userID": "userID"
  },
  ...
}

The app and user sections need to be set.

Serving

After deploy and configuration, we can run it.

node main.js

In some old node, we may need to force garbage collection manually. Just add the option: --expose-gc

node --expose-gc main.js

MQTT

Now the agent supports MQTT.

node main.js --mqtt

Also gc mode is

node --expose-gc main.js --mqtt

Development

# Install the dependencies
npm install

Force to upgrade kii-gateway-agent manually

# upgrade kii-gateway-agent
npm install kii-gateway-agent@latest

Gateway Replacement

In order to replace a gateway while keeping the data and identity of its current endnode devices, the following steps need to be executed:

  1. Unpair relationship of existing gateway and endnode
curl -X DELETE -H "Authorization: Bearer {accessToken}" "https://api-sg.kii.com/thing-if/apps/{appID}/things/{gatewayThingID}/end-nodes/{endnodeThingID}"
  1. Connect the endnode devices to a new gateway
  2. Follow the instruction of this page on the new gateway. If you copy the code files from the old gateway, please not forget to clean the db.json file so that gateway and endnode information is deleted.

kii-mt7688-agent's People

Contributors

ashramwen avatar leonardean avatar

Watchers

 avatar  avatar  avatar

Forkers

leonardean

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.