Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (53 sloc) 4.77 KB

Axeda Client Library for M2X

The AT&T M2X API provides all the needed operations to connect your device to AT&T's M2X service. This client provides an easy to use interface for the Axeda Platform using Groovy script.

About the Axeda Platform

The Axeda Platform is a M2M and IoT data integration and application development platform with infrastructure delivered as a cloud-based service. The Axeda Platform provides application services, an integration framework, and device + asset management. You can learn more about the Axeda Platform here:

Getting Started

  1. Signup for an M2X Account.
  2. Obtain your Master Key from the Master Keys tab of your Account Settings screen.
  3. Create your first Devices and copy its Device ID.
  4. Review the M2X API Documentation.

To upload data from the Axeda Platform to AT&T M2X, you need to perform the following two actions within your Axeda environment:

  1. Create a custom object with uploaded Axeda script;
  2. Create an expression rule containing the uploading action.

Creating a Device in M2X

In order to use this library, you will need an AT&T M2X API key and a Device ID. If you don't have an API key, create an account and, once registered and with your account activated, create a new Device, and set aside the Device ID and API Key values for later use.

How to Create Custom Objects with Axeda Script

  1. Login to your account on the Axeda Platform.
  2. Click the Manage tab at the top of the screen.
  3. Click the New button, then select Custom Object from the dropdown menu.
  4. Enter M2XPushCustomObject in the Name field, select Action as the type, and then paste the Groovy script at sources/push.groovy into the Source Code field.
  5. Click Compile – the script should then be compiled without errors or warnings.
  6. Click Configure parameters, and add the following variables:
    • Variable name: key, display name: key
    • Variable name: deviceid, display name: deviceid
    • Variable name: streamname, display name: streamname
    • Variable name: val, display name: val
    • Variable name: at, display name: at
  7. After adding all of the variables above, click Save Changes.
  8. Now, click the Finish button, or click Next >> repeatedly until you can see only the Finish button, and then click the Finish button.

At this point, you will have a vaild Custom Object named M2XPushCustomObject containing the Groovy script to upload data to M2X. The steps required to configure the uploading process are outlined in the following section.

How to Create an Expression Rule with Uploading Action

  1. Login to your account on the Axeda Platform.

  2. Click the Manage button at the top of the screen.

  3. Click the New button, then select Expression Rules from the dropdown menu.

  4. In the name field, enter M2XPushExpression or any meaningful name.

  5. Select Data in the type field.

  6. In the If field, enter DataItem.<dataitem_name>.changed.

    NOTE: Please replace <dataitem_name> with the attribute you want to monitor.

  7. In the Then field, enter ExecuteCustomObject("M2XPushCustomObject", "<m2x key>", "<device ID>", "<stream name>", DataItem.<dataitem_name>.value, DataItem.<dataitem_name>.time).

    NOTE: For all items enclosed in <>, please replace them with the real values you will use; in addition, if you use a name other than M2XPushCustomObject when creating a custom object, you need to change the corresponding name.

  8. Click Validate to check if the values entered are valid.

  9. If the values are all valid (shown in green), click Apply to asset.

  10. Select the assets that you want to work on — you can either specify assets of one particular model, or an individual asset.

  11. Click Save to save the expression rule, and click OK.

Now, whenever the data sent from the chosen asset to the server are changed, the data will also be uploaded to AT&T M2X.

Note that the steps in this section only push data from one attribute to one stream in M2X. If you want to push data from another attribute, or push the same attribute to another stream, you need to create a new Expression Rule with a new set of IF-THEN expressions.


These examples are provided under the MIT license. See LICENSE for applicable terms.