These docs are for v1.0. Click to read the latest docs for v2.0.

Dynamically Edit Device Attributes

  1. Navigate to the Token Management Page in your Team Settings.
  2. In the Device tab, Click Create.
1187
  1. Select the Account and Device you wish to access via the API. Then click Create
491
  1. This will generate a model as show in the JSON blob below.
{
  "device": "******",
  "account": "******",
  "token": "******",
  "secret": "******",
  "url": "******"
}
489
  1. Setup an API hook to PUT device attributes. For this example, we are using a dictionary to change the ROS up-loadable topics and what should be included or excluded.
/** Generic Model */
{
  "mc.ros.topics.uploadable": {
    "default": "none",
    "include": {
      {{topic name}}: {{frequency in hz}} //denominator is 1
   },
    "exclude": [{{topic name}}, {{topic name}}]
  }
}

/** Example A */

{
  "mc.ros.topics.uploadable": {
    "default": "none",
    "include": {
      "/battery/*": 0.1
   },
    "exclude": ["/camera/depth/raw"]
  }
}
  1. Use the url provided to make the endpoint {{url}}/accounts/{{account}}/devices/{{deviceId}}. Create a PUT request.

The following headers should be added to this request:

mc_token: {{token}}
mc_secret: {{secret}}

Result:
You should see a 200 and action update account attributes. You should be able to verify by going to the device Settings > Bandwidth > Included Topics & Excluded Topics

{
    "status": "success",
    "action": "update device attributes",
    "account": "AC24B7A194622B6C746DA3DF1",
    "device": "DDF4D690B6888D67B94FA380C3B",
    "updated_topics": true
}

The Included Topics have battery and the Excluded Topics have camera/depth/raw now.

1171