- Install PostgreSQL.
- Install NodeJS.
- Clone this repository (e.g. enter
git clone https://github.com/Happytreat/dynalite.git
in your command-line terminal). - Change directory to the newly created dynalite directory by entering
cd dynalite
.
- Change directory to the src folder by entering the command
cd src
. - Install the required packages by entering
npm install
. - Create a file named .env in the current directory (refer to .env.backup).
- Open .env and enter the following:
DATABASE_URL=postgres://<username>:<password>@<hostname>:<port>/<database_name>
ALGORITHM=<algorithm>
KEY=<key>
Replace the fields in < >
accordingly.
Example:
DATABASE_URL=postgres://postgres:password@localhost:5432/postgres
ALGORITHM=aes-128-cbc
KEY=helloWorldSecureKey21
- 5432 is the default port for PostgreSQL
- We do not actually use the above example values in deployment and neither should you
- Run this project on your local server by using
npm start
. - Stop the server by using
CTRL + C
.
- To test Dynalite without a Raspberry Pi, refer to COAP-CLI. An example command would be:
coap post coap://localhost/ -p "Hello COAP"
. - Dynalite receives POST COAP messages at
coap://localhost/
which are stored in a PostgreSQL table. - Dynalite displays these stored messages at
http://localhost:3000/
.
- Encrypt your payload:
node ./test/crypto_test.js '{"rpiId":"Room1","timestamp":"Mon Oct 28 2019 21:20:20 GMT+0800 (Singapore Standard Time)","isOccupied":false}'
- Send encrypted output through coap:
coap post coap://localhost/ -p <output from step_1>