# Install beta components:
gcloud components install beta

# Authenticate with Google Cloud:
gcloud auth login

# Create cloud project ¡X choose your unique project name:
gcloud projects create YOUR_PROJECT_NAME

# Add permissions for IoT Core
gcloud projects add-iam-policy-binding YOUR_PROJECT_NAME --member=serviceAccount:cloud-iot@system.gserviceaccount.com --role=roles/pubsub.publisher

# Create PubSub topic for device data:
gcloud beta pubsub topics create telemetry-topic

# Create PubSub subscription for device data:
gcloud beta pubsub subscriptions create --topic telemetry-topic telemetry-subscription

# Create device registry:
gcloud beta iot registries create weather-station-registry --region us-central1 --event-pubsub-topic=telemetry-topic




#####################
# device side
#####################

# Get project ID of your new project:
gcloud projects list

mos gcp-iot-setup --gcp-project YOUR_PROJECT_NAME --gcp-region us-central1 --gcp-registry YOUR_REGISTRY

mos gcp-iot-setup --gcp-project YOUR_PROJECT_ID --gcp-region europe-west1 --gcp-registry iot-registry
mos gcp-iot-setup --gcp-project YOUR_PROJECT_NAME --gcp-region us-central1 --gcp-registry weather-station-registry




####################
# Firebase Functions
####################

#https://firebase.google.com/docs/functions/get-started

#Install Node.js

https://nodejs.org/en/

#Once you have Node.js and npm installed, install the Firebase CLI via npm:
npm install -g firebase-tools

1. create a folder on disk. example "function_fire"
2. Windows command "firebase login" to login the firebase
3. Windows command "firebase init"
4. Select Functions and the existed project.
5. Windows command "firebase deploy"


####################
# Android Setting
####################

#APP build.gradle
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

dependencies {
	............
    compile 'com.google.firebase:firebase-core:12.0.1'
    compile 'com.google.firebase:firebase-database:12.0.1'
}

#Project build.gradle
    dependencies {
        ......
        classpath 'com.google.gms:google-services:3.2.0'

    }
allprojects {
    repositories {
        // ...
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

#download google.jason file copy to app/ folder
need to setup the path name:com.app.fanstel.giotdemo