@@ -317,7 +317,12 @@ class TBDeviceMqttClient:
317
317
def __init__ (self , host , port = 1883 , username = None , password = None , quality_of_service = None , client_id = "" ,
318
318
chunk_size = 0 , messages_rate_limit = "DEFAULT_MESSAGES_RATE_LIMIT" ,
319
319
telemetry_rate_limit = "DEFAULT_TELEMETRY_RATE_LIMIT" ,
320
- telemetry_dp_rate_limit = "DEFAULT_TELEMETRY_DP_RATE_LIMIT" , max_payload_size = 8196 ):
320
+ telemetry_dp_rate_limit = "DEFAULT_TELEMETRY_DP_RATE_LIMIT" , max_payload_size = 8196 , ** kwargs ):
321
+ # Added for compatibility with old versions
322
+ if kwargs .get ('rate_limit' ) is not None or kwargs .get ('dp_rate_limit' ) is not None :
323
+ messages_rate_limit = messages_rate_limit if kwargs .get ('rate_limit' ) == "DEFAULT_RATE_LIMIT" else kwargs .get ('rate_limit' , messages_rate_limit )
324
+ telemetry_rate_limit = telemetry_rate_limit if kwargs .get ('rate_limit' ) == "DEFAULT_RATE_LIMIT" else kwargs .get ('rate_limit' , telemetry_rate_limit )
325
+ telemetry_dp_rate_limit = telemetry_dp_rate_limit if kwargs .get ('dp_rate_limit' ) == "DEFAULT_RATE_LIMIT" else kwargs .get ('dp_rate_limit' , telemetry_dp_rate_limit )
321
326
self ._client = paho .Client (protocol = 5 , client_id = client_id )
322
327
self .quality_of_service = quality_of_service if quality_of_service is not None else 1
323
328
self .__host = host
@@ -648,6 +653,10 @@ def request_service_configuration(self, callback):
648
653
self .send_rpc_call ("getSessionLimits" , {}, callback )
649
654
650
655
def on_service_configuration (self , _ , service_config , * args , ** kwargs ):
656
+ if not isinstance (service_config , dict ) or 'rateLimits' not in service_config :
657
+ log .warning ("Cannot retrieve service configuration, session will use default configuration." )
658
+ log .debug ("Received the following response: %r" , service_config )
659
+ return
651
660
if service_config .get ("rateLimits" ):
652
661
rate_limits_config = service_config .get ("rateLimits" )
653
662
0 commit comments