<b>tinyIoT</b> is a ```Lightweight C-based oneM2M CSE``` for research & embedded deployments
<b>tinyIoT</b> is a secure, fast, lightweight and very flexible ```oneM2M service layer platform``` compliant with oneM2M specifications.💪
<b>tinyIoT</b> uses memory and CPU efficiently and has low resource use.
<b>tinyIoT</b> is implemented in C and uses lightweight open source components for database (SQLite, PostgreSQL), JSON parser (cJSON), http server (pico) and mqtt client (wolfMQTT)
<b>tinyIoT</b> also comes with a web-based dashboard implemented using Vue.
tinyIoT emphasizes simplicity in getting started. Users can easily set up the system by cloning the repository and executing the make command, which streamlines the installation process and reduces initial setup hurdles.
### For Exceptional Portabilit
tinyIoT is designed with universal compatibility in mind:
- It is coded in C, ensuring that it does not rely on platform-specific libraries such as those found in apt repositories, allowing it to run on all Linux distributions.
- Development of a Windows version is also underway, which will extend its usability across more operating systems.
### For Rapid Performance
tinyIoT utilizes the speed of C programming to offer fast performance which is crucial for systems with intensive data processing needs
- The architecture is optimized to minimize database access, enhancing performance especially in environments with limited I/O capabilities.
### For Adherence to Standards:
tinyIoT is committed to maintaining high standards in technology implementation
- It is developed in compliance with the latest oneM2M standards, ensuring that it meets global criteria for IoT communications and services.
You can configure the server by editing `config.h` file directly. Open `config.h` and modify the following settings:
```c
// Server Type (IN_CSE or MN_CSE)
#define SERVER_TYPE IN_CSE
// Basic Server Configuration
#define SERVER_IP "127.0.0.1" // Server IP address
#define SERVER_PORT "3000" // Server port number
#define CSE_BASE_NAME "TinyIoT" // CSE base name
#define CSE_BASE_RI "tinyiot" // CSE base resource identifier
#define CSE_BASE_SP_ID "tinyiot.example.com" // CSE base SP ID
// Remote CSE Configuration (for MN-CSE only)
#if SERVER_TYPE == MN_CSE
#define REMOTE_CSE_ID "" // Remote CSE ID
#define REMOTE_CSE_NAME "" // Remote CSE name
#define REMOTE_CSE_HOST "" // Remote CSE host
#define REMOTE_CSE_SP_ID "" // Remote CSE SP ID
#define REMOTE_CSE_PORT 0 // Remote CSE port
#endif
// Protocol Support
// To enable MQTT, uncomment the following line
// #define ENABLE_MQTT
// To enable CoAP, uncomment the following line
// #define ENABLE_COAP
// Database Settings
#define DB_SQLITE 1
#define DB_POSTGRESQL 2
// Select Database Type: DB_SQLITE or DB_POSTGRESQL
#define DB_TYPE DB_SQLITE
// #define DB_TYPE DB_POSTGRESQL
#if DB_TYPE == DB_POSTGRESQL
// PostgreSQL connection settings
#define PG_HOST "localhost"
#define PG_PORT 5432
#define PG_USER "user"
#define PG_PASSWORD "password"
#define PG_DBNAME "tinydb"
// PostgreSQL Schema Types
#define PG_SCHEMA_VARCHAR 0 // Use VARCHAR for string fields
#define PG_SCHEMA_TEXT 1 // Use TEXT for string fields
// Select PostgreSQL Schema Type: PG_SCHEMA_VARCHAR or PG_SCHEMA_TEXT
// #define PG_SCHEMA_TYPE PG_SCHEMA_VARCHAR
#define PG_SCHEMA_TYPE PG_SCHEMA_TEXT
#endif
```
### Essential Settings
#### 1. Server Type Selection
Choose your CSE type based on your deployment scenario:
- **IN_CSE**: Independent CSE (default) - Standalone oneM2M service platform
- **MN_CSE**: Middle Node CSE - Registers to a remote CSE
**For IN_CSE**: No additional configuration required.
**For MN_CSE**: You must configure the remote CSE connection details(example):
```c
#define REMOTE_CSE_ID "your-remote-cse-id"
#define REMOTE_CSE_NAME "your-remote-cse-name"
#define REMOTE_CSE_HOST "remote-cse-host-ip"
#define REMOTE_CSE_SP_ID "remote-cse-sp-id"
#define REMOTE_CSE_PORT your-remote-cse-port number
```
#### 2. Database Type Selection
Choose your database backend:
- **SQLite**: File-based database (default) - No additional setup required
- **PostgreSQL**: Server-based database - Requires separate installation and configuration
#### 3. PostgreSQL Setup (Required if DB_TYPE = DB_POSTGRESQL)
- Ubuntu
```bash
sudo apt update
sudo apt install libpq-dev
sudo apt install postgresql
sudo systemctl start postgresql
sudo-u postgres psql
CREATE DATABASE tinydb;
CREATE USER tinyuser WITH PASSWORD 'tinypass';
GRANT ALL PRIVILEGES ON DATABASE tinydb TO tinyuser;
\q
```
- macOS
```bash
brew install postgresql
# You can create it with the same information as config.h.
psql postgres
createdb [dbname]
createuser --interactive --pwprompt
```
### Additional Settings
For security settings (ADMIN_AE_ID, default_ACOP, etc.), logging configuration, and other advanced options, please refer to the comments in `config.h` file
4. Installation of required modules
- Ubuntu
```bash
sudo apt install build-essential openssl
sudo apt install libssl-dev
```
If error occurs when install openssl
```bash
sudo apt update
sudo apt-get install openssl
```
- macOS
```bash
brew install openssl@3
```
5. To make an excutable tinyIoT server, simply execute the make file.
```bash
make
```
6. Use the following command to run tinyIoT server:
```bash
./server
```
7. You can configure port number and ip address as parameters, for example,
```bash
./server -p [port] (port = 3000 by default)
```
### For binding protocols
tinyIoT supports HTTP and MQTT. CoAP bindings will be supported later.<br>
In order to run MQTT, Mosquitto MQTT broker should be installed on your machine.
|Protocol|Implementation/Tool|Description|
|--------|-------------------|-----------|
|HTTP|foxweb/pico|Server/library for HTTP|
|MQTT|Mosquitto|Message broker for MQTT protocol|
|CoAP|libcoap|Lightweight protocol for constrained devices|
|Websocket|libwebsockets|Full-duplex communication protocol over a single TCP connection |
<br>
If you would like to add a new protocol binding to tinyIoT, you can follow the steps outlined in the guide below.<br>