aws / aws-iot-device-sdk-arduino-yun

SDK for connecting to AWS IoT from an Arduino Yún.
Apache License 2.0
163 stars 77 forks source link

Received [ERR] command: setup code: -1 with Arduino Yun example: ThermostatSimulatorDevice #51

Closed LabGrunt closed 7 years ago

LabGrunt commented 7 years ago

I have setup my Arduino Yun as instructed in the Readme file in https://github.com/aws/aws-iot-device-sdk-arduino-yun.

Caveat:

I am using Win 7 64-bit. I could upload the blink example to the Yun for sanity check.

I could get Yun to commuicate with AWS IoT through the python examples. But it did not work with the Arduino code. The serial monitor returned a setup error -1. There are probably some steps or configurations that I have missed or incorrectly done but I could not find what they were.

AWS IoT SDK Version(dev) 2.2.0-

YunTestTwo
YunTestTwo
a*************8.iot.us-east-2.amazonaws.com  (I intentionally covered the my endpoint on this post)
8883
/root/AWS-IoT-Python-Runtime/certs/root-CA.crt
/root/AWS-IoT-Python-Runtime/certs/YunTestTwo.private.key
/root/AWS-IoT-Python-Runtime/certs/YunTestTwo.cert.pem
[ERR] command: setup code: -1

My initial setup with AWS IoT was to follow the instructions in Connect from the IoT menu. My steps were

Next, in the Arduino code, I opened the ThermostatSimulatorDevice example and modified aws_iot_config.h.

#define AWS_IOT_MQTT_HOST "a***********8.iot.us-east-2.amazonaws.com"   // your endpoint
#define AWS_IOT_MQTT_PORT 8883                                  // your port
#define AWS_IOT_CLIENT_ID   "YunTestTwo"                        // your client ID
#define AWS_IOT_MY_THING_NAME "YunTestTwo"                      // your thing name
#define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt"           // your root-CA filename
#define AWS_IOT_CERTIFICATE_FILENAME "YunTestTwo.cert.pem"                 // your certificate filename
#define AWS_IOT_PRIVATE_KEY_FILENAME "YunTestTwo.private.key"              // your private key filename

I even modified AWS_IOT_PATH_PREFIX from "../certs/" to "/root/AWS-IoT-Python-Runtime/certs/" but still got the same error.

Thank you in advance for reading my issue and helping me.

liuszeng commented 7 years ago

Hi @LabGrunt ,

Thank you very much for your interest in AWS IoT Arduino Yun SDK.

Yun SDK does depend on a specific version (v1.0.0) of the IoT Python SDK for its Python runtime that does the heavy lifting for MQTT communication. When you are installing the Python SDK on OpenWRT, you need to specify the version. More details can be found in the following documentation: https://github.com/aws/aws-iot-device-sdk-arduino-yun#installation-on-windows

For setup error code -1, to get more debugging information, you can add an extra line to print out rw_buf to the serial monitor to check what error message is coming from OpenWRT. More details can be found in the following post: https://github.com/aws/aws-iot-device-sdk-arduino-yun/issues/25

Can you try switch back to IoT Python SDK v1.0.0 on OpenWRT and attach the log output when experiencing the issue?

Thanks, Liusu

LabGrunt commented 7 years ago

I have installed Python SDK v1.0.0. and added the Serial.println.

The serial monitor output

AWS IoT SDK Version(dev) 2.2.0-

root@Arduino:/# 
/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
root@Arduino:~/AWS-IoTme# 

Traceback (most recent call last):
Setup failed!
-1

The log does not look informative to me.

LabGrunt commented 7 years ago

I have decided to start over and afterwards, it worked.

My steps were

  1. Placed the latest openwrt in a microSD card and inserted it to Yun. (see this tutorial.)
  2. Opened the web browser which should detect the openwrt image and offer to reset.
  3. Clicked the reset and waited for several minutes as instructed.
  4. Placed the AWS IoT certificate and key files as instructed in this git.
  5. Installed the libraries (including distribute, python-openssl, pip and AWSIoTPythonSDK v1.0.0)
  6. Opened the example BasicPubSub to Arduino Yun
  7. Modified the AWS macros in aws_iot_config.h
  8. Note that I did not CHMOD run.py
  9. Opened the serial monitor to see that it started sending messages
  10. Opened the AWS IoT menu > Test
  11. Subscribed to topic "topic1"
  12. Observed the messages appearing on the MQTT client too.