This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CSS | |
| .tb-image-select-wrapper { | |
| width: 100%; | |
| margin-bottom: 32px; | |
| } | |
| .tb-image-select-wrapper>label { | |
| display: none; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div layout="row"> | |
| <md-input-container flex class="md-block"> | |
| <label>Phone</label> | |
| <input name="phoneNumber" pattern="^[0-9-+\s()]*$" ng-model="vm.attributes.phone"> | |
| <div ng-messages="addEntityForm.phoneNumber.$error"> | |
| <div ng-message="pattern">Invalid format</div> | |
| </div> | |
| </md-input-container> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Temperature generator (for Thermometer) | |
| var msg = { temperature: +(Math.random()*6 + 25).toFixed(1)}; | |
| var msgType = "POST_TELEMETRY_REQUEST"; | |
| return { msg: msg, msgType: msgType }; | |
| _____________________________________________________________ | |
| Telemetry generator (for Asset) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Decode an uplink message from a buffer | |
| // payload - array of bytes | |
| // metadata - key/value object | |
| /** Decoder **/ | |
| // decode payload to JSON | |
| var data = decodeToString(payload); | |
| var deviceName = metadata['topic'].replace("/devices/", ""); | |
| var deviceType = 'thermostat'; | |
| var dataArray = data.split(","); | |
| // Result object with device attributes/telemetry data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mqtt = require('mqtt'); | |
| const ACCESS_TOKEN = process.argv[2]; | |
| var client = mqtt.connect('mqtt:localhost',{ | |
| username: ACCESS_TOKEN | |
| }); | |
| var controlValue, | |
| realValue = 25; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Decoder **/ | |
| // decode payload to string | |
| var payloadStr = decodeToString(payload); | |
| var data = JSON.parse(payloadStr); | |
| var topicPattern = 'tb/mqtt-integration-guide/sensors/(.+?)/.*'; | |
| var deviceName = metadata.topic.match(topicPattern)[1]; | |
| // decode payload to JSON | |
| var deviceType = 'sensor'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Encoder **/ | |
| var value = parseInt(msg.params.replace(/"/g,"")); | |
| var data = {value: value} | |
| // Result object with encoded downlink payload | |
| var result = { | |
| // downlink data content type: JSON, TEXT or BINARY (base64 format) | |
| contentType: "JSON", | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Encoder **/ | |
| var value = parseInt(msg.params.replace(/"/g,"")); | |
| var data = {value: value} | |
| // Result object with encoded downlink payload | |
| var result = { | |
| // downlink data content type: JSON, TEXT or BINARY (base64 format) | |
| contentType: "JSON", | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Decoder **/ | |
| // decode payload to string | |
| var payloadStr = decodeToString(payload); | |
| var data = JSON.parse(payloadStr); | |
| var topicPattern = 'tb/mqtt-integration-guide/sensors/(.+)/temperature'; | |
| var deviceName = metadata.topic.match(topicPattern)[1]; | |
| // decode payload to JSON | |
| var deviceType = 'sensor'; |
NewerOlder