Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: adding sample to communicate with aws iot #23469

Closed
wants to merge 1 commit into from

Conversation

md-jamal
Copy link

Signed-off-by: Mohammad Jamal Mohiuddin md.jamalmohiuddin@gmail.com

Signed-off-by: Mohammad Jamal Mohiuddin <md.jamalmohiuddin@gmail.com>
@zephyrbot
Copy link
Collaborator

Some checks failed. Please fix and resubmit.

checkpatch issues

-:279: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#279: FILE: samples/net/cloud/aws_mqtt/src/main.c:32:
+    APP_CA_CERT_TAG,$

-:280: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#280: FILE: samples/net/cloud/aws_mqtt/src/main.c:33:
+    APP_PRIVATE_SERVER_KEY_TAG,$

-:311: ERROR:SWITCH_CASE_INDENT_LEVEL: switch and case should be at the same indent
#311: FILE: samples/net/cloud/aws_mqtt/src/main.c:64:
+	switch (evt->type) {
+		case MQTT_EVT_CONNACK:
[...]
+		case MQTT_EVT_DISCONNECT:
[...]
+		case MQTT_EVT_PUBACK:
[...]
+		case MQTT_EVT_PUBREC:
[...]
+		case MQTT_EVT_PUBCOMP:
[...]
+		default:

-:333: WARNING:LONG_LINE: line over 80 characters
#333: FILE: samples/net/cloud/aws_mqtt/src/main.c:86:
+			LOG_INF("PUBACK packet id: %u", evt->param.puback.message_id);

-:343: WARNING:LONG_LINE: line over 80 characters
#343: FILE: samples/net/cloud/aws_mqtt/src/main.c:96:
+			LOG_INF("PUBREC packet id: %u", evt->param.pubrec.message_id);

-:394: WARNING:LINE_SPACING: Missing a blank line after declarations
#394: FILE: samples/net/cloud/aws_mqtt/src/main.c:147:
+	struct mqtt_sec_config *tls_config = &client->transport.tls.config;
+	tls_config->peer_verify = TLS_PEER_VERIFY_REQUIRED;

-:404: ERROR:CODE_INDENT: code indent should use tabs where possible
#404: FILE: samples/net/cloud/aws_mqtt/src/main.c:157:
+        int res;$

-:404: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#404: FILE: samples/net/cloud/aws_mqtt/src/main.c:157:
+        int res;$

-:405: ERROR:CODE_INDENT: code indent should use tabs where possible
#405: FILE: samples/net/cloud/aws_mqtt/src/main.c:158:
+        struct zsock_pollfd fds[1] = {$

-:405: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#405: FILE: samples/net/cloud/aws_mqtt/src/main.c:158:
+        struct zsock_pollfd fds[1] = {$

-:406: ERROR:CODE_INDENT: code indent should use tabs where possible
#406: FILE: samples/net/cloud/aws_mqtt/src/main.c:159:
+                [0] = {.fd = client_ctx.transport.tls.sock,$

-:406: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#406: FILE: samples/net/cloud/aws_mqtt/src/main.c:159:
+                [0] = {.fd = client_ctx.transport.tls.sock,$

-:407: ERROR:CODE_INDENT: code indent should use tabs where possible
#407: FILE: samples/net/cloud/aws_mqtt/src/main.c:160:
+                      .events = ZSOCK_POLLIN,$

-:407: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#407: FILE: samples/net/cloud/aws_mqtt/src/main.c:160:
+                      .events = ZSOCK_POLLIN,$

-:408: ERROR:CODE_INDENT: code indent should use tabs where possible
#408: FILE: samples/net/cloud/aws_mqtt/src/main.c:161:
+                      .revents = 0},$

-:408: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#408: FILE: samples/net/cloud/aws_mqtt/src/main.c:161:
+                      .revents = 0},$

-:409: ERROR:CODE_INDENT: code indent should use tabs where possible
#409: FILE: samples/net/cloud/aws_mqtt/src/main.c:162:
+        };$

-:409: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#409: FILE: samples/net/cloud/aws_mqtt/src/main.c:162:
+        };$

-:411: ERROR:CODE_INDENT: code indent should use tabs where possible
#411: FILE: samples/net/cloud/aws_mqtt/src/main.c:164:
+        res = zsock_poll(fds, 1, timeout);$

-:411: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#411: FILE: samples/net/cloud/aws_mqtt/src/main.c:164:
+        res = zsock_poll(fds, 1, timeout);$

-:412: ERROR:CODE_INDENT: code indent should use tabs where possible
#412: FILE: samples/net/cloud/aws_mqtt/src/main.c:165:
+        if (res < 0) {$

-:412: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#412: FILE: samples/net/cloud/aws_mqtt/src/main.c:165:
+        if (res < 0) {$

-:413: ERROR:CODE_INDENT: code indent should use tabs where possible
#413: FILE: samples/net/cloud/aws_mqtt/src/main.c:166:
+                LOG_ERR("poll read event error");$

-:413: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#413: FILE: samples/net/cloud/aws_mqtt/src/main.c:166:
+                LOG_ERR("poll read event error");$

-:414: ERROR:CODE_INDENT: code indent should use tabs where possible
#414: FILE: samples/net/cloud/aws_mqtt/src/main.c:167:
+                return -errno;$

-:414: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#414: FILE: samples/net/cloud/aws_mqtt/src/main.c:167:
+                return -errno;$

-:415: ERROR:CODE_INDENT: code indent should use tabs where possible
#415: FILE: samples/net/cloud/aws_mqtt/src/main.c:168:
+        }$

-:415: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#415: FILE: samples/net/cloud/aws_mqtt/src/main.c:168:
+        }$

-:416: ERROR:CODE_INDENT: code indent should use tabs where possible
#416: FILE: samples/net/cloud/aws_mqtt/src/main.c:169:
+        return res;$

-:416: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#416: FILE: samples/net/cloud/aws_mqtt/src/main.c:169:
+        return res;$

-:429: ERROR:SPACING: space required after that close brace '}'
#429: FILE: samples/net/cloud/aws_mqtt/src/main.c:182:
+	}else {

-:446: ERROR:CODE_INDENT: code indent should use tabs where possible
#446: FILE: samples/net/cloud/aws_mqtt/src/main.c:199:
+        char payload[] = "{id=123}";$

-:446: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#446: FILE: samples/net/cloud/aws_mqtt/src/main.c:199:
+        char payload[] = "{id=123}";$

-:447: ERROR:CODE_INDENT: code indent should use tabs where possible
#447: FILE: samples/net/cloud/aws_mqtt/src/main.c:200:
+        char topic[] = "/things/";$

-:447: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#447: FILE: samples/net/cloud/aws_mqtt/src/main.c:200:
+        char topic[] = "/things/";$

-:448: ERROR:CODE_INDENT: code indent should use tabs where possible
#448: FILE: samples/net/cloud/aws_mqtt/src/main.c:201:
+        u8_t len = strlen(topic);$

-:448: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#448: FILE: samples/net/cloud/aws_mqtt/src/main.c:201:
+        u8_t len = strlen(topic);$

-:449: ERROR:CODE_INDENT: code indent should use tabs where possible
#449: FILE: samples/net/cloud/aws_mqtt/src/main.c:202:
+        struct mqtt_publish_param param;$

-:449: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#449: FILE: samples/net/cloud/aws_mqtt/src/main.c:202:
+        struct mqtt_publish_param param;$

-:453: ERROR:CODE_INDENT: code indent should use tabs where possible
#453: FILE: samples/net/cloud/aws_mqtt/src/main.c:206:
+        param.message.topic.qos = qos;$

-:453: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#453: FILE: samples/net/cloud/aws_mqtt/src/main.c:206:
+        param.message.topic.qos = qos;$

-:454: ERROR:CODE_INDENT: code indent should use tabs where possible
#454: FILE: samples/net/cloud/aws_mqtt/src/main.c:207:
+        param.message.topic.topic.utf8 = (u8_t *)topic;$

-:454: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#454: FILE: samples/net/cloud/aws_mqtt/src/main.c:207:
+        param.message.topic.topic.utf8 = (u8_t *)topic;$

-:455: ERROR:CODE_INDENT: code indent should use tabs where possible
#455: FILE: samples/net/cloud/aws_mqtt/src/main.c:208:
+        param.message.topic.topic.size = len;$

-:455: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#455: FILE: samples/net/cloud/aws_mqtt/src/main.c:208:
+        param.message.topic.topic.size = len;$

-:456: ERROR:CODE_INDENT: code indent should use tabs where possible
#456: FILE: samples/net/cloud/aws_mqtt/src/main.c:209:
+        param.message.payload.data = pub_msg;$

-:456: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#456: FILE: samples/net/cloud/aws_mqtt/src/main.c:209:
+        param.message.payload.data = pub_msg;$

-:457: ERROR:CODE_INDENT: code indent should use tabs where possible
#457: FILE: samples/net/cloud/aws_mqtt/src/main.c:210:
+        param.message.payload.len = strlen(payload);$

-:457: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#457: FILE: samples/net/cloud/aws_mqtt/src/main.c:210:
+        param.message.payload.len = strlen(payload);$

-:458: ERROR:CODE_INDENT: code indent should use tabs where possible
#458: FILE: samples/net/cloud/aws_mqtt/src/main.c:211:
+        param.message_id = sys_rand32_get();$

-:458: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#458: FILE: samples/net/cloud/aws_mqtt/src/main.c:211:
+        param.message_id = sys_rand32_get();$

-:459: ERROR:CODE_INDENT: code indent should use tabs where possible
#459: FILE: samples/net/cloud/aws_mqtt/src/main.c:212:
+        param.dup_flag = 0U;$

-:459: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#459: FILE: samples/net/cloud/aws_mqtt/src/main.c:212:
+        param.dup_flag = 0U;$

-:460: ERROR:CODE_INDENT: code indent should use tabs where possible
#460: FILE: samples/net/cloud/aws_mqtt/src/main.c:213:
+        param.retain_flag = 0U;$

-:460: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#460: FILE: samples/net/cloud/aws_mqtt/src/main.c:213:
+        param.retain_flag = 0U;$

-:466: ERROR:CODE_INDENT: code indent should use tabs where possible
#466: FILE: samples/net/cloud/aws_mqtt/src/main.c:219:
+        while (1) {$

-:466: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#466: FILE: samples/net/cloud/aws_mqtt/src/main.c:219:
+        while (1) {$

-:467: ERROR:CODE_INDENT: code indent should use tabs where possible
#467: FILE: samples/net/cloud/aws_mqtt/src/main.c:220:
+                LOG_INF("Publishing data");$

-:467: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#467: FILE: samples/net/cloud/aws_mqtt/src/main.c:220:
+                LOG_INF("Publishing data");$

-:468: ERROR:CODE_INDENT: code indent should use tabs where possible
#468: FILE: samples/net/cloud/aws_mqtt/src/main.c:221:
+                sprintf(pub_msg, "%s: %d\n", "payload", param.message_id);$

-:468: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#468: FILE: samples/net/cloud/aws_mqtt/src/main.c:221:
+                sprintf(pub_msg, "%s: %d\n", "payload", param.message_id);$

-:469: ERROR:CODE_INDENT: code indent should use tabs where possible
#469: FILE: samples/net/cloud/aws_mqtt/src/main.c:222:
+                param.message.payload.len = strlen(pub_msg);$

-:469: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#469: FILE: samples/net/cloud/aws_mqtt/src/main.c:222:
+                param.message.payload.len = strlen(pub_msg);$

-:470: ERROR:CODE_INDENT: code indent should use tabs where possible
#470: FILE: samples/net/cloud/aws_mqtt/src/main.c:223:
+                err = mqtt_publish(client, &param);$

-:470: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#470: FILE: samples/net/cloud/aws_mqtt/src/main.c:223:
+                err = mqtt_publish(client, &param);$

-:471: ERROR:CODE_INDENT: code indent should use tabs where possible
#471: FILE: samples/net/cloud/aws_mqtt/src/main.c:224:
+                if (err) {$

-:471: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#471: FILE: samples/net/cloud/aws_mqtt/src/main.c:224:
+                if (err) {$

-:472: ERROR:CODE_INDENT: code indent should use tabs where possible
#472: FILE: samples/net/cloud/aws_mqtt/src/main.c:225:
+                        LOG_ERR("could not publish, error %d", err);$

-:472: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#472: FILE: samples/net/cloud/aws_mqtt/src/main.c:225:
+                        LOG_ERR("could not publish, error %d", err);$

-:472: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'publish', this function's name, in a string
#472: FILE: samples/net/cloud/aws_mqtt/src/main.c:225:
+                        LOG_ERR("could not publish, error %d", err);

-:473: ERROR:CODE_INDENT: code indent should use tabs where possible
#473: FILE: samples/net/cloud/aws_mqtt/src/main.c:226:
+                        break;$

-:473: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#473: FILE: samples/net/cloud/aws_mqtt/src/main.c:226:
+                        break;$

-:474: ERROR:CODE_INDENT: code indent should use tabs where possible
#474: FILE: samples/net/cloud/aws_mqtt/src/main.c:227:
+                }$

-:474: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#474: FILE: samples/net/cloud/aws_mqtt/src/main.c:227:
+                }$

-:476: ERROR:CODE_INDENT: code indent should use tabs where possible
#476: FILE: samples/net/cloud/aws_mqtt/src/main.c:229:
+                /* idle and process messages */$

-:477: ERROR:CODE_INDENT: code indent should use tabs where possible
#477: FILE: samples/net/cloud/aws_mqtt/src/main.c:230:
+                while (k_uptime_get() < next_alive) {$

-:477: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#477: FILE: samples/net/cloud/aws_mqtt/src/main.c:230:
+                while (k_uptime_get() < next_alive) {$

-:478: ERROR:CODE_INDENT: code indent should use tabs where possible
#478: FILE: samples/net/cloud/aws_mqtt/src/main.c:231:
+                        LOG_INF("... idling ...");$

-:478: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#478: FILE: samples/net/cloud/aws_mqtt/src/main.c:231:
+                        LOG_INF("... idling ...");$

-:479: ERROR:CODE_INDENT: code indent should use tabs where possible
#479: FILE: samples/net/cloud/aws_mqtt/src/main.c:232:
+                        if (wait_for_input(5000) > 0) {$

-:479: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#479: FILE: samples/net/cloud/aws_mqtt/src/main.c:232:
+                        if (wait_for_input(5000) > 0) {$

-:480: ERROR:CODE_INDENT: code indent should use tabs where possible
#480: FILE: samples/net/cloud/aws_mqtt/src/main.c:233:
+                                mqtt_input(client);$

-:480: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#480: FILE: samples/net/cloud/aws_mqtt/src/main.c:233:
+                                mqtt_input(client);$

-:481: ERROR:CODE_INDENT: code indent should use tabs where possible
#481: FILE: samples/net/cloud/aws_mqtt/src/main.c:234:
+                        }$

-:481: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#481: FILE: samples/net/cloud/aws_mqtt/src/main.c:234:
+                        }$

-:482: ERROR:CODE_INDENT: code indent should use tabs where possible
#482: FILE: samples/net/cloud/aws_mqtt/src/main.c:235:
+                }$

-:482: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#482: FILE: samples/net/cloud/aws_mqtt/src/main.c:235:
+                }$

-:483: ERROR:CODE_INDENT: code indent should use tabs where possible
#483: FILE: samples/net/cloud/aws_mqtt/src/main.c:236:
+                mqtt_live(client);$

-:483: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#483: FILE: samples/net/cloud/aws_mqtt/src/main.c:236:
+                mqtt_live(client);$

-:484: ERROR:CODE_INDENT: code indent should use tabs where possible
#484: FILE: samples/net/cloud/aws_mqtt/src/main.c:237:
+                next_alive += ALIVE_TIME;$

-:484: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#484: FILE: samples/net/cloud/aws_mqtt/src/main.c:237:
+                next_alive += ALIVE_TIME;$

-:485: ERROR:CODE_INDENT: code indent should use tabs where possible
#485: FILE: samples/net/cloud/aws_mqtt/src/main.c:238:
+        }$

-:485: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#485: FILE: samples/net/cloud/aws_mqtt/src/main.c:238:
+        }$

-:490: ERROR:CODE_INDENT: code indent should use tabs where possible
#490: FILE: samples/net/cloud/aws_mqtt/src/main.c:243:
+        int err = -EINVAL;$

-:490: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#490: FILE: samples/net/cloud/aws_mqtt/src/main.c:243:
+        int err = -EINVAL;$

-:492: ERROR:CODE_INDENT: code indent should use tabs where possible
#492: FILE: samples/net/cloud/aws_mqtt/src/main.c:245:
+        err = tls_credential_add(APP_CA_CERT_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,$

-:492: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#492: FILE: samples/net/cloud/aws_mqtt/src/main.c:245:
+        err = tls_credential_add(APP_CA_CERT_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,$

-:493: WARNING:LONG_LINE: line over 80 characters
#493: FILE: samples/net/cloud/aws_mqtt/src/main.c:246:
+                                 amazon_certificate, sizeof(amazon_certificate));

-:493: ERROR:CODE_INDENT: code indent should use tabs where possible
#493: FILE: samples/net/cloud/aws_mqtt/src/main.c:246:
+                                 amazon_certificate, sizeof(amazon_certificate));$

-:493: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#493: FILE: samples/net/cloud/aws_mqtt/src/main.c:246:
+                                 amazon_certificate, sizeof(amazon_certificate));$

-:494: ERROR:CODE_INDENT: code indent should use tabs where possible
#494: FILE: samples/net/cloud/aws_mqtt/src/main.c:247:
+        if (err < 0) {$

-:494: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#494: FILE: samples/net/cloud/aws_mqtt/src/main.c:247:
+        if (err < 0) {$

-:495: ERROR:CODE_INDENT: code indent should use tabs where possible
#495: FILE: samples/net/cloud/aws_mqtt/src/main.c:248:
+                LOG_ERR("Failed to register ca certificate: %d", err);$

-:495: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#495: FILE: samples/net/cloud/aws_mqtt/src/main.c:248:
+                LOG_ERR("Failed to register ca certificate: %d", err);$

-:496: ERROR:CODE_INDENT: code indent should use tabs where possible
#496: FILE: samples/net/cloud/aws_mqtt/src/main.c:249:
+                return err;$

-:496: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#496: FILE: samples/net/cloud/aws_mqtt/src/main.c:249:
+                return err;$

-:497: ERROR:CODE_INDENT: code indent should use tabs where possible
#497: FILE: samples/net/cloud/aws_mqtt/src/main.c:250:
+        }$

-:497: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#497: FILE: samples/net/cloud/aws_mqtt/src/main.c:250:
+        }$

-:499: WARNING:LONG_LINE: line over 80 characters
#499: FILE: samples/net/cloud/aws_mqtt/src/main.c:252:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_PRIVATE_KEY,

-:499: ERROR:CODE_INDENT: code indent should use tabs where possible
#499: FILE: samples/net/cloud/aws_mqtt/src/main.c:252:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_PRIVATE_KEY,$

-:499: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#499: FILE: samples/net/cloud/aws_mqtt/src/main.c:252:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_PRIVATE_KEY,$

-:500: ERROR:CODE_INDENT: code indent should use tabs where possible
#500: FILE: samples/net/cloud/aws_mqtt/src/main.c:253:
+                                 private_key, sizeof(private_key));$

-:500: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#500: FILE: samples/net/cloud/aws_mqtt/src/main.c:253:
+                                 private_key, sizeof(private_key));$

-:501: ERROR:CODE_INDENT: code indent should use tabs where possible
#501: FILE: samples/net/cloud/aws_mqtt/src/main.c:254:
+        if (err < 0) {$

-:501: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#501: FILE: samples/net/cloud/aws_mqtt/src/main.c:254:
+        if (err < 0) {$

-:502: ERROR:CODE_INDENT: code indent should use tabs where possible
#502: FILE: samples/net/cloud/aws_mqtt/src/main.c:255:
+                LOG_ERR("Failed to register private key: %d", err);$

-:502: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#502: FILE: samples/net/cloud/aws_mqtt/src/main.c:255:
+                LOG_ERR("Failed to register private key: %d", err);$

-:503: ERROR:CODE_INDENT: code indent should use tabs where possible
#503: FILE: samples/net/cloud/aws_mqtt/src/main.c:256:
+                return err;$

-:503: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#503: FILE: samples/net/cloud/aws_mqtt/src/main.c:256:
+                return err;$

-:504: ERROR:CODE_INDENT: code indent should use tabs where possible
#504: FILE: samples/net/cloud/aws_mqtt/src/main.c:257:
+        }$

-:504: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#504: FILE: samples/net/cloud/aws_mqtt/src/main.c:257:
+        }$

-:506: WARNING:LONG_LINE: line over 80 characters
#506: FILE: samples/net/cloud/aws_mqtt/src/main.c:259:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_SERVER_CERTIFICATE,

-:506: ERROR:CODE_INDENT: code indent should use tabs where possible
#506: FILE: samples/net/cloud/aws_mqtt/src/main.c:259:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_SERVER_CERTIFICATE,$

-:506: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#506: FILE: samples/net/cloud/aws_mqtt/src/main.c:259:
+        err = tls_credential_add(APP_PRIVATE_SERVER_KEY_TAG, TLS_CREDENTIAL_SERVER_CERTIFICATE,$

-:507: ERROR:CODE_INDENT: code indent should use tabs where possible
#507: FILE: samples/net/cloud/aws_mqtt/src/main.c:260:
+                                 server_cert, sizeof(server_cert));$

-:507: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#507: FILE: samples/net/cloud/aws_mqtt/src/main.c:260:
+                                 server_cert, sizeof(server_cert));$

-:508: ERROR:CODE_INDENT: code indent should use tabs where possible
#508: FILE: samples/net/cloud/aws_mqtt/src/main.c:261:
+        if (err < 0) {$

-:508: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#508: FILE: samples/net/cloud/aws_mqtt/src/main.c:261:
+        if (err < 0) {$

-:509: ERROR:CODE_INDENT: code indent should use tabs where possible
#509: FILE: samples/net/cloud/aws_mqtt/src/main.c:262:
+                LOG_ERR("Failed to register server certificate: %d", err);$

-:509: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#509: FILE: samples/net/cloud/aws_mqtt/src/main.c:262:
+                LOG_ERR("Failed to register server certificate: %d", err);$

-:510: ERROR:CODE_INDENT: code indent should use tabs where possible
#510: FILE: samples/net/cloud/aws_mqtt/src/main.c:263:
+                return err;$

-:510: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#510: FILE: samples/net/cloud/aws_mqtt/src/main.c:263:
+                return err;$

-:511: ERROR:CODE_INDENT: code indent should use tabs where possible
#511: FILE: samples/net/cloud/aws_mqtt/src/main.c:264:
+        }$

-:511: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#511: FILE: samples/net/cloud/aws_mqtt/src/main.c:264:
+        }$

-:512: ERROR:CODE_INDENT: code indent should use tabs where possible
#512: FILE: samples/net/cloud/aws_mqtt/src/main.c:265:
+        return err;$

-:512: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#512: FILE: samples/net/cloud/aws_mqtt/src/main.c:265:
+        return err;$

-:518: ERROR:TRAILING_WHITESPACE: trailing whitespace
#518: FILE: samples/net/cloud/aws_mqtt/src/main.c:271:
+^Iint err, cnt;^I$

-:549: ERROR:CODE_INDENT: code indent should use tabs where possible
#549: FILE: samples/net/cloud/aws_mqtt/src/main.c:302:
+        int rc;$

-:549: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#549: FILE: samples/net/cloud/aws_mqtt/src/main.c:302:
+        int rc;$

-:552: ERROR:CODE_INDENT: code indent should use tabs where possible
#552: FILE: samples/net/cloud/aws_mqtt/src/main.c:305:
+        rc = tls_init();$

-:552: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#552: FILE: samples/net/cloud/aws_mqtt/src/main.c:305:
+        rc = tls_init();$

-:556: ERROR:TRAILING_WHITESPACE: trailing whitespace
#556: FILE: samples/net/cloud/aws_mqtt/src/main.c:309:
+^Imqtt_startup(CONFIG_AWS_HOSTNAME, CONFIG_AWS_PORT);^I$

- total: 69 errors, 73 warnings, 509 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Kconfig issues


Found references to undefined Kconfig symbols. If any of these are false
positives, then add them to UNDEF_KCONFIG_WHITELIST in check_compliance.py in the ci-tools repo.

If the reference is for a comment like /* CONFIG_FOO_* */ (or
/* CONFIG_FOO_*_... */), then please use exactly that form (with the '*'). The
CI check knows not to flag it.

More generally, a reference followed by $, @, {, *, or ## will never be
flagged.

CONFIG_AWS_HOSTNAME                        samples/net/cloud/aws_mqtt/src/config.h:11, samples/net/cloud/aws_mqtt/src/main.c:151, samples/net/cloud/aws_mqtt/src/main.c:281, samples/net/cloud/aws_mqtt/src/main.c:291, samples/net/cloud/aws_mqtt/src/main.c:309
CONFIG_AWS_PORT                            samples/net/cloud/aws_mqtt/src/config.h:12, samples/net/cloud/aws_mqtt/src/main.c:52, samples/net/cloud/aws_mqtt/src/main.c:291, samples/net/cloud/aws_mqtt/src/main.c:309

Nits issues

Please remove blank lines at end of 'samples/net/cloud/aws_mqtt/src/config.h'

Gitlint issues

1: UC6 Body has no content, should at least have 1 line.

Identity/Emails issues

5c0c394: author email (David Developer md.jamalmohiuddin@gmail.com) needs to match one of the signed-off-by entries.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the sample! Looks good, just minor changes needed.

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the commit subject to samples: net: cloud: Add AWS IoT sample
You also need to add something in commit body. In this case it could just be something like

Adding a network sample to communicate with Amazon cloud.

Please also go through style issues that the checkpatch complains about.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do i need to push a new commit or create a new pull request, i am unaware about the process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just squash your changes together (as you had only 1 commit in this PR) and then force push to this branch related to this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to confirm, make all the changes in another commit and push to the branch,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to confirm, make all the changes in another commit and push to the branch,

no, just squash the changes in the same branch and force push to this PR

CONFIG_MAIN_STACK_SIZE=4096

# Enable Logging support
CONFIG_LOG_IMMEDIATE=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the immediate logging, it can slow down the system and is useful only in limited use cases.

CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=n
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=n
CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=n
CONFIG_SOC_PART_NUMBER_SAME70Q21B=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove board specific stuff from this file. If you need to enable something board specific, create boards directory and put board file there (see example in various networking samples what this means).

tests:
sample.net.cloud.aws_mqtt:
harness: net
platform_whitelist: sam_e70_xplained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the whitelisting and put instead minimum ram requirement. That way the sample can be run any device with network connectivity and enough ram.


#error "Fill this before generating the build"

unsigned char amazon_certificate[] = {
Copy link
Member

@jukkar jukkar Mar 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that we do things here similar way as in other samples where some file needs to be embedded into the binary. So please write this as

unsigned char amazon_certificate[] = {
#include "amazon.cert"
}

if the cert is in ascii format. If you have the cert in binary format (DER), there is automatic way to create a file that can be included here (search generate_inc_file in networking samples for an example).
The point here is that the amazon.cert file is not put to version control and this will not compile if user does not provide the file. Some nice error message can be generated of course.
Edit: we probably need to provide some sample cert files so that the sample compiles, otherwise we cannot build test this. The certs do not need to have proper credentials of course.

#define ALIVE_TIME (MSEC_PER_SEC * 60U)
#define APP_MQTT_BUFFER_SIZE 128
#error "Fill the Host Name and compile"
#define CONFIG_AWS_HOSTNAME ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hostname must be provided via Kconfig file in this case. A sample app can have a Kconfig file of its own, see other networking samples how to do it.
Probably also port and mqtt client id should be put to kconfig file too as these can change for different users.


net_ipaddr_copy(&broker4->sin_addr,
&net_sin(haddr->ai_addr)->sin_addr);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line


LOG_INF("PUBREC packet id: %u", evt->param.pubrec.message_id);

const struct mqtt_pubrel_param rel_param = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not introduce variables in the middle of the block but place them at the start instead.


LOG_INF("PUBCOMP packet id: %u",
evt->param.pubcomp.message_id);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra empty line here.

char topic[] = "/things/";
u8_t len = strlen(topic);
struct mqtt_publish_param param;
char pub_msg[64];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation wrong. Also we try to avoid magic constants, please use defines instead for the length

@pfalcon pfalcon requested a review from d3zd3z March 16, 2020 12:48
};


unsigned char private_key[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this key expected to be filled in by someone? Please look at the samples/net/cloud/google_iot_mqtt to see how the keys are handled there. Right now, it isn't obvious how this would be loaded (or that it needs to be).

@carlescufi carlescufi requested a review from rlubos April 7, 2020 17:38
@github-actions
Copy link

github-actions bot commented Jul 9, 2020

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jul 9, 2020
@github-actions github-actions bot closed this Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants