• Medium One

Medium One Mobile App Quick Start Guide

Getting Started Guide- Mobile App

This guide will get you started on the Medium One IoT Controller App.

You will need:

  1. The IoT Controller App

Important information before you begin:

The mobile app can consume your Medium One credits.  It’s recommended to use it to send commands to Medium One’s cloud.

Each visualization widget refreshes every 2 second and will consume credits.

The GPS will transmit coordinates once every 5 seconds

The control widgets will only consume credits when you send an event

It is recommended to use the Dashboard for visualization and mobile for control if you have limited credits.

Step 1: Create a Medium One Sandbox Account

Visit mediumone.com and click “Sign Up” in the top right hand corner, which will take you to another page where you will enter your first and last name, email address, and project name.

Step 2: Create API user and API key

Log into Medium One web account.  Then go to Setup -> Manage Users

Create an API user, you can use these credentials or your own.  It will need to match the following steps.  Note your username, password, you will need it.

Then click Manage API keys, and + Add New API Key, type any description and Save.

Note your API Key, you will need it..

Step 3: Let’s create sample data from curl to the cloud

This curl example is based on Mac OS linux.  Refer to docs.mediumone.com on Windows example.

TIP: Make sure you have write access in your directory, the curl command creates and saves a cookie file.

Open terminal and type the following (substitute your username, password and API key from previous step):

curl -c cookies.txt -X POST -k -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -i ‘https://api-sandbox.mediumone.com/v2/login’ -d ‘{“login_id”: “mobile“, “password”: “9243>73kA“, “api_key”: “ABXTEM2R5KCCNZDBXTFBIAJQGQ4DCNRRHA2GENJYGQ3TAMBQ“}’

If successful, it will return true at the command line.

Next, we are going to send an event.

curl -b cookies.txt -k -i -H “Content-Type: application/json” -H “Accept: application/json” -X POST “https://api-sandbox.mediumone.com/v2/events/raw/mobile” -d ‘{“event_data”:{“gps”:”37.354107 -121.955238″,”temperature”:110,”notification”:”Fire! Fire!”}}’

There are 3 events created, gps, temperature, and notification.

Step 4: Activate Tags in Medium One

Go back to Medium One’s web portal and click on Config => Data Streams

Click on “Edit” for raw datastream.

Change gps Extended Type to “GeoPoint Time Series” and active all three tags as shown below.  Save.

Click in Dashboard  and add the “Single User – Real Time Event Log” widget to your view.

Select user “mobile” (or the name of the user you created)

Step 5: Create a New Profile on Mobile

In the Iot Controller app, create a new profile. Click the + in the top righthand corner, then click the new profile created and name it. You will need to create an API Key, Login, and Password (see Steps 2).

You will create a “new” profile.

Note: You can delete profiles by swiping right.

Open the “new” profile.  Click API login and enter your credentials from above.

Click Sandbox and Done.  Remember to click “Save” (only for iOS)

Step 6: Adding New Widgets

Click the +Add New Widget button on the top, and you will see a scrolling list of 8 Widgets you can enable.

Add a slider widget, then click on the slider icon to configure it.  Enter raw for stream and temperature for tag

Now add the switch widget.  Enter raw for stream and switch for tag

Your screen should look something like this

Go back to your dashboard and observe the real-time event chart as your toggle the switch and change the slider on the mobile phone.  You should see the events appear.  Congrats! you just sent events to Medium One’s cloud using your mobile device.

Additional notes on the different widgets

GPS: This widget will transmit geoPoints once every 5 seconds*

Gauge: This widget will query a stream/tag once every 2 seconds*

Notification: This widget will query a stream/tag once every 2 seconds for a text message*

Log: This widget will query a stream/tag once every 2 seconds for last 10 text message*

Map: This widget will query a stream/tag with type geoPoint to display location on the map*

JSON: This widget will transmit a JSON key value pair

* These widget consume a lot of credits and not recommended for Sandbox.

Appendix

How to send a push notification

If you allow push notifications on the mobile app, a FCM_token tag and key are created in the raw data stream when the profile is created.  Be sure to activate the FCM_token key.  If you don’t see it, you’ve probably disabled push notifications, or have not created a profile on the mobile app.

Next create a workflow to send Push Notification.  Click on Workflow Studio and “Create”

Give your workflow a name like “Push Notification.”

Click on “Tags and Triggers” on the right panel and expand the raw stream.  Drag “temperature” over to the center canvas.

Click on Modules on the right panel and under Foundation, drag “Base Python” to the center canvas as well.

Double click on Base Python.  Expand IONodes to expose “Add Input”, click here to add an addition input to this module.  Click Save.

You will now see two input nodes.  Under Tags and Triggers on the right panel, drag “FCM_token” to the main canvas.  Note, you need to activate the tag in order to see it and use it.

Drag FCM_token to the canvas and connect it to in2 of the module

Now we are going to write a simple workflow script.  Double click on Python and add these lines.  It’s important that the temperature and FCM_token trigger are in the same order as described to match the code

Code snippet here:

import FCM

temperature = IONode.get_input(‘in1’)[‘event_data’][‘value’]

FCM_token = IONode.get_input(‘in2’)[‘event_data’][‘value’]

FCM.send_fcm_notification_to_m1_application([FCM_token],temperature, sound=”chime”)

Explanation:

import FCM  (This is the FCM module library)

These are the more recent values for the event triggers

temperature = IONode.get_input(‘in1’)[‘event_data’][‘value’]

FCM_token = IONode.get_input(‘in2’)[‘event_data’][‘value’]

This command sends a notification to the Medium One mobile app.

Note: FCM_token must be in an array.

FCM.send_fcm_notification_to_m1_application([FCM_token],temperature, sound=”chime”)

Click “Check Syntax” and “Save”.  If syntax fails, check your code again.

Now you need to activate the workflow. Click on “Revisions” on the right panel and activate the topmost (recent) version.

TIP: Medium One has revision control, so you can continue working on your workflow and only activate when ready.

When you activate the workflow, it’s instantly live.  In this case, when a temperature or FCM_token event is sent, it will trigger this workflow.

TIP: You may want to disable FCM_token as a trigger.  To do so, simple double click on it, and uncheck “trigger.”

Note let’s trigger the workflow.  Go back to your terminal, send the last curl command once again.

curl -b cookies.txt -k -i -H “Content-Type: application/json” -H “Accept: application/json” -X POST “https://api-sandbox.mediumone.com/v2/events/raw/mobile” -d ‘{“event_data”:{“gps”:”37.354107 -121.955238″,”temperature”:110,”notification”:”Fire! Fire!”}}’

You should receive a push notification on your phone

4 views

© 2018 Medium One   All Rights Reserved

4633 Old Ironsides Dr. #280, Santa Clara, CA  95054                

info@mediumone.com

|

  • LinkedIn - White Circle
  • Twitter - White Circle
  • YouTube - White Circle
  • Google+ - White Circle