Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
attdona committed Oct 2, 2017
1 parent cb23d65 commit 5d23c65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions pynais/junction.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async def open(self):

asyncio.ensure_future(self.dispatch())

await self.mqtt.subscribe([('hb/' + self.topic, QOS_1)])
await self.mqtt.subscribe([(self.topic, QOS_1)])

asyncio.ensure_future(self.mqtt_reader_handler())

Expand All @@ -517,6 +517,7 @@ async def dispatch(self):
Route messages enqueued by related endpoints
"""
topic = 'hb/' + self.topic
while True:
LOG.debug("MQTT: dequeueing from %s", self)
message = await self.msg_queue.get()
Expand All @@ -525,8 +526,8 @@ async def dispatch(self):
# message = bytes(message, 'utf-8')

LOG.debug("topic: |%s| - message to deliver: |%r|",
self.topic, message)
await self.mqtt.publish(self.topic, message.data)
topic, message)
await self.mqtt.publish(topic, message.data)


class TcpLine(Line):
Expand Down
17 changes: 10 additions & 7 deletions recipes/cc3200/mqtt_leds.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ async def main(color, value, topic):
try:
while True:
message = await mqtt.deliver_message()

obj = ns.unmarshall(message.publish_packet.payload.data)
if ns.is_ack(obj):
break
payload = message.publish_packet.payload.data
if ns.is_protobuf(payload):
obj = ns.unmarshall(payload)
if ns.is_ack(obj):
break
else:
LOG.debug(">> %s", payload)

await mqtt.unsubscribe([sub_topic])
await mqtt.disconnect()
except ClientException as ce:
LOG.error("Client exception: %s" % ce)

except ClientException as cli_exc:
LOG.error("Client exception: %s", cli_exc)


@click.command()
Expand Down

0 comments on commit 5d23c65

Please sign in to comment.