Shop OBEX P1 Docs P2 Docs Learn Events
Alexa Connect Kit (ACK) — Parallax Forums

Alexa Connect Kit (ACK)

RaymanRayman Posts: 14,755

Was reading about ACK and think it might be neat to try out.
Be fun to control a P1/P2 robot using your voice with Alexa.

It appears to mostly target Arduino, but I've been able to port Arduino code to P1/P2 using FlexProp.
Clang/LLVM might make that easier.

This board looks to be an easy way to implement it:
https://www.digikey.com/en/products/detail/espressif-systems/ESP32-PICO-V3-ZERO-DEVKIT/13560504
Way overpriced given that the actual Pico thing is ~$3, but guess OK to get started.

One thing that concerns me is that I can't find actual Ardiuno code anywhere.
Looks like you have to get it from Amazon after signing up as developer.
So, I'm wondering if Amazon prevents anybody from posting ACK code or if there's just no hobbyists doing this...

Comments

  • RaymanRayman Posts: 14,755

    Just bought the Pico gizmo. Digikey made me sign off on this being an "Engineering Sample". Not seen that before...

  • Seems to me I went down this rabbit hole.

    Alexa can't control your hardware. You have to build a server in the cloud that uses Alexa services that are then used to control your application.

    I think you have to build a skill that is used by Alexa.

    That skill converts your commands into actions that your cloud services use to send commands to your device.

    I gave up after a while.

    Mike

  • RaymanRayman Posts: 14,755

    I found a similar project with what appears to be source code for a Microchip MCU here:
    https://microchip-mplab-harmony.github.io/reference_apps/apps/sam_d21_cnano/samd21_amazon_ack/applications/HelloWorld/readme.html

    @iseries Maybe you're right, but it appears that this setup allows your voice to turn on and off an led on the MCU.
    Maybe cloud services are involved, but nothing I've seens says that so far... But, it's not at all clear how this works...

  • RaymanRayman Posts: 14,755
    edited 2022-02-26 19:58

    Followed the guide here to get Arduino SmartLight example compiling:
    https://developer.amazon.com/en-US/docs/alexa/ack/dev-kit-control-smart-light.html

    Took that code, changed the .ino to .cpp and turned into a project in Visual Studio Pro, so can more easily look through the code.

    Looks like the might not be that hard to port. All the Arduino specific stuff is in one file, ack_arduino_platform.cpp.
    Also, all the ACK library files are plain looking C files. So, FlexProp should work on it. C++ doesn't look to be required.

    All the ACK library does is send and receive specially formatted messages over a serial port connection to the Pico Zero.
    This example initializes the reset and interrupt pins, but doesn't appear to do anything else with them.
    So, might not need to even connect them... Might just need the serial wires and IOREF (for the level shifter) connected.

  • RaymanRayman Posts: 14,755

    Might have an issue with the fancy way the ACK SDK does it's debug printing to serial terminal...
    Seems FlexProp preprocessor doesn't like what they are doing:

    1>C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_core_lifecycle.c:125: error: Not a valid preprocessing token ",("
    1>    macro "ACK_DEBUG_PRINT_C" defined as: #define ACK_DEBUG_PRINT_C(_format,...) ACK_DEBUG_PRINT_BASE(c_pCriticalLevelString, _format, ##__VA_ARGS__)     /* C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_debug_print.h:65    */
    1>    from C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_core_lifecycle.c: 125:            (uint32_t)firmwareVersion);
    1>    from C:/Prop2/Demos_P2/ACK_SmartLight/SmartLight.c: 38:    #include "src/ack_core_lifecycle.c"
    

    Looks like I might have to globally replace things like "ACK_DEBUG_PRINT_C" with just "printf".

  • So, it looks like there is a serial number attached to this device that registers it with the cloud service, so it knows how to communicate with it.

    You register it with your developer account on Alexa to send commands to it which in turn control the LED.

    The key is building that webservice so that it generates a beacon that allows you to register it with Alexa.

    Mike

  • OK, have gone down the rabbit hole again.

    So, the Expressif chip they sell comes with the secret sauce needed to connect to the cloud services. They don't give you that code so that's where I ended.

    Mike

  • @Rayman said:
    Might have an issue with the fancy way the ACK SDK does it's debug printing to serial terminal...
    Seems FlexProp preprocessor doesn't like what they are doing:

    1>C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_core_lifecycle.c:125: error: Not a valid preprocessing token ",("
    1>    macro "ACK_DEBUG_PRINT_C" defined as: #define ACK_DEBUG_PRINT_C(_format,...) ACK_DEBUG_PRINT_BASE(c_pCriticalLevelString, _format, ##__VA_ARGS__)   /* C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_debug_print.h:65    */
    1>    from C:/Prop2/Demos_P2/ACK_SmartLight/src/ack_core_lifecycle.c: 125:            (uint32_t)firmwareVersion);
    1>    from C:/Prop2/Demos_P2/ACK_SmartLight/SmartLight.c: 38:    #include "src/ack_core_lifecycle.c"
    

    Looks like I might have to globally replace things like "ACK_DEBUG_PRINT_C" with just "printf".

    ##__VA_ARGS__ is a C99 feature that FlexProp must be missing. I've use it for that same purpose - writing variadic wrappers around printf. If @ersmith isn't planning on implementing this soon, I imagine you could set up your build system to run the code through a standard C99 preprocessor, such as GCC's cpp, before feeding the result to flexprop.

  • RaymanRayman Posts: 14,755

    @iseries said:
    OK, have gone down the rabbit hole again.

    So, the Expressif chip they sell comes with the secret sauce needed to connect to the cloud services. They don't give you that code so that's where I ended.

    Mike

    So, there is some hidden magic in there...
    But, looks like the Alexa App takes care of this for you.

    When the Pico board powers up, it goes into beacon mode for 5 minutes.
    During that time, you add the device to the Alexa App and then scan the barcode on the Pico board.
    Looks like it automagically works after that...

  • RaymanRayman Posts: 14,755

    @Electrodude Thanks. I guess there are a lot of options here... Can try Clang/LLVM, Catalina, GCC for P1... Not sure what would work best yet...

  • RaymanRayman Posts: 14,755
    edited 2022-02-26 21:44

    Ok, this is starting to look like FlexProp isn't the best option... Getting an error on this:

    // Compiler-independent means of expressing structure packing.
    #if defined(_MSC_VER)
    #define BEGIN_PACKED_STRUCT __pragma(pack(push, 1))
    #define END_PACKED_STRUCT __pragma(pack(pop))
    #define PACKED_STRUCT1
    #define PACKED_STRUCT2
    #elif defined(__GNUC__) || defined(__clang__)
    #define BEGIN_PACKED_STRUCT
    #define END_PACKED_STRUCT
    #define PACKED_STRUCT1 __attribute__((packed))
    #define PACKED_STRUCT2
    #elif defined(__CC_ARM)
    #define BEGIN_PACKED_STRUCT
    #define END_PACKED_STRUCT
    #define PACKED_STRUCT1
    #define PACKED_STRUCT2 __packed
    #else
    #error Unknown compiler; structure packing not configured
    #endif
    

    Never seen something like this before... But, looks like Clang or GCC would work...

  • @Rayman said:
    Ok, this is starting to look like FlexProp isn't the best option... Getting an error on this:

    // Compiler-independent means of expressing structure packing.
    #if defined(_MSC_VER)
    #define BEGIN_PACKED_STRUCT __pragma(pack(push, 1))
    #define END_PACKED_STRUCT __pragma(pack(pop))
    #define PACKED_STRUCT1
    #define PACKED_STRUCT2
    #elif defined(__GNUC__) || defined(__clang__)
    #define BEGIN_PACKED_STRUCT
    #define END_PACKED_STRUCT
    #define PACKED_STRUCT1 __attribute__((packed))
    #define PACKED_STRUCT2
    #elif defined(__CC_ARM)
    #define BEGIN_PACKED_STRUCT
    #define END_PACKED_STRUCT
    #define PACKED_STRUCT1
    #define PACKED_STRUCT2 __packed
    #else
    #error Unknown compiler; structure packing not configured
    #endif
    

    Never seen something like this before... But, looks like Clang or GCC would work...

    Does flexprop support __attribute__((packed)) or some other way to make it pack structs? If not, I imagine it wouldn't be hard for Eric to add.

  • RaymanRayman Posts: 14,755
    edited 2022-03-04 15:07

    Got SmartLight.cpp to compile after adding _Bool, adding a main() function, and adding a space in two places to fix this:

    1>SmartLight.cpp(324,37): error GBBE5DCEC: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
    1> "Handling Mode directive: %"PRIu32" isDelta: %u value: %d",

    Looks like Arduino complains about this too, but treats as a warning instead of error.

    Now, have to figure out all the other .o files we need to make in order for this to actually generate an executable...

  • RaymanRayman Posts: 14,755

    Appears that Arduino compiles all the C/C++ files in the project folder. Guess we need to do that too...

  • Arduino compiles everything every time you do a build. It uses MakeFiles under the covers and then links all the .o together.

    LLVM does the same except for P2LLVM where there are some prebuild archive files to make things simpler.

    Mike

  • RaymanRayman Posts: 14,755
    edited 2022-03-12 19:54

    Trying to compile with GCC for P1...

    Seems like it might work.
    Need to convert stuff in ack_arduino_platform.cpp to P1 version, but just commented it all out for now.

    Have to fix some build errors:
    ack_core_document.c has several place where a typecast is needed. Arduino IDE must allow you to cast from void* to anything without a typecast.
    ack_core_document_wrappers.c has this problem and also is using "namespace" as a variable whereas it seems to be keyword in GCC.
    ack_core_event_builder.c needed some typecasts too.
    same for ack_core_module_acp.c
    same for ack_core_processevent.c

    After that, appears to build, but hub overflowed by 13240 bytes.
    also, several undefined references...

Sign In or Register to comment.