def __init__(self, host: str = 'localhost', port: int = None): self.__id = mqttbase.create_client_id('tlwbe') super().__init__(host, port=port, id=self.__id, topics=[ TOPIC_CONTROL_RESULT, TOPIC_UPLINK_RESULT, TOPIC_DOWNLINK_RESULT ]) self.queue_joins = Queue() self.queue_uplinks = Queue() self.__control_results = {} self.__uplink_results = {} self.__downlink_results = {} self.mqtt_client.message_callback_add('tlwbe/join/+/+', self.__on_join) self.mqtt_client.message_callback_add('tlwbe/uplink/#', self.__on_uplink) self.mqtt_client.message_callback_add(TOPIC_CONTROL_RESULT, self.__on_control_result) self.mqtt_client.message_callback_add(TOPIC_UPLINK_RESULT, self.__on_uplink_result) self.mqtt_client.message_callback_add(TOPIC_DOWNLINK_RESULT, self.__on_downlink_result) self.__logger = logging.getLogger('tlwbe')
def __init__(self, host: str, gwid: str): self.__last_uptime = -1 self.__reboot_queue = Queue() self.gwid = gwid heartbeat_topic = '%s/%s/%s' % (TOPICROOT, gwid, HEARTBEAT) super().__init__(host, id=mqttbase.create_client_id('gwctrl'), topics=[heartbeat_topic]) self.__logger = logging.getLogger('gwctrl') self.mqtt_client.message_callback_add(heartbeat_topic, self.__on_heartbeat)
def __init__(self, host: str, port: int = None): rx_topic = 'pktfwdbr/+/rx/#' tx_topic = 'pktfwdbr/+/tx/#' txack_topic = 'pktfwdbr/+/txack/#' super().__init__(host, port=port, id=mqttbase.create_client_id('pktfwdbr'), topics=[rx_topic, tx_topic, txack_topic]) self.joinacks = asyncio.Queue() self.uplinks = asyncio.Queue() self.downlinks = asyncio.Queue() self.__logger = logging.getLogger('pktfwdbr') self.mqtt_client.message_callback_add(rx_topic, self.__on_rx) self.mqtt_client.message_callback_add(tx_topic, self.__on_tx) self.mqtt_client.message_callback_add(txack_topic, self.__on_txack)
def __init__(self, host: str = None, port: int = None, gateway_id: str = None): super(Gateway, self).__init__(host, port, id=mqttbase.create_client_id("gwsim")) if gateway_id is not None: self.__gateway_id = gateway_id else: self.__gateway_id = 'fakegw' self.__pktfwdbr = tlwpy.pktfwdbr.PacketForwarder(host=host, port=port)
def __init__(self, host: str, id: str, port: int = None, topic_root: str = 'nodectrl'): self.__last_uptime = -1 self.__reboot_queue = Queue() self.topic_root = topic_root self.id = id heartbeat_topic = '%s/%s/%s' % (self.topic_root, id, HEARTBEAT) super().__init__(host, port=port, id=mqttbase.create_client_id('nodectrl'), topics=[heartbeat_topic]) self.__logger = logging.getLogger('nodectrl') self.mqtt_client.message_callback_add(heartbeat_topic, self.__on_heartbeat)