WF8266R-b1f8b93c.html 注意:線上實作平台僅供練習, 程式請自行下載留存, 不定期會清空

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <title>WF8266R.js WebSocket</title>

    <!-- Imports -->
    <script src="http://wf8266.com/wf8266r/webcomponent/jquery-2.1.4.min.js"></script>
    <link href="http://wf8266.com/wf8266r/webcomponent/wf8266r/wf8266r.css" rel="stylesheet" />
    <script>
    function init() {
        var connection = new WebSocket('ws://mywfXXXX.local:81/api', ['wf8266r']);
        connection.onopen = function (e) {
            //連線成功
            connection.send("gpio/adc");
        };
        connection.onclose = function (e) {
            //連線關閉
        };
        connection.onmessage = function (e) {
            //收到來自 WF8266R 的訊息
            $("#message").text(e.data);
        };
        connection.onerror = function (e) {
            //不明的錯誤
        };
    }
    </script>
</head>
<body onload="init()">
Data : <span id="message"></span>
</body>

</html>

請按 RUN 執行