• "listening" is not implemented. Espruino code reduced to:

    /*
    ESPRUINO WIFI
    */
    var WIFI_NAME = "Paradise";
    var WIFI_OPTIONS = { password : "XYZ" };
    var PORT = 7077;
    var wifi = require("EspruinoWiFi");
    var dgram = require('dgram');
    wifi.connect(WIFI_NAME, WIFI_OPTIONS, function (err) {
        if (err) {
            console.log("Connection error: " + err);
        }
        wifi.getIP(function (f, ip) {
            console.log("Connected: " + ip.ip);
            // UDP Broadcast
            var client = dgram.createSocket("udp4");
    
            client.on('message', function (message, rinfo) {
                console.log('UDP Msg: ' + rinfo.address + ':' + rinfo.port +' - ' + message);
                try {
                    var u = JSON.parse(message);
                    console.log('OK:'+u.cfg);
                }
                catch(err) {
                    console.log('ERR: UPD packet not JSON, ignore');
                }
            });
            client.bind(PORT);
        });
    });
    
About

Avatar for Sacha @Sacha started