Open raftalarico opened 5 years ago
I've added the debug line Serial.println(rw_buf); to aws_iot_mqtt.cpp
and this is what I'm getting: `
Traceback (most recent call last): Setup failed! -1 Try connect with client-id: ArduinoYun ot@Arduino:~/AWS-IoT-Python-Runtime/runtime# 5 /bin/ash: 1: not found /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied Linux / `
Hi there, I'm trying to set up the Alexa-Arduino Christmas tree project you see here: https://github.com/KayLerch/alexa-xmas-tree
But after uploading the following arduino sketch to the Arduino Yun, I keep getting the "Setup Failed! -1" Error.
Tried Telnet and connection is ok, but probably some issue with authentication. I've checked the pem certificate is in the right folder: /root /AWS-IoT-Python-Runtim /certs aws_iot_root_cert_xmastree.pem
*please note that I'm using MQTT over Websockets connection.
Thanks in advance for your help!
`#include
include
include
include "aws_iot_config.h"
define PIN 6
define NUM_LEDS 50
define BRIGHTNESS 100
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_RGB + NEO_KHZ800); aws_iot_mqtt_client myClient; // init iot_mqtt_client
char msg[32]; // read-write buffer int cnt = 0; // loop counts int numYieldFailed = 0; int rc = -100; // return value placeholder bool success_connect = false; // whether it is connected char JSON_buf[100];
void setup() { // Start Serial for print-out and wait until it's ready Serial.begin(115200); //while(!Serial);
strip.setBrightness(BRIGHTNESS); strip.begin(); strip.show(); // initial color set is orange changeColorBackwards(160, 52, 3, 30); strip.show();
char curr_version[80]; snprintf_P(curr_version, 80, PSTR("AWS IoT SDK Version(dev) %d.%d.%d-%s\n"), VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG); Serial.println(curr_version);
while(success_connect == false) { connect(); } }
void reconnect() { myClient.disconnect(); success_connect = false; while(success_connect == false) { connect(); } }
void connect() { // append random number to client id so that it won't clash with the last connection Serial.println("Try connect with client-id: " + String(AWS_IOT_CLIENT_ID));
if((rc = myClient.setup(AWS_IOT_CLIENT_ID, true, MQTTv311, true)) == 0) { if((rc = myClient.configWss(AWS_IOT_MQTT_HOST, AWS_IOT_MQTT_PORT, AWS_IOT_ROOT_CA_PATH)) == 0) { if((rc = myClient.connect()) == 0) { success_connect = true;
}
void loop() { if(success_connect) { if(myClient.yield()) { light_status_led(124, 114, 32, 500); // indicate with yellow Serial.println(F("Yield failed.")); if (numYieldFailed++ > 9) { // only reconnect if ten invalid attempts in a row reconnect(); } } else { light_status_led(0, 0, 255, 500); // reset error counter numYieldFailed = 0; } delay(500); } }
// the first led of the strand is to show runtime state void light_status_led(int r, int g, int b, int delayMs) { strip.setPixelColor(0, strip.Color(r, g, b)); strip.show(); delay(delayMs); strip.setPixelColor(0, strip.Color(0, 0, 0)); strip.show(); }
bool print_log(const char* src, int code) { bool ret = true; if(code == 0) {
ifdef AWS_IOT_DEBUG
} else {
ifdef AWS_IOT_DEBUG
} Serial.flush(); return ret; }
void msg_callback_delta(char* src, unsigned int len, Message_status_t flag) { Serial.println(F("Message arrived.")); if(flag == STATUS_NORMAL) { print_log("getDeltaKeyValue", myClient.getDeltaValueByKey(src, "io.klerch.alexa.xmastree.skill.model.TreeState\"r", JSON_buf, 50)); int r = (String(JSON_buf)).toInt(); Serial.println(r);
} }
void changeColor(uint8_t r, uint8_t g, uint8_t b, int delayMs) { changeColorPartial(r, g, b, delayMs, strip.numPixels()); }
void changeColorPartial(uint8_t r, uint8_t g, uint8_t b, int delayMs, int to) { for(uint8_t i=0; i < to; i++) { // look for colorful if (r == 1 && g == 1 && b == 1) { strip.setPixelColor(i, strip.Color(random(0, 255), random(0, 255), random(0, 255))); } else { strip.setPixelColor(i, strip.Color(r, g, b)); } if (delayMs > 0) { delay(delayMs); strip.show(); } } strip.show(); }
void randomColors() { for(uint8_t i=0; i<strip.numPixels(); i++) { int r = random(0, 255); int g = random(0, 255); int b = random(0, 255); strip.setPixelColor(i, strip.Color(r, g, b)); Serial.println(String(i) + ") " + String(r) + ", " + String(g) + ", " + String(b)); } strip.show(); }
void changeColorBackwards(uint8_t r, uint8_t g, uint8_t b, int delayMs) { changeColorBackwardsPartial(r, g, b, delayMs, 0); }
void changeColorBackwardsPartial(uint8_t r, uint8_t g, uint8_t b, int delayMs, int to) { for(uint8_t i=strip.numPixels()-1; i > to; i--) { // look for colorful if (r == 1 && g == 1 && b == 1) { strip.setPixelColor(i, strip.Color(random(0, 255), random(0, 255), random(0, 255))); } else { strip.setPixelColor(i, strip.Color(r, g, b)); }
} strip.show(); }`