• I might have found a way around my problem with an additional call eval('typeof prop') to check if the property exist and is a function or not.

    Ok that approach work. It is a tricky code with a few promise and using https://github.com/kozhevnikov/proxymise­ on top.

    Code is very rough right now, just working my way around things. But, if curious, for now code is here: https://editor.p5js.org/jgrizou/sketches­/Si31amD_p (see robot.js and sketch.js) and testable at https://editor.p5js.org/jgrizou/present/­Si31amD_p

    For example, if you have a espruino device with a code like:

    var speed = 0.5;
    var on;
    function toggle() {
      on = !on;
      digitalWrite(LED1, on);
    function add(x, y) {
      return x+y;

    You can load this page https://editor.p5js.org/jgrizou/present/­Si31amD_p, click connect button and connect to the device.

    Then in the webbrowser console the following commands should work:

    await proxymiseRobot.speed
    // 0.5
    await proxymiseRobot.toggle()
    // light should toggle
    await proxymiseRobot.add(2,2)
    // 4

    A lot of cleaning, refactoring, bulletproofing is required, but the conceptual basis are there and it seems to work so I have hope, see head of sketch.js at https://editor.p5js.org/jgrizou/sketches­/Si31amD_p.

    That was fun anyway! I will try to handle the set route in the proxy too.

    In time, I will make it a standalone and actually usable library but for now I am exploring.


Avatar for jgrizou @jgrizou started