You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • Sorry, I'm not sure I understand...

    Sample code on Mac that is causing no issues when sending to a Espruino device after two time JSON5.stringify() like this:

    var noble = require('@abandonware/noble');
    const JSON5 = require('json5');
    var  aJS = {txt : "012345\nabcde\näöüß"};
    var  saJS5 = JSON5.stringify(aJS);    
    // {txt:'012345\nabcde\näöüß'}
    var sa2JS5 =  JSON5.stringify(saJS5);
    // {txt:'012345\\nabcde\\näöüß'}
    var COMMAND = `\x03\x10transfer(${sa2JS5})\n`;
    // transfer("{txt:'012345\\nabcde\\näöüß'}"­)
    
    // use  https://www.espruino.com/Interfacing  Node.js / JavaScript
    // added some seconds before calling disconnect to catch more data
    
    

    sample code on PuckJS

    
    transfer = function (saJS5) {
            var aJS5;
            try {
                aJS5 = eval('('+saJS5+')');
            } catch(e){
                console.log("error in eval:",e);
            }
    }
     
    
About

Avatar for MaBe @MaBe started