File tree Expand file tree Collapse file tree 5 files changed +29
-0
lines changed Expand file tree Collapse file tree 5 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 22
22
lrwn_filters = { version = " 4.7" , features = [" serde" ] }
23
23
serde_json = " 1.0"
24
24
serde = { version = " 1.0" , features = [" derive" ] }
25
+ humantime-serde = " 1.1"
25
26
log = " 0.4"
26
27
simple_logger = " 4.3"
27
28
syslog = " 6.1"
Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ pub fn run(config: &Configuration) {
81
81
# a random id will be generated by ChirpStack.
82
82
client_id="{{ mqtt.client_id }}"
83
83
84
+ # Keep alive interval.
85
+ #
86
+ # This defines the maximum time that that should pass without communication
87
+ # between the client and server.
88
+ keep_alive_interval="{{ integration.mqtt.keep_alive_interval }}"
89
+
84
90
# CA certificate file (optional)
85
91
#
86
92
# Use this when setting up a secure connection (when server uses ssl://...)
Original file line number Diff line number Diff line change 1
1
use std:: collections:: HashMap ;
2
2
use std:: fs;
3
+ use std:: time:: Duration ;
3
4
4
5
use anyhow:: Result ;
5
6
use serde:: { Deserialize , Serialize } ;
@@ -52,6 +53,8 @@ pub struct Mqtt {
52
53
pub qos : u8 ,
53
54
pub clean_session : bool ,
54
55
pub client_id : String ,
56
+ #[ serde( with = "humantime_serde" ) ]
57
+ pub keep_alive_interval : Duration ,
55
58
pub ca_cert : String ,
56
59
pub tls_cert : String ,
57
60
pub tls_key : String ,
@@ -68,6 +71,7 @@ impl Default for Mqtt {
68
71
qos : 0 ,
69
72
clean_session : false ,
70
73
client_id : "" . into ( ) ,
74
+ keep_alive_interval : Duration :: from_secs ( 30 ) ,
71
75
ca_cert : "" . into ( ) ,
72
76
tls_cert : "" . into ( ) ,
73
77
tls_key : "" . into ( ) ,
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ pub async fn setup(conf: &Configuration) -> Result<()> {
141
141
142
142
mqtt_opts. set_last_will ( lwt_msg) ;
143
143
mqtt_opts. set_clean_start ( conf. mqtt . clean_session ) ;
144
+ mqtt_opts. set_keep_alive ( conf. mqtt . keep_alive_interval ) ;
144
145
if !conf. mqtt . username . is_empty ( ) || !conf. mqtt . password . is_empty ( ) {
145
146
mqtt_opts. set_credentials ( & conf. mqtt . username , & conf. mqtt . password ) ;
146
147
}
You can’t perform that action at this time.
0 commit comments