Demo application for using the AT&T IoT Starter Kit Powered by AWS.

Dependencies:   SDFileSystem

Fork of ATT_AWS_IoT_demo by Anthony Phillips

IoT Starter Kit Powered by AWS Demo

This program demonstrates the AT&T IoT Starter Kit sending data directly into AWS IoT. It's explained and used in the Getting Started with the IoT Starter Kit Powered by AWS on starterkit.att.com.

What's required

  • AT&T IoT LTE Add-on (also known as the Cellular Shield)
  • NXP K64F - for programming
  • microSD card - used to store your AWS security credentials
  • AWS account
  • Python, locally installed

If you don't already have an IoT Starter Kit, you can purchase a kit here. The IoT Starter Kit Powered by AWS includes the LTE cellular shield, K64F, and a microSD card.

Committer:
rfinn
Date:
Tue Feb 07 16:18:57 2017 +0000
Revision:
27:2f486c766854
Parent:
15:6f2798e45099
changed SDFileSystem library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ampembeng 15:6f2798e45099 1 /*
ampembeng 15:6f2798e45099 2 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
ampembeng 15:6f2798e45099 3 *
ampembeng 15:6f2798e45099 4 * Licensed under the Apache License, Version 2.0 (the "License").
ampembeng 15:6f2798e45099 5 * You may not use this file except in compliance with the License.
ampembeng 15:6f2798e45099 6 * A copy of the License is located at
ampembeng 15:6f2798e45099 7 *
ampembeng 15:6f2798e45099 8 * http://aws.amazon.com/apache2.0
ampembeng 15:6f2798e45099 9 *
ampembeng 15:6f2798e45099 10 * or in the "license" file accompanying this file. This file is distributed
ampembeng 15:6f2798e45099 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
ampembeng 15:6f2798e45099 12 * express or implied. See the License for the specific language governing
ampembeng 15:6f2798e45099 13 * permissions and limitations under the License.
ampembeng 15:6f2798e45099 14 */
ampembeng 15:6f2798e45099 15
ampembeng 15:6f2798e45099 16 #include "aws_iot_shadow_actions.h"
ampembeng 15:6f2798e45099 17
ampembeng 15:6f2798e45099 18 #include "aws_iot_log.h"
ampembeng 15:6f2798e45099 19 #include "aws_iot_shadow_json.h"
ampembeng 15:6f2798e45099 20 #include "aws_iot_shadow_records.h"
ampembeng 15:6f2798e45099 21 #include "aws_iot_config.h"
ampembeng 15:6f2798e45099 22
ampembeng 15:6f2798e45099 23 IoT_Error_t iot_shadow_action(MQTTClient_t *pClient, const char *pThingName, ShadowActions_t action,
ampembeng 15:6f2798e45099 24 const char *pJsonDocumentToBeSent, fpActionCallback_t callback, void *pCallbackContext,
ampembeng 15:6f2798e45099 25 uint32_t timeout_seconds, bool isSticky) {
ampembeng 15:6f2798e45099 26
ampembeng 15:6f2798e45099 27 IoT_Error_t ret_val = NONE_ERROR;
ampembeng 15:6f2798e45099 28 bool isCallbackPresent = false;
ampembeng 15:6f2798e45099 29 bool isClientTokenPresent = false;
ampembeng 15:6f2798e45099 30 bool isAckWaitListFree = false;
ampembeng 15:6f2798e45099 31 uint8_t indexAckWaitList;
ampembeng 15:6f2798e45099 32
ampembeng 15:6f2798e45099 33 if(pClient == NULL || pThingName == NULL || pJsonDocumentToBeSent == NULL){
ampembeng 15:6f2798e45099 34 return NULL_VALUE_ERROR;
ampembeng 15:6f2798e45099 35 }
ampembeng 15:6f2798e45099 36
ampembeng 15:6f2798e45099 37 if (callback != NULL) {
ampembeng 15:6f2798e45099 38 isCallbackPresent = true;
ampembeng 15:6f2798e45099 39 }
ampembeng 15:6f2798e45099 40
ampembeng 15:6f2798e45099 41 char extractedClientToken[MAX_SIZE_CLIENT_ID_WITH_SEQUENCE];
ampembeng 15:6f2798e45099 42 isClientTokenPresent = extractClientToken(pJsonDocumentToBeSent, extractedClientToken);
ampembeng 15:6f2798e45099 43
ampembeng 15:6f2798e45099 44 if (isClientTokenPresent && isCallbackPresent) {
ampembeng 15:6f2798e45099 45 if (getNextFreeIndexOfAckWaitList(&indexAckWaitList)) {
ampembeng 15:6f2798e45099 46 isAckWaitListFree = true;
ampembeng 15:6f2798e45099 47 }
ampembeng 15:6f2798e45099 48
ampembeng 15:6f2798e45099 49 if(isAckWaitListFree) {
ampembeng 15:6f2798e45099 50 if (!isSubscriptionPresent(pThingName, action)) {
ampembeng 15:6f2798e45099 51 ret_val = subscribeToShadowActionAcks(pThingName, action, isSticky);
ampembeng 15:6f2798e45099 52 } else {
ampembeng 15:6f2798e45099 53 incrementSubscriptionCnt(pThingName, action, isSticky);
ampembeng 15:6f2798e45099 54 }
ampembeng 15:6f2798e45099 55 }
ampembeng 15:6f2798e45099 56 else {
ampembeng 15:6f2798e45099 57 ret_val = GENERIC_ERROR;
ampembeng 15:6f2798e45099 58 }
ampembeng 15:6f2798e45099 59 }
ampembeng 15:6f2798e45099 60
ampembeng 15:6f2798e45099 61
ampembeng 15:6f2798e45099 62 if (ret_val == NONE_ERROR) {
ampembeng 15:6f2798e45099 63 ret_val = publishToShadowAction(pThingName, action, pJsonDocumentToBeSent);
ampembeng 15:6f2798e45099 64 }
ampembeng 15:6f2798e45099 65
ampembeng 15:6f2798e45099 66 if (isClientTokenPresent && isCallbackPresent && ret_val == NONE_ERROR && isAckWaitListFree) {
ampembeng 15:6f2798e45099 67 addToAckWaitList(indexAckWaitList, pThingName, action, extractedClientToken, callback, pCallbackContext,
ampembeng 15:6f2798e45099 68 timeout_seconds);
ampembeng 15:6f2798e45099 69 }
ampembeng 15:6f2798e45099 70 return ret_val;
ampembeng 15:6f2798e45099 71 }
ampembeng 15:6f2798e45099 72