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 2222 lrwn_filters = { version = " 4.7" , features = [" serde" ] }
2323 serde_json = " 1.0"
2424 serde = { version = " 1.0" , features = [" derive" ] }
25+ humantime-serde = " 1.1"
2526 log = " 0.4"
2627 simple_logger = " 4.3"
2728 syslog = " 6.1"
Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ pub fn run(config: &Configuration) {
8181 # a random id will be generated by ChirpStack.
8282 client_id="{{ mqtt.client_id }}"
8383
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+
8490 # CA certificate file (optional)
8591 #
8692 # Use this when setting up a secure connection (when server uses ssl://...)
Original file line number Diff line number Diff line change 11use std:: collections:: HashMap ;
22use std:: fs;
3+ use std:: time:: Duration ;
34
45use anyhow:: Result ;
56use serde:: { Deserialize , Serialize } ;
@@ -52,6 +53,8 @@ pub struct Mqtt {
5253 pub qos : u8 ,
5354 pub clean_session : bool ,
5455 pub client_id : String ,
56+ #[ serde( with = "humantime_serde" ) ]
57+ pub keep_alive_interval : Duration ,
5558 pub ca_cert : String ,
5659 pub tls_cert : String ,
5760 pub tls_key : String ,
@@ -68,6 +71,7 @@ impl Default for Mqtt {
6871 qos : 0 ,
6972 clean_session : false ,
7073 client_id : "" . into ( ) ,
74+ keep_alive_interval : Duration :: from_secs ( 30 ) ,
7175 ca_cert : "" . into ( ) ,
7276 tls_cert : "" . into ( ) ,
7377 tls_key : "" . into ( ) ,
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ pub async fn setup(conf: &Configuration) -> Result<()> {
141141
142142 mqtt_opts. set_last_will ( lwt_msg) ;
143143 mqtt_opts. set_clean_start ( conf. mqtt . clean_session ) ;
144+ mqtt_opts. set_keep_alive ( conf. mqtt . keep_alive_interval ) ;
144145 if !conf. mqtt . username . is_empty ( ) || !conf. mqtt . password . is_empty ( ) {
145146 mqtt_opts. set_credentials ( & conf. mqtt . username , & conf. mqtt . password ) ;
146147 }
You can’t perform that action at this time.
0 commit comments