├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINERS.md ├── README.md ├── docs ├── cloudant.png ├── connections.png ├── iot-blockchain.png ├── iot-dash.png ├── iot-platform.png ├── node-red-dash.png ├── nodered-nodes.png └── nr-dash-setup.png └── scripts └── iot-blockchain-analytics.json /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This is an open source project, and we appreciate your help! 4 | 5 | We use the GitHub issue tracker to discuss new features and non-trivial bugs. 6 | 7 | In addition to the issue tracker, [#journeys on Slack](https://dwopen.slack.com) 8 | is the best way to get into contact with the 9 | project's maintainers. 10 | 11 | To contribute code, documentation, or tests, please submit a pull request to 12 | the GitHub repository. Generally, we expect two maintainers to review your pull 13 | request before it is approved for merging. For more details, see the 14 | [MAINTAINERS](MAINTAINERS.md) page. 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers Guide 2 | 3 | This guide is intended for maintainers - anybody with commit access to one or 4 | more Code Pattern repositories. 5 | 6 | ## Methodology 7 | 8 | This repository does not have a traditional release management cycle, but 9 | should instead be maintained as a useful, working, and polished reference at 10 | all times. While all work can therefore be focused on the master branch, the 11 | quality of this branch should never be compromised. 12 | 13 | The remainder of this document details how to merge pull requests to the 14 | repositories. 15 | 16 | ## Merge approval 17 | 18 | The project maintainers use LGTM (Looks Good To Me) in comments on the pull 19 | request to indicate acceptance prior to merging. A change requires LGTMs from 20 | two project maintainers. If the code is written by a maintainer, the change 21 | only requires one additional LGTM. 22 | 23 | ## Reviewing Pull Requests 24 | 25 | We recommend reviewing pull requests directly within GitHub. This allows a 26 | public commentary on changes, providing transparency for all users. When 27 | providing feedback be civil, courteous, and kind. Disagreement is fine, so long 28 | as the discourse is carried out politely. If we see a record of uncivil or 29 | abusive comments, we will revoke your commit privileges and invite you to leave 30 | the project. 31 | 32 | During your review, consider the following points: 33 | 34 | ### Does the change have positive impact? 35 | 36 | Some proposed changes may not represent a positive impact to the project. Ask 37 | whether or not the change will make understanding the code easier, or if it 38 | could simply be a personal preference on the part of the author (see 39 | [bikeshedding](https://en.wiktionary.org/wiki/bikeshedding)). 40 | 41 | Pull requests that do not have a clear positive impact should be closed without 42 | merging. 43 | 44 | ### Do the changes make sense? 45 | 46 | If you do not understand what the changes are or what they accomplish, ask the 47 | author for clarification. Ask the author to add comments and/or clarify test 48 | case names to make the intentions clear. 49 | 50 | At times, such clarification will reveal that the author may not be using the 51 | code correctly, or is unaware of features that accommodate their needs. If you 52 | feel this is the case, work up a code sample that would address the pull 53 | request for them, and feel free to close the pull request once they confirm. 54 | 55 | ### Does the change introduce a new feature? 56 | 57 | For any given pull request, ask yourself "is this a new feature?" If so, does 58 | the pull request (or associated issue) contain narrative indicating the need 59 | for the feature? If not, ask them to provide that information. 60 | 61 | Are new unit tests in place that test all new behaviors introduced? If not, do 62 | not merge the feature until they are! Is documentation in place for the new 63 | feature? (See the documentation guidelines). If not do not merge the feature 64 | until it is! Is the feature necessary for general use cases? Try and keep the 65 | scope of any given component narrow. If a proposed feature does not fit that 66 | scope, recommend to the user that they maintain the feature on their own, and 67 | close the request. You may also recommend that they see if the feature gains 68 | traction among other users, and suggest they re-submit when they can show such 69 | support. 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WARNING: This repository is no longer maintained :warning: 2 | 3 | > This repository will not be updated. The repository will be kept available in read-only mode. 4 | 5 | # Using-IOT-toProcess-BlockchainAnalytics 6 | 7 | ![](docs/iot-blockchain.png) 8 | 9 | 10 | ## Introduction 11 | IoT's role in this project will take the users from the Blockchain network and list them as devices on the Watson IoT Platform everytime there's a new user created. 12 | 13 | Besides that IoT will simulate a demo device and/or a real device can be chosen to display their data on the platform's dashboard. All these devices in this project will one Device Type. 14 | 15 | 16 | ![](docs/iot-dash.png) 17 | 18 | 19 | That's with the Watson IoT Platform, but within Node-Red our IoT app will run analytics to display the total steps and total fitcoins of all users. 20 | 21 | The app will also use a graph in real-time to show the Blockchain transactions coming to the IoT whether for new user creation, user validation or for generated values of steps and fitcoins. 22 | 23 | 24 | ![](docs/node-red-dash.png) 25 | 26 | 27 | ## Prerequisites 28 | You will need the following accounts and tools: 29 | * [IBM Cloud account](https://console.ng.bluemix.net/registration/) 30 | * [Blockchain Network Pattern (Optional)](https://developer.ibm.com/code/patterns/explore-hyperledger-fabric-through-a-complete-set-of-apis/) 31 | 32 | 33 | ## Steps of use 34 | Choose from IBM Cloud/Bluemix Catalog the Internet of Things service, name it and create it. After few minutes when your app is ready, open Cloudant and create a database with the name of `secretmap` as seen below in the pic. 35 | 36 | 37 | ![](docs/cloudant.png) 38 | 39 | 40 | Click your app's URL to open your Node-Red editor. Copy in there all the contents from the json file inside the scripts folder and paste them in the import box. 41 | 42 | Blockchain Network will pass the blocks where all the information will be taken and be saved to be used for analytics and display the values on the Node-Red dashboard as seen in the above image. 43 | 44 | * Make sure to have Cloudant database service available and binded to your Bluemix/IBM Cloud app instance. 45 | 46 | * Make sure also to have a Watson IoT Platform created and binded as a service too. 47 | 48 | 49 | ![](docs/connections.png) 50 | 51 | 52 | * Dashboard needs to be created in the Node-Red if it's not taken care of by the code import. 53 | 54 | 55 | ![](docs/nr-dash-setup.png) 56 | 57 | 58 | * This is how the Node-Red code looks like: 59 | 60 | 61 | ![](docs/nodered-nodes.png) 62 | 63 | 64 | * Watson IoT Platform list of devices preview: 65 | 66 | 67 | ![](docs/iot-platform.png) 68 | 69 | 70 | * Values are passed in as json into: `'https://.mybluemix.net/steps?message=' + blocks` 71 | 72 | 73 | **Try live demo url:** 74 | > [Demo display](https://think-iot-processor.mybluemix.net/ui/#/0) 75 | 76 | 77 | # Technology 78 | 79 | * [Blockchain](https://developer.ibm.com/code/technologies/blockchain/) 80 | * [Hyperledger Fabric V1.0](https://www.hyperledger.org/projects/fabric?cm_mc_uid=56476701007714999647300&cm_mc_sid_50200000=1501558767) 81 | 82 | ## Useful links 83 | 84 | * [IBM Cloud](https://bluemix.net/) 85 | * [IBM Cloud Documentation](https://www.ng.bluemix.net/docs/) 86 | * [IBM Cloud Developers Community](http://developer.ibm.com/bluemix) 87 | * [IBM Watson Internet of Things](http://www.ibm.com/internet-of-things/) 88 | * [IBM Watson IoT Platform](http://www.ibm.com/internet-of-things/iot-solutions/watson-iot-platform/) 89 | * [IBM Watson IoT Platform Developers Community](https://developer.ibm.com/iotplatform/) 90 | * [Node Red](https://nodered.org/) 91 | 92 | 93 | ## License 94 | This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](http://www.apache.org/licenses/LICENSE-2.0.txt). 95 | 96 | [Apache Software License (ASL) FAQ](http://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN) 97 | -------------------------------------------------------------------------------- /docs/cloudant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/cloudant.png -------------------------------------------------------------------------------- /docs/connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/connections.png -------------------------------------------------------------------------------- /docs/iot-blockchain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/iot-blockchain.png -------------------------------------------------------------------------------- /docs/iot-dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/iot-dash.png -------------------------------------------------------------------------------- /docs/iot-platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/iot-platform.png -------------------------------------------------------------------------------- /docs/node-red-dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/node-red-dash.png -------------------------------------------------------------------------------- /docs/nodered-nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/nodered-nodes.png -------------------------------------------------------------------------------- /docs/nr-dash-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/Using-IOT-toProcess-BlockchainAnalytics/eb993dcbc4269b5b8ada1c1f3c1095c14c83129d/docs/nr-dash-setup.png -------------------------------------------------------------------------------- /scripts/iot-blockchain-analytics.json: -------------------------------------------------------------------------------- 1 | [{"id":"59f08660.aba898","type":"comment","z":"d8c9ab31.c9e8b8","name":"","info":"{\n \"deviceName\": ,\n \"steps\" : ,\n \"fitcoin\" : ,\n \"location\" :\n {\n \"longitude\" : ,\n \"latitude\" : \n }\n}","x":55,"y":166,"wires":[]},{"id":"a5418146.84ced","type":"device-manager","z":"d8c9ab31.c9e8b8","auth":"bluemix","name":"","apiKey":"","deviceType":"","method":"Create","deviceId":"","password":"","ignore":false,"x":805.75,"y":68,"wires":[["d1572808.68d938"]]},{"id":"455cee1b.eb5b1","type":"function","z":"d8c9ab31.c9e8b8","name":"Set message event","func":"var numberDevices = parseInt(msg.payload.numberDevices);\nvar deviceCount = 0;\nvar chunkSize = parseInt(msg.payload.chunkSize) || 500;\n\nchunkSize > 2000 ? 2000 : chunkSize;\nchunkSize > numberDevices ? numberDevices : chunkSize;\n\nvar typeId = msg.payload.typeId || \"thinkDevices\";\nvar password = msg.payload.authToken;\nvar deviceName = msg.payload.deviceName;\n\nvar chunks = numberDevices / chunkSize;\nvar deviceCreateCallback = function() {\n var devicePointer = 0;\n for (var cycle = 0 ; cycle <= chunks ; cycle++) {\n msg.payload=[];\n for (var i = 0 ; devicePointer < numberDevices && i < chunkSize ; i++) {\n var singleDevice = {};\n devicePointer++;\n singleDevice.deviceId = deviceName;// + devicePointer;\n singleDevice.typeId = typeId;\n if(password) {\n singleDevice.authToken = password; \n }\n msg.payload.push(singleDevice);\n }\n if(msg.payload.length !== 0)\n node.send(msg);\n }\n}\ndeviceCreateCallback();\n//var timerId = setInterval(deviceCreateCallback, timerId);","outputs":1,"noerr":0,"x":611.25,"y":68.25,"wires":[["a5418146.84ced"]]},{"id":"a0c1a40b.1cce88","type":"delay","z":"d8c9ab31.c9e8b8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":286.25,"y":24,"wires":[["edea0d92.f42a9","455cee1b.eb5b1"]]},{"id":"645b45ef.a3ec6c","type":"inject","z":"d8c9ab31.c9e8b8","name":"create device","topic":"","payload":"{\"numberDevices\":1,\"typeId\":\"thinkDevices\",\"authToken\":\"secretmap\",\"chunkSize\":1,\"deviceName\":\"phone\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":109.25,"y":25,"wires":[["a0c1a40b.1cce88"]]},{"id":"d1572808.68d938","type":"debug","z":"d8c9ab31.c9e8b8","name":"","active":false,"console":"false","complete":"payload","x":989.75,"y":42.5,"wires":[]},{"id":"79ac4c27.556a34","type":"device-type-manager","z":"d8c9ab31.c9e8b8","auth":"bluemix","name":"","apiKey":"","deviceType":"","classId":"Device","method":"Create","deviceTypeId":"","serialNumber":"","manufacturer":"","model":"","deviceClass":"","infoDescription":"","firmwareVersion":"","hardwareVersion":"","descriptiveLocation":"","metadata":"","password":"","properties":[],"ignore":false,"x":735.25,"y":25.000001907348633,"wires":[["d1572808.68d938"]]},{"id":"edea0d92.f42a9","type":"function","z":"d8c9ab31.c9e8b8","name":"Override device type","func":"msg.payload.deviceType = msg.payload.typeId\nreturn msg;","outputs":1,"noerr":0,"x":499.25,"y":25,"wires":[["79ac4c27.556a34"]]},{"id":"7a54a600.22b4ec","type":"http in","z":"d8c9ab31.c9e8b8","name":"","url":"/steps","method":"get","upload":false,"swaggerDoc":"","x":66.25,"y":77.50000190734863,"wires":[["4132a41d.54ebbc","e3b130ab.4e136"]]},{"id":"52928293.54fe7c","type":"cloudant out","z":"d8c9ab31.c9e8b8","name":"secretmap","cloudant":"","database":"secretmap","service":"think-iot-processor-cloudantNoSQLDB","payonly":true,"operation":"insert","x":578.9722290039062,"y":109.55555725097656,"wires":[]},{"id":"aac2d9a5.7697c8","type":"function","z":"d8c9ab31.c9e8b8","name":"Separate values","func":"var val = [];\nobj = JSON.parse(msg.payload.message);\nval = JSON.parse(JSON.stringify(obj));\n\nvar n = [];\nn = val.result.results.payload;\n\nvar m = JSON.parse(n);\n\nvar payload = {\n id : m.id,\n steps: m.totalSteps,\n fitcoins: m.fitcoinsBalance,\n multiplier: m.generatedFitcoins\n};\n\n// global.set(\"id\", m.id);\n// global.set(\"steps\", m.totalSteps);\n// global.set(\"fitcoins\", m.fitcoinsBalance);\n\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":415.7777404785156,"y":115.80551147460938,"wires":[["52928293.54fe7c","a4e9aa2d.821e08","1fedd3d9.a0fc5c"]]},{"id":"866e299f.ffd9b8","type":"function","z":"d8c9ab31.c9e8b8","name":"Create Props","func":"msg.payload = {\"numberDevices\":1,\"typeId\":\"thinkDevices\",\"authToken\":\"secretmap\",\"chunkSize\":1,\"deviceName\":msg.payload};//global.get(\"id\")};\nreturn msg;\n","outputs":1,"noerr":0,"x":235.00001525878906,"y":63.75,"wires":[["a0c1a40b.1cce88"]]},{"id":"d37c802f.9a107","type":"function","z":"d8c9ab31.c9e8b8","name":"steps-sim","func":"var steps = msg.payload;\nglobal.set(\"steps-sim\", steps);\nreturn msg;","outputs":1,"noerr":0,"x":230.5,"y":186.25,"wires":[["ebe9b58b.9e2328"]]},{"id":"8692767e.b2e2c8","type":"debug","z":"d8c9ab31.c9e8b8","name":"count","active":false,"tosidebar":true,"console":false,"complete":"payload","x":719.5,"y":157.5,"wires":[]},{"id":"ebe9b58b.9e2328","type":"function","z":"d8c9ab31.c9e8b8","name":"fitcoins-sim","func":"var count = 0;\nvar fit = [];\n\nif(global.get(\"steps-sim\")%100===0) {\n for(var i=0; i<=1; i++){\n count = Math.floor(global.get(\"steps-sim\"))/100;\n }\n}\nglobal.set(\"fitcoins-sim\", count)\nreturn msg;","outputs":1,"noerr":0,"x":378.25,"y":146.5,"wires":[["dc6338db.68b168"]]},{"id":"dc6338db.68b168","type":"function","z":"d8c9ab31.c9e8b8","name":"final","func":"\nvar options = {\n steps: global.get(\"steps-sim\"),\n fitcoins: global.get(\"fitcoins-sim\")\n}\n\nmsg.payload = options;\nreturn msg;","outputs":1,"noerr":0,"x":244.5,"y":245.25,"wires":[["8692767e.b2e2c8","75577eff.0a224"]]},{"id":"75577eff.0a224","type":"ibmiot out","z":"d8c9ab31.c9e8b8","authentication":"apiKey","apiKey":"b813990f.05bd18","outputType":"evt","deviceId":"demo","deviceType":"thinkDevices","eventCommandType":"steps","format":"json","data":"{\"d\":{\"steps\":1,\"fitcoins\":0}}","qos":0,"name":"IBM IoT","service":"registered","x":394.75,"y":232.75,"wires":[]},{"id":"a4e9aa2d.821e08","type":"counter","z":"d8c9ab31.c9e8b8","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":1,"x":80.5,"y":206,"wires":[["d37c802f.9a107","9d68fd4a.ac2a1"]]},{"id":"9536b2d4.989c5","type":"ui_gauge","z":"d8c9ab31.c9e8b8","name":"","group":"1e81fc6f.c62984","order":3,"width":0,"height":0,"gtype":"gage","title":"Steps","label":"","format":"{{msg.payload}}","min":0,"max":"1999999","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":767.75,"y":198.50001525878906,"wires":[]},{"id":"e3947fe9.8a209","type":"ui_gauge","z":"d8c9ab31.c9e8b8","name":"","group":"1e81fc6f.c62984","order":4,"width":0,"height":0,"gtype":"gage","title":"Fitcoins","label":"","format":"{{msg.payload}}","min":0,"max":"20000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":875.75,"y":159,"wires":[]},{"id":"16f135b3.94922a","type":"ui_chart","z":"d8c9ab31.c9e8b8","name":"","group":"1e81fc6f.c62984","order":2,"width":0,"height":0,"label":"Blockchain Transactions","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"Blockchain Transactions","dot":false,"ymin":"0","ymax":"10000","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":890,"y":117.25001525878906,"wires":[[],[]]},{"id":"5d6cd902.245ef8","type":"function","z":"d8c9ab31.c9e8b8","name":"Get user id","func":"msg.payload = JSON.parse(msg.payload.message).result.user;\nreturn msg;","outputs":1,"noerr":0,"x":416.5,"y":67,"wires":[["866e299f.ffd9b8","d1572808.68d938"]]},{"id":"4132a41d.54ebbc","type":"function","z":"d8c9ab31.c9e8b8","name":"Check","func":"var options={\n message: msg.payload.message,\n size: JSON.stringify(msg.payload.message).length\n}\nmsg.payload = options;\nreturn msg;","outputs":1,"noerr":0,"x":69.75,"y":126,"wires":[["436a5049.de95b"]]},{"id":"436a5049.de95b","type":"switch","z":"d8c9ab31.c9e8b8","name":"","property":"payload.size","propertyType":"msg","rules":[{"t":"lt","v":"250","vt":"num"},{"t":"gte","v":"300","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":198,"y":147.5,"wires":[["5d6cd902.245ef8"],["aac2d9a5.7697c8"]]},{"id":"13c799e0.ae5fd6","type":"comment","z":"d8c9ab31.c9e8b8","name":"","info":"The counter helps feed the simulator with steps and fitcoin values","x":709.75,"y":116,"wires":[]},{"id":"7b847e69.be896","type":"cloudant in","z":"d8c9ab31.c9e8b8","name":"","cloudant":"","database":"secretmap","service":"think-iot-processor-cloudantNoSQLDB","search":"_all_","design":"secret","index":"fitcoins-view","x":420.0972595214844,"y":190.83331298828125,"wires":[["c031f5fd.7bcd58"]]},{"id":"a7de8575.ec3a28","type":"inject","z":"d8c9ab31.c9e8b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":81.37500762939453,"y":249.25,"wires":[["7b847e69.be896"]]},{"id":"1fedd3d9.a0fc5c","type":"delay","z":"d8c9ab31.c9e8b8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":555.5139007568359,"y":148.58331298828125,"wires":[["7b847e69.be896"]]},{"id":"e3b130ab.4e136","type":"counter","z":"d8c9ab31.c9e8b8","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":1,"x":224.5,"y":107.00001525878906,"wires":[["16f135b3.94922a"]]},{"id":"c031f5fd.7bcd58","type":"function","z":"d8c9ab31.c9e8b8","name":"Separate values","func":"var s = [];\nvar f = [];\nvar g = [];\nvar obj = msg.payload;\n\nfor(var j=0; j