test_command.py 690 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. #!/usr/bin/env python
  3. def test_topic_command():
  4. """
  5. var mqtt = require('mqtt');
  6. var client = mqtt.connect('mqtt://test.mosquitto.org');
  7. client.on('connect', function () {
  8. //订阅presence主题
  9. client.subscribe('presence');
  10. //向presence主题发布消息
  11. client.publish('presence', 'Hello mqtt');
  12. });
  13. client.on('message', function (topic, message) {
  14. //收到的消息是一个Buffer
  15. console.log(message.toString());
  16. client.end();
  17. });
  18. :return:
  19. """
  20. from apps.dispatch.commands import TopicCommand
  21. tc = TopicCommand(cmdNo=201, devNo='test1', params=[], prefix='diag')