2019-01-09 17:04:34 +01:00
## Step 1 - Run the System
2018-04-08 23:03:12 +02:00
Before proceeding, install the following prerequisites:
2019-10-29 03:22:41 -06:00
- [Docker ](https://docs.docker.com/install/ ) (version 18.09)
- [Docker compose ](https://docs.docker.com/compose/install/ ) (version 1.24.1)
2018-04-08 23:03:12 +02:00
2019-01-09 17:04:34 +01:00
Once everything is installed, execute the following command from project root:
2018-04-08 23:03:12 +02:00
```bash
2019-01-09 17:04:34 +01:00
make run
2018-04-11 14:30:37 +02:00
```
2019-01-09 17:04:34 +01:00
This will start Mainflux docker composition, which will output the logs from the containers.
2018-04-11 14:30:37 +02:00
2019-01-09 17:04:34 +01:00
## Step 2 - Install the CLI
2019-10-17 22:15:45 +02:00
Open a new terminal from which you can interact with the running Mainflux system. The easiest way to do this is by using the Mainflux CLI,
2019-10-29 03:22:41 -06:00
which can be downloaded as a tarball from GitHub (here we use release `0.9.0` but be sure to use the latest release):
2018-04-11 14:30:37 +02:00
2019-01-09 17:04:34 +01:00
```bash
2019-10-29 03:22:41 -06:00
wget -O- https://github.com/mainflux/mainflux/releases/download/0.9.0/mainflux-cli_v0.9.0_linux-amd64.tar.gz | tar xvz -C $GOBIN
2018-04-11 14:30:37 +02:00
```
2019-01-09 17:04:34 +01:00
> Make sure that `$GOBIN` is added to your `$PATH` so that `mainflux-cli` command can be accessible system-wide
2018-04-11 14:30:37 +02:00
2019-01-09 17:04:34 +01:00
## Step 3 - Provision the System
Once installed, you can use the CLI to quick-provision the system for testing:
```bash
mainflux-cli provision test
2018-04-11 14:30:37 +02:00
```
2019-10-17 22:15:45 +02:00
This command actually creates a temporary testing user, logs it in, then creates two things and two channels on behalf of this user.
This quickly provisions a Mainflux system with one simple testing scenario.
2018-04-11 14:30:37 +02:00
2019-10-29 03:22:41 -06:00
You can read more about system provisioning in the dedicated [Provisioning ](./provisioning.md ) chapter
2018-04-11 14:30:37 +02:00
2019-10-17 22:15:45 +02:00
Output of the command follows this pattern:
2018-04-11 14:30:37 +02:00
2019-01-09 17:04:34 +01:00
```json
2018-04-11 14:30:37 +02:00
{
2019-01-09 17:04:34 +01:00
"email": "friendly_beaver@email .com",
"password": "123"
2018-04-11 14:30:37 +02:00
}
2018-04-18 22:36:24 +02:00
2019-01-09 17:04:34 +01:00
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NDcwMjE3ODAsImlhdCI6MTU0Njk4NTc4MCwiaXNzIjoibWFpbmZsdXgiLCJzdWIiOiJmcmllbmRseV9iZWF2ZXJAZW1haWwuY29tIn0.Tyk31Ae680KqMrDqP895PRZg_GUytLE0IMIR_o3oO7o"
2018-04-18 23:06:11 +02:00
2018-04-08 23:03:12 +02:00
2019-01-09 17:04:34 +01:00
[
{
"id": "513d02d2-16c1-4f23-98be-9e12f8fee898",
"key": "69590b3a-9d76-4baa-adae-9b5fec0ea14f",
"name": "d0",
},
{
"id": "bf78ca98-2fef-4cfc-9f26-e02da5ecdf67",
"key": "840c1ea1-2e8d-4809-a6d3-3433a5c489d2",
"name": "d1",
}
]
2018-04-08 23:03:12 +02:00
2018-04-11 14:30:37 +02:00
2019-01-09 17:04:34 +01:00
[
{
"id": "b7bfc4b6-c18d-47c5-b343-98235c5acc19",
"name": "c0"
},
{
"id": "378678cd-891b-4a39-b026-869938783f54",
"name": "c1"
}
]
2018-04-11 14:30:37 +02:00
```
2018-09-20 15:32:50 +02:00
2019-10-17 22:15:45 +02:00
In the Mainflux system terminal (where docker compose is running) you should see following logs:
2018-09-20 15:32:50 +02:00
```bash
2019-01-09 17:04:34 +01:00
mainflux-users | {"level":"info","message":"Method register for user friendly_beaver@email .com took 97.573974ms to complete without errors.","ts":"2019-01-08T22:16:20.745989495Z"}
mainflux-users | {"level":"info","message":"Method login for user friendly_beaver@email .com took 69.308406ms to complete without errors.","ts":"2019-01-08T22:16:20.820610461Z"}
mainflux-users | {"level":"info","message":"Method identity for client friendly_beaver@email .com took 50.903µs to complete without errors.","ts":"2019-01-08T22:16:20.822208948Z"}
2019-10-17 22:15:45 +02:00
mainflux-things | {"level":"info","message":"Method add_thing for token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NDcwMjE3ODAsImlhdCI6MTU0Njk4NTc4MCwiaXNzIjoibWFpbmZsdXgiLCJzdWIiOiJmcmllbmRseV9iZWF2ZXJAZW1haWwuY29tIn0.Tyk31Ae680KqMrDqP895PRZg_GUytLE0IMIR_o3oO7o and thing 513d02d2-16c1-4f23-98be-9e12f8fee898 took 4.865299ms to complete without errors.","ts":"2019-01-08T22:16:20.826786175Z"}
2018-09-20 15:32:50 +02:00
2019-01-09 17:04:34 +01:00
...
2018-09-20 15:32:50 +02:00
```
2019-01-09 17:04:34 +01:00
This proves that these provisioning commands were sent from the CLI to the Mainflux system.
2018-09-20 15:32:50 +02:00
2019-01-09 17:04:34 +01:00
## Step 4 - Send Messages
2019-10-17 22:15:45 +02:00
Once system is provisioned, a `thing` can start sending messages on a `channel` :
2018-09-20 15:32:50 +02:00
```bash
2019-01-09 17:04:34 +01:00
mainflux-cli messages send < channel_id > '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]' < thing_key >
2018-11-27 12:46:18 +01:00
```
2018-09-20 15:32:50 +02:00
2019-01-09 17:04:34 +01:00
For example:
2018-09-20 15:32:50 +02:00
```bash
2019-01-09 17:04:34 +01:00
mainflux-cli messages send b7bfc4b6-c18d-47c5-b343-98235c5acc19 '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]' 69590b3a-9d76-4baa-adae-9b5fec0ea14f
2018-09-20 15:32:50 +02:00
```
2019-01-09 17:04:34 +01:00
In the Mainflux system terminal you should see following logs:
2018-09-20 15:32:50 +02:00
```bash
2019-01-09 17:04:34 +01:00
mainflux-things | {"level":"info","message":"Method can_access for channel b7bfc4b6-c18d-47c5-b343-98235c5acc19 and thing 513d02d2-16c1-4f23-98be-9e12f8fee898 took 1.410194ms to complete without errors.","ts":"2019-01-08T22:19:30.148097648Z"}
mainflux-http | {"level":"info","message":"Method publish took 336.685µs to complete without errors.","ts":"2019-01-08T22:19:30.148689601Z"}
2018-11-27 12:46:18 +01:00
```
2018-11-06 14:09:17 -06:00
2019-10-31 14:04:47 +01:00
This proves that messages have been correctly sent through the system via the protocol adapter (`mainflux-http` ).