A simple and lightweight IoT platform made as part of Communication Technologies and Security in IoT course.
The backend APIs are written in TypeScript using Node.js and Express.js. Database access is handled with Mongoose. And node-coap library, alongside with Express, is used to handle the CoAP traffic coming from end-devices.
The UI is a browser based Create-React-App application written also in TypeScript. The UI components used are mainly provided by React-Bootstrap.
https://iot-platform-demo.netlify.app/
-
Node (and npm)
-
TypeScript
- install with
npm install -g typescript
- install with
-
MongoDB database
-
Connection to MongoDB requires a
.envfile in the root directory with the following entries in it:MONGO_USERNAME=<username>MONGO_PASSWORD=<password>MONGO_HOST=<host (e.g. cluster1337.foobar.mongodb.net/iot-platform)>
-
git clonecd IoT-Platformnpm installnpm run buildnpm start- View the UI in the browser http://localhost:7000
- Consume the REST API at http://localhost:7000/api
-
git clone -
cd IoT-Platform -
Back-end
3.1
npm install3.2
npm run dev:api -
Front-end
4.1
cd src/client-app4.2
npm install4.3
npm run dev:client4.4 View the UI in browser http://localhost:3000
New devices can be registered in the Register a Device page. When registering a device, you must specify a name, optional description, status (enabled or disabled), communication protocol, and an access token. The access token is used to send data from the end-devices to the IoT platform.
Registered devices can be viewed in the View Devices page. From there you can delete a device by pressing the corresponding red delete button. To view or update a device's configuration, you must select a device from the list. This will navigate you to the device's configration page where you can view and update the configuration.
To view the received device data, you must press the View Device Data button while not modifying the device in the device's configuration page. In the device data page you can view the most recent received data, export all of the device data (JSON), or delete all of the device data.
To send device data to the platform, you must perform an appropriate request to an API endpoint with a valid access token. Reference HTTP API endpoints or CoAP API endpoints to make the requests. If the device that the access token belongs to is disabled or if it does not exist, the token is not valid.
To fetch device data and to create and modify devices via a REST interface, reference Web API endpoints on how to do it.
To simulate an end-device sending data to the platform, the project contains a npm script that can mock HTTP or CoAP requests. To use the script run npm run demo-device <protocol> <address> <access_token> <data_type> <count> <interval> where:
protocolis http or coapaddressis the API address (e.g. localhost:7100)access_tokenis the access token of a valid registered devicedata_typeis the type of the demo data set, options are car, water, weather, wordcountis the number of requests to be madeintervalis the request interval in milli seconds
Example: npm run demo-device http localhost:7100 superSecret123 word 5 0
Web API port can be configured with WEB_PORT in the .env file. (Default 7000)
-
GET /api/devicesGets all the registered devicesResponse Body: [ { id: <string> name: <string>, accessToken: <string>, enabled: <boolean>, protocol: "http" | "coap", description: <string>, createdAt: Date, updatedAt: Date, }, ... ] -
GET /api/devices/{id}Gets a registered device that has the corresponding idResponse Body: { id: <string> name: <string>, accessToken: <string>, enabled: <boolean>, protocol: "http" | "coap", description: <string>, createdAt: Date, updatedAt: Date, } -
POST /api/devicesRegisters a new deviceRequest Body: { name: <string>, accessToken: <string>, enabled: <boolean>, protocol: "http" | "coap" }Response Body: { id: <string> name: <string>, accessToken: <string>, enabled: <boolean>, protocol: "http" | "coap", description: <string>, createdAt: Date, updatedAt: Date, } -
PUT /api/devices/{id}Modifies a registered device that has the corresponding id with the details provided in the bodyRequest Body: { name?: <string>, accessToken?: <string>, enabled?: <boolean>, protocol?: "http" | "coap" }Response Body: { id: <string> name: <string>, accessToken: <string>, enabled: <boolean>, protocol: "http" | "coap", description: <string>, createdAt: Date, updatedAt: Date, } -
DELETE /api/device/{id}Deletes a registered device that has the corresponding id
GET /api/deviceData/{id}?start={startIndex}&stop={stopIndex}Gets the device data associated with a device that has the corresponding id starting from start index to stop index. Leaving start index or end index undefined, will result in all of the data being returned.
Response Body:
[
{
totalCount: <number>,
deviceData: {
id: <string>,
deviceId: <string>,
createdAt: Date,
[key: <string>]: any
}
},
...
]
DELETE /api/deviceData/{id}
HTTP API port can be configured with HTTP_PORT in the .env file. (Default 7100)
-
POST /{accessToken}Body: { [key: <string>]: any }
CoAP API port can be configured with COAP_PORT in the .env file. (Default 7200)
-
POST /{accessToken}Body: { [key: <string>]: any }



