1
- # Mainflux IoT Agent
1
+ # Magistrala IoT Agent
2
2
3
- ![ badge] ( https://github.com/mainflux /agent/workflows/Go/badge.svg )
3
+ ![ badge] ( https://github.com/absmach /agent/workflows/Go/badge.svg )
4
4
![ ci] [ ci ]
5
5
![ release] [ release ]
6
6
[ ![ go report card] [ grc-badge ]] [ grc-url ]
11
11
<img width =" 30% " height =" 30% " src =" ./docs/img/agent.png " >
12
12
</p >
13
13
14
- Mainflux IoT Agent is a communication, execution and SW management agent for Mainflux system.
14
+ Magistrala IoT Agent is a communication, execution and SW management agent for Magistrala system.
15
15
16
16
## Install
17
17
18
18
Get the code:
19
19
20
20
``` bash
21
- go get github.com/mainflux /agent
22
- cd $GOPATH /github.com/mainflux /agent
21
+ go get github.com/absmach /agent
22
+ cd $GOPATH /github.com/absmach /agent
23
23
```
24
24
25
25
Make:
@@ -37,24 +37,24 @@ go install github.com/nats-io/nats-server/v2@latest
37
37
nats-server
38
38
```
39
39
40
- Create gateway configuration with [ Provision] [ provision ] service or through [ Mainflux UI] [ mfxui ] .
40
+ Create gateway configuration with [ Provision] [ provision ] service or through [ Mainflux UI] [ mfxui ] .
41
41
42
42
Start Agent with:
43
43
44
44
``` bash
45
- MF_AGENT_BOOTSTRAP_ID =< bootstrap_id> \
46
- MF_AGENT_BOOTSTRAP_KEY =< bootstrap_key> \
47
- MF_AGENT_BOOTSTRAP_URL =http://localhost:9013/things/bootstrap \
48
- build/mainflux -agent
45
+ MG_AGENT_BOOTSTRAP_ID =< bootstrap_id> \
46
+ MG_AGENT_BOOTSTRAP_KEY =< bootstrap_key> \
47
+ MG_AGENT_BOOTSTRAP_URL =http://localhost:9013/things/bootstrap \
48
+ build/magistrala -agent
49
49
```
50
50
51
- or,if [ Mainflux UI] ( https://github.com/mainflux /ui ) is used,
51
+ or,if [ Magistrala UI] ( https://github.com/absmach /ui ) is used,
52
52
53
53
``` bash
54
- MF_AGENT_BOOTSTRAP_ID =< bootstrap_id> \
55
- MF_AGENT_BOOTSTRAP_KEY =< bootstrap_key> \
56
- MF_AGENT_BOOTSTRAP_URL =http://localhost:9013/bootstrap/things/bootstrap \
57
- build/mainflux -agent
54
+ MG_AGENT_BOOTSTRAP_ID =< bootstrap_id> \
55
+ MG_AGENT_BOOTSTRAP_KEY =< bootstrap_key> \
56
+ MG_AGENT_BOOTSTRAP_URL =http://localhost:9013/bootstrap/things/bootstrap \
57
+ build/magistrala -agent
58
58
```
59
59
60
60
### Config
@@ -95,48 +95,48 @@ Example configuration:
95
95
```
96
96
97
97
Environment:
98
- | Variable | Description | Default |
98
+ | Variable | Description | Default |
99
99
| ----------------------------------------| ---------------------------------------------------------------| ----------------------------------------|
100
- | MF_AGENT_CONFIG_FILE | Location of configuration file | config.toml |
101
- | MF_AGENT_LOG_LEVEL | Log level | info |
102
- | MF_AGENT_EDGEX_URL | Edgex base url | http://localhost:48090/api/v1/ |
103
- | MF_AGENT_MQTT_URL | MQTT broker url | localhost:1883 |
104
- | MF_AGENT_HTTP_PORT | Agent http port | 9999 |
105
- | MF_AGENT_BOOTSTRAP_URL | Mainflux bootstrap url | http://localhost:9013/things/bootstrap |
106
- | MF_AGENT_BOOTSTRAP_ID | Mainflux bootstrap id | |
107
- | MF_AGENT_BOOTSTRAP_KEY | Mainflux bootstrap key | |
108
- | MF_AGENT_BOOTSTRAP_RETRIES | Number of retries for bootstrap procedure | 5 |
109
- | MF_AGENT_BOOTSTRAP_SKIP_TLS | Skip TLS verification for bootstrap | true |
110
- | MF_AGENT_BOOTSTRAP_RETRY_DELAY_SECONDS | Number of seconds between retries | 10 |
111
- | MF_AGENT_CONTROL_CHANNEL | Channel for sending controls, commands | |
112
- | MF_AGENT_DATA_CHANNEL | Channel for data sending | |
113
- | MF_AGENT_ENCRYPTION | Encryption | false |
114
- | MF_AGENT_BROKER_URL | Broker url | nats://localhost:4222 |
115
- | MF_AGENT_MQTT_USERNAME | MQTT username, Mainflux thing id | |
116
- | MF_AGENT_MQTT_PASSWORD | MQTT password, Mainflux thing key | |
117
- | MF_AGENT_MQTT_SKIP_TLS | Skip TLS verification for MQTT | true |
118
- | MF_AGENT_MQTT_MTLS | Use MTLS for MQTT | false |
119
- | MF_AGENT_MQTT_CA | Location for CA certificate for MTLS | ca.crt |
120
- | MF_AGENT_MQTT_QOS | QoS | 0 |
121
- | MF_AGENT_MQTT_RETAIN | MQTT retain | false |
122
- | MF_AGENT_MQTT_CLIENT_CERT | Location of client certificate for MTLS | thing.cert |
123
- | MF_AGENT_MQTT_CLIENT_PK | Location of client certificate key for MTLS | thing.key |
124
- | MF_AGENT_HEARTBEAT_INTERVAL | Interval in which heartbeat from service is expected | 30s |
125
- | MF_AGENT_TERMINAL_SESSION_TIMEOUT | Timeout for terminal session | 30s |
126
-
127
- Here ` thing ` is a Mainflux thing, and control channel from ` channels ` is used with ` req ` and ` res ` subtopic
100
+ | MG_AGENT_CONFIG_FILE | Location of configuration file | config.toml |
101
+ | MG_AGENT_LOG_LEVEL | Log level | info |
102
+ | MG_AGENT_EDGEX_URL | Edgex base url | http://localhost:48090/api/v1/ |
103
+ | MG_AGENT_MQTT_URL | MQTT broker url | localhost:1883 |
104
+ | MG_AGENT_HTTP_PORT | Agent http port | 9999 |
105
+ | MG_AGENT_BOOTSTRAP_URL | Magistrala bootstrap url | http://localhost:9013/things/bootstrap |
106
+ | MG_AGENT_BOOTSTRAP_ID | Magistrala bootstrap id | |
107
+ | MG_AGENT_BOOTSTRAP_KEY | Magistrala bootstrap key | |
108
+ | MG_AGENT_BOOTSTRAP_RETRIES | Number of retries for bootstrap procedure | 5 |
109
+ | MG_AGENT_BOOTSTRAP_SKIP_TLS | Skip TLS verification for bootstrap | true |
110
+ | MG_AGENT_BOOTSTRAP_RETRY_DELAY_SECONDS | Number of seconds between retries | 10 |
111
+ | MG_AGENT_CONTROL_CHANNEL | Channel for sending controls, commands | |
112
+ | MG_AGENT_DATA_CHANNEL | Channel for data sending | |
113
+ | MG_AGENT_ENCRYPTION | Encryption | false |
114
+ | MG_AGENT_BROKER_URL | Broker url | nats://localhost:4222 |
115
+ | MG_AGENT_MQTT_USERNAME | MQTT username, Magistrala thing id | |
116
+ | MG_AGENT_MQTT_PASSWORD | MQTT password, Magistrala thing key | |
117
+ | MG_AGENT_MQTT_SKIP_TLS | Skip TLS verification for MQTT | true |
118
+ | MG_AGENT_MQTT_MTLS | Use MTLS for MQTT | false |
119
+ | MG_AGENT_MQTT_CA | Location for CA certificate for MTLS | ca.crt |
120
+ | MG_AGENT_MQTT_QOS | QoS | 0 |
121
+ | MG_AGENT_MQTT_RETAIN | MQTT retain | false |
122
+ | MG_AGENT_MQTT_CLIENT_CERT | Location of client certificate for MTLS | thing.cert |
123
+ | MG_AGENT_MQTT_CLIENT_PK | Location of client certificate key for MTLS | thing.key |
124
+ | MG_AGENT_HEARTBEAT_INTERVAL | Interval in which heartbeat from service is expected | 30s |
125
+ | MG_AGENT_TERMINAL_SESSION_TIMEOUT | Timeout for terminal session | 30s |
126
+
127
+ Here ` thing ` is a Magistrala thing, and control channel from ` channels ` is used with ` req ` and ` res ` subtopic
128
128
(i.e. app needs to PUB/SUB on ` /channels/<control_channel_id>/messages/req ` and ` /channels/<control_channel_id>/messages/res ` ).
129
129
130
130
## Sending commands to other services
131
131
132
132
You can send commands to other services that are subscribed on the same Broker as Agent.
133
133
Commands are being sent via MQTT to topic:
134
134
135
- * ` channels/<control_channel_id>/messages/services/<service_name>/<subtopic> `
135
+ - ` channels/<control_channel_id>/messages/services/<service_name>/<subtopic> `
136
136
137
137
when messages is received Agent forwards them to Broker on subject:
138
138
139
- * ` commands.<service_name>.<subtopic> ` .
139
+ - ` commands.<service_name>.<subtopic> ` .
140
140
141
141
Payload is up to the application and service itself.
142
142
@@ -191,13 +191,13 @@ Or you can send a command via MQTT to Agent and receive response on MQTT topic l
191
191
In one terminal subscribe for result:
192
192
193
193
``` bash
194
- mosquitto_sub -u < thing_id> -P < thing_key> -t channels/< control_channel_id> /messages/req -h < mqtt_host> -p 1883
194
+ mosquitto_sub -u < thing_id> -P < thing_key> -t channels/< control_channel_id> /messages/req -h < mqtt_host> -p 1883
195
195
```
196
196
197
197
In another terminal publish request to view the list of services:
198
198
199
199
``` bash
200
- mosquitto_pub -u < thing_id> -P < thing_key> -t channels/< control_channel_id> /messages/req -h < mqtt_host> -p 1883 -m ' [{"bn":"1:", "n":"config", "vs":"view"}]'
200
+ mosquitto_pub -u < thing_id> -P < thing_key> -t channels/< control_channel_id> /messages/req -h < mqtt_host> -p 1883 -m ' [{"bn":"1:", "n":"config", "vs":"view"}]'
201
201
```
202
202
203
203
Check the output in terminal where you subscribed for results. You should see something like:
@@ -213,7 +213,6 @@ Check the output in terminal where you subscribed for results. You should see so
213
213
]
214
214
```
215
215
216
-
217
216
## How to save config via agent
218
217
219
218
Agent can be used to send configuration file for the [ Export] [ export ] service from cloud to gateway via MQTT.
@@ -224,8 +223,8 @@ mosquitto_pub -u <thing_id> -P <thing_key> -t channels/<control_channel_id>/mess
224
223
225
224
```
226
225
227
- * ` <config_file_path> ` - file path where to save contents
228
- * ` <file_content_base64> ` - file content, base64 encoded marshaled toml.
226
+ - ` <config_file_path> ` - file path where to save contents
227
+ - ` <file_content_base64> ` - file content, base64 encoded marshaled toml.
229
228
230
229
Here is an example how to make payload for the command:
231
230
@@ -244,15 +243,14 @@ RmlsZSA9ICIuLi9jb25maWdzL2NvbmZpZy50b21sIgoKW2V4cF0KICBsb2dfbGV2ZWwgPSAiZGVidWci
244
243
245
244
[ Apache-2.0] ( LICENSE )
246
245
247
- [ grc-badge ] : https://goreportcard.com/badge/github.com/mainflux /agent
248
- [ grc-url ] : https://goreportcard.com/report/github.com/mainflux /agent
246
+ [ grc-badge ] : https://goreportcard.com/badge/github.com/absmach /agent
247
+ [ grc-url ] : https://goreportcard.com/report/github.com/absmach /agent
249
248
[ docs ] : http://mainflux.readthedocs.io
250
249
[ gitter ] : https://gitter.im/mainflux/mainflux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
251
250
[ gitter-badge ] : https://badges.gitter.im/Join%20Chat.svg
252
251
[ license ] : https://img.shields.io/badge/license-Apache%20v2.0-blue.svg
253
-
254
252
[ export ] : https://github.com/mainflux/export
255
253
[ provision ] : https://github.com/mainflux/mainflux/tree/master/provision
256
254
[ mfxui ] : https://github.com/mainflux/ui
257
- [ ci ] : https://github.com/mainflux /agent/actions/workflows/ci.yml/badge.svg
258
- [ release ] : https://github.com/mainflux /agent/actions/workflows/release.yml/badge.svg
255
+ [ ci ] : https://github.com/absmach /agent/actions/workflows/ci.yml/badge.svg
256
+ [ release ] : https://github.com/absmach /agent/actions/workflows/release.yml/badge.svg
0 commit comments