Avatar for Steffen

Steffen

Member since Jan 2017 • Last active Mar 2019
  • 17 conversations
  • 54 comments

Most recent activity

    • 2 comments
    • 24 views
  • in Interfacing
    Avatar for Steffen

    I was in need for a small MQTT module with Last Will support and builtin reconnect. I've created one for Node and a derived version for Espruino.
    The code has been written from scratch after the OASIS 3.1.1 spec (without implementing stateful sessions, with some side glances at Paco-MQTT and Espruino MQTT). It is smaller than the existing MQTT module and very fast.
    Is there an interest in having yet another one (file is attached)?

    • Steffen
  • in JavaScript
    Avatar for Steffen

    You are right, it works perfectly well on a clean device.
    It seems like passing a wrong argument (the '\x07' string) causes the error:

    >String.fromCharCode('\x07')  // wrong argument, but no complaint
    ="\0FD"
    >String.fromCharCode(7)     // correct argument, but extra chars
    ="\7FD"
    >String.fromCharCode(8)    // correct argument (above 8 every value gives the correct result)
    ="\b"
    >String.fromCharCode(7)    // correct argument below 8, always with extra chars
    ="\7FD"
    

    (It was pretty hard to find out how to reproduce the effect.)

  • in JavaScript
    Avatar for Steffen

    process.env
    ={
    VERSION: "2v01",
    GIT_COMMIT: "748a4d3",
    BOARD: "ESPRUINOWIFI",
    FLASH: 524288, RAM: 131072,
    SERIAL: "65005000-0b513532-39333638",
    CONSOLE: "USB",
    MODULES: "Flash,Storage,hea" ... ",neopixel,Wifi,AT",
    EXPTR: 536871128 }

  • in JavaScript
    Avatar for Steffen

    String.fromCharCode seems to return strange values for codes below 8:
    String.fromCharCode(8) -> "\b" (OK) String.fromCharCode(7) -> "\713" (???)
    Although String.fromCharCode(7).length returns 1 it doesn't seem to be the same as "\x07".
    What's going on here?

  • in JavaScript
    Avatar for Steffen

    I don't call analogRead() but there is another Waveform active (looking for brightness every 10 s).
    Does it have the same sort of interferences? In this case I'll need to coordinate them.

  • in JavaScript
    Avatar for Steffen

    After putting process.memory() at the end of the callback the errors seem to be gone, along with the inexplicable delays.

    @allObjects: On top of this, I've replaced setInterval with setTimeouts as you suggested. This ensures that the intervals never overlap, allowing to use much shorter intervals.

    Leaves the - somewhat academic - question open why explicitly calling the garbage collection via process.memory was necessary. GC takes about 15 ms, while the idle time between intervals is about 200 ms. I don't mind calling it, quite the contrary. Just thought that > 100 ms were enough for Espruino to decide to do it itself.

  • in JavaScript
    Avatar for Steffen

    .. published part of the code: well, it is pretty nested.
    The code is basically a presence sensor that needs to react snappy (turning on the kitchen light!!).
    I like your suggestion of using setTimeout instead of the more rigid setInterval. Although I think this way the root cause of the (very rare but annoying) delays is only obfuscated.
    I was trying something in the line of setTimeout within the callback but it didn't help so far. I obviously missed some point :(

Actions