{"__v":15,"_id":"55aecfa8555b900d0036d1a2","category":{"__v":8,"_id":"55a823b88b9fdf0d00117111","pages":["55a823b88b9fdf0d00117113","55a84903a9824d2d00a6b94b","55a84c9ea9824d2d00a6b956","55a84cb972e7120d004ae6e8","55a84e83a9824d2d00a6b95d","55ad8eb433616a0d00599ee7","55aecfa8555b900d0036d1a2","55aee068555b900d0036d1e9"],"project":"55a823b78b9fdf0d0011710d","version":"55a823b78b9fdf0d00117110","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-16T21:35:52.065Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"project":"55a823b78b9fdf0d0011710d","user":"5564f227f0f70f0d00a9ab20","version":{"__v":5,"_id":"55a823b78b9fdf0d00117110","project":"55a823b78b9fdf0d0011710d","createdAt":"2015-07-16T21:35:51.544Z","releaseDate":"2015-07-16T21:35:51.544Z","categories":["55a823b88b9fdf0d00117111","55a8485472e7120d004ae6de","55a84e53a9824d2d00a6b95c","55aecf97c97a1a0d002245af","55aedfe0c97a1a0d00224606"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-21T23:03:04.115Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"One of the biggest goals of The Tentacle (and Meshblu in general!) is to make it as easy as possible to talk to it. \n\nAs such, we maintain [a github repo](https://github.com/octoblu/tentacle-protocol-buffer) for the express purpose of defining the message and configuration schemas in JSON and Google's Protocol Buffer format.\n\nThis repo should always be checked first before using any of these examples - It is always up to date, whereas the documentation may not be!\n\nThe Tentacle has been primarily developed for use in [Meshblu](http://meshblu.octoblu.com), though it can definitely be used without it. As such, some of the code below may be Meshblu-specific.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Usage Examples\",\n  \"body\": \"the \\\"usage\\\" after the examples assume you're using our command-line utility, [meshblu-util](http://meshblu.readme.io/docs/meshblu-utility). Any other method of communicating with Meshblu will work - it's just easier to do it this way.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example Message and Configuration\"\n}\n[/block]\nThe following are JSON examples that The Tentacle can understand.\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Send The Tentacle a Correctly Formatted Message!\",\n  \"body\": \"If a message fails to follow the schema below, Meshblu will rudely disconnect the microcontroller. This is to prevent the microcontroller from losing it's mind when it tries to parse an invalid format.\"\n}\n[/block]\n\nExample Message:\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"devices\\\": \\\"ff12c403-04c7-4e63-9073-2e3b1f8e4450\\\",\\n  \\\"payload\\\": {\\n    \\\"pins\\\": [\\n      { \\\"action\\\" : \\\"analogRead\\\", \\\"number\\\": 16},\\n      { \\\"action\\\" : \\\"digitalWrite\\\", \\\"number\\\": 13, \\\"value\\\": 1}\\n    ]\\n  },\\n  \\\"customData\\\" : \\\"You can put whatever you want here! Or nothing! The world's your oyster.\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"example-message\"\n    }\n  ]\n}\n[/block]\nUsage: **meshblu-util message -u <tentacle-uuid> -f ./message.json ./subscriber.json**\n\n\n\n\nExample Configuration:\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Serial Port Configuration\",\n  \"body\": \"\\\"port\\\" is only needed if The Tentacle is used over serial. This can be accomplished with [this github repo](https://github.com/octoblu/meshblu-tentacle) or by using it like any other Gateblu plugin.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"options\\\": {\\n    \\\"port\\\" : \\\"/dev/tty.usbmodem14110000.1\\\",\\n    \\\"broadcastPins\\\" : true,\\n    \\\"broadcastInterval\\\": 2500,\\n    \\\"pins\\\": [\\n      {\\\"action\\\" : \\\"digitalWrite\\\", \\\"number\\\" : 7},\\n      {\\\"action\\\" : \\\"analogRead\\\", \\\"number\\\" : 15}\\n    ]\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nUsage: **meshblu-util update -f ./configuration.json ./example-meshblu.json**\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"JSON Schema, for the Schema Enthusiasts\"\n}\n[/block]\nMessaging: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"type\\\": \\\"object\\\",\\n  \\\"required\\\": [\\n    \\\"pins\\\"\\n  ],\\n  \\\"properties\\\": {\\n    \\\"customData\\\" : {\\n      \\\"type\\\": \\\"string\\\"\\n    },\\n    \\\"pins\\\": {\\n     \\\"title\\\": \\\"Pin Configuration\\\",\\n      \\\"type\\\": \\\"array\\\",\\n      \\\"default\\\": [],\\n      \\\"items\\\": {\\n        \\\"type\\\": \\\"object\\\",\\n        \\\"properties\\\": {\\n          \\\"number\\\": {\\n            \\\"title\\\": \\\"Number\\\",\\n            \\\"type\\\": \\\"integer\\\",\\n            \\\"minimum\\\": 0,\\n            \\\"default\\\": 13\\n          },\\n          \\\"action\\\": {\\n            \\\"title\\\": \\\"Action\\\",\\n            \\\"type\\\": \\\"string\\\",\\n             \\\"enum\\\": [\\n              \\\"digitalRead\\\" ,\\n              \\\"digitalWrite\\\" ,\\n              \\\"analogRead\\\",\\n              \\\"analogWrite\\\",\\n              \\\"servoWrite\\\",\\n              \\\"pwmWrite\\\",\\n              \\\"i2cWrite\\\",\\n              \\\"i2cRead\\\"\\n               ]\\n          },\\n          \\\"value\\\": {\\n            \\\"type\\\": \\\"integer\\\",\\n            \\\"default\\\": 1\\n          }\\n        },\\n        \\\"required\\\": [\\n          \\\"number\\\",\\n          \\\"action\\\"\\n        ]\\n      }\\n    }\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"messaging-schema\"\n    }\n  ]\n}\n[/block]\n\nConfiguration:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n\\n{\\n  \\\"type\\\": \\\"object\\\",\\n  \\\"required\\\": [\\n    \\\"pins\\\"\\n  ],\\n  \\\"properties\\\": {\\n    \\\"pins\\\": {\\n     \\\"title\\\": \\\"Pin Configuration\\\",\\n      \\\"type\\\": \\\"array\\\",\\n      \\\"default\\\": [],\\n      \\\"items\\\": {\\n        \\\"type\\\": \\\"object\\\",\\n        \\\"properties\\\": {\\n          \\\"number\\\": {\\n            \\\"title\\\": \\\"Number\\\",\\n            \\\"type\\\": \\\"integer\\\",\\n            \\\"minimum\\\": 0\\n          },\\n          \\\"action\\\": {\\n            \\\"title\\\": \\\"Action\\\",\\n            \\\"type\\\": \\\"string\\\",\\n             \\\"enum\\\": [\\n              \\\"digitalRead\\\" ,\\n              \\\"digitalWrite\\\" ,\\n              \\\"analogRead\\\",\\n              \\\"analogWrite\\\",\\n              \\\"servoWrite\\\",\\n              \\\"pwmWrite\\\",\\n              \\\"i2cWrite\\\",\\n              \\\"i2cRead\\\",\\n              \\\"ignore\\\"\\n               ]\\n          }\\n        },\\n        \\\"required\\\": [\\n          \\\"number\\\",\\n          \\\"action\\\"\\n        ]\\n      }\\n    },\\n    \\\"broadcastPins\\\" : {\\n      \\\"title\\\" : \\\"Broadcast Pins?\\\",\\n      \\\"type\\\": \\\"boolean\\\",\\n      \\\"default\\\": false\\n    },\\n    \\\"broadcastInterval\\\" : {\\n      \\\"title\\\" : \\\"Broadcast Interval (ms)\\\",\\n      \\\"type\\\" : \\\"number\\\",\\n      \\\"default\\\" : 2000,\\n      \\\"minimum\\\": 15\\n    }\\n  }\\n}\\n\",\n      \"language\": \"json\",\n      \"name\": \"configuration-schema\"\n    }\n  ]\n}\n[/block]","excerpt":"Learn how to speak the language of The Tentacle.","slug":"message-formats","type":"basic","title":"Message Formats"}

Message Formats

Learn how to speak the language of The Tentacle.

One of the biggest goals of The Tentacle (and Meshblu in general!) is to make it as easy as possible to talk to it. As such, we maintain [a github repo](https://github.com/octoblu/tentacle-protocol-buffer) for the express purpose of defining the message and configuration schemas in JSON and Google's Protocol Buffer format. This repo should always be checked first before using any of these examples - It is always up to date, whereas the documentation may not be! The Tentacle has been primarily developed for use in [Meshblu](http://meshblu.octoblu.com), though it can definitely be used without it. As such, some of the code below may be Meshblu-specific. [block:callout] { "type": "info", "title": "Usage Examples", "body": "the \"usage\" after the examples assume you're using our command-line utility, [meshblu-util](http://meshblu.readme.io/docs/meshblu-utility). Any other method of communicating with Meshblu will work - it's just easier to do it this way." } [/block] [block:api-header] { "type": "basic", "title": "Example Message and Configuration" } [/block] The following are JSON examples that The Tentacle can understand. [block:callout] { "type": "warning", "title": "Send The Tentacle a Correctly Formatted Message!", "body": "If a message fails to follow the schema below, Meshblu will rudely disconnect the microcontroller. This is to prevent the microcontroller from losing it's mind when it tries to parse an invalid format." } [/block] Example Message: [block:code] { "codes": [ { "code": "{\n \"devices\": \"ff12c403-04c7-4e63-9073-2e3b1f8e4450\",\n \"payload\": {\n \"pins\": [\n { \"action\" : \"analogRead\", \"number\": 16},\n { \"action\" : \"digitalWrite\", \"number\": 13, \"value\": 1}\n ]\n },\n \"customData\" : \"You can put whatever you want here! Or nothing! The world's your oyster.\"\n}", "language": "json", "name": "example-message" } ] } [/block] Usage: **meshblu-util message -u <tentacle-uuid> -f ./message.json ./subscriber.json** Example Configuration: [block:callout] { "type": "info", "title": "Serial Port Configuration", "body": "\"port\" is only needed if The Tentacle is used over serial. This can be accomplished with [this github repo](https://github.com/octoblu/meshblu-tentacle) or by using it like any other Gateblu plugin." } [/block] [block:code] { "codes": [ { "code": "{\n \"options\": {\n \"port\" : \"/dev/tty.usbmodem14110000.1\",\n \"broadcastPins\" : true,\n \"broadcastInterval\": 2500,\n \"pins\": [\n {\"action\" : \"digitalWrite\", \"number\" : 7},\n {\"action\" : \"analogRead\", \"number\" : 15}\n ]\n }\n}", "language": "json" } ] } [/block] Usage: **meshblu-util update -f ./configuration.json ./example-meshblu.json** [block:api-header] { "type": "basic", "title": "JSON Schema, for the Schema Enthusiasts" } [/block] Messaging: [block:code] { "codes": [ { "code": "{\n \"type\": \"object\",\n \"required\": [\n \"pins\"\n ],\n \"properties\": {\n \"customData\" : {\n \"type\": \"string\"\n },\n \"pins\": {\n \"title\": \"Pin Configuration\",\n \"type\": \"array\",\n \"default\": [],\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"number\": {\n \"title\": \"Number\",\n \"type\": \"integer\",\n \"minimum\": 0,\n \"default\": 13\n },\n \"action\": {\n \"title\": \"Action\",\n \"type\": \"string\",\n \"enum\": [\n \"digitalRead\" ,\n \"digitalWrite\" ,\n \"analogRead\",\n \"analogWrite\",\n \"servoWrite\",\n \"pwmWrite\",\n \"i2cWrite\",\n \"i2cRead\"\n ]\n },\n \"value\": {\n \"type\": \"integer\",\n \"default\": 1\n }\n },\n \"required\": [\n \"number\",\n \"action\"\n ]\n }\n }\n }\n}", "language": "json", "name": "messaging-schema" } ] } [/block] Configuration: [block:code] { "codes": [ { "code": "\n\n{\n \"type\": \"object\",\n \"required\": [\n \"pins\"\n ],\n \"properties\": {\n \"pins\": {\n \"title\": \"Pin Configuration\",\n \"type\": \"array\",\n \"default\": [],\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"number\": {\n \"title\": \"Number\",\n \"type\": \"integer\",\n \"minimum\": 0\n },\n \"action\": {\n \"title\": \"Action\",\n \"type\": \"string\",\n \"enum\": [\n \"digitalRead\" ,\n \"digitalWrite\" ,\n \"analogRead\",\n \"analogWrite\",\n \"servoWrite\",\n \"pwmWrite\",\n \"i2cWrite\",\n \"i2cRead\",\n \"ignore\"\n ]\n }\n },\n \"required\": [\n \"number\",\n \"action\"\n ]\n }\n },\n \"broadcastPins\" : {\n \"title\" : \"Broadcast Pins?\",\n \"type\": \"boolean\",\n \"default\": false\n },\n \"broadcastInterval\" : {\n \"title\" : \"Broadcast Interval (ms)\",\n \"type\" : \"number\",\n \"default\" : 2000,\n \"minimum\": 15\n }\n }\n}\n", "language": "json", "name": "configuration-schema" } ] } [/block]