Connect using the simulator

The CLI provides a software implementation of Cat Tracker for testing purposes. This implementation allows to verify that the cloud configuration works, and this feature is also used for testing Bifravst using Continuous integration.

To connect to a device and control the device using the simulator, complete the following steps:

  • Create certificates for the device

  • Connect to the device

  • Use the device simulator web application to control the device

To create certificates for a simulated device, run the following command:

node create-device-cert

As the next step, you can run a simulated device using the generated certificate by running the following command:

node cli connect "<id of your device>"

Note

The device simulator will print a link to the device simulator web application. For the link to work, either enable Continuous deployment, or manually deploy the device simulator web application as described in Deploying the device simulator web application.

Using the device simulator web application

The device-ui provides a browser-based UI to control the simulated device.

Device simulator web application

Device simulator web application

To use the device simulator web application, complete the following steps:

  • Clone the project and install the dependencies

  • Run the device simulator web application

Clone the project and install the dependencies

Clone the latest version of the device-ui project and install the dependencies:

git clone https://github.com/bifravst/device-ui.git bifravst-device-ui
cd bifravst-device-ui
npm ci

Run the device simulator web application

You can run the device simulator web application by using the following command:

npm run

After executing the above command, copy the connection string printed from node cli connect "<id of your device>" (for example, ?endpoint=http%3A%2F%2Flocalhost%3A23719) and append it to the browser address (for example, http://localhost:8080/?endpoint=http%3A%2F%2Flocalhost%3A23719).

Deploying the device simulator web application

To build and setup the device simulator web application to the S3 bucket created when setting up Bifravst in your AWS account, run the following commands:

export $(cd ../bifravst-aws && node cli device-ui-config | xargs)
npm run build
aws s3 cp build s3://$SNOWPACK_PUBLIC_DEVICE_UI_BUCKET_NAME \
--recursive --metadata-directive REPLACE \
--cache-control 'public,max-age=600' --expires ''
aws cloudfront create-invalidation --distribution-id \
$SNOWPACK_PUBLIC_CLOUDFRONT_DISTRIBUTION_ID_DEVICE_UI --paths /,/index.html
echo "Done. Now open $SNOWPACK_PUBLIC_DEVICE_UI_BASE_URL to view the web app."

After executing the above commands, you can open the domain name printed in SNOWPACK_PUBLIC_DEVICE_UI_BASE_URL to view the device simulator web application.