• I finally got to Espruino speaking with Alexa (or viceversa indeed).

    At the moment of writing, it is not working with official 1.94 version, but is working with the current build 2017/11/17 where a fix of UDP.send long message was fixed. (the fix will come into next Espruino firmware).

    In short, I ported to Espruino my Arduino code which emulates Espruino device as a Belkin smart-switch.

    Current stage:

    1. upload BasicCode.js to device first (change your WLan). After that you can access the device over Wlan (each device has its own AP, and it also connects to your local WLan. The rest you work remotely.
    2. Alexa integration what is done already:
      2.a Alexa discover device, each device has it's own ID
      2.b. Device receiving Alexa command and can switch itself ON/OFF each time.

    TODO:
    a. recognize Alexa "SetBinaryState" request ON or OFF the device
    b. send Alexa device "GetBinaryState" status correctly (use Alexa Beta on Android to get those commands easily)

    The code is still dirty work-in-progress (really dirty :) )

    CURRENT STATUS:
    I have major problem that I cann't parse the incoming Alexa.....
    I am struggling with function doPost1() to parse Alexa's POST request where it actually sending if the Light must be ON or OFF.

    I need to retrieve tag <BinaryState> value and make on/off accordingly.

    The text that is stored in pdata is exactly below. Any help is greatly apresciated...

    attached ALEXA_protocol.txt with POST data... not able to copy it here.

    pdata= ..... u:SetBinaryState ... <BinaryState>0</BinaryState>...
    pdata length= 299
    a.pathname= /upnp/control/basicevent1

    Uncaught SyntaxError: Expecting a valid value, got '<'
    at line 1 col 300
    ......
    ^

    Error reported when executing the line pobj=JSON.parse(pdata);


    3 Attachments

About

Avatar for Vasily @Vasily started