mqtt.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <div id="main">
  2. <div id="spinner" class="spinner" hidden></div>
  3. <div id="notification" class="spinner" hidden></div>
  4. <div id="warning" class="spinner" hidden></div>
  5. <div class="header">
  6. <h1>REST &amp; MQTT</h1>
  7. </div>
  8. <div class="content">
  9. <div class="pure-g">
  10. <div class="pure-u-1"><div class="card">
  11. <p>The REST &amp; MQTT support uses the SLIP protocol over the serial port to enable
  12. the attached microcontroller to initiate outbound connections.
  13. The REST support lets the uC initiate simple HTTP requests while the MQTT support
  14. lets it communicate with an MQTT server bidirectionally at QoS 0 thru 2.</p>
  15. <p>The MQTT support is in the form of a built-in client that connects to a server
  16. using parameters set below and stored in meta-id's flash settings. This allows
  17. meta-id to take care of connection parameters and disconnect/reconnect operations.</p>
  18. <p>The MQTT client also supports sending periodic status messages about meta-id itself,
  19. including WiFi RSSI, and free heap memory.</p>
  20. <div class="form-horizontal">
  21. <input type="checkbox" name="slip-enable"/>
  22. <label>Enable SLIP on serial port</label>
  23. </div>
  24. </div></div>
  25. </div>
  26. <div class="pure-g">
  27. <div class="pure-u-1 pure-u-md-1-2">
  28. <div class="card">
  29. <h1>MQTT
  30. <div id="mqtt-spinner" class="spinner spinner-small"></div>
  31. </h1>
  32. <form action="#" id="mqtt-form" class="pure-form" >
  33. <div>
  34. <input type="checkbox" name="mqtt-enable"/>
  35. <label>Enable MQTT client</label>
  36. </div>
  37. <div>
  38. <label>MQTT client state: </label>
  39. <b id="mqtt-state"></b>
  40. </div>
  41. <br>
  42. <legend>MQTT server settings</legend>
  43. <div class="pure-form-stacked">
  44. <label>Server hostname or IP</label>
  45. <input type="text" name="mqtt-host"/>
  46. <label>Server port</label>
  47. <input type="text" name="mqtt-port"/>
  48. <label>Client ID</label>
  49. <input type="text" name="mqtt-client-id"/>
  50. <label>Client Timeout (seconds)</label>
  51. <input type="text" name="mqtt-timeout" />
  52. <label>Keep Alive Interval (seconds)</label>
  53. <input type="text" name="mqtt-keepalive" />
  54. <label>Username</label>
  55. <input type="text" name="mqtt-username"/>
  56. <label>Password</label>
  57. <input type="password" name="mqtt-password"/>
  58. </div>
  59. <button id="mqtt-button" type="submit" class="pure-button button-primary">
  60. Update server settings!
  61. </button>
  62. </form>
  63. </div>
  64. </div>
  65. <div class="pure-u-1 pure-u-md-1-2">
  66. <div class="card">
  67. <h1>Status reporting
  68. <div id="mqtt-status-spinner" class="spinner spinner-small"></div>
  69. </h1>
  70. <form action="#" id="mqtt-status-form" class="pure-form" >
  71. <div class="form-horizontal">
  72. <input type="checkbox" name="mqtt-status-enable"/>
  73. <label>Enable status reporting via MQTT</label>
  74. </div>
  75. <br>
  76. <div class="pure-form-stacked">
  77. <label>Status topic</label>
  78. <input type="text" name="mqtt-status-topic"/>
  79. Message: <tt id="mqtt-status-value"></tt>
  80. <div class="popup">MQTT topic to which status message is sent</div>
  81. </div>
  82. <button id="mqtt-status-button" type="submit" class="pure-button button-primary">
  83. Update status settings!
  84. </button>
  85. </form>
  86. </div>
  87. <div class="card">
  88. <h1>Status reporting
  89. <div id="mqtt-test-spinner" class="spinner spinner-small"></div>
  90. </h1>
  91. <form action="#" id="mqtt-test-form" class="pure-form" >
  92. <div class="form-horizontal">
  93. <input name="mqtt-test"/>
  94. <label>Enable status reporting via MQTT</label>
  95. </div>
  96. <br>
  97. <button id="mqtt-test-button" type="submit" class="pure-button button-primary">
  98. Send !
  99. </button>
  100. </form>
  101. </div>
  102. <div class="card">
  103. <h1>REST</h1>
  104. <p>REST requests are enabled as soon as SLIP is enabled.
  105. There are no REST-specific settings.</p>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <script src="mqtt.js"></script>
  113. <script type="text/javascript">
  114. onLoad(function() {
  115. fetchMqtt();
  116. bnd($("#mqtt-form"), "submit", changeMqtt);
  117. bnd($("#mqtt-test-form"), "submit", changeMqttTest);
  118. bnd($("#mqtt-status-form"), "submit", changeMqttStatus);
  119. });
  120. </script>
  121. </body></html>