Alexa Connect Kit (ACK)
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
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
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...
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.
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:
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
##__VA_ARGS__
is a C99 feature that FlexProp must be missing. I've use it for that same purpose - writing variadic wrappers aroundprintf
. 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'scpp
, before feeding the result toflexprop
.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...
@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...
Ok, this is starting to look like FlexProp isn't the best option... Getting an error on this:
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.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...
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
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...