Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

Commit 573dd1f

Browse files
committed
XB-27 remove control topic related code
1 parent b32c36c commit 573dd1f

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

xi_client/xively_client.py

+4-45
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ def __init__(self):
350350

351351
self._last_connection_time = 0
352352
self._last_cooldown_time = 0
353-
self._control_request_id = -1
354353
self._backoff_duration = 0
355354

356355
self._hostindex = 0
@@ -360,27 +359,14 @@ def __init__(self):
360359
self._options = None
361360
self._disconnection_state = xec.XI_STATE_OK
362361

363-
self._cbHandler.add_listener(self._get_control_topic_name(), self._boHandler)
364-
self._cbHandler.add_listener(self._get_control_topic_name(), self._coHandler)
365-
366362
self._thread = None
367363
self._routine = None
368364

369365
def __del__(self):
370366

371-
self._cbHandler.remove_listener(self._get_control_topic_name(), self._boHandler)
372-
self._cbHandler.remove_listener(self._get_control_topic_name(), self._coHandler)
373-
374367
self._cbHandler = None
375368
self._boHandler = None
376369

377-
378-
def _get_control_topic_name(self):
379-
return "xi/ctrl/v1/unique device id/clt"
380-
381-
def _get_device_status_topic_name(self):
382-
return "device-status"
383-
384370
def _runloop(self):
385371

386372
while self._alive:
@@ -406,16 +392,8 @@ def _routine_connecting(self):
406392
self._mqtt_loop()
407393

408394

409-
def _routine_waiting_for_control_subscription_result(self):
410-
if time.time() - self._last_connection_time > float(self._options.connection_timeout):
411-
self._disconnection_state = xec.XI_CONTROL_TOPIC_SUBSCRIPTION_ERROR
412-
self._routine = self._routine_rejected
413-
else:
414-
self._mqtt_loop()
415-
self._try_cooldown()
416-
417-
418395
def _routine_connected(self):
396+
print("_routine_connected")
419397
self._mqtt_loop()
420398
self._try_cooldown()
421399

@@ -539,11 +517,8 @@ def _mqtt_on_connected(self, previous_connection_result):
539517

540518
XivelyBackoff.reset_last_update()
541519

542-
# subscribe for control topic
543-
result, self._control_request_id = self._mqtt.subscribe([(self._get_control_topic_name(), 1)])
544-
545-
# start timeout for control topic SUBACK
546-
self._routine = self._routine_waiting_for_control_subscription_result
520+
self._routine = self._routine_connected
521+
self._cbHandler.on_connect_finished(xec.XI_STATE_OK)
547522

548523

549524
def _mqtt_on_connect_finished(self, flag_or_result, result=-1):
@@ -599,10 +574,6 @@ def _mqtt_on_disconnect_finished(self, result):
599574
self._last_connection_time = 0
600575
self._routine = self._routine_rejected
601576

602-
elif self._routine == self._routine_waiting_for_control_subscription_result :
603-
self._last_connection_time = 0
604-
self._routine = self._routine_rejected
605-
606577
elif self._routine == self._routine_connected :
607578
self._last_connection_time = 0
608579
self._routine = self._routine_disconnected
@@ -626,19 +597,7 @@ def _mqtt_on_publish_finished(self, request_id):
626597

627598
def _mqtt_on_subscribe_finished(self, request_id, granted_qos):
628599

629-
if request_id != self._control_request_id :
630-
631-
self._cbHandler.on_subscribe_finished(request_id, granted_qos)
632-
633-
else :
634-
635-
# control topic subscription finished
636-
# reset control request id and notify user
637-
638-
self._control_request_id = -1
639-
640-
self._routine = self._routine_connected
641-
self._cbHandler.on_connect_finished(xec.XI_STATE_OK)
600+
self._cbHandler.on_subscribe_finished(request_id, granted_qos)
642601

643602

644603
def _mqtt_on_unsubscribe_finished(self, request_id):

xi_client/xively_error_codes.py

-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ class XivelyErrorCodes:
1818
XI_MQTT_IDENTIFIER_REJECTED = 11
1919
XI_SOCKET_ERROR = 12
2020
XI_SOCKET_CONNECTION_ERROR = 13
21-
XI_CONTROL_TOPIC_SUBSCRIPTION_ERROR = 14
22-

0 commit comments

Comments
 (0)