in workspace/src/greengrass-bridge/greengrass_bridge/app.py [0:0]
def init_subscribers(self):
for topic in self.iot_topics:
self.get_logger().info("Setting up IoT subscriber for %s" % topic)
self.ros_publishers[topic] = self.create_publisher(String, topic, 10)
handler = gg.client.SubscribeToIoTCoreStreamHandler()
handler.on_stream_event = self.execute_publish_thread
operation = self.ipc_client.new_subscribe_to_iot_core(stream_handler=handler)
response = operation.activate(model.SubscribeToIoTCoreRequest(
topic_name=topic.strip(),
qos=model.QOS.AT_LEAST_ONCE
))
response.result()
self.get_logger().info("Subscribed to iot topic %s" % topic.strip())
for ros_topic in self.ros_topics:
self.get_logger().info("Setting up ROS Topic subscriber for %s" % ros_topic)
self.iot_publishers[ros_topic] = partial(self.publish_to_iot, ros_topic)
self.create_subscription(String, ros_topic.strip(), self.iot_publishers[ros_topic], 1)
self.get_logger().info("Subscribed to ros topic %s" % ros_topic.strip())