Communicate with the Puck code

Posted on
  • How am i able to communicate with the puck say from node red.

    at the moment the puck is advertising events when button is pressed.
    how am i able to sent a response from node red, i.e. MQTT to tell the puck to run a function on my code

  • Check this out:­#controlling-the-puck

    You can have a custom Bluetooth service set up but this way just connects to the Puck's BLE UART and allows you to send JavaScript code to be executed.

  • I have seen this, but i would like to execute a function within my code.

  • Ok, all you do is:

    • Write a function on Puck.js, maybe function myFunction() { ... }
    • Then send an MQTT packet like "myFunction()\n" to /ble/write/de:vi:ce:ad:dr/nus/nus_tx

    If you're interested in what is sent as a reply and don't want Espruino polluting the response with characters like > for the REPL, just prefix the line with char code 16:


  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Communicate with the Puck code

Posted by Avatar for Ossama @Ossama