diff --git a/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c-2.1.1/0001-aws-iot-samples-modify-provided-samples-to-work-in-o.patch b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c-2.1.1/0001-aws-iot-samples-modify-provided-samples-to-work-in-o.patch new file mode 100644 index 000000000..8cf616baf --- /dev/null +++ b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c-2.1.1/0001-aws-iot-samples-modify-provided-samples-to-work-in-o.patch @@ -0,0 +1,149 @@ +From: Tatiana Leon +Date: Wed, 3 May 2017 18:12:52 +0200 +Subject: [PATCH] aws-iot-samples: modify provided samples to work in our + platforms + +Signed-off-by: Tatiana Leon +--- + samples/linux/shadow_sample/shadow_sample.c | 20 ++++++++++---------- + .../shadow_sample_console_echo/shadow_console_echo.c | 20 ++++++++++---------- + .../subscribe_publish_sample.c | 12 ++++++------ + 3 files changed, 26 insertions(+), 26 deletions(-) + +diff --git a/samples/linux/shadow_sample/shadow_sample.c b/samples/linux/shadow_sample/shadow_sample.c +index 9a0b270..fc73a2d 100644 +--- a/samples/linux/shadow_sample/shadow_sample.c ++++ b/samples/linux/shadow_sample/shadow_sample.c +@@ -59,7 +59,7 @@ + + #define MAX_LENGTH_OF_UPDATE_JSON_BUFFER 200 + +-static char certDirectory[PATH_MAX + 1] = "../../../certs"; ++static char certDirectory[PATH_MAX + 1] = ""; + static char HostAddress[255] = AWS_IOT_MQTT_HOST; + static uint32_t port = AWS_IOT_MQTT_PORT; + static uint8_t numPubs = 5; +@@ -164,27 +164,27 @@ int main(int argc, char **argv) { + char rootCA[PATH_MAX + 1]; + char clientCRT[PATH_MAX + 1]; + char clientKey[PATH_MAX + 1]; +- char CurrentWD[PATH_MAX + 1]; + + IOT_INFO("\nAWS IoT SDK Version %d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG); + +- getcwd(CurrentWD, sizeof(CurrentWD)); +- snprintf(rootCA, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_ROOT_CA_FILENAME); +- snprintf(clientCRT, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_CERTIFICATE_FILENAME); +- snprintf(clientKey, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); ++ parseInputArgsForConnectParams(argc, argv); ++ ++ if (certDirectory[0] == '\0') ++ snprintf(certDirectory, PATH_MAX + 1, "%s", "/etc/ssl/certs"); ++ snprintf(rootCA, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_ROOT_CA_FILENAME); ++ snprintf(clientCRT, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_CERTIFICATE_FILENAME); ++ snprintf(clientKey, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); + + IOT_DEBUG("rootCA %s", rootCA); + IOT_DEBUG("clientCRT %s", clientCRT); + IOT_DEBUG("clientKey %s", clientKey); + +- parseInputArgsForConnectParams(argc, argv); +- + // initialize the mqtt client + AWS_IoT_Client mqttClient; + + ShadowInitParameters_t sp = ShadowInitParametersDefault; +- sp.pHost = AWS_IOT_MQTT_HOST; +- sp.port = AWS_IOT_MQTT_PORT; ++ sp.pHost = HostAddress; ++ sp.port = port; + sp.pClientCRT = clientCRT; + sp.pClientKey = clientKey; + sp.pRootCA = rootCA; +diff --git a/samples/linux/shadow_sample_console_echo/shadow_console_echo.c b/samples/linux/shadow_sample_console_echo/shadow_console_echo.c +index 1c491fb..e333094 100644 +--- a/samples/linux/shadow_sample_console_echo/shadow_console_echo.c ++++ b/samples/linux/shadow_sample_console_echo/shadow_console_echo.c +@@ -53,7 +53,7 @@ + * @note Ensure the buffer sizes in aws_iot_config.h are big enough to receive the delta message. The delta message will also contain the metadata with the timestamps + */ + +-char certDirectory[PATH_MAX + 1] = "../../../certs"; ++char certDirectory[PATH_MAX + 1] = ""; + char HostAddress[255] = AWS_IOT_MQTT_HOST; + uint32_t port = AWS_IOT_MQTT_PORT; + bool messageArrivedOnDelta = false; +@@ -80,27 +80,27 @@ int main(int argc, char** argv) { + char rootCA[PATH_MAX + 1]; + char clientCRT[PATH_MAX + 1]; + char clientKey[PATH_MAX + 1]; +- char CurrentWD[PATH_MAX + 1]; + + IOT_INFO("\nAWS IoT SDK Version %d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG); + +- getcwd(CurrentWD, sizeof(CurrentWD)); +- snprintf(rootCA, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_ROOT_CA_FILENAME); +- snprintf(clientCRT, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_CERTIFICATE_FILENAME); +- snprintf(clientKey, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); ++ parseInputArgsForConnectParams(argc, argv); ++ ++ if (certDirectory[0] == '\0') ++ snprintf(certDirectory, PATH_MAX + 1, "%s", "/etc/ssl/certs"); ++ snprintf(rootCA, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_ROOT_CA_FILENAME); ++ snprintf(clientCRT, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_CERTIFICATE_FILENAME); ++ snprintf(clientKey, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); + + IOT_DEBUG("rootCA %s", rootCA); + IOT_DEBUG("clientCRT %s", clientCRT); + IOT_DEBUG("clientKey %s", clientKey); + +- parseInputArgsForConnectParams(argc, argv); +- + // initialize the mqtt client + AWS_IoT_Client mqttClient; + + ShadowInitParameters_t sp = ShadowInitParametersDefault; +- sp.pHost = AWS_IOT_MQTT_HOST; +- sp.port = AWS_IOT_MQTT_PORT; ++ sp.pHost = HostAddress; ++ sp.port = port; + sp.pClientCRT = clientCRT; + sp.pClientKey = clientKey; + sp.pRootCA = rootCA; +diff --git a/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c b/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c +index 4f92645..d0fef05 100644 +--- a/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c ++++ b/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c +@@ -40,7 +40,7 @@ + /** + * @brief Default cert location + */ +-char certDirectory[PATH_MAX + 1] = "../../../certs"; ++char certDirectory[PATH_MAX + 1] = ""; + + /** + * @brief Default MQTT HOST URL is pulled from the aws_iot_config.h +@@ -132,7 +132,6 @@ int main(int argc, char **argv) { + char rootCA[PATH_MAX + 1]; + char clientCRT[PATH_MAX + 1]; + char clientKey[PATH_MAX + 1]; +- char CurrentWD[PATH_MAX + 1]; + char cPayload[100]; + + int32_t i = 0; +@@ -150,10 +149,11 @@ int main(int argc, char **argv) { + + IOT_INFO("\nAWS IoT SDK Version %d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG); + +- getcwd(CurrentWD, sizeof(CurrentWD)); +- snprintf(rootCA, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_ROOT_CA_FILENAME); +- snprintf(clientCRT, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_CERTIFICATE_FILENAME); +- snprintf(clientKey, PATH_MAX + 1, "%s/%s/%s", CurrentWD, certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); ++ if (certDirectory[0] == '\0') ++ snprintf(certDirectory, PATH_MAX + 1, "%s", "/etc/ssl/certs"); ++ snprintf(rootCA, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_ROOT_CA_FILENAME); ++ snprintf(clientCRT, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_CERTIFICATE_FILENAME); ++ snprintf(clientKey, PATH_MAX + 1, "%s/%s", certDirectory, AWS_IOT_PRIVATE_KEY_FILENAME); + + IOT_DEBUG("rootCA %s", rootCA); + IOT_DEBUG("clientCRT %s", clientCRT); diff --git a/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb index 866990ef0..47d97b281 100644 --- a/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb +++ b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb @@ -10,6 +10,7 @@ DEPENDS = "mbedtls" SRC_URI = " \ https://github.com/aws/aws-iot-device-sdk-embedded-C/archive/v${PV}.tar.gz \ + file://0001-aws-iot-samples-modify-provided-samples-to-work-in-o.patch \ file://aws_iot_config.h.template \ file://awsiotsdk.pc \ file://Makefile \