2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node-redでwebsocketブリッヂ使ってmythingsを発火

Posted at

概要

どうにも、node-redからmythingsにトリガー送れなくて、裏技使った。
jsdo.itで動かす。ライブラリーは、meshblu.js使った。

写真

websocket.jpg

サンプルコード

var red;
var conn;
function setup() {
    var url = "you .jp-east.compute.idcfcloud.com";
    var uuid = '';
    var token = '';
    red = new WebSocket("ws://node-red /test0");
    red.onmessage = function(e) {
        alert("red received data : " + e.data);
        conn.data({
            'uuid': uuid,
            'text1': 'ohisama'
        });
    };
    conn = meshblu.createConnection({
         'uuid': uuid,
         'token': token,
         'server': url, 
         'port': 80
    });
    conn.on('notReady', function(data) {
        alert('UUID FAILED AUTHENTICATION!');
    });
    conn.on('ready', function(data) {
        alert('conn open');
    });
}
setup();
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?