#!/bin/bash

#  Copyright (c) 2016, Oracle and/or its affiliates.  All rights reserved.
#  
#  This software is dual-licensed to you under the MIT License (MIT) and
#  the Universal Permissive License (UPL).  See the LICENSE file in the root
#  directory for license terms.  You may choose either license, or both.
#  

# If you don't want to enter information each time, you can uncomment following lines
# and change the environment variables after export XXX, except SHARED_SECRET_BASE64
# after that you can directly execute quick-start

#######################BEGIN################################
# # iot server URL, port number, user name and password
# export IOTSERVER="your iot server url"
# export PORT=
# export USERNAME=
# export PASSWORD=
# # Shared secret you want to use to register & activate your device
# export SHARED_SECRET="secret"
# # Activation ID you want to use to register & activate your device
# export ACTIVATION_ID="unique activationID"
# # URN, FORMAT_URN and device model name for new device model, make sure they are unique
# export URN="urn:oracle:iot:testmodel:uniquetestmodel"
# export FORMAT_URN="urn:format:test:message:uniqueformat"
# export DEVICE_MODEL_NAME="Test model"
# Generate shared secret encoded with base64
# export SHARED_SECRET_BASE64=$(echo -n $SHARED_SECRET | base64)

# # Clean old files
# ./prepare
#######################END################################

# Create a new device model with URN and DEVICE_MODEL_NAME
read -rsp $'Press any key to continue...\n' -n1 key
./create-device-model

# Register a new device
read -rsp $'Press any key to continue...\n' -n1 key
./register-device

# Activate device, including 4 steps, get-activation-token, get-activation-policy, generate-RSA, direct-activation
read -rsp $'Press any key to continue...\n' -n1 key
./activate

# Generate message token and send messages, including 2 steps, get-message-token, send-messages
read -rsp $'Press any key to continue...\n' -n1 key
./generate-token-send-messages

# Retrieve messages
read -rsp $'Press any key to continue...\n' -n1 key
./retrieve-messages