Kalki component that monitors and polls information from IoT devices, as well as sends commands to them.
Kalki is an IoT platform for allowing untrusted IoT devices to connect to a network in a secure way, protecting both the IoT device and the network from malicious attackers.
Kalki comprises a total of 8 GitHub projects:
- kalki-node-setup (Kalki Main Repository, composes all non-UI components)
- kalki-controller (Kalki Main Controller)
- kalki-umbox-controller (Kalki Umbox Controller)
- kalki-device-controller (Kalki Device Controller)
- kalki-dashboard (Kalki Dashboard)
- kalki-db (Kalki Database Library)
- kalki-iot-interface (Kalki IoT Interface)
- kalki-umboxes (Kalki Umboxes, sample umboxes and umboxes components)
- Docker and Docker-Compose have to be installed.
- Kalki-db library build env Docker image. See here for installation details.
- Each API plugin may have additional setup requirements. Review the readme file for each plugin that is to be used to set up all necessary configs or dependencies.
The file app/config.json contains mandatory and optional configuration:
- device_controller_api_ip (mandatory): IP of the Control Node where the Device Controller is.
- device_controller_api_port (optional): port where Device Controller is listening, default should be ok in most cases.
- iot_interface_api_port (optional): port where IoT Interface is listening locally, default should be ok in most cases.
To build and run along with any other containers that are needed for device type APIs.
First compile and build the docker images with:
$ bash build_container.sh
To run:
$ bash run_compose.sh
When exiting the log view after running this, containers will continue running in the background.
If the log window is exited, the logs can be still monitored with this command:
$ bash compose_logs.sh
To stop all:
$ bash stop_compose.sh
Optionally, the parameter test
can be passed to either script above, to enter a simple test mode for IoTInterface. Additional parameters have to be passed after this to execute specific tests. For more details, see the IotInterface.java source file.
To add an API implementation for a new device type, follow these steps:
- Add a new project for the API to the repo:
- Create a subfolder
/plugins/<DeviceTypeName>
, and add abuild.gradle
file that at least contains:dependencies {compile project(':common')}
- Create a
src/main/java
folder inside it, along with a package inside it callededu.cmu.sei.kalki.iotinterface.plugins.<DeviceTypeName>
- Modify
settings.gradle
in the root of the repo, and add the lineinclude ":plugins/<DeviceTypeName>
- Modiffy
app/build.gradle
and add the dependencycompile project(':plugins/DeviceTypeName>')
- Create a subfolder
- Implement either a Monitor or a CommandSender class, or both, for this device type:
- For Monitors:
- Create a class called
Monitor.java
inside the package created above, and inherit fromIotMonitor
orPollingMonitor
- Make sure the constructor calls the base constructor
- If deriving from
PollingMonitor
, override thepollDevice()
method, and fill theDeviceStatus
param that is received with the polled information - If not deriving from
PollingMonitor
, override thestart()
andstop()
methods as needed to initialize and stop your monitor. Be sure to manually callsendStatusToDB()
when you have a new status to report.
- Create a class called
- For Command Senders
- Create a class called
CommandSender.java
inside the package created above, and inherit fromIotCommandSender
- Make sure the constructor calls the base constructor
- Create a method called
command_<command_name>()
for each command to be supported.
- Create a class called
- For Monitors: