Dynamically Edit Device Attributes
- Navigate to the Token Management Page in your Team Settings.
- In the Device tab, Click Create.

- Select the Account and Device you wish to access via the API. Then click Create

- This will generate a model as show in the JSON blob below.
{
"device": "******",
"account": "******",
"token": "******",
"secret": "******",
"url": "******"
}

- 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"]
}
}
- 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.

Updated over 4 years ago