For those with Espruino Pico, this opens TLS connection from espruino to socat, and TLS v1.2 from socat to AWS IoT.
root@192.168.2.1> socat openssl-listen:8883,fork,reuseaddr,cert="$HOME/Downloads/61a57a0f66-certificate.pem.crt",key="$HOME/Downloads/61a57a0f66-private.pem.key",verify=0 openssl-connect:A4B6O0T19QBXJ.iot.ap-northeast-1.amazonaws.com:8883,method=TLS1.2,cert="$HOME/Downloads/61a57a0f66-certificate.pem.crt",key="$HOME/Downloads/61a57a0f66-private.pem.key",cafile="$HOME/Downloads/VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem",verify=1
function initEthernet(cb) { SPI2.setup({ mosi:B15, miso:B14, sck:B13 }); var eth = require("WIZnet").connect(SPI2, B10); eth.setIP(); global.eth = eth; if('function' === typeof cb){cb();} } function initMQTT(cb) { var mqtt = require("MQTT").create(); mqtt.on('connected', function() { mqtt.subscribe("$aws/things/+/shadow/#"); mqtt.on('publish', function (pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); if('function' === typeof cb){cb();} }); require("tls").connect("mqtts://192.168.2.1:8883", function(conn) { mqtt.connect(conn); global.mqtt = mqtt; }); } //E.on('init', initEthernet); //E.on('init', initMQTT); //save(); initEthernet(function() { console.log(global.eth.getIP()); initMQTT(function() { console.log("AWS IoT Ready"); }); });
@heri16 started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
For those with Espruino Pico, this opens TLS connection from espruino to socat, and TLS v1.2 from socat to AWS IoT.