Xyte sample device implementation
This repository contains a sample implementation of the Xyte V1 HTTP Device API in TypeScript (JavaScript) and runnable with NodeJS.
This code is only intended to be used as a demo of an Xyte agent.
- Partner account on Xyte
- Node version 18.5 or above (* see notes for older version support)
- Clone / download the repository code
- Edit
src/helpers/constants.tsand setup values for the current device (each device should have its own unique values):- Hardware key generated from the
Hardware Keystab under "Product -> Models -> Model -> Hardware Keys", on the Partner Portal. - Cloud ID
- Firmware version
- Optional friendly name given to the devices
- Hardware key generated from the
- Open a shell/command-line
- Run
npm installto install dependencies - Run
npm run bundleto build a distribution- (Copy the bundle outside of repo folder if they're bundled for an older node version with no es modules support)
- Copy
dist/node-agent-starter.min.jsanddist/node-agent-main.min.jsto desired installation folder
- Open a shell/command-line
- Run:
node node-agent-starter.min.js
After a successful execution, the device should appear in the Partner Portal Device List
The device can be assigned to the Lab Organization automatically created and afterwards accessed via the Application Portal
- For envs like
nw.jsusedist/nw.js.index.htmlfile and consult the docs of your provider on how to load them. - This code was tested with NodeJS@18.5 but may run on older versions.
- Please note that
dist/node-agent-starter.min.jsis an auxiliary script, you may rundist/node-agent-main.min.jsdirectly, but you should be using your preferred tools to ensure that the agent runs continuously.
For easier live development, the code can be executed without bundling & minification:
- Open a shell/command-line
- Execute:
- If you prefer editing TS code:
- If you prefer running with TS-Node:
npm run dev - If you prefer running JS:
npm run dev:js
- If you prefer running with TS-Node:
- If you prefer editing JS code:
- Build (
npm run dev) and then copy the output (./lib) to your workspace, you may use a library likenodemonfor file watching.
- Build (
- If you prefer editing TS code:
- please search the project for
TODOcomments and console logs, they are there for you to let you know that something needs to be implemented. We did our best to localize thoseTODOs in two files:src/helpers/constants.tsandsrc/todos.ts. the latter for implementing device functionalities.