├── .gitignore ├── .travis.yml ├── CONTRIBUTING ├── LICENSE ├── Makefile ├── README.md ├── guide ├── README.md └── images │ ├── Build.png │ ├── Build_Success.png │ ├── Building.png │ ├── Curie_Installed.png │ ├── FolderOpened.png │ ├── Github.png │ ├── IDE.png │ ├── Install_Curie.png │ ├── Launch_Board_Manager.png │ ├── OpenFolder.png │ ├── PIO_Build.png │ ├── PIO_Serial.png │ ├── PIO_Serial_Baud.png │ ├── PIO_Serial_Success.png │ ├── PIO_Upload_Start.png │ ├── PIO_Upload_Success.png │ ├── PlatformIO.png │ ├── Terminal.png │ └── Upload.png ├── lib ├── GoosciBleGatt │ ├── GoosciBleGatt.cpp │ ├── GoosciBleGatt.h │ ├── making_science_sensor_gatt.xml │ └── ublue_setup.gen.out.txt ├── goosci │ ├── arduino_nrf_pins.h │ ├── config_change.cpp │ ├── config_change.h │ ├── debug_print.h │ ├── goosci_utility.cpp │ ├── goosci_utility.h │ ├── heartbeat.cpp │ ├── heartbeat.h │ ├── sensor.pb.c │ ├── sensor.pb.h │ ├── services.h │ └── services_lock.h └── readme.txt ├── platformio.ini └── src ├── arduino ├── BLEPeripheralGetAddress.cpp ├── BLEPeripheralGetAddress.h └── science-journal-arduino.cpp ├── arduino101 └── science-journal-arduino.cpp └── blend └── science-journal-arduino.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .clang_complete 3 | .gcc-flags.json 4 | .piolibdeps 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < http://docs.platformio.org/en/latest/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < http://docs.platformio.org/en/latest/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choice one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # 39 | # script: 40 | # - platformio run 41 | 42 | 43 | # 44 | # Template #2: The project is intended to by used as a library with examples 45 | # 46 | 47 | # language: python 48 | # python: 49 | # - "2.7" 50 | # 51 | # sudo: false 52 | # cache: 53 | # directories: 54 | # - "~/.platformio" 55 | # 56 | # env: 57 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 58 | # - PLATFORMIO_CI_SRC=examples/file.ino 59 | # - PLATFORMIO_CI_SRC=path/to/test/directory 60 | # 61 | # install: 62 | # - pip install -U platformio 63 | # 64 | # script: 65 | # - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N 66 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at the end). 2 | 3 | ### Before you contribute 4 | Before we can use your code, you must sign the 5 | [Google Individual Contributor License Agreement] 6 | (https://cla.developers.google.com/about/google-individual) 7 | (CLA), which you can do online. The CLA is necessary mainly because you own the 8 | copyright to your changes, even after your contribution becomes part of our 9 | codebase, so we need your permission to use and distribute your code. We also 10 | need to be sure of various other things—for instance that you'll tell us if you 11 | know that your code infringes on other people's patents. You don't have to sign 12 | the CLA until after you've submitted your code for review and a member has 13 | approved it, but you must do it before we can put your code into our codebase. 14 | Before you start working on a larger contribution, you should get in touch with 15 | us first through the issue tracker with your idea so that we can help out and 16 | possibly guide you. Coordinating up front makes it much easier to avoid 17 | frustration later on. 18 | 19 | ### Code reviews 20 | All submissions, including submissions by project members, require review. We 21 | use Github pull requests for this purpose. 22 | 23 | ### The small print 24 | Contributions made by corporations are covered by a different agreement than 25 | the one above, the 26 | [Software Grant and Corporate Contributor License Agreement] 27 | (https://cla.developers.google.com/about/google-corporate). 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | platformio -f -c vim run 3 | 4 | upload: 5 | platformio -f -c vim run --target upload 6 | 7 | clean: 8 | platformio -f -c vim run --target clean 9 | 10 | program: 11 | platformio -f -c vim run --target program 12 | 13 | uploadfs: 14 | platformio -f -c vim run --target uploadfs 15 | 16 | update: 17 | platformio -f -c vim update 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Science Journal][play-store] allows you to gather data from the world around you. It uses sensors to measure your environment, like light and sound, so you can graph your data, record your experiments, and organize your questions and ideas. It's the lab notebook you always have with you. 2 | 3 | This sketch is used to make an Arduino that has Bluetooth Low Energy 4 | (BLE) capabilities (such as the RedBear BLEND board and the Arduino 101) 5 | send data from its pins to Science Journal. The arduinoUno firmware 6 | is provided for reference, but does not work because of limited RAM on 7 | the Uno. 8 | 9 | ## Building the firmware 10 | 11 | This project uses [Platform IO](http://platformio.org/get-started). 12 | Please refer to [Build Guide][guide] 13 | 14 | ## Contributing 15 | 16 | Please read our [guidelines for contributors][contributing]. 17 | 18 | ## License 19 | 20 | Open Science Journal is licensed under the [Apache 2 license][license]. 21 | 22 | ## More 23 | 24 | Science Journal is brought to you by [Making & Science][making-science], an initiative by Google. Open Science Journal is not an official Google product. 25 | 26 | [play-store]: https://play.google.com/store/apps/details?id=com.google.android.apps.forscience.whistlepunk 27 | [contributing]: https://github.com/google/science-journal-arduino/blob/master/CONTRIBUTING 28 | [license]: https://github.com/google/science-journal-arduino/blob/master/LICENSE 29 | [making-science]: https://makingscience.withgoogle.com 30 | [guide]: https://github.com/google/science-journal-arduino/tree/master/guide 31 | -------------------------------------------------------------------------------- /guide/README.md: -------------------------------------------------------------------------------- 1 | # A walkthru of the basic workflow of PlatformIO building and uploading the Science-Journal-Arduino firmware. 2 | 3 | **How to Flash an Arduino** 4 | 5 | In order to get your Arduino and the Science Journal app connected via bluetooth, you will need to download a small piece of firmware onto your Arduino. 6 | 7 | **What you need:** 8 | Bluetooth enabled Arduino 9 | USB cable 10 | Computer 11 | Internet access 12 | 13 | **Windows Users: ** 14 | If you're on Windows and using an [Arduino 101](https://www.arduino.cc/en/Main/ArduinoBoard101), first you need to install the Arduino IDE and follow these substeps. 15 | 16 | * Launch the IDE 17 | 18 | ![](images/IDE.png "Arduino IDE") 19 | 20 | * Load the Boards Manager via Tools -> Board: ... -> Boards Manager... 21 | 22 | ![](images/Launch_Board_Manager.png "Boards Manager") 23 | 24 | * Install the Intel Curie boards files and drivers by searching for "curie" and clicking install. During the install you will be asked to authorize installation of a few packages, approve them. 25 | 26 | ![](images/Install_Curie.png "Install Curie") 27 | 28 | * Once completed 29 | 30 | ![](images/Curie_Installed.png "Curie Installed") 31 | 32 | *** 33 | 34 | **All Other users start here:** 35 | 36 | How to: 37 | 38 | 1. **Download PlatformIO IDE and install on your computer.** 39 | You will need a free piece of software called PlatformIO IDE. You can download this [here](http://platformio.org/get-started). Note, if you have a Mac, you will be downloading this outside the App store so you might need to [enable third party developer access](https://support.apple.com/kb/PH21769?locale=en_US) to open. 40 | 2. **Download the Science Journal firmware [Science Journal firmware](https://github.com/google/science-journal-arduino) from GitHub.** 41 | This will download as a zip file. You can do this by clicking “clone or download” and selecting “download zip.” When downloaded, unzip the file so you see a folder titled “science-journal-arduino-master”. 42 | ![](images/Github.png "Repository Index") 43 | 3. **Connect your Arduino to your computer via the usb cable. ** 44 | 4. **Launch PlatformIO IDE.** 45 | You should see a home screen that looks something like this: 46 | ![PlatformIO Home](images/PlatformIO.png) 47 | 5. **Select “Open Project” and open your newly unzipped folder “science-journal-arduino-master”.** 48 | When the project has loaded, your screen should look something like this: 49 | ![](images/FolderOpened.png "PIO Home") 50 | 6. **Click on the checkmark in the top left corner of the app to begin the firmware compilation.** 51 | Compilation can take a couple minutes. 52 | ![](images/Build.png "Build") 53 | 7. When it has finished, you should see something like this for a little bit and then be returned to the project screen. 54 | ![](images/Build_Success.png "Build Success") 55 | 8. **Click the upload button to upload to the arduino.** 56 | ![](images/Upload.png "Upload") 57 | 9. **Select Serial Monitor (plug icon) and set the port and baud rate.** 58 | Look for the port with Arduino in the title. Select a baud rate that is right for your connection. If you are connecting via a standard usb, select 115200. 59 | ![](images/PIO_Serial_Baud.png "Select Baud") 60 | 10. **Record your arduino’s longname on the back of the board. ** 61 | The longname is the id that science journal will register when connecting to it via bluetooth. 62 | ![](images/PIO_Serial_Success.png "Serial Success") 63 | 64 | Now you are ready to connect your arduino to science journal! 65 | 66 | *** 67 | 68 | **Troubleshooting:** 69 | 70 | If you are having trouble with the upload process, you can attempt a manual upload via the terminal window. 71 | 72 | **Launch the terminal by clicking on the terminal icon.** 73 | ![](images/Terminal.png "Terminal") 74 | 75 | **Manually Upload the firmware to your device. ** 76 | Copy and paste the following to the terminal line: 77 | 78 | pio run -e --target upload 79 | 80 | Depending on what arduino you are using, you must replace the with the correct board specification. 81 | 82 | For example, if you are using an Arduino 101, your script should look like: 83 | 84 | pio run -e 101 --target upload 85 | 86 | Other available environments are blend, uno, mega2560 87 | 88 | Remember, punctuation, spacing, and spelling are critical when entering something into the terminal. If you get an error message, check to see if you made a typo. 89 | 90 | When you are done, you should see a screen that looks like this: 91 | ![](images/PIO_Upload_Success.png "Upload Success") 92 | -------------------------------------------------------------------------------- /guide/images/Build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Build.png -------------------------------------------------------------------------------- /guide/images/Build_Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Build_Success.png -------------------------------------------------------------------------------- /guide/images/Building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Building.png -------------------------------------------------------------------------------- /guide/images/Curie_Installed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Curie_Installed.png -------------------------------------------------------------------------------- /guide/images/FolderOpened.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/FolderOpened.png -------------------------------------------------------------------------------- /guide/images/Github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Github.png -------------------------------------------------------------------------------- /guide/images/IDE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/IDE.png -------------------------------------------------------------------------------- /guide/images/Install_Curie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Install_Curie.png -------------------------------------------------------------------------------- /guide/images/Launch_Board_Manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Launch_Board_Manager.png -------------------------------------------------------------------------------- /guide/images/OpenFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/OpenFolder.png -------------------------------------------------------------------------------- /guide/images/PIO_Build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Build.png -------------------------------------------------------------------------------- /guide/images/PIO_Serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Serial.png -------------------------------------------------------------------------------- /guide/images/PIO_Serial_Baud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Serial_Baud.png -------------------------------------------------------------------------------- /guide/images/PIO_Serial_Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Serial_Success.png -------------------------------------------------------------------------------- /guide/images/PIO_Upload_Start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Upload_Start.png -------------------------------------------------------------------------------- /guide/images/PIO_Upload_Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PIO_Upload_Success.png -------------------------------------------------------------------------------- /guide/images/PlatformIO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/PlatformIO.png -------------------------------------------------------------------------------- /guide/images/Terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Terminal.png -------------------------------------------------------------------------------- /guide/images/Upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/science-journal-arduino/7f38a2a325658ee3886cd36901ea562ccf1941d4/guide/images/Upload.png -------------------------------------------------------------------------------- /lib/GoosciBleGatt/GoosciBleGatt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "GoosciBleGatt.h" 22 | #include "goosci_utility.h" 23 | #include "services.h" 24 | #include "sensor.pb.h" 25 | #include "debug_print.h" 26 | #include 27 | 28 | extern void handle(uint8_t* data, int8_t length); 29 | 30 | // Get the service pipe data created in nRFGo Studio 31 | #ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT 32 | static services_pipe_type_mapping_t 33 | services_pipe_type_mapping[NUMBER_OF_PIPES] = 34 | SERVICES_PIPE_TYPE_MAPPING_CONTENT; 35 | #else 36 | #define NUMBER_OF_PIPES 0 37 | static services_pipe_type_mapping_t *services_pipe_type_mapping = NULL; 38 | #endif 39 | 40 | #define BTLE_DEVICE_NAME_SIZE 8 41 | #define BTLE_BUFFER_SIZE 20 42 | 43 | // Store the setup for the nRF8001 in the flash of the AVR to save on RAM 44 | static const hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = 45 | SETUP_MESSAGES_CONTENT; 46 | 47 | static struct aci_state_t aci_state; // ACI state data 48 | static hal_aci_evt_t aci_data; // Command buffer 49 | 50 | static bool addrReceived; 51 | static bool addrSet = false; 52 | static bool timing_change_done = false; 53 | static int adTimeout; 54 | static int adInterval; 55 | static char deviceName[BTLE_DEVICE_NAME_SIZE]; 56 | static char longName[BTLE_BUFFER_SIZE]; 57 | static char deviceDesc[BTLE_BUFFER_SIZE]; 58 | static unsigned char 59 | deviceAddress[BTLE_DEVICE_ADDRESS_SIZE]; // LSB to MSB byte order 60 | 61 | // Define how assert should function in the BLE library 62 | void __ble_assert(const char *file, uint16_t line) { 63 | DEBUG_PRINT(F("ERROR ")); 64 | DEBUG_PRINT(file); 65 | DEBUG_PRINT(F(": ")); 66 | DEBUG_PRINT(line); 67 | DEBUG_PRINT(F("\n")); 68 | while (1) 69 | ; 70 | } 71 | 72 | static int _REQ, _RDY, _RST; 73 | 74 | // Methods 75 | bool GoosciBleGatt::isInitialized() { 76 | return (aci_state.device_state == ACI_DEVICE_STANDBY); 77 | } 78 | 79 | bool GoosciBleGatt::isReadyToSend() { 80 | return lib_aci_is_pipe_available(&aci_state, PIPE_GOOSCI_SENSOR_VALUE_TX) && aci_state.data_credit_available > 0; 81 | } 82 | 83 | uint8_t packet[BTLE_BUFFER_SIZE]; 84 | 85 | bool GoosciBleGatt::sendData(const char *buffer, int32_t size) { 86 | const uint8_t max_packet_size = BTLE_BUFFER_SIZE - 2; 87 | /* Force size/max_packet_size to round up */ 88 | uint8_t num_packets = (size + max_packet_size - 1) / max_packet_size; 89 | bool send_complete = true; 90 | for (uint8_t ii = 0; ii < num_packets; ii++) { 91 | 92 | bool is_last_packet = ((num_packets - 1) == ii); 93 | /* There are 3 possibilities for current_packet_size 94 | 1) It is the last packet and the remaining data is smaller than our allocated buffer (size % max_packet_size) 95 | 2) It is the last packet and the remaining data is equal to our allocated buffer (max_packet_size) 96 | 3) It is not the last packet (max_packet_size) 97 | */ 98 | uint8_t current_packet_size = (is_last_packet ? ((size % max_packet_size == 0) ? max_packet_size : (size % max_packet_size)) : max_packet_size); 99 | packet[0] = current_packet_size; 100 | packet[1] = is_last_packet; 101 | memcpy((void*)(packet + 2), buffer + ii * max_packet_size, current_packet_size); 102 | 103 | /* If send fails then we give up */ 104 | if (!(send_complete = lib_aci_send_data(PIPE_GOOSCI_SENSOR_VALUE_TX, packet, current_packet_size + 2))) 105 | break; 106 | 107 | aci_state.data_credit_available--; 108 | while (!is_last_packet && !isReadyToSend()) 109 | pollACI(); 110 | } 111 | 112 | return send_complete; 113 | } 114 | 115 | void initLocalData(void) { 116 | if (strlen(deviceName) > 0) { 117 | lib_aci_set_local_data(&aci_state, PIPE_GAP_DEVICE_NAME_SET, 118 | (unsigned char *)&deviceName, strlen(deviceName)); 119 | } 120 | 121 | if (strlen(deviceDesc) > 0) { 122 | lib_aci_set_local_data(&aci_state, PIPE_GOOSCI_SENSOR_DESCRIPTION_SET, 123 | (unsigned char *)deviceDesc, strlen(deviceDesc)); 124 | } 125 | 126 | if (strlen(longName) > 0) { 127 | lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST, 128 | (unsigned char *)longName, 8); 129 | } 130 | } 131 | 132 | /************************************************************************** 133 | * 134 | * Constructor for the Goosci service 135 | * 136 | **************************************************************************/ 137 | GoosciBleGatt::GoosciBleGatt(int req, int rdy, int rst) { 138 | _REQ = req; 139 | _RDY = rdy; 140 | _RST = rst; 141 | 142 | memset(deviceName, 0x00, BTLE_DEVICE_NAME_SIZE); 143 | memset(deviceDesc, 0x00, BTLE_BUFFER_SIZE); 144 | } 145 | 146 | /************************************************************************** 147 | * 148 | * Update the device name (7 characters or less!) 149 | * 150 | **************************************************************************/ 151 | void GoosciBleGatt::setDeviceName(const char *newName) { 152 | if (strlen(newName) > BTLE_DEVICE_NAME_SIZE - 1) { 153 | DEBUG_PRINTLN(F("Device name too long; new name was not set. ")); 154 | return; 155 | } else { 156 | strcpy(deviceName, newName); 157 | } 158 | } 159 | 160 | /************************************************************************** 161 | * 162 | * Copy the device name to the input buffer 163 | * 164 | **************************************************************************/ 165 | void GoosciBleGatt::getDeviceName(char *name) { 166 | if (strlen(deviceName) > 0) { 167 | strcpy(name, deviceName); 168 | } 169 | } 170 | 171 | /************************************************************************** 172 | * 173 | * Update the long name (20 characters or less!) 174 | * 175 | **************************************************************************/ 176 | void GoosciBleGatt::setLongName(const char *newName) { 177 | if (strlen(newName) > BTLE_BUFFER_SIZE - 1) { 178 | DEBUG_PRINTLN(F("Name too long; new name was not set. ")); 179 | return; 180 | } else { 181 | strcpy(longName, newName); 182 | } 183 | } 184 | 185 | /************************************************************************** 186 | * 187 | * Set the device description (20 characters or less!). 188 | * This is the place to store the long name. 189 | * 190 | **************************************************************************/ 191 | void GoosciBleGatt::setDeviceDescription(const char *desc) { 192 | // Set the value of the description characteristic. 193 | if (strlen(desc) > BTLE_BUFFER_SIZE - 1) { 194 | DEBUG_PRINTLN(F("Description too long; new description was not set.")); 195 | return; 196 | } else { 197 | strcpy(deviceDesc, desc); 198 | } 199 | } 200 | 201 | /************************************************************************** 202 | * 203 | * Configures the nRF8001 and starts advertising the service 204 | * 205 | * @param[in] advTimeout 206 | * The advertising timeout in seconds 207 | * (0 = infinite advertising). 208 | * @param[in] advInterval 209 | * The delay between advertising packets in 0.625ms units 210 | * (1600 = 1 second). 211 | * 212 | **************************************************************************/ 213 | bool GoosciBleGatt::begin(int advTimeout, int advInterval) { 214 | // Store the advertising timeout and interval 215 | // TODO(nmai): check for valid ranges. 216 | adTimeout = advTimeout; 217 | adInterval = advInterval; 218 | 219 | // Setup the service data from nRFGo Studio (services.h) 220 | if (NULL != services_pipe_type_mapping) { 221 | aci_state.aci_setup_info.services_pipe_type_mapping = 222 | &services_pipe_type_mapping[0]; 223 | } else { 224 | aci_state.aci_setup_info.services_pipe_type_mapping = NULL; 225 | } 226 | 227 | aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES; 228 | aci_state.aci_setup_info.setup_msgs = (hal_aci_data_t *)setup_msgs; 229 | aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES; 230 | 231 | // Setup the nRF8001 pins. 232 | aci_state.aci_pins.board_name = BOARD_DEFAULT; 233 | aci_state.aci_pins.reqn_pin = _REQ; 234 | aci_state.aci_pins.rdyn_pin = _RDY; 235 | aci_state.aci_pins.mosi_pin = MOSI; 236 | aci_state.aci_pins.miso_pin = MISO; 237 | aci_state.aci_pins.sck_pin = SCK; 238 | 239 | // SPI_CLOCK_DIV8 = 2MHz SPI speed. 240 | aci_state.aci_pins.spi_clock_divider = SPI_CLOCK_DIV8; 241 | 242 | // The Active pin is optional and can be marked UNUSED. 243 | aci_state.aci_pins.reset_pin = _RST; 244 | aci_state.aci_pins.active_pin = UNUSED; 245 | aci_state.aci_pins.optional_chip_sel_pin = UNUSED; 246 | 247 | // Interrupts still not available in Chipkit. 248 | aci_state.aci_pins.interface_is_interrupt = false; 249 | aci_state.aci_pins.interrupt_number = 1; 250 | 251 | // The second parameter is for turning debug printing on 252 | // for the ACI Commands and Events so they be printed on the Serial 253 | lib_aci_init(&aci_state, false); 254 | 255 | // Get the device address 256 | lib_aci_get_address(); 257 | // Wait for the get address response 258 | addrReceived = false; 259 | while (!addrReceived) { 260 | pollACI(); 261 | } 262 | 263 | return true; 264 | } 265 | 266 | void GoosciBleGatt::get_address(void) { 267 | // Generate a unique name using the last 4 digits of device address. 268 | if (!addrSet) { 269 | char d[20]; 270 | char l[8]; 271 | snprintf(l, 8, "Sci%02x%02x\0", deviceAddress[1], deviceAddress[0]); 272 | setLongName(l); 273 | strcpy(d, l); 274 | setDeviceName(d); 275 | initLocalData(); 276 | addrSet = true; 277 | } 278 | } 279 | 280 | void GoosciBleGatt::print_address(void) { 281 | get_address(); 282 | #ifdef GIT_COMMIT_HASH 283 | DEBUG_PRINT(F("Firmware version: ")); 284 | DEBUG_PRINTLN(F(GIT_COMMIT_HASH)); 285 | #endif 286 | #ifdef JENKINS_BUILD_ID 287 | DEBUG_PRINT(F("Jenkins build id: ")); 288 | DEBUG_PRINTLN(F(JENKINS_BUILD_ID)); 289 | #endif 290 | DEBUG_PRINT(F("DeviceName: ")); 291 | DEBUG_PRINTLN(deviceName); 292 | DEBUG_PRINT(F("DeviceDesc: ")); 293 | DEBUG_PRINTLN(deviceDesc); 294 | DEBUG_PRINT(F("LongName: ")); 295 | DEBUG_PRINTLN(longName); 296 | } 297 | 298 | /************************************************************************** 299 | * 300 | * Handles low level ACI events, and passes them up to an application 301 | * level callback when appropriate 302 | * 303 | **************************************************************************/ 304 | void GoosciBleGatt::pollACI() { 305 | static bool setup_required = false; 306 | 307 | // We enter the if statement only when there is a ACI event 308 | // available to be processed 309 | if (lib_aci_event_get(&aci_state, &aci_data)) { 310 | aci_evt_t *aci_evt; 311 | aci_evt = &aci_data.evt; 312 | // DEBUG_PRINTLN(F("pollACI")); 313 | // DEBUG_PRINT("evt opcode: "); 314 | // DEBUG_PRINTLN2(aci_evt->evt_opcode, HEX); 315 | // DEBUG_PRINT(F("State Total credit: ")); 316 | // DEBUG_PRINTLN(aci_state.data_credit_total); 317 | // DEBUG_PRINT(F("State Available credit: ")); 318 | // DEBUG_PRINTLN(aci_state.data_credit_available); 319 | // DEBUG_PRINT("Event Available credit: "); 320 | // DEBUG_PRINTLN(aci_evt->params.device_started.credit_available); 321 | switch (aci_evt->evt_opcode) { 322 | case ACI_EVT_DEVICE_STARTED: { 323 | // DEBUG_PRINTLN("STARTED"); 324 | aci_state.data_credit_total = 325 | aci_evt->params.device_started.credit_available; 326 | switch (aci_evt->params.device_started.device_mode) { 327 | case ACI_DEVICE_SETUP: { 328 | // DEBUG_PRINTLN("SETUP"); 329 | aci_state.device_state = ACI_DEVICE_SETUP; 330 | setup_required = true; 331 | break; 332 | } 333 | 334 | case ACI_DEVICE_STANDBY: { 335 | // DEBUG_PRINTLN("STANDBY"); 336 | aci_state.device_state = ACI_DEVICE_STANDBY; 337 | 338 | // sleep_to_wakeup_timeout = 30; 339 | 340 | if (aci_evt->params.device_started.hw_error) { 341 | // Magic number used to make sure the HW error 342 | // event is handled correctly. 343 | delay(20); 344 | } else { 345 | get_address(); 346 | // DEBUG_PRINTLN("lib_aci_connect"); 347 | lib_aci_connect(adTimeout, adInterval); 348 | } 349 | break; 350 | } 351 | case ACI_DEVICE_INVALID: { 352 | DEBUG_PRINTLN(F("Evt Device Invalid")); 353 | break; 354 | } 355 | 356 | case ACI_DEVICE_TEST: { 357 | break; 358 | } 359 | 360 | case ACI_DEVICE_SLEEP: { 361 | break; 362 | } 363 | } 364 | break; // case ACI_EVT_DEVICE_STARTED: 365 | } 366 | 367 | case ACI_EVT_CMD_RSP: { 368 | DEBUG_PRINTLN("ACI_EVT_CMD_RSP"); 369 | // If an ACI command response event comes with an error -> stop 370 | if (ACI_STATUS_SUCCESS != aci_evt->params.cmd_rsp.cmd_status) { 371 | // ACI ReadDynamicData and ACI WriteDynamicData 372 | // will have status codes of 373 | // TRANSACTION_CONTINUE and TRANSACTION_COMPLETE 374 | // all other ACI commands will have status code of 375 | // ACI_STATUS_SCUCCESS for a successful command 376 | DEBUG_PRINT(F("ACI Command 0x")); 377 | DEBUG_PRINTLN2(aci_evt->params.cmd_rsp.cmd_opcode, HEX); 378 | DEBUG_PRINT(F("Evt Cmd response: Error. ")); 379 | DEBUG_PRINTLN2(aci_evt->params.cmd_rsp.cmd_status, HEX); 380 | } 381 | if (ACI_CMD_GET_DEVICE_ADDRESS == aci_evt->params.cmd_rsp.cmd_opcode) { 382 | // If this is a response to get device address, save the address 383 | addrReceived = true; 384 | // DEBUG_PRINT(F("Get device address response: ")); 385 | for (int i = BTLE_DEVICE_ADDRESS_SIZE - 1; i >= 0; --i) { 386 | deviceAddress[i] = aci_evt->params.cmd_rsp.params.get_device_address 387 | .bd_addr_own[i]; 388 | // DEBUG_PRINT2(deviceAddress[i], HEX); 389 | // DEBUG_PRINT(F(":")); 390 | } 391 | // DEBUG_PRINTLN(F("")); 392 | } else if (ACI_CMD_OPEN_ADV_PIPE == 393 | aci_evt->params.cmd_rsp.cmd_opcode) { 394 | DEBUG_PRINTLN( 395 | F("Open advertising pipe response, setting service data.")); 396 | lib_aci_set_local_data( 397 | &aci_state, PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST, 398 | (unsigned char *)longName, 8); 399 | 400 | DEBUG_PRINT(F("Advertising starting for ")); 401 | DEBUG_PRINTLN(deviceName); 402 | lib_aci_connect(adTimeout, adInterval); 403 | } else if (ACI_CMD_GET_DEVICE_VERSION == aci_evt->params.cmd_rsp.cmd_opcode) { 404 | DEBUG_PRINTLN("ACI_CMD_GET_DEVICE_VERSION"); 405 | } else if (ACI_CMD_SET_LOCAL_DATA == aci_evt->params.cmd_rsp.cmd_opcode) { 406 | DEBUG_PRINTLN("ACI_CMD_SET_LOCAL_DATA"); 407 | } else if (ACI_CMD_CONNECT == aci_evt->params.cmd_rsp.cmd_opcode) { 408 | DEBUG_PRINTLN("ACI_CMD_CONNECT"); 409 | } else if (ACI_CMD_DISCONNECT == aci_evt->params.cmd_rsp.cmd_opcode) { 410 | DEBUG_PRINTLN("ACI_CMD_DISCONNECT"); 411 | } else if (ACI_CMD_CHANGE_TIMING == aci_evt->params.cmd_rsp.cmd_opcode) { 412 | DEBUG_PRINTLN("ACI_CMD_CHANGE_TIMING"); 413 | } else { 414 | // print command 415 | DEBUG_PRINT(F("Unexpected ACI Command 0x")); 416 | DEBUG_PRINTLN2(aci_evt->params.cmd_rsp.cmd_opcode, HEX); 417 | } 418 | break; 419 | } 420 | 421 | case ACI_EVT_CONNECTED: { 422 | // The nRF8001 is now connected to the peer device. 423 | DEBUG_PRINTLN(F("Evt Connected")); 424 | aci_state.data_credit_available = aci_state.data_credit_total; 425 | timing_change_done = false; 426 | break; 427 | } 428 | 429 | case ACI_EVT_PIPE_STATUS: { 430 | DEBUG_PRINTLN(F("Evt Pipe Status: ")); 431 | // DEBUG_PRINT2((int) aci_evt->params.pipe_status.pipes_open_bitmap, HEX); 432 | // DEBUG_PRINT(" "); 433 | // DEBUG_PRINTLN2((int) aci_evt->params.pipe_status.pipes_closed_bitmap, HEX); 434 | if (lib_aci_is_pipe_available(&aci_state, PIPE_GOOSCI_SENSOR_VALUE_TX) && !timing_change_done) { 435 | lib_aci_change_timing(6, 6, 0, 600); // Low-latency parameters 436 | timing_change_done = true; 437 | } 438 | 439 | break; 440 | } 441 | 442 | case ACI_EVT_TIMING: { 443 | // DEBUG_PRINT("ACI_EVT_TIMING: "); 444 | // DEBUG_PRINT(aci_evt->params.timing.conn_rf_interval); 445 | // DEBUG_PRINT(" "); 446 | // DEBUG_PRINT(aci_evt->params.timing.conn_slave_rf_latency); 447 | // DEBUG_PRINT(" "); 448 | // DEBUG_PRINT(aci_evt->params.timing.conn_rf_timeout); 449 | // DEBUG_PRINT(" "); 450 | // DEBUG_PRINTLN(aci_evt->params.timing.conn_rf_interval); 451 | break; 452 | } 453 | 454 | case ACI_EVT_DISCONNECTED: { 455 | // Advertise again if the advertising timed out. 456 | DEBUG_PRINTLN(F("Evt Disconnected.")); 457 | // TODO(dek): figure out why the transition to using credits 458 | // broke disconnection (packets are still transmitted). 459 | // Setting the credits to 0 was an experiment but it didn't work. 460 | // aci_state.data_credit_available = 0; 461 | lib_aci_connect(adTimeout, adInterval); 462 | timing_change_done = false; 463 | break; 464 | } 465 | 466 | case ACI_EVT_DATA_RECEIVED: { 467 | DEBUG_PRINTLN("ACI_EVT_DATA_RECEIVED"); 468 | if (aci_evt->params.data_received.rx_data.pipe_number == PIPE_GOOSCI_SENSOR_CONFIGURATION_RX_ACK_AUTO) { 469 | int8_t packet_length = aci_evt->len; 470 | handle(aci_evt->params.data_received.rx_data.aci_data, aci_evt->len); 471 | } else { 472 | DEBUG_PRINT(F(" Data(Hex) : ")); 473 | for (int i = 0; i < aci_evt->len - 2; i++) { 474 | DEBUG_PRINT2(aci_evt->params.data_received.rx_data.aci_data[i], HEX); 475 | DEBUG_PRINT(F(" ")); 476 | } 477 | DEBUG_PRINTLN(F("")); 478 | } 479 | break; 480 | } 481 | 482 | 483 | case ACI_EVT_DATA_CREDIT: { 484 | // DEBUG_PRINTLN(F("Evt Credit: Peer has received our send")); 485 | aci_state.data_credit_available = aci_state.data_credit_available + aci_evt->params.data_credit.credit; 486 | break; 487 | } 488 | 489 | case ACI_EVT_PIPE_ERROR: { 490 | // See the appendix in the nRF8001 491 | // Product Specication for details on the error codes 492 | DEBUG_PRINT(F("ACI Evt Pipe Error: Pipe #:")); 493 | DEBUG_PRINT2(aci_evt->params.pipe_error.pipe_number, DEC); 494 | DEBUG_PRINT(F(" Pipe Error Code: 0x")); 495 | DEBUG_PRINTLN2(aci_evt->params.pipe_error.error_code, HEX); 496 | 497 | // Increment the credit available as the data packet was not sent. 498 | // The pipe error also represents the Attribute protocol 499 | // Error Response sent from the peer and that should not be counted 500 | // for the credit. 501 | if (ACI_STATUS_ERROR_PEER_ATT_ERROR != 502 | aci_evt->params.pipe_error.error_code) { 503 | aci_state.data_credit_available++; 504 | } 505 | break; 506 | } 507 | 508 | case ACI_EVT_DATA_ACK: { 509 | // DEBUG_PRINTLN(F("ACK")); 510 | break; 511 | } 512 | case ACI_EVT_HW_ERROR: { 513 | DEBUG_PRINTLN(F("HW error: ")); 514 | DEBUG_PRINTLN2(aci_evt->params.hw_error.line_num, DEC); 515 | 516 | for (int counter = 0; counter <= (aci_evt->len - 3); counter++) { 517 | DEBUG_PRINT(aci_evt->params.hw_error.file_name[counter]); 518 | } 519 | DEBUG_PRINTLN(); 520 | initLocalData(); 521 | lib_aci_connect(adTimeout, adInterval); 522 | break; 523 | } 524 | 525 | default: { 526 | DEBUG_PRINT(F("Evt Opcode 0x")); 527 | DEBUG_PRINT2(aci_evt->evt_opcode, HEX); 528 | DEBUG_PRINTLN(F(" unhandled")); 529 | break; 530 | } 531 | } 532 | } 533 | 534 | // setup_required is set to true when the device starts 535 | // up and enters setup mode. 536 | // It indicates that do_aci_setup() should be called. 537 | // The flag should be cleared if do_aci_setup() returns 538 | // ACI_STATUS_TRANSACTION_COMPLETE. 539 | if (setup_required) { 540 | int result = do_aci_setup(&aci_state); 541 | if (result != SETUP_SUCCESS ) { 542 | switch(result) { 543 | case SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY: 544 | DEBUG_PRINTLN("SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY"); 545 | break; 546 | case SETUP_FAIL_EVENT_QUEUE_NOT_EMPTY: 547 | DEBUG_PRINTLN("SETUP_EVENT_COMMAND_QUEUE_NOT_EMPTY"); 548 | break; 549 | case SETUP_FAIL_NOT_SETUP_EVENT: 550 | DEBUG_PRINTLN("SETUP_FAIL_NOT_SETUP_EVENT"); 551 | break; 552 | case SETUP_FAIL_NOT_COMMAND_RESPONSE: 553 | DEBUG_PRINTLN("SETUP_FAIL_NOT_COMMAND_RESPONSE"); 554 | break; 555 | } 556 | } else { 557 | setup_required = false; 558 | } 559 | } 560 | } 561 | -------------------------------------------------------------------------------- /lib/GoosciBleGatt/GoosciBleGatt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _GOOSCI_BLE_GATT_H_ 17 | #define _GOOSCI_BLE_GATT_H_ 18 | 19 | class GoosciBleGatt { 20 | public: 21 | GoosciBleGatt(int req, int rdy, int rst); 22 | bool begin(int advTimeout = 180, int advInterval = 0x0050); 23 | void get_address(); 24 | void print_address(); 25 | void pollACI (void); 26 | void getDeviceName(char *name); 27 | void setDeviceName(const char *deviceName); 28 | void setLongName(const char *deviceName); 29 | void setDeviceDescription(const char *desc); 30 | void setSensorConfig(const char *config, int size); 31 | bool isInitialized(void); 32 | bool isReadyToSend(void); 33 | bool sendData(const char *buffer, int32_t size); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/GoosciBleGatt/making_science_sensor_gatt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0 5 | nRF8001_Dx 6 | 7 | GooSci Sensor 8 | 0001 9 | 10 | Description 11 | 0002 12 | GooSci Sensor 13 | 1 14 | 20 15 | 1 16 | false 17 | false 18 | 19 | false 20 | false 21 | false 22 | false 23 | false 24 | 25 | true 26 | false 27 | 28 | 0 29 | 30 | 31 | 32 | Value 33 | 0003 34 | 35 | 1 36 | 20 37 | 2 38 | false 39 | false 40 | 41 | false 42 | false 43 | true 44 | false 45 | false 46 | 47 | false 48 | false 49 | 50 | 0 51 | 52 | 53 | false 54 | false 55 | 56 | false 57 | true 58 | 59 | 2901 60 | true 61 | true 62 | 63 | 64 | false 65 | false 66 | 67 | false 68 | true 69 | 70 | 2906 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | Software Revision String 79 | 0004 80 | Rev 0.1 81 | 1 82 | 10 83 | 2 84 | false 85 | false 86 | 87 | false 88 | false 89 | false 90 | false 91 | false 92 | 93 | true 94 | false 95 | 96 | 0 97 | 98 | 99 | 100 | Firmware Revision String 101 | 0005 102 | 01.1 103 | 1 104 | 10 105 | 1 106 | false 107 | false 108 | 109 | false 110 | false 111 | false 112 | false 113 | false 114 | 115 | true 116 | false 117 | 118 | 0 119 | 120 | 121 | 122 | Configuration 123 | 0010 124 | 125 | 0 126 | 20 127 | 2 128 | false 129 | false 130 | 131 | false 132 | true 133 | false 134 | false 135 | false 136 | 137 | false 138 | true 139 | 140 | 0 141 | 142 | 143 | 144 | Protocol Version 145 | 0011 146 | 2048 147 | 0 148 | 2 149 | 1 150 | false 151 | false 152 | 153 | false 154 | false 155 | false 156 | false 157 | false 158 | 159 | true 160 | false 161 | 162 | 0 163 | 164 | 165 | 166 | 167 | Device Information 168 | 180a 169 | 170 | Model Number String 171 | 2a24 172 | Windmill 173 | 1 174 | 20 175 | 2 176 | false 177 | false 178 | 179 | false 180 | false 181 | false 182 | false 183 | true 184 | 185 | true 186 | false 187 | 188 | 0 189 | 190 | 191 | 192 | 193 | Windmill 194 | 8 195 | true 196 | 0 197 | 0000 198 | 0 199 | 0 200 | 0 201 | 600 202 | 10 203 | 7 204 | 16 205 | 0 206 | c1a 207 | 0 208 | 0 209 | 1010 210 | 0 211 | 0 212 | 0 213 | 0 214 | 0 215 | 0 216 | 0 217 | 0 218 | 65535 219 | 65535 220 | 0 221 | 65535 222 | false 223 | false 224 | 5 225 | 226 | 0001 227 | 228 | 229 | 230 | 12 231 | 232 | 233 | 234 | 1 235 | 236 | 237 | 238 | 239 | 240 | 1 241 | 1 242 | 3 243 | 0 244 | 0 245 | 0 246 | 0 247 | false 248 | 249 | 250 | 220 251 | 10 252 | 1000 253 | 0 254 | 0 255 | 1280 256 | 257 | 258 | -------------------------------------------------------------------------------- /lib/GoosciBleGatt/ublue_setup.gen.out.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | uBlue Setup generation report 3 | Generated with uBlue setup DLL version: 1.0.0.16903 4 | Generated: Fri Jul 08 17:05:50 2016 (UTC) 5 | This file is automatically generated, do not modify 6 | ------------------------------------------------------------------------------ 7 | 8 | [Counts] 9 | 10 | Setup data size = 1045 bytes 11 | Local database size = 658 bytes 12 | Local attribute count = 10 13 | Remote attribute count = 0 14 | Total pipe count = 11 15 | Dynamic data size = 298 bytes (worst case) 16 | 17 | [Setup Area Layout] 18 | 19 | Setup area, total = 1595 bytes 20 | Setup area, used = 804 bytes ( 50% of total ) 21 | Local services = 658 bytes ( 81% of used ) 22 | Remote services = 0 bytes ( 0% of used ) 23 | Pipes = 100 bytes ( 12% of used ) 24 | VS UUID area = 16 bytes ( 1% of used ) 25 | Extended Attr area = 30 bytes ( 3% of used ) 26 | 27 | [Device Settings] 28 | 29 | Setup ID = 0x00000000 30 | Setup Format = 0x03 31 | Security = OPEN (0) 32 | Bond Timeout = 600 33 | Security Request Delay = 10 34 | Change Timing Delay = 5 35 | Whitelist = Enabled 36 | 37 | [Advertisement Data] 38 | 39 | Bond Advertise = 0x00000000 [] 40 | Bond Scan Resp = 0x00000000 [] 41 | General Advertise = 0x00000014 [SERVICES_128_COMPLETE | LOCAL_NAME_COMPLETE] 42 | General Scan Resp = 0x00001010 [LOCAL_NAME_COMPLETE | SERVICE_DATA] 43 | Broadcast Advertise = 0x00000000 [] 44 | Broadcast Scan Resp = 0x00000000 [] 45 | 46 | Custom Bond Advertise = 0x00 [] 47 | Custom Bond Scan Resp = 0x00 [] 48 | Custom General Advertise = 0x00 [] 49 | Custom General Scan Resp = 0x00 [] 50 | Custom Broadcast Advertise = 0x00 [] 51 | Custom Broadcast Scan Resp = 0x00 [] 52 | 53 | No custom AD types 54 | 55 | [Vendor Specific UUIDs] 56 | 57 | VS UUID #0 (type=0x02): 0xE8 0x74 0x2C 0x65 0xF0 0x01 0x38 0x95 0x7A 0x46 0xAA 0x0A 0x00 0x00 0x5A 0x55 58 | 59 | [Local Database] 60 | 61 | Handle Pipes Structure 62 | ------ ----- --------- 63 | 0x0001 +----- Service (Primary): "GAP" (01:0x1800) 64 | 0x0002 |----- |Characteristic: "Device Name" (01:0x2A00) [rd|wwr|wr] [rd:allow|wr:none] 65 | 0x0003 x |Value: {0x57 0x69 0x6E 0x64 0x6D 0x69 0x6C 0x6C} [rd:allow|wr:allow] 66 | 0x0004 |----- |Characteristic: "Appearance" (01:0x2A01) [rd] [rd:allow|wr:none] 67 | 0x0005 |Value: {0x00 0x00} [rd:allow|wr:none] 68 | 0x0006 |----- |Characteristic: "PPCP" (01:0x2A04) [rd] [rd:allow|wr:none] 69 | 0x0007 |Value: {0xFF 0xFF 0xFF 0xFF 0x00 0x00 0xFF 0xFF} [rd:allow|wr:none] 70 | 0x0008 +----- Service (Primary): "GATT" (01:0x1801) 71 | 0x0009 +----- Service (Primary): "?" (02:0x0001) 72 | 0x000A |----- |Characteristic: "?" (02:0x0002) [rd] [rd:allow|wr:none] 73 | 0x000B x |Value: {0x47 0x6F 0x6F 0x53 0x63 0x69 0x20 0x53 0x65 0x6E 0x73 0x6F 0x72 0x00 0x00 0x00 0x00 0x00 0x00 0x00} [rd:allow|wr:none] 74 | 0x000C |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none] 75 | 0x000D |----- |Characteristic: "?" (02:0x0003) [not] [rd:allow|wr:none] 76 | 0x000E > |Value: {} [rd:none|wr:none] 77 | 0x000F |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x1B 0x00 0x28 0x27 0x01 0x04 0x29} [rd:allow|wr:none] 78 | 0x0010 |----- |Descriptor: "Client Characteristic Configuration" (01:0x2902) Value: {0x00 0x00} [rd:allow|wr:allow] 79 | 0x0011 x |----- |Descriptor: "User Description" (01:0x2901) Value: {} [rd:allow|wr:none] 80 | 0x0012 x |----- |Descriptor: "?" (01:0x2906) Value: {} [rd:allow|wr:none] 81 | 0x0013 |----- |Characteristic: "?" (02:0x0004) [rd] [rd:allow|wr:none] 82 | 0x0014 x |Value: {0x52 0x65 0x76 0x20 0x30 0x2E 0x31} [rd:allow|wr:none] 83 | 0x0015 |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none] 84 | 0x0016 |----- |Characteristic: "?" (02:0x0005) [rd] [rd:allow|wr:none] 85 | 0x0017 x |Value: {0x30 0x31 0x2E 0x31 0x00 0x00 0x00 0x00 0x00 0x00} [rd:allow|wr:none] 86 | 0x0018 |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none] 87 | 0x0019 |----- |Characteristic: "?" (02:0x0010) [wr] [rd:allow|wr:none] 88 | 0x001A < |Value: {} [rd:none|wr:allow] 89 | 0x001B |----- |Characteristic: "?" (02:0x0011) [rd] [rd:allow|wr:none] 90 | 0x001C x |Value: {0x00 0x08} [rd:allow|wr:none] 91 | 0x001D |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x06 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none] 92 | 0x001E +----- Service (Primary): "Device Info" (01:0x180A) 93 | 0x001F |----- |Characteristic: "Model Num" (01:0x2A24) [rd] [rd:allow|wr:none] 94 | 0x0020 x> |Value: {0x57 0x69 0x6E 0x64 0x6D 0x69 0x6C 0x6C} [rd:allow|wr:none] 95 | 0x0021 |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none] 96 | 97 | [Remote Database] 98 | 99 | Handle Pipes Structure 100 | ------ ----- --------- 101 | 102 | [Pipe Map] 103 | 104 | Pipe Store Type Service Char. CPF Desc. 105 | ---- ------ ------ ---------- --------- ----------- --------- 106 | 01 Local SET 01:0x1800 01:0x2A00 -- -- 107 | 02 Local SET 02:0x0001 02:0x0002 -- -- 108 | 03 Local TX 02:0x0001 02:0x0003 -- -- 109 | 04 Local SET 02:0x0001 02:0x0003 -- 01:0x2901 110 | 05 Local SET 02:0x0001 02:0x0003 -- 01:0x2906 111 | 06 Local SET 02:0x0001 02:0x0004 -- -- 112 | 07 Local SET 02:0x0001 02:0x0005 -- -- 113 | 08 Local RX_AA 02:0x0001 02:0x0010 -- -- 114 | 09 Local SET 02:0x0001 02:0x0011 -- -- 115 | 10 Local TX_BC 01:0x180A 01:0x2A24 -- -- 116 | 11 Local SET 01:0x180A 01:0x2A24 -- -- 117 | 118 | [Setup Data] 119 | 120 | 07-06-00-00-03-02-42-07 121 | 1F-06-10-00-00-00-00-00-00-00-0A-00-0B-01-01-00-00-06-00-00-90-00-00-00-00-00-00-00-00-00-00-00 122 | 1F-06-10-1C-01-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-14-03-90-01-FF 123 | 1F-06-10-38-FF-FF-02-58-0A-05-00-00-00-00-00-00-10-10-00-00-00-00-00-00-00-00-00-00-00-00-00-00 124 | 05-06-10-54-00-00 125 | 1F-06-20-00-04-04-02-02-00-01-28-00-01-00-18-04-04-05-05-00-02-28-03-01-0E-03-00-00-2A-04-14-08 126 | 1F-06-20-1C-08-00-03-2A-00-01-57-69-6E-64-6D-69-6C-6C-04-04-05-05-00-04-28-03-01-02-05-00-01-2A 127 | 1F-06-20-38-06-04-03-02-00-05-2A-01-01-00-00-04-04-05-05-00-06-28-03-01-02-07-00-04-2A-06-04-09 128 | 1F-06-20-54-08-00-07-2A-04-01-FF-FF-FF-FF-00-00-FF-FF-04-04-02-02-00-08-28-00-01-01-18-04-04-10 129 | 1F-06-20-70-10-00-09-28-00-01-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-01-00-5A-55-04-04-13-13-00-0A 130 | 1F-06-20-8C-28-03-01-02-0B-00-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-02-00-5A-55-06-04-15-14-00-0B 131 | 1F-06-20-A8-00-02-02-47-6F-6F-53-63-69-20-53-65-6E-73-6F-72-00-00-00-00-00-00-00-06-04-08-07-00 132 | 1F-06-20-C4-0C-29-04-01-19-00-00-00-01-00-00-04-04-13-13-00-0D-28-03-01-10-0E-00-E8-74-2C-65-F0 133 | 1F-06-20-E0-01-38-95-7A-46-AA-0A-03-00-5A-55-14-00-14-00-00-0E-00-03-02-00-00-00-00-00-00-00-00 134 | 1F-06-20-FC-00-00-00-00-00-00-00-00-00-00-00-00-06-04-08-07-00-0F-29-04-01-1B-00-28-27-01-04-29 135 | 1F-06-21-18-46-14-03-02-00-10-29-02-01-00-00-04-04-14-00-00-11-29-01-01-00-00-00-00-00-00-00-00 136 | 1F-06-21-34-00-00-00-00-00-00-00-00-00-00-00-00-04-04-14-00-00-12-29-06-01-00-00-00-00-00-00-00 137 | 1F-06-21-50-00-00-00-00-00-00-00-00-00-00-00-00-00-04-04-13-13-00-13-28-03-01-02-14-00-E8-74-2C 138 | 1F-06-21-6C-65-F0-01-38-95-7A-46-AA-0A-04-00-5A-55-04-04-0A-07-00-14-00-04-02-52-65-76-20-30-2E 139 | 1F-06-21-88-31-00-00-00-06-04-08-07-00-15-29-04-01-19-00-00-00-01-00-00-04-04-13-13-00-16-28-03 140 | 1F-06-21-A4-01-02-17-00-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-05-00-5A-55-06-04-0B-0A-00-17-00-05 141 | 1F-06-21-C0-02-30-31-2E-31-00-00-00-00-00-00-06-04-08-07-00-18-29-04-01-19-00-00-00-01-00-00-04 142 | 1F-06-21-DC-04-13-13-00-19-28-03-01-08-1A-00-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-10-00-5A-55-44 143 | 1F-06-21-F8-10-14-00-00-1A-00-10-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 144 | 1F-06-22-14-04-04-13-13-00-1B-28-03-01-02-1C-00-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-11-00-5A-55 145 | 1F-06-22-30-06-04-03-02-00-1C-00-11-02-00-08-06-04-08-07-00-1D-29-04-01-06-00-00-00-01-00-00-04 146 | 1F-06-22-4C-04-02-02-00-1E-28-00-01-0A-18-04-04-05-05-00-1F-28-03-01-02-20-00-24-2A-04-04-14-08 147 | 1F-06-22-68-00-20-2A-24-01-57-69-6E-64-6D-69-6C-6C-00-00-00-00-00-00-00-00-00-00-00-00-06-04-08 148 | 11-06-22-84-07-00-21-29-04-01-19-00-00-00-01-00-00-00 149 | 1F-06-40-00-2A-00-01-00-80-04-00-03-00-00-00-02-02-00-80-04-00-0B-00-00-00-03-02-00-02-04-00-0E 150 | 1F-06-40-1C-00-10-29-01-01-00-80-05-00-11-00-00-29-06-01-00-80-05-00-12-00-00-00-04-02-00-80-04 151 | 1F-06-40-38-00-14-00-00-00-05-02-00-80-04-00-17-00-00-00-10-02-04-00-04-00-1A-00-00-00-11-02-00 152 | 13-06-40-54-80-04-00-1C-00-00-2A-24-01-00-81-04-00-20-00-00 153 | 13-06-50-00-E8-74-2C-65-F0-01-38-95-7A-46-AA-0A-00-00-5A-55 154 | 1F-06-60-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 155 | 05-06-60-1C-00-00 156 | 06-06-F0-00-83-9B-AC 157 | -------------------------------------------------------------------------------- /lib/goosci/arduino_nrf_pins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _ARDUINO_NRF_PINS_H_ 17 | #define _ARDUINO_NRF_PINS_H_ 18 | 19 | // Digital pins on the Arduino. 20 | #if defined(__AVR_ATmega32U4__) 21 | #define REQ 9 22 | #define RDY 8 23 | #define RESET 255 // 255 = UNUSED in hal_aci_tl.h 24 | #else 25 | #define REQ 10 26 | #define RDY 2 27 | #define RESET 9 28 | #endif 29 | 30 | #endif // ARDUINO_NRF_PINS_H_ 31 | -------------------------------------------------------------------------------- /lib/goosci/config_change.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include "config_change.h" 18 | #include "sensor.pb.h" 19 | #include "goosci_utility.h" 20 | #include "debug_print.h" 21 | 22 | #define SENSOR_CONFIG_SIZE 20 23 | 24 | PinType pin_type = ANALOG; 25 | int pin = A0; 26 | static uint8_t sensorConfig[SENSOR_CONFIG_SIZE]; 27 | 28 | bool decode_pin(pb_istream_t *stream, const pb_field_t *field, void * *arg) { 29 | goosci_Pin sp = goosci_Pin_init_zero; 30 | if (!pb_decode(stream, goosci_Pin_fields, &sp)) 31 | return false; 32 | 33 | if (sp.which_pin == goosci_Pin_analog_pin_tag) { 34 | pin_type = ANALOG; 35 | pin = sp.pin.analog_pin.pin; 36 | } else if (sp.which_pin == goosci_Pin_digital_pin_tag) { 37 | pin_type = DIGITAL; 38 | pin = sp.pin.digital_pin.pin; 39 | pinMode(pin, INPUT); 40 | } else { 41 | pin_type = VIRTUAL; 42 | } 43 | return true; 44 | } 45 | 46 | void handle(uint8_t* data, int8_t length) { 47 | int8_t size = data[0]; 48 | bool last = data[1] == 1; 49 | memcpy(sensorConfig, data + 2, size); 50 | if (last) { 51 | pb_istream_t stream = pb_istream_from_buffer(sensorConfig,size); 52 | goosci_SensorDataRequest sdr = goosci_SensorDataRequest_init_zero; 53 | sdr.pin.funcs.decode = &decode_pin; 54 | if (!pb_decode(&stream, goosci_SensorDataRequest_fields, &sdr)) { 55 | DEBUG_PRINTLN(F("Failed parse of string.")); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /lib/goosci/config_change.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _CONFIG_CHANGE_H_ 17 | #define _CONFIG_CHANGE_H_ 18 | 19 | #include 20 | enum PinType { 21 | ANALOG = 1, 22 | DIGITAL = 2, 23 | VIRTUAL = 3, 24 | }; 25 | 26 | 27 | bool decode_pin(pb_istream_t *stream, const pb_field_t *field, void * *arg); 28 | void handle(uint8_t* data, int8_t length); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/goosci/debug_print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _DEBUG_PRINT_H_ 17 | 18 | #define DEBUG_PRINT(x) \ 19 | { \ 20 | if (Serial) { \ 21 | Serial.print(x); \ 22 | } \ 23 | } 24 | #define DEBUG_PRINTLN(x) \ 25 | { \ 26 | if (Serial) { \ 27 | Serial.println(x); \ 28 | } \ 29 | } 30 | 31 | #define DEBUG_PRINT2(x, y) \ 32 | { \ 33 | if (Serial) { \ 34 | Serial.print(x, y); \ 35 | } \ 36 | } 37 | #define DEBUG_PRINTLN2(x, y) \ 38 | { \ 39 | if (Serial) { \ 40 | Serial.println(x, y); \ 41 | } \ 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/goosci/goosci_utility.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include "pb_encode.h" 19 | #include "debug_print.h" 20 | #include "goosci_utility.h" 21 | #include "sensor.pb.h" 22 | 23 | void wait_for_serial(void) { 24 | #if defined(__AVR_ATmega32U4__) || defined(__ARDUINO_ARC__) 25 | // Wait for 5 seconds to see if the USB Serial connects 26 | // We don't need to call Serial.begin because the 32u4 auto detects 27 | // a serial connection and baud rate for us. 28 | delay(5000); 29 | #else 30 | Serial.begin(115200); 31 | #endif 32 | #if defined(__ARDUINO_ARC__) 33 | Serial.begin(115200); 34 | #endif 35 | } 36 | 37 | goosci_SensorData sd = goosci_SensorData_init_zero; 38 | const int BUFFER_LEN=256; 39 | uint8_t buffer[BUFFER_LEN]; 40 | pb_ostream_t stream; 41 | 42 | #define BTLE_BUFFER_SIZE 20 43 | int packets = 0; 44 | 45 | #if defined(__AVR_ATmega32U4__) 46 | void send_data(GoosciBleGatt &goosciBle, unsigned long timestamp_key, int value) { 47 | #elif defined(__ARDUINO_ARC__) || defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_UNO) 48 | uint8_t packet[BTLE_BUFFER_SIZE]; 49 | void send_data(BLECharacteristic& characteristic, unsigned long timestamp_key, int value) { 50 | #endif 51 | stream = pb_ostream_from_buffer(buffer, BUFFER_LEN); 52 | 53 | sd.timestamp_key = timestamp_key; // timestamp 54 | sd.which_result = (pb_size_t)goosci_SensorData_data_tag; 55 | sd.result.data.pin = goosci_Pin(); 56 | sd.result.data.pin.which_pin = goosci_Pin_analog_pin_tag; 57 | sd.result.data.pin.pin.analog_pin.pin = 0; 58 | sd.result.data.which_value = goosci_Data_analog_value_tag; 59 | sd.result.data.value.analog_value.value = value; 60 | 61 | if (!pb_encode(&stream, goosci_SensorData_fields, &sd)) { 62 | DEBUG_PRINT(F("Encoding failed: ")); 63 | DEBUG_PRINTLN(PB_GET_ERROR(&stream)); 64 | } else { 65 | /* 66 | DEBUG_PRINT(F("send_data timestamp: ")); 67 | DEBUG_PRINTLN(sd.timestamp_key); 68 | DEBUG_PRINT(F("send_data value: ")); 69 | DEBUG_PRINTLN(value); 70 | DEBUG_PRINT(F("size: ")); 71 | DEBUG_PRINT(stream.bytes_written); 72 | DEBUG_PRINTLN(F(" bytes.")); 73 | String s; 74 | for (unsigned int i = 0; i < stream.bytes_written; ++i) { 75 | s += String(buffer[i], HEX); 76 | if ((i-1) % 2 == 0) s += " "; 77 | } 78 | DEBUG_PRINTLN(s.c_str()); 79 | */ 80 | #if defined(__AVR_ATmega32U4__) 81 | goosciBle.sendData((const char *)buffer, stream.bytes_written); 82 | #else 83 | uint8_t size = stream.bytes_written; 84 | const uint8_t max_packet_size = BTLE_BUFFER_SIZE - 2; 85 | /* Force size/max_packet_size to round up */ 86 | uint8_t num_packets = (size + max_packet_size - 1) / max_packet_size; 87 | 88 | 89 | for (uint8_t ii = 0; ii < num_packets; ii++) { 90 | bool is_last_packet = ((num_packets - 1) == ii); 91 | /* There are 3 possibilities for current_packet_size 92 | 1) It is the last packet and the remaining data is smaller than our allocated buffer (size % max_packet_size) 93 | 2) It is the last packet and the remaining data is equal to our allocated buffer (max_packet_size) 94 | 3) It is not the last packet (max_packet_size) 95 | */ 96 | uint8_t current_packet_size = (is_last_packet ? ((size % max_packet_size == 0) ? max_packet_size : (size % max_packet_size)) : max_packet_size); 97 | packet[0] = current_packet_size; 98 | packet[1] = is_last_packet; 99 | memcpy((void*)(packet + 2), buffer + ii * max_packet_size, current_packet_size); 100 | 101 | /* If send fails then we give up */ 102 | if (!characteristic.setValue(packet, current_packet_size+2)) { 103 | DEBUG_PRINTLN("Send of packet failed."); 104 | break; 105 | } 106 | } 107 | #endif 108 | } 109 | } 110 | 111 | bool encode_pin(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) { 112 | goosci_Pin sp = goosci_Pin_init_zero; 113 | sp.pin.analog_pin.pin = 0; 114 | if (!pb_encode_tag_for_field(stream, field)) 115 | return false; 116 | if (!pb_encode_submessage(stream, goosci_Pin_fields, &sp)) 117 | return false; 118 | return true; 119 | } 120 | -------------------------------------------------------------------------------- /lib/goosci/goosci_utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _GOOSCI_UTILITY_H_ 17 | #define _GOOSCI_UTILITY_H_ 18 | 19 | #if defined(__ARDUINO_ARC__) 20 | #include 21 | void send_data(BLECharacteristic& characteristic, unsigned long timestamp, int value); 22 | #endif 23 | 24 | #if defined(__AVR_ATmega32U4__) 25 | #include "GoosciBleGatt.h" 26 | void send_data(GoosciBleGatt &goosciBle, unsigned long timestamp, int value); 27 | #endif 28 | 29 | #if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_UNO) 30 | #include 31 | void send_data(BLECharacteristic& characteristic, unsigned long timestamp, int value); 32 | #endif 33 | 34 | // The serial port on leonardo will hang (UART buffer full) if the 35 | // serial port is not physically opened on the USB host. This 36 | // function will block until the serial port is open. 37 | void wait_for_serial(void); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/goosci/heartbeat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | int heartbeat_interval = 1000; // blink every second 19 | long heartbeat_timer = 0; 20 | bool heartbeat_led_status = false; 21 | int heartbeat_led_pin = 13; 22 | 23 | 24 | // just call at the end of loop() and this will blink the LED every 25 | // heart_beat_interval milli_seconds, useful for knowing if your sketch 26 | // is still running or has hung some place 27 | bool heartbeat(void) { 28 | if (heartbeat_timer == 0) { 29 | heartbeat_timer = millis(); 30 | } else { 31 | if (millis() - heartbeat_timer > heartbeat_interval) { 32 | heartbeat_timer = millis(); 33 | heartbeat_led_status = !heartbeat_led_status; 34 | digitalWrite(heartbeat_led_pin, heartbeat_led_status); 35 | } 36 | } 37 | return heartbeat_led_status; 38 | } 39 | -------------------------------------------------------------------------------- /lib/goosci/heartbeat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | bool heartbeat(void); 17 | -------------------------------------------------------------------------------- /lib/goosci/sensor.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.3.7-dev at Mon Jun 20 12:30:01 2016. */ 3 | 4 | #include "sensor.pb.h" 5 | 6 | /* @@protoc_insertion_point(includes) */ 7 | #if PB_PROTO_HEADER_VERSION != 30 8 | #error Regenerate this file with the current version of nanopb generator. 9 | #endif 10 | 11 | 12 | 13 | const pb_field_t goosci_Empty_fields[1] = { 14 | PB_LAST_FIELD 15 | }; 16 | 17 | const pb_field_t goosci_Version_fields[1] = { 18 | PB_LAST_FIELD 19 | }; 20 | 21 | const pb_field_t goosci_Unit_fields[2] = { 22 | PB_FIELD( 1, UENUM , REQUIRED, STATIC , FIRST, goosci_Unit, units, units, 0), 23 | PB_LAST_FIELD 24 | }; 25 | 26 | const pb_field_t goosci_AnalogExtremum_fields[2] = { 27 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_AnalogExtremum, extremum, extremum, 0), 28 | PB_LAST_FIELD 29 | }; 30 | 31 | const pb_field_t goosci_AnalogZero_fields[2] = { 32 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_AnalogZero, zero, zero, 0), 33 | PB_LAST_FIELD 34 | }; 35 | 36 | const pb_field_t goosci_AnalogExtrema_fields[3] = { 37 | PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, goosci_AnalogExtrema, minimum, minimum, &goosci_AnalogExtremum_fields), 38 | PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_AnalogExtrema, maximum, minimum, &goosci_AnalogExtremum_fields), 39 | PB_LAST_FIELD 40 | }; 41 | 42 | const pb_field_t goosci_FloatExtremum_fields[2] = { 43 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_FloatExtremum, extremum, extremum, 0), 44 | PB_LAST_FIELD 45 | }; 46 | 47 | const pb_field_t goosci_FloatZero_fields[2] = { 48 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_FloatZero, zero, zero, 0), 49 | PB_LAST_FIELD 50 | }; 51 | 52 | const pb_field_t goosci_FloatExtrema_fields[3] = { 53 | PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, goosci_FloatExtrema, minimum, minimum, &goosci_FloatExtremum_fields), 54 | PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_FloatExtrema, maximum, minimum, &goosci_FloatExtremum_fields), 55 | PB_LAST_FIELD 56 | }; 57 | 58 | const pb_field_t goosci_IntExtremum_fields[2] = { 59 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_IntExtremum, extremum, extremum, 0), 60 | PB_LAST_FIELD 61 | }; 62 | 63 | const pb_field_t goosci_IntZero_fields[2] = { 64 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_IntZero, zero, zero, 0), 65 | PB_LAST_FIELD 66 | }; 67 | 68 | const pb_field_t goosci_IntExtrema_fields[3] = { 69 | PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, goosci_IntExtrema, minimum, minimum, &goosci_IntExtremum_fields), 70 | PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_IntExtrema, maximum, minimum, &goosci_IntExtremum_fields), 71 | PB_LAST_FIELD 72 | }; 73 | 74 | const pb_field_t goosci_Range_fields[4] = { 75 | PB_ONEOF_FIELD(extrema, 1, MESSAGE , ONEOF, STATIC , FIRST, goosci_Range, analog_extrema, analog_extrema, &goosci_AnalogExtrema_fields), 76 | PB_ONEOF_FIELD(extrema, 2, MESSAGE , ONEOF, STATIC , FIRST, goosci_Range, float_extrema, float_extrema, &goosci_FloatExtrema_fields), 77 | PB_ONEOF_FIELD(extrema, 3, MESSAGE , ONEOF, STATIC , FIRST, goosci_Range, int_extrema, int_extrema, &goosci_IntExtrema_fields), 78 | PB_LAST_FIELD 79 | }; 80 | 81 | const pb_field_t goosci_Zero_fields[4] = { 82 | PB_ONEOF_FIELD(zero, 1, MESSAGE , ONEOF, STATIC , FIRST, goosci_Zero, analog_zero, analog_zero, &goosci_AnalogZero_fields), 83 | PB_ONEOF_FIELD(zero, 2, MESSAGE , ONEOF, STATIC , FIRST, goosci_Zero, float_zero, float_zero, &goosci_FloatZero_fields), 84 | PB_ONEOF_FIELD(zero, 3, MESSAGE , ONEOF, STATIC , FIRST, goosci_Zero, int_zero, int_zero, &goosci_IntZero_fields), 85 | PB_LAST_FIELD 86 | }; 87 | 88 | const pb_field_t goosci_AxisConfig_fields[3] = { 89 | PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, goosci_AxisConfig, range, range, &goosci_Range_fields), 90 | PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_AxisConfig, zero_value, range, &goosci_Zero_fields), 91 | PB_LAST_FIELD 92 | }; 93 | 94 | const pb_field_t goosci_AnalogPin_fields[2] = { 95 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_AnalogPin, pin, pin, 0), 96 | PB_LAST_FIELD 97 | }; 98 | 99 | const pb_field_t goosci_DigitalPin_fields[2] = { 100 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_DigitalPin, pin, pin, 0), 101 | PB_LAST_FIELD 102 | }; 103 | 104 | const pb_field_t goosci_ScalarDescriptor_fields[5] = { 105 | PB_FIELD( 1, STRING , REQUIRED, CALLBACK, FIRST, goosci_ScalarDescriptor, label, label, 0), 106 | PB_FIELD( 2, UENUM , REQUIRED, STATIC , OTHER, goosci_ScalarDescriptor, type, label, 0), 107 | PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_ScalarDescriptor, axis_config, type, &goosci_AxisConfig_fields), 108 | PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, goosci_ScalarDescriptor, unit, axis_config, &goosci_Unit_fields), 109 | PB_LAST_FIELD 110 | }; 111 | 112 | const pb_field_t goosci_VirtualPin_fields[2] = { 113 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_VirtualPin, pin, pin, 0), 114 | PB_LAST_FIELD 115 | }; 116 | 117 | const pb_field_t goosci_Pin_fields[4] = { 118 | PB_ONEOF_FIELD(pin, 10, MESSAGE , ONEOF, STATIC , FIRST, goosci_Pin, analog_pin, analog_pin, &goosci_AnalogPin_fields), 119 | PB_ONEOF_FIELD(pin, 11, MESSAGE , ONEOF, STATIC , FIRST, goosci_Pin, digital_pin, digital_pin, &goosci_DigitalPin_fields), 120 | PB_ONEOF_FIELD(pin, 12, MESSAGE , ONEOF, STATIC , FIRST, goosci_Pin, virtual_pin, virtual_pin, &goosci_VirtualPin_fields), 121 | PB_LAST_FIELD 122 | }; 123 | 124 | const pb_field_t goosci_PinDescriptor_fields[4] = { 125 | PB_FIELD( 1, STRING , REQUIRED, CALLBACK, FIRST, goosci_PinDescriptor, label, label, 0), 126 | PB_FIELD( 2, MESSAGE , REQUIRED, STATIC , OTHER, goosci_PinDescriptor, pin, label, &goosci_Pin_fields), 127 | PB_FIELD( 3, MESSAGE , REQUIRED, STATIC , OTHER, goosci_PinDescriptor, scalar_descriptor, pin, &goosci_ScalarDescriptor_fields), 128 | PB_LAST_FIELD 129 | }; 130 | 131 | const pb_field_t goosci_Interval_fields[3] = { 132 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_Interval, count, count, 0), 133 | PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, goosci_Interval, frequency, count, 0), 134 | PB_LAST_FIELD 135 | }; 136 | 137 | const pb_field_t goosci_SensorDataRequest_fields[4] = { 138 | PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, goosci_SensorDataRequest, timestamp_key, timestamp_key, 0), 139 | PB_FIELD( 2, MESSAGE , REQUIRED, STATIC , OTHER, goosci_SensorDataRequest, interval, timestamp_key, &goosci_Interval_fields), 140 | PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, goosci_SensorDataRequest, pin, interval, &goosci_Pin_fields), 141 | PB_LAST_FIELD 142 | }; 143 | 144 | const pb_field_t goosci_BleSensorConfig_fields[2] = { 145 | PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, goosci_BleSensorConfig, address, address, 0), 146 | PB_LAST_FIELD 147 | }; 148 | 149 | const pb_field_t goosci_SensorEnumeration_fields[2] = { 150 | PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, goosci_SensorEnumeration, pin_descriptor, pin_descriptor, &goosci_PinDescriptor_fields), 151 | PB_LAST_FIELD 152 | }; 153 | 154 | const pb_field_t goosci_AnalogValue_fields[2] = { 155 | PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, goosci_AnalogValue, value, value, 0), 156 | PB_LAST_FIELD 157 | }; 158 | 159 | const pb_field_t goosci_DigitalValue_fields[2] = { 160 | PB_FIELD( 1, BOOL , REQUIRED, STATIC , FIRST, goosci_DigitalValue, value, value, 0), 161 | PB_LAST_FIELD 162 | }; 163 | 164 | const pb_field_t goosci_FloatValue_fields[2] = { 165 | PB_FIELD( 1, FLOAT , REQUIRED, STATIC , FIRST, goosci_FloatValue, value, value, 0), 166 | PB_LAST_FIELD 167 | }; 168 | 169 | const pb_field_t goosci_IntValue_fields[2] = { 170 | PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, goosci_IntValue, value, value, 0), 171 | PB_LAST_FIELD 172 | }; 173 | 174 | const pb_field_t goosci_StringValue_fields[2] = { 175 | PB_FIELD( 1, STRING , REQUIRED, CALLBACK, FIRST, goosci_StringValue, value, value, 0), 176 | PB_LAST_FIELD 177 | }; 178 | 179 | const pb_field_t goosci_Data_fields[7] = { 180 | PB_FIELD( 1, MESSAGE , REQUIRED, STATIC , FIRST, goosci_Data, pin, pin, &goosci_Pin_fields), 181 | PB_ONEOF_FIELD(value, 10, MESSAGE , ONEOF, STATIC , OTHER, goosci_Data, analog_value, pin, &goosci_AnalogValue_fields), 182 | PB_ONEOF_FIELD(value, 11, MESSAGE , ONEOF, STATIC , OTHER, goosci_Data, digital_value, pin, &goosci_DigitalValue_fields), 183 | PB_ONEOF_FIELD(value, 12, MESSAGE , ONEOF, STATIC , OTHER, goosci_Data, float_value, pin, &goosci_FloatValue_fields), 184 | PB_ONEOF_FIELD(value, 13, MESSAGE , ONEOF, STATIC , OTHER, goosci_Data, int_value, pin, &goosci_IntValue_fields), 185 | PB_ONEOF_FIELD(value, 14, MESSAGE , ONEOF, STATIC , OTHER, goosci_Data, string_value, pin, &goosci_StringValue_fields), 186 | PB_LAST_FIELD 187 | }; 188 | 189 | const pb_field_t goosci_Error_fields[2] = { 190 | PB_FIELD( 1, STRING , REQUIRED, CALLBACK, FIRST, goosci_Error, error, error, 0), 191 | PB_LAST_FIELD 192 | }; 193 | 194 | const pb_field_t goosci_SensorData_fields[4] = { 195 | PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, goosci_SensorData, timestamp_key, timestamp_key, 0), 196 | PB_ONEOF_FIELD(result, 10, MESSAGE , ONEOF, STATIC , OTHER, goosci_SensorData, error, timestamp_key, &goosci_Error_fields), 197 | PB_ONEOF_FIELD(result, 11, MESSAGE , ONEOF, STATIC , OTHER, goosci_SensorData, data, timestamp_key, &goosci_Data_fields), 198 | PB_LAST_FIELD 199 | }; 200 | 201 | 202 | /* Check that field information fits in pb_field_t */ 203 | #if !defined(PB_FIELD_32BIT) 204 | /* If you get an error here, it means that you need to define PB_FIELD_32BIT 205 | * compile-time option. You can do that in pb.h or on compiler command line. 206 | * 207 | * The reason you need to do this is that some of your messages contain tag 208 | * numbers or field sizes that are larger than what can fit in 8 or 16 bit 209 | * field descriptors. 210 | */ 211 | PB_STATIC_ASSERT((pb_membersize(goosci_AnalogExtrema, minimum) < 65536 && pb_membersize(goosci_AnalogExtrema, maximum) < 65536 && pb_membersize(goosci_FloatExtrema, minimum) < 65536 && pb_membersize(goosci_FloatExtrema, maximum) < 65536 && pb_membersize(goosci_IntExtrema, minimum) < 65536 && pb_membersize(goosci_IntExtrema, maximum) < 65536 && pb_membersize(goosci_Range, extrema.analog_extrema) < 65536 && pb_membersize(goosci_Range, extrema.float_extrema) < 65536 && pb_membersize(goosci_Range, extrema.int_extrema) < 65536 && pb_membersize(goosci_Zero, zero.analog_zero) < 65536 && pb_membersize(goosci_Zero, zero.float_zero) < 65536 && pb_membersize(goosci_Zero, zero.int_zero) < 65536 && pb_membersize(goosci_AxisConfig, range) < 65536 && pb_membersize(goosci_AxisConfig, zero_value) < 65536 && pb_membersize(goosci_ScalarDescriptor, axis_config) < 65536 && pb_membersize(goosci_ScalarDescriptor, unit) < 65536 && pb_membersize(goosci_Pin, pin.analog_pin) < 65536 && pb_membersize(goosci_Pin, pin.digital_pin) < 65536 && pb_membersize(goosci_Pin, pin.virtual_pin) < 65536 && pb_membersize(goosci_PinDescriptor, pin) < 65536 && pb_membersize(goosci_PinDescriptor, scalar_descriptor) < 65536 && pb_membersize(goosci_SensorDataRequest, interval) < 65536 && pb_membersize(goosci_SensorDataRequest, pin) < 65536 && pb_membersize(goosci_SensorEnumeration, pin_descriptor) < 65536 && pb_membersize(goosci_Data, value.analog_value) < 65536 && pb_membersize(goosci_Data, value.digital_value) < 65536 && pb_membersize(goosci_Data, value.float_value) < 65536 && pb_membersize(goosci_Data, value.int_value) < 65536 && pb_membersize(goosci_Data, value.string_value) < 65536 && pb_membersize(goosci_Data, pin) < 65536 && pb_membersize(goosci_SensorData, result.error) < 65536 && pb_membersize(goosci_SensorData, result.data) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_goosci_Empty_goosci_Version_goosci_Unit_goosci_AnalogExtremum_goosci_AnalogZero_goosci_AnalogExtrema_goosci_FloatExtremum_goosci_FloatZero_goosci_FloatExtrema_goosci_IntExtremum_goosci_IntZero_goosci_IntExtrema_goosci_Range_goosci_Zero_goosci_AxisConfig_goosci_AnalogPin_goosci_DigitalPin_goosci_ScalarDescriptor_goosci_VirtualPin_goosci_Pin_goosci_PinDescriptor_goosci_Interval_goosci_SensorDataRequest_goosci_BleSensorConfig_goosci_SensorEnumeration_goosci_AnalogValue_goosci_DigitalValue_goosci_FloatValue_goosci_IntValue_goosci_StringValue_goosci_Data_goosci_Error_goosci_SensorData) 212 | #endif 213 | 214 | #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) 215 | /* If you get an error here, it means that you need to define PB_FIELD_16BIT 216 | * compile-time option. You can do that in pb.h or on compiler command line. 217 | * 218 | * The reason you need to do this is that some of your messages contain tag 219 | * numbers or field sizes that are larger than what can fit in the default 220 | * 8 bit descriptors. 221 | */ 222 | PB_STATIC_ASSERT((pb_membersize(goosci_AnalogExtrema, minimum) < 256 && pb_membersize(goosci_AnalogExtrema, maximum) < 256 && pb_membersize(goosci_FloatExtrema, minimum) < 256 && pb_membersize(goosci_FloatExtrema, maximum) < 256 && pb_membersize(goosci_IntExtrema, minimum) < 256 && pb_membersize(goosci_IntExtrema, maximum) < 256 && pb_membersize(goosci_Range, extrema.analog_extrema) < 256 && pb_membersize(goosci_Range, extrema.float_extrema) < 256 && pb_membersize(goosci_Range, extrema.int_extrema) < 256 && pb_membersize(goosci_Zero, zero.analog_zero) < 256 && pb_membersize(goosci_Zero, zero.float_zero) < 256 && pb_membersize(goosci_Zero, zero.int_zero) < 256 && pb_membersize(goosci_AxisConfig, range) < 256 && pb_membersize(goosci_AxisConfig, zero_value) < 256 && pb_membersize(goosci_ScalarDescriptor, axis_config) < 256 && pb_membersize(goosci_ScalarDescriptor, unit) < 256 && pb_membersize(goosci_Pin, pin.analog_pin) < 256 && pb_membersize(goosci_Pin, pin.digital_pin) < 256 && pb_membersize(goosci_Pin, pin.virtual_pin) < 256 && pb_membersize(goosci_PinDescriptor, pin) < 256 && pb_membersize(goosci_PinDescriptor, scalar_descriptor) < 256 && pb_membersize(goosci_SensorDataRequest, interval) < 256 && pb_membersize(goosci_SensorDataRequest, pin) < 256 && pb_membersize(goosci_SensorEnumeration, pin_descriptor) < 256 && pb_membersize(goosci_Data, value.analog_value) < 256 && pb_membersize(goosci_Data, value.digital_value) < 256 && pb_membersize(goosci_Data, value.float_value) < 256 && pb_membersize(goosci_Data, value.int_value) < 256 && pb_membersize(goosci_Data, value.string_value) < 256 && pb_membersize(goosci_Data, pin) < 256 && pb_membersize(goosci_SensorData, result.error) < 256 && pb_membersize(goosci_SensorData, result.data) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_goosci_Empty_goosci_Version_goosci_Unit_goosci_AnalogExtremum_goosci_AnalogZero_goosci_AnalogExtrema_goosci_FloatExtremum_goosci_FloatZero_goosci_FloatExtrema_goosci_IntExtremum_goosci_IntZero_goosci_IntExtrema_goosci_Range_goosci_Zero_goosci_AxisConfig_goosci_AnalogPin_goosci_DigitalPin_goosci_ScalarDescriptor_goosci_VirtualPin_goosci_Pin_goosci_PinDescriptor_goosci_Interval_goosci_SensorDataRequest_goosci_BleSensorConfig_goosci_SensorEnumeration_goosci_AnalogValue_goosci_DigitalValue_goosci_FloatValue_goosci_IntValue_goosci_StringValue_goosci_Data_goosci_Error_goosci_SensorData) 223 | #endif 224 | 225 | 226 | /* @@protoc_insertion_point(eof) */ 227 | -------------------------------------------------------------------------------- /lib/goosci/sensor.pb.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb header */ 2 | /* Generated by nanopb-0.3.7-dev at Mon Jun 20 12:30:01 2016. */ 3 | 4 | #ifndef PB_SENSOR_PB_H_INCLUDED 5 | #define PB_SENSOR_PB_H_INCLUDED 6 | #include 7 | 8 | /* @@protoc_insertion_point(includes) */ 9 | #if PB_PROTO_HEADER_VERSION != 30 10 | #error Regenerate this file with the current version of nanopb generator. 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Enum definitions */ 18 | typedef enum _goosci_DataType { 19 | goosci_DataType_ANALOG = 1, 20 | goosci_DataType_DIGITAL = 2, 21 | goosci_DataType_FLOAT = 3, 22 | goosci_DataType_INT = 4, 23 | goosci_DataType_STRING = 5 24 | } goosci_DataType; 25 | #define _goosci_DataType_MIN goosci_DataType_ANALOG 26 | #define _goosci_DataType_MAX goosci_DataType_STRING 27 | #define _goosci_DataType_ARRAYSIZE ((goosci_DataType)(goosci_DataType_STRING+1)) 28 | 29 | typedef enum _goosci_Version_Version { 30 | goosci_Version_Version_V_1_0_0 = 2048, 31 | goosci_Version_Version_LATEST = 2048 32 | } goosci_Version_Version; 33 | #define _goosci_Version_Version_MIN goosci_Version_Version_V_1_0_0 34 | #define _goosci_Version_Version_MAX goosci_Version_Version_LATEST 35 | #define _goosci_Version_Version_ARRAYSIZE ((goosci_Version_Version)(goosci_Version_Version_LATEST+1)) 36 | 37 | typedef enum _goosci_Unit_Units_Type { 38 | goosci_Unit_Units_Type_UNITLESS = 9984, 39 | goosci_Unit_Units_Type_LENGTH = 9985, 40 | goosci_Unit_Units_Type_VELOCITY = 10002, 41 | goosci_Unit_Units_Type_PLANE_ORIENTATION = 10016, 42 | goosci_Unit_Units_Type_VOLT = 10024, 43 | goosci_Unit_Units_Type_RPM = 10152 44 | } goosci_Unit_Units_Type; 45 | #define _goosci_Unit_Units_Type_MIN goosci_Unit_Units_Type_UNITLESS 46 | #define _goosci_Unit_Units_Type_MAX goosci_Unit_Units_Type_RPM 47 | #define _goosci_Unit_Units_Type_ARRAYSIZE ((goosci_Unit_Units_Type)(goosci_Unit_Units_Type_RPM+1)) 48 | 49 | /* Struct definitions */ 50 | typedef struct _goosci_BleSensorConfig { 51 | pb_callback_t address; 52 | /* @@protoc_insertion_point(struct:goosci_BleSensorConfig) */ 53 | } goosci_BleSensorConfig; 54 | 55 | typedef struct _goosci_Empty { 56 | char dummy_field; 57 | /* @@protoc_insertion_point(struct:goosci_Empty) */ 58 | } goosci_Empty; 59 | 60 | typedef struct _goosci_Error { 61 | pb_callback_t error; 62 | /* @@protoc_insertion_point(struct:goosci_Error) */ 63 | } goosci_Error; 64 | 65 | typedef struct _goosci_SensorEnumeration { 66 | pb_callback_t pin_descriptor; 67 | /* @@protoc_insertion_point(struct:goosci_SensorEnumeration) */ 68 | } goosci_SensorEnumeration; 69 | 70 | typedef struct _goosci_StringValue { 71 | pb_callback_t value; 72 | /* @@protoc_insertion_point(struct:goosci_StringValue) */ 73 | } goosci_StringValue; 74 | 75 | typedef struct _goosci_Version { 76 | char dummy_field; 77 | /* @@protoc_insertion_point(struct:goosci_Version) */ 78 | } goosci_Version; 79 | 80 | typedef struct _goosci_AnalogExtremum { 81 | int32_t extremum; 82 | /* @@protoc_insertion_point(struct:goosci_AnalogExtremum) */ 83 | } goosci_AnalogExtremum; 84 | 85 | typedef struct _goosci_AnalogPin { 86 | int32_t pin; 87 | /* @@protoc_insertion_point(struct:goosci_AnalogPin) */ 88 | } goosci_AnalogPin; 89 | 90 | typedef struct _goosci_AnalogValue { 91 | uint32_t value; 92 | /* @@protoc_insertion_point(struct:goosci_AnalogValue) */ 93 | } goosci_AnalogValue; 94 | 95 | typedef struct _goosci_AnalogZero { 96 | int32_t zero; 97 | /* @@protoc_insertion_point(struct:goosci_AnalogZero) */ 98 | } goosci_AnalogZero; 99 | 100 | typedef struct _goosci_DigitalPin { 101 | int32_t pin; 102 | /* @@protoc_insertion_point(struct:goosci_DigitalPin) */ 103 | } goosci_DigitalPin; 104 | 105 | typedef struct _goosci_DigitalValue { 106 | bool value; 107 | /* @@protoc_insertion_point(struct:goosci_DigitalValue) */ 108 | } goosci_DigitalValue; 109 | 110 | typedef struct _goosci_FloatExtremum { 111 | int32_t extremum; 112 | /* @@protoc_insertion_point(struct:goosci_FloatExtremum) */ 113 | } goosci_FloatExtremum; 114 | 115 | typedef struct _goosci_FloatValue { 116 | float value; 117 | /* @@protoc_insertion_point(struct:goosci_FloatValue) */ 118 | } goosci_FloatValue; 119 | 120 | typedef struct _goosci_FloatZero { 121 | int32_t zero; 122 | /* @@protoc_insertion_point(struct:goosci_FloatZero) */ 123 | } goosci_FloatZero; 124 | 125 | typedef struct _goosci_IntExtremum { 126 | int32_t extremum; 127 | /* @@protoc_insertion_point(struct:goosci_IntExtremum) */ 128 | } goosci_IntExtremum; 129 | 130 | typedef struct _goosci_IntValue { 131 | int32_t value; 132 | /* @@protoc_insertion_point(struct:goosci_IntValue) */ 133 | } goosci_IntValue; 134 | 135 | typedef struct _goosci_IntZero { 136 | int32_t zero; 137 | /* @@protoc_insertion_point(struct:goosci_IntZero) */ 138 | } goosci_IntZero; 139 | 140 | typedef struct _goosci_Interval { 141 | int32_t count; 142 | bool has_frequency; 143 | int32_t frequency; 144 | /* @@protoc_insertion_point(struct:goosci_Interval) */ 145 | } goosci_Interval; 146 | 147 | typedef struct _goosci_Unit { 148 | goosci_Unit_Units_Type units; 149 | /* @@protoc_insertion_point(struct:goosci_Unit) */ 150 | } goosci_Unit; 151 | 152 | typedef struct _goosci_VirtualPin { 153 | int32_t pin; 154 | /* @@protoc_insertion_point(struct:goosci_VirtualPin) */ 155 | } goosci_VirtualPin; 156 | 157 | typedef struct _goosci_AnalogExtrema { 158 | bool has_minimum; 159 | goosci_AnalogExtremum minimum; 160 | bool has_maximum; 161 | goosci_AnalogExtremum maximum; 162 | /* @@protoc_insertion_point(struct:goosci_AnalogExtrema) */ 163 | } goosci_AnalogExtrema; 164 | 165 | typedef struct _goosci_FloatExtrema { 166 | bool has_minimum; 167 | goosci_FloatExtremum minimum; 168 | bool has_maximum; 169 | goosci_FloatExtremum maximum; 170 | /* @@protoc_insertion_point(struct:goosci_FloatExtrema) */ 171 | } goosci_FloatExtrema; 172 | 173 | typedef struct _goosci_IntExtrema { 174 | bool has_minimum; 175 | goosci_IntExtremum minimum; 176 | bool has_maximum; 177 | goosci_IntExtremum maximum; 178 | /* @@protoc_insertion_point(struct:goosci_IntExtrema) */ 179 | } goosci_IntExtrema; 180 | 181 | typedef struct _goosci_Pin { 182 | pb_size_t which_pin; 183 | union { 184 | goosci_AnalogPin analog_pin; 185 | goosci_DigitalPin digital_pin; 186 | goosci_VirtualPin virtual_pin; 187 | } pin; 188 | /* @@protoc_insertion_point(struct:goosci_Pin) */ 189 | } goosci_Pin; 190 | 191 | typedef struct _goosci_SensorDataRequest { 192 | uint32_t timestamp_key; 193 | goosci_Interval interval; 194 | pb_callback_t pin; 195 | /* @@protoc_insertion_point(struct:goosci_SensorDataRequest) */ 196 | } goosci_SensorDataRequest; 197 | 198 | typedef struct _goosci_Zero { 199 | pb_size_t which_zero; 200 | union { 201 | goosci_AnalogZero analog_zero; 202 | goosci_FloatZero float_zero; 203 | goosci_IntZero int_zero; 204 | } zero; 205 | /* @@protoc_insertion_point(struct:goosci_Zero) */ 206 | } goosci_Zero; 207 | 208 | typedef struct _goosci_Data { 209 | goosci_Pin pin; 210 | pb_size_t which_value; 211 | union { 212 | goosci_AnalogValue analog_value; 213 | goosci_DigitalValue digital_value; 214 | goosci_FloatValue float_value; 215 | goosci_IntValue int_value; 216 | goosci_StringValue string_value; 217 | } value; 218 | /* @@protoc_insertion_point(struct:goosci_Data) */ 219 | } goosci_Data; 220 | 221 | typedef struct _goosci_Range { 222 | pb_size_t which_extrema; 223 | union { 224 | goosci_AnalogExtrema analog_extrema; 225 | goosci_FloatExtrema float_extrema; 226 | goosci_IntExtrema int_extrema; 227 | } extrema; 228 | /* @@protoc_insertion_point(struct:goosci_Range) */ 229 | } goosci_Range; 230 | 231 | typedef struct _goosci_AxisConfig { 232 | bool has_range; 233 | goosci_Range range; 234 | bool has_zero_value; 235 | goosci_Zero zero_value; 236 | /* @@protoc_insertion_point(struct:goosci_AxisConfig) */ 237 | } goosci_AxisConfig; 238 | 239 | typedef struct _goosci_SensorData { 240 | uint32_t timestamp_key; 241 | pb_size_t which_result; 242 | union { 243 | goosci_Error error; 244 | goosci_Data data; 245 | } result; 246 | /* @@protoc_insertion_point(struct:goosci_SensorData) */ 247 | } goosci_SensorData; 248 | 249 | typedef struct _goosci_ScalarDescriptor { 250 | pb_callback_t label; 251 | goosci_DataType type; 252 | bool has_axis_config; 253 | goosci_AxisConfig axis_config; 254 | bool has_unit; 255 | goosci_Unit unit; 256 | /* @@protoc_insertion_point(struct:goosci_ScalarDescriptor) */ 257 | } goosci_ScalarDescriptor; 258 | 259 | typedef struct _goosci_PinDescriptor { 260 | pb_callback_t label; 261 | goosci_Pin pin; 262 | goosci_ScalarDescriptor scalar_descriptor; 263 | /* @@protoc_insertion_point(struct:goosci_PinDescriptor) */ 264 | } goosci_PinDescriptor; 265 | 266 | /* Default values for struct fields */ 267 | 268 | /* Initializer values for message structs */ 269 | #define goosci_Empty_init_default {0} 270 | #define goosci_Version_init_default {0} 271 | #define goosci_Unit_init_default {(goosci_Unit_Units_Type)0} 272 | #define goosci_AnalogExtremum_init_default {0} 273 | #define goosci_AnalogZero_init_default {0} 274 | #define goosci_AnalogExtrema_init_default {false, goosci_AnalogExtremum_init_default, false, goosci_AnalogExtremum_init_default} 275 | #define goosci_FloatExtremum_init_default {0} 276 | #define goosci_FloatZero_init_default {0} 277 | #define goosci_FloatExtrema_init_default {false, goosci_FloatExtremum_init_default, false, goosci_FloatExtremum_init_default} 278 | #define goosci_IntExtremum_init_default {0} 279 | #define goosci_IntZero_init_default {0} 280 | #define goosci_IntExtrema_init_default {false, goosci_IntExtremum_init_default, false, goosci_IntExtremum_init_default} 281 | #define goosci_Range_init_default {0, {goosci_AnalogExtrema_init_default}} 282 | #define goosci_Zero_init_default {0, {goosci_AnalogZero_init_default}} 283 | #define goosci_AxisConfig_init_default {false, goosci_Range_init_default, false, goosci_Zero_init_default} 284 | #define goosci_AnalogPin_init_default {0} 285 | #define goosci_DigitalPin_init_default {0} 286 | #define goosci_ScalarDescriptor_init_default {{{NULL}, NULL}, (goosci_DataType)0, false, goosci_AxisConfig_init_default, false, goosci_Unit_init_default} 287 | #define goosci_VirtualPin_init_default {0} 288 | #define goosci_Pin_init_default {0, {goosci_AnalogPin_init_default}} 289 | #define goosci_PinDescriptor_init_default {{{NULL}, NULL}, goosci_Pin_init_default, goosci_ScalarDescriptor_init_default} 290 | #define goosci_Interval_init_default {0, false, 0} 291 | #define goosci_SensorDataRequest_init_default {0, goosci_Interval_init_default, {{NULL}, NULL}} 292 | #define goosci_BleSensorConfig_init_default {{{NULL}, NULL}} 293 | #define goosci_SensorEnumeration_init_default {{{NULL}, NULL}} 294 | #define goosci_AnalogValue_init_default {0} 295 | #define goosci_DigitalValue_init_default {0} 296 | #define goosci_FloatValue_init_default {0} 297 | #define goosci_IntValue_init_default {0} 298 | #define goosci_StringValue_init_default {{{NULL}, NULL}} 299 | #define goosci_Data_init_default {goosci_Pin_init_default, 0, {goosci_AnalogValue_init_default}} 300 | #define goosci_Error_init_default {{{NULL}, NULL}} 301 | #define goosci_SensorData_init_default {0, 0, {goosci_Error_init_default}} 302 | #define goosci_Empty_init_zero {0} 303 | #define goosci_Version_init_zero {0} 304 | #define goosci_Unit_init_zero {(goosci_Unit_Units_Type)0} 305 | #define goosci_AnalogExtremum_init_zero {0} 306 | #define goosci_AnalogZero_init_zero {0} 307 | #define goosci_AnalogExtrema_init_zero {false, goosci_AnalogExtremum_init_zero, false, goosci_AnalogExtremum_init_zero} 308 | #define goosci_FloatExtremum_init_zero {0} 309 | #define goosci_FloatZero_init_zero {0} 310 | #define goosci_FloatExtrema_init_zero {false, goosci_FloatExtremum_init_zero, false, goosci_FloatExtremum_init_zero} 311 | #define goosci_IntExtremum_init_zero {0} 312 | #define goosci_IntZero_init_zero {0} 313 | #define goosci_IntExtrema_init_zero {false, goosci_IntExtremum_init_zero, false, goosci_IntExtremum_init_zero} 314 | #define goosci_Range_init_zero {0, {goosci_AnalogExtrema_init_zero}} 315 | #define goosci_Zero_init_zero {0, {goosci_AnalogZero_init_zero}} 316 | #define goosci_AxisConfig_init_zero {false, goosci_Range_init_zero, false, goosci_Zero_init_zero} 317 | #define goosci_AnalogPin_init_zero {0} 318 | #define goosci_DigitalPin_init_zero {0} 319 | #define goosci_ScalarDescriptor_init_zero {{{NULL}, NULL}, (goosci_DataType)0, false, goosci_AxisConfig_init_zero, false, goosci_Unit_init_zero} 320 | #define goosci_VirtualPin_init_zero {0} 321 | #define goosci_Pin_init_zero {0, {goosci_AnalogPin_init_zero}} 322 | #define goosci_PinDescriptor_init_zero {{{NULL}, NULL}, goosci_Pin_init_zero, goosci_ScalarDescriptor_init_zero} 323 | #define goosci_Interval_init_zero {0, false, 0} 324 | #define goosci_SensorDataRequest_init_zero {0, goosci_Interval_init_zero, {{NULL}, NULL}} 325 | #define goosci_BleSensorConfig_init_zero {{{NULL}, NULL}} 326 | #define goosci_SensorEnumeration_init_zero {{{NULL}, NULL}} 327 | #define goosci_AnalogValue_init_zero {0} 328 | #define goosci_DigitalValue_init_zero {0} 329 | #define goosci_FloatValue_init_zero {0} 330 | #define goosci_IntValue_init_zero {0} 331 | #define goosci_StringValue_init_zero {{{NULL}, NULL}} 332 | #define goosci_Data_init_zero {goosci_Pin_init_zero, 0, {goosci_AnalogValue_init_zero}} 333 | #define goosci_Error_init_zero {{{NULL}, NULL}} 334 | #define goosci_SensorData_init_zero {0, 0, {goosci_Error_init_zero}} 335 | 336 | /* Field tags (for use in manual encoding/decoding) */ 337 | #define goosci_BleSensorConfig_address_tag 1 338 | #define goosci_Error_error_tag 1 339 | #define goosci_SensorEnumeration_pin_descriptor_tag 1 340 | #define goosci_StringValue_value_tag 1 341 | #define goosci_AnalogExtremum_extremum_tag 1 342 | #define goosci_AnalogPin_pin_tag 1 343 | #define goosci_AnalogValue_value_tag 1 344 | #define goosci_AnalogZero_zero_tag 1 345 | #define goosci_DigitalPin_pin_tag 1 346 | #define goosci_DigitalValue_value_tag 1 347 | #define goosci_FloatExtremum_extremum_tag 1 348 | #define goosci_FloatValue_value_tag 1 349 | #define goosci_FloatZero_zero_tag 1 350 | #define goosci_IntExtremum_extremum_tag 1 351 | #define goosci_IntValue_value_tag 1 352 | #define goosci_IntZero_zero_tag 1 353 | #define goosci_Interval_count_tag 1 354 | #define goosci_Interval_frequency_tag 2 355 | #define goosci_Unit_units_tag 1 356 | #define goosci_VirtualPin_pin_tag 1 357 | #define goosci_AnalogExtrema_minimum_tag 1 358 | #define goosci_AnalogExtrema_maximum_tag 2 359 | #define goosci_FloatExtrema_minimum_tag 1 360 | #define goosci_FloatExtrema_maximum_tag 2 361 | #define goosci_IntExtrema_minimum_tag 1 362 | #define goosci_IntExtrema_maximum_tag 2 363 | #define goosci_Pin_analog_pin_tag 10 364 | #define goosci_Pin_digital_pin_tag 11 365 | #define goosci_Pin_virtual_pin_tag 12 366 | #define goosci_SensorDataRequest_timestamp_key_tag 1 367 | #define goosci_SensorDataRequest_interval_tag 2 368 | #define goosci_SensorDataRequest_pin_tag 3 369 | #define goosci_Zero_analog_zero_tag 1 370 | #define goosci_Zero_float_zero_tag 2 371 | #define goosci_Zero_int_zero_tag 3 372 | #define goosci_Data_analog_value_tag 10 373 | #define goosci_Data_digital_value_tag 11 374 | #define goosci_Data_float_value_tag 12 375 | #define goosci_Data_int_value_tag 13 376 | #define goosci_Data_string_value_tag 14 377 | #define goosci_Data_pin_tag 1 378 | #define goosci_Range_analog_extrema_tag 1 379 | #define goosci_Range_float_extrema_tag 2 380 | #define goosci_Range_int_extrema_tag 3 381 | #define goosci_AxisConfig_range_tag 1 382 | #define goosci_AxisConfig_zero_value_tag 2 383 | #define goosci_SensorData_error_tag 10 384 | #define goosci_SensorData_data_tag 11 385 | #define goosci_SensorData_timestamp_key_tag 1 386 | #define goosci_ScalarDescriptor_label_tag 1 387 | #define goosci_ScalarDescriptor_type_tag 2 388 | #define goosci_ScalarDescriptor_axis_config_tag 3 389 | #define goosci_ScalarDescriptor_unit_tag 4 390 | #define goosci_PinDescriptor_label_tag 1 391 | #define goosci_PinDescriptor_pin_tag 2 392 | #define goosci_PinDescriptor_scalar_descriptor_tag 3 393 | 394 | /* Struct field encoding specification for nanopb */ 395 | extern const pb_field_t goosci_Empty_fields[1]; 396 | extern const pb_field_t goosci_Version_fields[1]; 397 | extern const pb_field_t goosci_Unit_fields[2]; 398 | extern const pb_field_t goosci_AnalogExtremum_fields[2]; 399 | extern const pb_field_t goosci_AnalogZero_fields[2]; 400 | extern const pb_field_t goosci_AnalogExtrema_fields[3]; 401 | extern const pb_field_t goosci_FloatExtremum_fields[2]; 402 | extern const pb_field_t goosci_FloatZero_fields[2]; 403 | extern const pb_field_t goosci_FloatExtrema_fields[3]; 404 | extern const pb_field_t goosci_IntExtremum_fields[2]; 405 | extern const pb_field_t goosci_IntZero_fields[2]; 406 | extern const pb_field_t goosci_IntExtrema_fields[3]; 407 | extern const pb_field_t goosci_Range_fields[4]; 408 | extern const pb_field_t goosci_Zero_fields[4]; 409 | extern const pb_field_t goosci_AxisConfig_fields[3]; 410 | extern const pb_field_t goosci_AnalogPin_fields[2]; 411 | extern const pb_field_t goosci_DigitalPin_fields[2]; 412 | extern const pb_field_t goosci_ScalarDescriptor_fields[5]; 413 | extern const pb_field_t goosci_VirtualPin_fields[2]; 414 | extern const pb_field_t goosci_Pin_fields[4]; 415 | extern const pb_field_t goosci_PinDescriptor_fields[4]; 416 | extern const pb_field_t goosci_Interval_fields[3]; 417 | extern const pb_field_t goosci_SensorDataRequest_fields[4]; 418 | extern const pb_field_t goosci_BleSensorConfig_fields[2]; 419 | extern const pb_field_t goosci_SensorEnumeration_fields[2]; 420 | extern const pb_field_t goosci_AnalogValue_fields[2]; 421 | extern const pb_field_t goosci_DigitalValue_fields[2]; 422 | extern const pb_field_t goosci_FloatValue_fields[2]; 423 | extern const pb_field_t goosci_IntValue_fields[2]; 424 | extern const pb_field_t goosci_StringValue_fields[2]; 425 | extern const pb_field_t goosci_Data_fields[7]; 426 | extern const pb_field_t goosci_Error_fields[2]; 427 | extern const pb_field_t goosci_SensorData_fields[4]; 428 | 429 | /* Maximum encoded size of messages (where known) */ 430 | #define goosci_Empty_size 0 431 | #define goosci_Version_size 0 432 | #define goosci_Unit_size 3 433 | #define goosci_AnalogExtremum_size 11 434 | #define goosci_AnalogZero_size 11 435 | #define goosci_AnalogExtrema_size 26 436 | #define goosci_FloatExtremum_size 11 437 | #define goosci_FloatZero_size 11 438 | #define goosci_FloatExtrema_size 26 439 | #define goosci_IntExtremum_size 11 440 | #define goosci_IntZero_size 11 441 | #define goosci_IntExtrema_size 26 442 | #define goosci_Range_size 28 443 | #define goosci_Zero_size 13 444 | #define goosci_AxisConfig_size 45 445 | #define goosci_AnalogPin_size 11 446 | #define goosci_DigitalPin_size 11 447 | /* goosci_ScalarDescriptor_size depends on runtime parameters */ 448 | #define goosci_VirtualPin_size 11 449 | #define goosci_Pin_size 13 450 | /* goosci_PinDescriptor_size depends on runtime parameters */ 451 | #define goosci_Interval_size 22 452 | /* goosci_SensorDataRequest_size depends on runtime parameters */ 453 | /* goosci_BleSensorConfig_size depends on runtime parameters */ 454 | /* goosci_SensorEnumeration_size depends on runtime parameters */ 455 | #define goosci_AnalogValue_size 6 456 | #define goosci_DigitalValue_size 2 457 | #define goosci_FloatValue_size 5 458 | #define goosci_IntValue_size 11 459 | /* goosci_StringValue_size depends on runtime parameters */ 460 | /* goosci_Data_size depends on runtime parameters */ 461 | /* goosci_Error_size depends on runtime parameters */ 462 | /* goosci_SensorData_size depends on runtime parameters */ 463 | 464 | /* Message IDs (where set with "msgid" option) */ 465 | #ifdef PB_MSGID 466 | 467 | #define SENSOR_MESSAGES \ 468 | 469 | 470 | #endif 471 | 472 | #ifdef __cplusplus 473 | } /* extern "C" */ 474 | #endif 475 | /* @@protoc_insertion_point(eof) */ 476 | 477 | #endif 478 | -------------------------------------------------------------------------------- /lib/goosci/services.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is autogenerated by nRFgo Studio 1.21.1.3 3 | */ 4 | 5 | #ifndef SETUP_MESSAGES_H__ 6 | #define SETUP_MESSAGES_H__ 7 | 8 | #include "hal_platform.h" 9 | #include "aci.h" 10 | 11 | 12 | #define SETUP_ID 0 13 | #define SETUP_FORMAT 3 /** nRF8001 D */ 14 | #define ACI_DYNAMIC_DATA_SIZE 298 15 | 16 | /* Service: Gap - Characteristic: Device name - Pipe: SET */ 17 | #define PIPE_GAP_DEVICE_NAME_SET 1 18 | #define PIPE_GAP_DEVICE_NAME_SET_MAX_SIZE 8 19 | 20 | /* Service: GooSci Sensor - Characteristic: Description - Pipe: SET */ 21 | #define PIPE_GOOSCI_SENSOR_DESCRIPTION_SET 2 22 | #define PIPE_GOOSCI_SENSOR_DESCRIPTION_SET_MAX_SIZE 20 23 | 24 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: TX */ 25 | #define PIPE_GOOSCI_SENSOR_VALUE_TX 3 26 | #define PIPE_GOOSCI_SENSOR_VALUE_TX_MAX_SIZE 20 27 | 28 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: SET */ 29 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_USER_DESCRIPTION 4 30 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_USER_DESCRIPTION_MAX_SIZE 20 31 | 32 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: SET */ 33 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_VALID_RANGE 5 34 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_VALID_RANGE_MAX_SIZE 20 35 | 36 | /* Service: GooSci Sensor - Characteristic: Software Revision String - Pipe: SET */ 37 | #define PIPE_GOOSCI_SENSOR_SOFTWARE_REVISION_STRING_SET 6 38 | #define PIPE_GOOSCI_SENSOR_SOFTWARE_REVISION_STRING_SET_MAX_SIZE 10 39 | 40 | /* Service: GooSci Sensor - Characteristic: Firmware Revision String - Pipe: SET */ 41 | #define PIPE_GOOSCI_SENSOR_FIRMWARE_REVISION_STRING_SET 7 42 | #define PIPE_GOOSCI_SENSOR_FIRMWARE_REVISION_STRING_SET_MAX_SIZE 10 43 | 44 | /* Service: GooSci Sensor - Characteristic: Configuration - Pipe: RX_ACK_AUTO */ 45 | #define PIPE_GOOSCI_SENSOR_CONFIGURATION_RX_ACK_AUTO 8 46 | #define PIPE_GOOSCI_SENSOR_CONFIGURATION_RX_ACK_AUTO_MAX_SIZE 20 47 | 48 | /* Service: GooSci Sensor - Characteristic: Protocol Version - Pipe: SET */ 49 | #define PIPE_GOOSCI_SENSOR_PROTOCOL_VERSION_SET 9 50 | #define PIPE_GOOSCI_SENSOR_PROTOCOL_VERSION_SET_MAX_SIZE 2 51 | 52 | /* Service: Device Information - Characteristic: Model Number String - Pipe: BROADCAST */ 53 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST 10 54 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST_MAX_SIZE 20 55 | 56 | /* Service: Device Information - Characteristic: Model Number String - Pipe: SET */ 57 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET 11 58 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE 20 59 | 60 | 61 | #define NUMBER_OF_PIPES 11 62 | 63 | #define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ 64 | {ACI_STORE_LOCAL, ACI_SET}, \ 65 | {ACI_STORE_LOCAL, ACI_SET}, \ 66 | {ACI_STORE_LOCAL, ACI_TX}, \ 67 | {ACI_STORE_LOCAL, ACI_SET}, \ 68 | {ACI_STORE_LOCAL, ACI_SET}, \ 69 | {ACI_STORE_LOCAL, ACI_SET}, \ 70 | {ACI_STORE_LOCAL, ACI_SET}, \ 71 | {ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \ 72 | {ACI_STORE_LOCAL, ACI_SET}, \ 73 | {ACI_STORE_LOCAL, ACI_TX_BROADCAST}, \ 74 | {ACI_STORE_LOCAL, ACI_SET}, \ 75 | } 76 | 77 | #define GAP_PPCP_MAX_CONN_INT 0xffff /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ 78 | #define GAP_PPCP_MIN_CONN_INT 0xffff /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ 79 | #define GAP_PPCP_SLAVE_LATENCY 0 80 | #define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ 81 | 82 | #define NB_SETUP_MESSAGES 37 83 | #define SETUP_MESSAGES_CONTENT {\ 84 | {0x00,\ 85 | {\ 86 | 0x07,0x06,0x00,0x00,0x03,0x02,0x42,0x07,\ 87 | },\ 88 | },\ 89 | {0x00,\ 90 | {\ 91 | 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x0b,0x01,0x01,0x00,0x00,0x06,0x00,0x00,\ 92 | 0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 93 | },\ 94 | },\ 95 | {0x00,\ 96 | {\ 97 | 0x1f,0x06,0x10,0x1c,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 98 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x03,0x90,0x01,0xff,\ 99 | },\ 100 | },\ 101 | {0x00,\ 102 | {\ 103 | 0x1f,0x06,0x10,0x38,0xff,0xff,0x02,0x58,0x0a,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,\ 104 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 105 | },\ 106 | },\ 107 | {0x00,\ 108 | {\ 109 | 0x05,0x06,0x10,0x54,0x00,0x00,\ 110 | },\ 111 | },\ 112 | {0x00,\ 113 | {\ 114 | 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ 115 | 0x02,0x28,0x03,0x01,0x0e,0x03,0x00,0x00,0x2a,0x04,0x14,0x08,\ 116 | },\ 117 | },\ 118 | {0x00,\ 119 | {\ 120 | 0x1f,0x06,0x20,0x1c,0x08,0x00,0x03,0x2a,0x00,0x01,0x57,0x69,0x6e,0x64,0x6d,0x69,0x6c,0x6c,0x04,0x04,\ 121 | 0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,0x00,0x01,0x2a,\ 122 | },\ 123 | },\ 124 | {0x00,\ 125 | {\ 126 | 0x1f,0x06,0x20,0x38,0x06,0x04,0x03,0x02,0x00,0x05,0x2a,0x01,0x01,0x00,0x00,0x04,0x04,0x05,0x05,0x00,\ 127 | 0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,0x06,0x04,0x09,\ 128 | },\ 129 | },\ 130 | {0x00,\ 131 | {\ 132 | 0x1f,0x06,0x20,0x54,0x08,0x00,0x07,0x2a,0x04,0x01,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x04,0x04,\ 133 | 0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,0x04,0x04,0x10,\ 134 | },\ 135 | },\ 136 | {0x00,\ 137 | {\ 138 | 0x1f,0x06,0x20,0x70,0x10,0x00,0x09,0x28,0x00,0x01,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,\ 139 | 0xaa,0x0a,0x01,0x00,0x5a,0x55,0x04,0x04,0x13,0x13,0x00,0x0a,\ 140 | },\ 141 | },\ 142 | {0x00,\ 143 | {\ 144 | 0x1f,0x06,0x20,0x8c,0x28,0x03,0x01,0x02,0x0b,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,\ 145 | 0xaa,0x0a,0x02,0x00,0x5a,0x55,0x06,0x04,0x15,0x14,0x00,0x0b,\ 146 | },\ 147 | },\ 148 | {0x00,\ 149 | {\ 150 | 0x1f,0x06,0x20,0xa8,0x00,0x02,0x02,0x47,0x6f,0x6f,0x53,0x63,0x69,0x20,0x53,0x65,0x6e,0x73,0x6f,0x72,\ 151 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,\ 152 | },\ 153 | },\ 154 | {0x00,\ 155 | {\ 156 | 0x1f,0x06,0x20,0xc4,0x0c,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,\ 157 | 0x0d,0x28,0x03,0x01,0x10,0x0e,0x00,0xe8,0x74,0x2c,0x65,0xf0,\ 158 | },\ 159 | },\ 160 | {0x00,\ 161 | {\ 162 | 0x1f,0x06,0x20,0xe0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x03,0x00,0x5a,0x55,0x14,0x00,0x14,0x00,0x00,\ 163 | 0x0e,0x00,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 164 | },\ 165 | },\ 166 | {0x00,\ 167 | {\ 168 | 0x1f,0x06,0x20,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,\ 169 | 0x00,0x0f,0x29,0x04,0x01,0x1b,0x00,0x28,0x27,0x01,0x04,0x29,\ 170 | },\ 171 | },\ 172 | {0x00,\ 173 | {\ 174 | 0x1f,0x06,0x21,0x18,0x46,0x14,0x03,0x02,0x00,0x10,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x14,0x00,0x00,\ 175 | 0x11,0x29,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 176 | },\ 177 | },\ 178 | {0x00,\ 179 | {\ 180 | 0x1f,0x06,0x21,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x14,0x00,\ 181 | 0x00,0x12,0x29,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 182 | },\ 183 | },\ 184 | {0x00,\ 185 | {\ 186 | 0x1f,0x06,0x21,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x13,\ 187 | 0x13,0x00,0x13,0x28,0x03,0x01,0x02,0x14,0x00,0xe8,0x74,0x2c,\ 188 | },\ 189 | },\ 190 | {0x00,\ 191 | {\ 192 | 0x1f,0x06,0x21,0x6c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x04,0x00,0x5a,0x55,0x04,0x04,0x0a,\ 193 | 0x07,0x00,0x14,0x00,0x04,0x02,0x52,0x65,0x76,0x20,0x30,0x2e,\ 194 | },\ 195 | },\ 196 | {0x00,\ 197 | {\ 198 | 0x1f,0x06,0x21,0x88,0x31,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,0x15,0x29,0x04,0x01,0x19,0x00,0x00,\ 199 | 0x00,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,0x16,0x28,0x03,\ 200 | },\ 201 | },\ 202 | {0x00,\ 203 | {\ 204 | 0x1f,0x06,0x21,0xa4,0x01,0x02,0x17,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,\ 205 | 0x05,0x00,0x5a,0x55,0x06,0x04,0x0b,0x0a,0x00,0x17,0x00,0x05,\ 206 | },\ 207 | },\ 208 | {0x00,\ 209 | {\ 210 | 0x1f,0x06,0x21,0xc0,0x02,0x30,0x31,0x2e,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,\ 211 | 0x18,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x04,\ 212 | },\ 213 | },\ 214 | {0x00,\ 215 | {\ 216 | 0x1f,0x06,0x21,0xdc,0x04,0x13,0x13,0x00,0x19,0x28,0x03,0x01,0x08,0x1a,0x00,0xe8,0x74,0x2c,0x65,0xf0,\ 217 | 0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x10,0x00,0x5a,0x55,0x44,\ 218 | },\ 219 | },\ 220 | {0x00,\ 221 | {\ 222 | 0x1f,0x06,0x21,0xf8,0x10,0x14,0x00,0x00,0x1a,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 223 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 224 | },\ 225 | },\ 226 | {0x00,\ 227 | {\ 228 | 0x1f,0x06,0x22,0x14,0x04,0x04,0x13,0x13,0x00,0x1b,0x28,0x03,0x01,0x02,0x1c,0x00,0xe8,0x74,0x2c,0x65,\ 229 | 0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x11,0x00,0x5a,0x55,\ 230 | },\ 231 | },\ 232 | {0x00,\ 233 | {\ 234 | 0x1f,0x06,0x22,0x30,0x06,0x04,0x03,0x02,0x00,0x1c,0x00,0x11,0x02,0x00,0x08,0x06,0x04,0x08,0x07,0x00,\ 235 | 0x1d,0x29,0x04,0x01,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x04,\ 236 | },\ 237 | },\ 238 | {0x00,\ 239 | {\ 240 | 0x1f,0x06,0x22,0x4c,0x04,0x02,0x02,0x00,0x1e,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,0x05,0x00,0x1f,\ 241 | 0x28,0x03,0x01,0x02,0x20,0x00,0x24,0x2a,0x04,0x04,0x14,0x08,\ 242 | },\ 243 | },\ 244 | {0x00,\ 245 | {\ 246 | 0x1f,0x06,0x22,0x68,0x00,0x20,0x2a,0x24,0x01,0x57,0x69,0x6e,0x64,0x6d,0x69,0x6c,0x6c,0x00,0x00,0x00,\ 247 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,\ 248 | },\ 249 | },\ 250 | {0x00,\ 251 | {\ 252 | 0x11,0x06,0x22,0x84,0x07,0x00,0x21,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\ 253 | },\ 254 | },\ 255 | {0x00,\ 256 | {\ 257 | 0x1f,0x06,0x40,0x00,0x2a,0x00,0x01,0x00,0x80,0x04,0x00,0x03,0x00,0x00,0x00,0x02,0x02,0x00,0x80,0x04,\ 258 | 0x00,0x0b,0x00,0x00,0x00,0x03,0x02,0x00,0x02,0x04,0x00,0x0e,\ 259 | },\ 260 | },\ 261 | {0x00,\ 262 | {\ 263 | 0x1f,0x06,0x40,0x1c,0x00,0x10,0x29,0x01,0x01,0x00,0x80,0x05,0x00,0x11,0x00,0x00,0x29,0x06,0x01,0x00,\ 264 | 0x80,0x05,0x00,0x12,0x00,0x00,0x00,0x04,0x02,0x00,0x80,0x04,\ 265 | },\ 266 | },\ 267 | {0x00,\ 268 | {\ 269 | 0x1f,0x06,0x40,0x38,0x00,0x14,0x00,0x00,0x00,0x05,0x02,0x00,0x80,0x04,0x00,0x17,0x00,0x00,0x00,0x10,\ 270 | 0x02,0x04,0x00,0x04,0x00,0x1a,0x00,0x00,0x00,0x11,0x02,0x00,\ 271 | },\ 272 | },\ 273 | {0x00,\ 274 | {\ 275 | 0x13,0x06,0x40,0x54,0x80,0x04,0x00,0x1c,0x00,0x00,0x2a,0x24,0x01,0x00,0x81,0x04,0x00,0x20,0x00,0x00,\ 276 | },\ 277 | },\ 278 | {0x00,\ 279 | {\ 280 | 0x13,0x06,0x50,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x00,0x00,0x5a,0x55,\ 281 | },\ 282 | },\ 283 | {0x00,\ 284 | {\ 285 | 0x1f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 286 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 287 | },\ 288 | },\ 289 | {0x00,\ 290 | {\ 291 | 0x05,0x06,0x60,0x1c,0x00,0x00,\ 292 | },\ 293 | },\ 294 | {0x00,\ 295 | {\ 296 | 0x06,0x06,0xf0,0x00,0x03,0x0a,0x24,\ 297 | },\ 298 | },\ 299 | } 300 | 301 | #endif 302 | -------------------------------------------------------------------------------- /lib/goosci/services_lock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is autogenerated by nRFgo Studio 1.21.1.3 3 | */ 4 | 5 | #ifndef SETUP_MESSAGES_H__ 6 | #define SETUP_MESSAGES_H__ 7 | 8 | #include "hal_platform.h" 9 | #include "aci.h" 10 | 11 | // You have now chosen to upload the configuration to OTP on the device. 12 | // This will result in a device that you can not modify afterwards. If this is your intention, 13 | // remove this comment and the #error below 14 | #error Generating configuration for OTP. Please verify usage by removing this error message from include file. 15 | 16 | #define SETUP_ID 0 17 | #define SETUP_FORMAT 3 /** nRF8001 D */ 18 | #define ACI_DYNAMIC_DATA_SIZE 298 19 | 20 | /* Service: Gap - Characteristic: Device name - Pipe: SET */ 21 | #define PIPE_GAP_DEVICE_NAME_SET 1 22 | #define PIPE_GAP_DEVICE_NAME_SET_MAX_SIZE 8 23 | 24 | /* Service: GooSci Sensor - Characteristic: Description - Pipe: SET */ 25 | #define PIPE_GOOSCI_SENSOR_DESCRIPTION_SET 2 26 | #define PIPE_GOOSCI_SENSOR_DESCRIPTION_SET_MAX_SIZE 20 27 | 28 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: TX */ 29 | #define PIPE_GOOSCI_SENSOR_VALUE_TX 3 30 | #define PIPE_GOOSCI_SENSOR_VALUE_TX_MAX_SIZE 20 31 | 32 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: SET */ 33 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_USER_DESCRIPTION 4 34 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_USER_DESCRIPTION_MAX_SIZE 20 35 | 36 | /* Service: GooSci Sensor - Characteristic: Value - Pipe: SET */ 37 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_VALID_RANGE 5 38 | #define PIPE_GOOSCI_SENSOR_VALUE_SET_VALID_RANGE_MAX_SIZE 20 39 | 40 | /* Service: GooSci Sensor - Characteristic: Software Revision String - Pipe: SET */ 41 | #define PIPE_GOOSCI_SENSOR_SOFTWARE_REVISION_STRING_SET 6 42 | #define PIPE_GOOSCI_SENSOR_SOFTWARE_REVISION_STRING_SET_MAX_SIZE 10 43 | 44 | /* Service: GooSci Sensor - Characteristic: Firmware Revision String - Pipe: SET */ 45 | #define PIPE_GOOSCI_SENSOR_FIRMWARE_REVISION_STRING_SET 7 46 | #define PIPE_GOOSCI_SENSOR_FIRMWARE_REVISION_STRING_SET_MAX_SIZE 10 47 | 48 | /* Service: GooSci Sensor - Characteristic: Configuration - Pipe: RX_ACK_AUTO */ 49 | #define PIPE_GOOSCI_SENSOR_CONFIGURATION_RX_ACK_AUTO 8 50 | #define PIPE_GOOSCI_SENSOR_CONFIGURATION_RX_ACK_AUTO_MAX_SIZE 20 51 | 52 | /* Service: GooSci Sensor - Characteristic: Protocol Version - Pipe: SET */ 53 | #define PIPE_GOOSCI_SENSOR_PROTOCOL_VERSION_SET 9 54 | #define PIPE_GOOSCI_SENSOR_PROTOCOL_VERSION_SET_MAX_SIZE 2 55 | 56 | /* Service: Device Information - Characteristic: Model Number String - Pipe: BROADCAST */ 57 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST 10 58 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_BROADCAST_MAX_SIZE 20 59 | 60 | /* Service: Device Information - Characteristic: Model Number String - Pipe: SET */ 61 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET 11 62 | #define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE 20 63 | 64 | 65 | #define NUMBER_OF_PIPES 11 66 | 67 | #define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ 68 | {ACI_STORE_LOCAL, ACI_SET}, \ 69 | {ACI_STORE_LOCAL, ACI_SET}, \ 70 | {ACI_STORE_LOCAL, ACI_TX}, \ 71 | {ACI_STORE_LOCAL, ACI_SET}, \ 72 | {ACI_STORE_LOCAL, ACI_SET}, \ 73 | {ACI_STORE_LOCAL, ACI_SET}, \ 74 | {ACI_STORE_LOCAL, ACI_SET}, \ 75 | {ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \ 76 | {ACI_STORE_LOCAL, ACI_SET}, \ 77 | {ACI_STORE_LOCAL, ACI_TX_BROADCAST}, \ 78 | {ACI_STORE_LOCAL, ACI_SET}, \ 79 | } 80 | 81 | #define GAP_PPCP_MAX_CONN_INT 0xffff /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ 82 | #define GAP_PPCP_MIN_CONN_INT 0xffff /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ 83 | #define GAP_PPCP_SLAVE_LATENCY 0 84 | #define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ 85 | 86 | #define NB_SETUP_MESSAGES 37 87 | #define SETUP_MESSAGES_CONTENT {\ 88 | {0x00,\ 89 | {\ 90 | 0x07,0x06,0x00,0x00,0x03,0x02,0x42,0x07,\ 91 | },\ 92 | },\ 93 | {0x00,\ 94 | {\ 95 | 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x0b,0x01,0x01,0x00,0x00,0x06,0x00,0x00,\ 96 | 0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 97 | },\ 98 | },\ 99 | {0x00,\ 100 | {\ 101 | 0x1f,0x06,0x10,0x1c,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 102 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x03,0x90,0x01,0xff,\ 103 | },\ 104 | },\ 105 | {0x00,\ 106 | {\ 107 | 0x1f,0x06,0x10,0x38,0xff,0xff,0x02,0x58,0x0a,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,\ 108 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 109 | },\ 110 | },\ 111 | {0x00,\ 112 | {\ 113 | 0x05,0x06,0x10,0x54,0x00,0x00,\ 114 | },\ 115 | },\ 116 | {0x00,\ 117 | {\ 118 | 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ 119 | 0x02,0x28,0x03,0x01,0x0e,0x03,0x00,0x00,0x2a,0x04,0x14,0x08,\ 120 | },\ 121 | },\ 122 | {0x00,\ 123 | {\ 124 | 0x1f,0x06,0x20,0x1c,0x08,0x00,0x03,0x2a,0x00,0x01,0x57,0x69,0x6e,0x64,0x6d,0x69,0x6c,0x6c,0x04,0x04,\ 125 | 0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,0x00,0x01,0x2a,\ 126 | },\ 127 | },\ 128 | {0x00,\ 129 | {\ 130 | 0x1f,0x06,0x20,0x38,0x06,0x04,0x03,0x02,0x00,0x05,0x2a,0x01,0x01,0x00,0x00,0x04,0x04,0x05,0x05,0x00,\ 131 | 0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,0x06,0x04,0x09,\ 132 | },\ 133 | },\ 134 | {0x00,\ 135 | {\ 136 | 0x1f,0x06,0x20,0x54,0x08,0x00,0x07,0x2a,0x04,0x01,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x04,0x04,\ 137 | 0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,0x04,0x04,0x10,\ 138 | },\ 139 | },\ 140 | {0x00,\ 141 | {\ 142 | 0x1f,0x06,0x20,0x70,0x10,0x00,0x09,0x28,0x00,0x01,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,\ 143 | 0xaa,0x0a,0x01,0x00,0x5a,0x55,0x04,0x04,0x13,0x13,0x00,0x0a,\ 144 | },\ 145 | },\ 146 | {0x00,\ 147 | {\ 148 | 0x1f,0x06,0x20,0x8c,0x28,0x03,0x01,0x02,0x0b,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,\ 149 | 0xaa,0x0a,0x02,0x00,0x5a,0x55,0x06,0x04,0x15,0x14,0x00,0x0b,\ 150 | },\ 151 | },\ 152 | {0x00,\ 153 | {\ 154 | 0x1f,0x06,0x20,0xa8,0x00,0x02,0x02,0x47,0x6f,0x6f,0x53,0x63,0x69,0x20,0x53,0x65,0x6e,0x73,0x6f,0x72,\ 155 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,\ 156 | },\ 157 | },\ 158 | {0x00,\ 159 | {\ 160 | 0x1f,0x06,0x20,0xc4,0x0c,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,\ 161 | 0x0d,0x28,0x03,0x01,0x10,0x0e,0x00,0xe8,0x74,0x2c,0x65,0xf0,\ 162 | },\ 163 | },\ 164 | {0x00,\ 165 | {\ 166 | 0x1f,0x06,0x20,0xe0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x03,0x00,0x5a,0x55,0x14,0x00,0x14,0x00,0x00,\ 167 | 0x0e,0x00,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 168 | },\ 169 | },\ 170 | {0x00,\ 171 | {\ 172 | 0x1f,0x06,0x20,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,\ 173 | 0x00,0x0f,0x29,0x04,0x01,0x1b,0x00,0x28,0x27,0x01,0x04,0x29,\ 174 | },\ 175 | },\ 176 | {0x00,\ 177 | {\ 178 | 0x1f,0x06,0x21,0x18,0x46,0x14,0x03,0x02,0x00,0x10,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x14,0x00,0x00,\ 179 | 0x11,0x29,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 180 | },\ 181 | },\ 182 | {0x00,\ 183 | {\ 184 | 0x1f,0x06,0x21,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x14,0x00,\ 185 | 0x00,0x12,0x29,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 186 | },\ 187 | },\ 188 | {0x00,\ 189 | {\ 190 | 0x1f,0x06,0x21,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x13,\ 191 | 0x13,0x00,0x13,0x28,0x03,0x01,0x02,0x14,0x00,0xe8,0x74,0x2c,\ 192 | },\ 193 | },\ 194 | {0x00,\ 195 | {\ 196 | 0x1f,0x06,0x21,0x6c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x04,0x00,0x5a,0x55,0x04,0x04,0x0a,\ 197 | 0x07,0x00,0x14,0x00,0x04,0x02,0x52,0x65,0x76,0x20,0x30,0x2e,\ 198 | },\ 199 | },\ 200 | {0x00,\ 201 | {\ 202 | 0x1f,0x06,0x21,0x88,0x31,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,0x15,0x29,0x04,0x01,0x19,0x00,0x00,\ 203 | 0x00,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,0x16,0x28,0x03,\ 204 | },\ 205 | },\ 206 | {0x00,\ 207 | {\ 208 | 0x1f,0x06,0x21,0xa4,0x01,0x02,0x17,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,\ 209 | 0x05,0x00,0x5a,0x55,0x06,0x04,0x0b,0x0a,0x00,0x17,0x00,0x05,\ 210 | },\ 211 | },\ 212 | {0x00,\ 213 | {\ 214 | 0x1f,0x06,0x21,0xc0,0x02,0x30,0x31,0x2e,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,0x07,0x00,\ 215 | 0x18,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x04,\ 216 | },\ 217 | },\ 218 | {0x00,\ 219 | {\ 220 | 0x1f,0x06,0x21,0xdc,0x04,0x13,0x13,0x00,0x19,0x28,0x03,0x01,0x08,0x1a,0x00,0xe8,0x74,0x2c,0x65,0xf0,\ 221 | 0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x10,0x00,0x5a,0x55,0x44,\ 222 | },\ 223 | },\ 224 | {0x00,\ 225 | {\ 226 | 0x1f,0x06,0x21,0xf8,0x10,0x14,0x00,0x00,0x1a,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 227 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 228 | },\ 229 | },\ 230 | {0x00,\ 231 | {\ 232 | 0x1f,0x06,0x22,0x14,0x04,0x04,0x13,0x13,0x00,0x1b,0x28,0x03,0x01,0x02,0x1c,0x00,0xe8,0x74,0x2c,0x65,\ 233 | 0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x11,0x00,0x5a,0x55,\ 234 | },\ 235 | },\ 236 | {0x00,\ 237 | {\ 238 | 0x1f,0x06,0x22,0x30,0x06,0x04,0x03,0x02,0x00,0x1c,0x00,0x11,0x02,0x00,0x08,0x06,0x04,0x08,0x07,0x00,\ 239 | 0x1d,0x29,0x04,0x01,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x04,\ 240 | },\ 241 | },\ 242 | {0x00,\ 243 | {\ 244 | 0x1f,0x06,0x22,0x4c,0x04,0x02,0x02,0x00,0x1e,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,0x05,0x00,0x1f,\ 245 | 0x28,0x03,0x01,0x02,0x20,0x00,0x24,0x2a,0x04,0x04,0x14,0x08,\ 246 | },\ 247 | },\ 248 | {0x00,\ 249 | {\ 250 | 0x1f,0x06,0x22,0x68,0x00,0x20,0x2a,0x24,0x01,0x57,0x69,0x6e,0x64,0x6d,0x69,0x6c,0x6c,0x00,0x00,0x00,\ 251 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x08,\ 252 | },\ 253 | },\ 254 | {0x00,\ 255 | {\ 256 | 0x11,0x06,0x22,0x84,0x07,0x00,0x21,0x29,0x04,0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\ 257 | },\ 258 | },\ 259 | {0x00,\ 260 | {\ 261 | 0x1f,0x06,0x40,0x00,0x2a,0x00,0x01,0x00,0x80,0x04,0x00,0x03,0x00,0x00,0x00,0x02,0x02,0x00,0x80,0x04,\ 262 | 0x00,0x0b,0x00,0x00,0x00,0x03,0x02,0x00,0x02,0x04,0x00,0x0e,\ 263 | },\ 264 | },\ 265 | {0x00,\ 266 | {\ 267 | 0x1f,0x06,0x40,0x1c,0x00,0x10,0x29,0x01,0x01,0x00,0x80,0x05,0x00,0x11,0x00,0x00,0x29,0x06,0x01,0x00,\ 268 | 0x80,0x05,0x00,0x12,0x00,0x00,0x00,0x04,0x02,0x00,0x80,0x04,\ 269 | },\ 270 | },\ 271 | {0x00,\ 272 | {\ 273 | 0x1f,0x06,0x40,0x38,0x00,0x14,0x00,0x00,0x00,0x05,0x02,0x00,0x80,0x04,0x00,0x17,0x00,0x00,0x00,0x10,\ 274 | 0x02,0x04,0x00,0x04,0x00,0x1a,0x00,0x00,0x00,0x11,0x02,0x00,\ 275 | },\ 276 | },\ 277 | {0x00,\ 278 | {\ 279 | 0x13,0x06,0x40,0x54,0x80,0x04,0x00,0x1c,0x00,0x00,0x2a,0x24,0x01,0x00,0x81,0x04,0x00,0x20,0x00,0x00,\ 280 | },\ 281 | },\ 282 | {0x00,\ 283 | {\ 284 | 0x13,0x06,0x50,0x00,0xe8,0x74,0x2c,0x65,0xf0,0x01,0x38,0x95,0x7a,0x46,0xaa,0x0a,0x00,0x00,0x5a,0x55,\ 285 | },\ 286 | },\ 287 | {0x00,\ 288 | {\ 289 | 0x1f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 290 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 291 | },\ 292 | },\ 293 | {0x00,\ 294 | {\ 295 | 0x05,0x06,0x60,0x1c,0x00,0x00,\ 296 | },\ 297 | },\ 298 | {0x00,\ 299 | {\ 300 | 0x06,0x06,0xf0,0x00,0x83,0x9b,0xac,\ 301 | },\ 302 | },\ 303 | } 304 | 305 | #endif 306 | -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | See additional options for PlatformIO Library Dependency Finder `lib_*`: 36 | 37 | http://docs.platformio.org/en/latest/projectconf.html#lib-install 38 | 39 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; http://docs.platformio.org/en/stable/projectconf.html 9 | 10 | [env:blend] 11 | platform = atmelavr 12 | framework = arduino 13 | board = blend 14 | src_filter = + 15 | lib_deps = 16 | EEPROM 17 | SPI 18 | ble-sdk-arduino 19 | Nanopb@0.3.7 20 | ; force goosci for now, fix the circular dependency between GoosciBleGatt and goosci 21 | build_flags = -I$PROJECT_DIR/lib/goosci 22 | lib_ldf_mode = 1 23 | 24 | [env:101] 25 | platform = intel_arc32@1.2.0 26 | framework = arduino 27 | board = genuino101 28 | src_filter = + 29 | lib_deps = Nanopb@0.3.7 30 | lib_ignore = GoosciBleGatt, BLEPeripheral 31 | 32 | [env:mega2560] 33 | platform = atmelavr 34 | framework = arduino 35 | board = megaatmega2560 36 | src_filter = + 37 | lib_deps = 38 | SPI 39 | BLEPeripheral@^0.3.1 40 | lib_ignore = GoosciBleGatt 41 | 42 | [env:uno] 43 | platform = atmelavr 44 | framework = arduino 45 | board = uno 46 | src_filter = + 47 | lib_deps = 48 | SPI 49 | BLEPeripheral@^0.3.1 50 | lib_ignore = GoosciBleGatt 51 | -------------------------------------------------------------------------------- /src/arduino/BLEPeripheralGetAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "BLEPeripheralGetAddress.h" 17 | #include "BLEUtil.h" 18 | 19 | BLEPeripheralGetAddress::BLEPeripheralGetAddress(unsigned char req, unsigned char rdy, unsigned char rst) : 20 | _have_address(false), 21 | _device_address({0}), 22 | BLEPeripheral(req, rdy, rst) { 23 | } 24 | 25 | void BLEPeripheralGetAddress::BLEDeviceAddressReceived(BLEDevice& device, const unsigned char* address) { 26 | _have_address = true; 27 | memcpy(_device_address, address, 6); 28 | } 29 | 30 | bool BLEPeripheralGetAddress::haveAddress() { 31 | return _have_address; 32 | } 33 | 34 | unsigned char* BLEPeripheralGetAddress::getAddress() { 35 | if (!_have_address) return NULL; 36 | return _device_address; 37 | } 38 | -------------------------------------------------------------------------------- /src/arduino/BLEPeripheralGetAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _BLE_PERIPHERAL_GET_ADDRESS_H_ 17 | #define _BLE_PERIPHERAL_GET_ADDRESS_H_ 18 | #include "BLEPeripheral.h" 19 | #include "BLEDevice.h" 20 | 21 | class BLEPeripheralGetAddress : public BLEPeripheral { 22 | public: 23 | BLEPeripheralGetAddress(unsigned char req = BLE_DEFAULT_REQ, unsigned char rdy = BLE_DEFAULT_RDY, unsigned char rst = BLE_DEFAULT_RST); 24 | virtual void BLEDeviceAddressReceived(BLEDevice& device, const unsigned char* address); 25 | unsigned char* getAddress(); 26 | bool haveAddress(); 27 | private: 28 | bool _have_address; 29 | unsigned char _device_address[6]; 30 | }; 31 | 32 | #endif // _BLE_PERIPHERAL_GET_ADDRESS_H_ 33 | -------------------------------------------------------------------------------- /src/arduino/science-journal-arduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "BLEPeripheralGetAddress.h" 17 | #include "goosci_utility.h" 18 | #include "arduino_nrf_pins.h" 19 | #include "debug_print.h" 20 | #include "config_change.h" 21 | #include "heartbeat.h" 22 | #include "sensor.pb.h" 23 | 24 | #define BLE_REQ 9 25 | #define BLE_RDY 8 26 | #define BLE_RST 2 27 | 28 | bool have_address = false; 29 | unsigned char *address = NULL; 30 | BLEPeripheralGetAddress blePeripheral(BLE_REQ, BLE_RDY, BLE_RST); // create peripheral instance 31 | 32 | BLEService whistlepunkService("555a0001-0aaa-467a-9538-01f0652c74e8"); // create service 33 | // Must be 20 char long to accommodate full-size messages. 34 | const char *value = " "; 35 | const char *config = " "; 36 | BLECharacteristic valueCharacteristic( "555a0003-0aaa-467a-9538-01f0652c74e8", BLENotify, value); 37 | BLECharacteristic configCharacteristic("555a0010-0aaa-467a-9538-01f0652c74e8", BLEWrite, config); 38 | const unsigned short version = goosci_Version_Version_LATEST; 39 | 40 | BLEUnsignedShortCharacteristic versionCharacteristic("555a0011-0aaa-467a-9538-01f0652c74e8", BLERead); 41 | 42 | char BleLongName[8]; 43 | bool serialConnected = false; 44 | extern PinType pin_type; 45 | extern int pin; 46 | 47 | void blePeripheralConnectHandler(BLECentral& central) { 48 | // central connected event handler 49 | DEBUG_PRINT("Connected event, central: "); 50 | DEBUG_PRINTLN(central.address()); 51 | } 52 | 53 | void blePeripheralDisconnectHandler(BLECentral& central) { 54 | // central disconnected event handler 55 | DEBUG_PRINT("Disconnected event, central: "); 56 | DEBUG_PRINTLN(central.address()); 57 | } 58 | 59 | void bleNotificationSubscribeHandler(BLECentral& central, BLECharacteristic& characteristic) { 60 | // value characteristic event handler 61 | DEBUG_PRINT("Subscribe event, central: "); 62 | DEBUG_PRINTLN(central.address()); 63 | } 64 | 65 | void bleNotificationUnsubscribeHandler(BLECentral& central, BLECharacteristic& characteristic) { 66 | // value characteristic unsubscribe event handler 67 | DEBUG_PRINT("Unsubscribe event, central: "); 68 | DEBUG_PRINTLN(central.address()); 69 | } 70 | 71 | void bleConfigChangeHandler(BLECentral& central, BLECharacteristic& characteristic) { 72 | // config characteristic event handler 73 | DEBUG_PRINTLN("config change event"); 74 | handle( (uint8_t*) characteristic.value(), characteristic.valueLength()); 75 | DEBUG_PRINT("Pin: "); 76 | DEBUG_PRINTLN(pin); 77 | } 78 | 79 | void setup() { 80 | wait_for_serial(); 81 | 82 | // set the UUID for the service this peripheral advertises: 83 | blePeripheral.setAdvertisedServiceUuid(whistlepunkService.uuid()); 84 | 85 | // add service and characteristics 86 | blePeripheral.addAttribute(whistlepunkService); 87 | blePeripheral.addAttribute(valueCharacteristic); 88 | blePeripheral.addAttribute(configCharacteristic); 89 | blePeripheral.addAttribute(versionCharacteristic); 90 | versionCharacteristic.setValue(version); 91 | 92 | // assign event handlers for connected, disconnected to peripheral 93 | blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler); 94 | blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); 95 | valueCharacteristic.setEventHandler(BLESubscribed, bleNotificationSubscribeHandler); 96 | valueCharacteristic.setEventHandler(BLEUnsubscribed, bleNotificationUnsubscribeHandler); 97 | configCharacteristic.setEventHandler(BLEWritten, bleConfigChangeHandler); 98 | 99 | 100 | // advertise the service 101 | blePeripheral.begin(); 102 | while (true) { 103 | blePeripheral.poll(); 104 | if (blePeripheral.haveAddress()) { 105 | have_address = true; 106 | address = blePeripheral.getAddress(); 107 | sprintf(BleLongName, "Sci%02x%02x", address[0], address[1]); 108 | blePeripheral.setLocalName(BleLongName); 109 | blePeripheral.begin(); 110 | break; 111 | } 112 | } 113 | } 114 | 115 | 116 | void loop() { 117 | if (Serial) { 118 | if (!serialConnected) { 119 | serialConnected = true; 120 | DEBUG_PRINT(F("LongName: ")); 121 | DEBUG_PRINTLN(BleLongName); 122 | } 123 | } else { 124 | if (serialConnected) 125 | serialConnected = false; 126 | } 127 | 128 | // poll peripheral 129 | blePeripheral.poll(); 130 | 131 | if (valueCharacteristic.subscribed()) { 132 | int sensorValue = 0; 133 | if (pin_type == ANALOG) { 134 | sensorValue = analogRead(pin); 135 | } else if (pin_type == DIGITAL) { 136 | sensorValue = digitalRead(pin); 137 | } else { 138 | sensorValue = 666; 139 | } 140 | send_data(valueCharacteristic, millis(), sensorValue); 141 | } 142 | #ifdef GOOSCI_DEVELOPER_MODE 143 | heartbeat(); 144 | #endif 145 | } 146 | -------------------------------------------------------------------------------- /src/arduino101/science-journal-arduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include "goosci_utility.h" 18 | #include "arduino_nrf_pins.h" 19 | #include "debug_print.h" 20 | #include "config_change.h" 21 | #include "heartbeat.h" 22 | #include "internal/ble_client.h" 23 | #include "services/ble/ble_service_gap_api.h" 24 | #include "sensor.pb.h" 25 | 26 | BLEPeripheral blePeripheral; // create peripheral instance 27 | BLEService whistlepunkService("555a0001-0aaa-467a-9538-01f0652c74e8"); // create service 28 | // Must be 20 char long to accommodate full-size messages. 29 | const char *value = " "; 30 | const char *config = " "; 31 | BLECharacteristic valueCharacteristic( "555a0003-0aaa-467a-9538-01f0652c74e8", BLENotify, value); 32 | BLECharacteristic configCharacteristic("555a0010-0aaa-467a-9538-01f0652c74e8", BLEWrite, config); 33 | const unsigned short version = goosci_Version_Version_LATEST; 34 | 35 | BLEUnsignedShortCharacteristic versionCharacteristic("555a0011-0aaa-467a-9538-01f0652c74e8", BLERead); 36 | 37 | char BleLongName[8]; 38 | bool serialConnected = false; 39 | extern PinType pin_type; 40 | extern int pin; 41 | 42 | void blePeripheralConnectHandler(BLECentral& central) { 43 | // central connected event handler 44 | DEBUG_PRINT("Connected event, central: "); 45 | DEBUG_PRINTLN(central.address()); 46 | } 47 | 48 | void blePeripheralDisconnectHandler(BLECentral& central) { 49 | // central disconnected event handler 50 | DEBUG_PRINT("Disconnected event, central: "); 51 | DEBUG_PRINTLN(central.address()); 52 | } 53 | 54 | void bleNotificationSubscribeHandler(BLECentral& central, BLECharacteristic& characteristic) { 55 | // value characteristic event handler 56 | DEBUG_PRINT("Subscribe event, central: "); 57 | DEBUG_PRINTLN(central.address()); 58 | } 59 | 60 | void bleNotificationUnsubscribeHandler(BLECentral& central, BLECharacteristic& characteristic) { 61 | // value characteristic unsubscribe event handler 62 | DEBUG_PRINT("Unsubscribe event, central: "); 63 | DEBUG_PRINTLN(central.address()); 64 | } 65 | 66 | void bleConfigChangeHandler(BLECentral& central, BLECharacteristic& characteristic) { 67 | // config characteristic event handler 68 | DEBUG_PRINTLN("config change event"); 69 | handle( (uint8_t*) characteristic.value(), characteristic.valueLength()); 70 | DEBUG_PRINT("Pin: "); 71 | DEBUG_PRINTLN(pin); 72 | } 73 | 74 | void setup() { 75 | wait_for_serial(); 76 | 77 | // set the local name peripheral advertises 78 | blePeripheral.setLocalName("Initial"); 79 | // set the UUID for the service this peripheral advertises: 80 | blePeripheral.setAdvertisedServiceUuid(whistlepunkService.uuid()); 81 | 82 | // add service and characteristics 83 | blePeripheral.addAttribute(whistlepunkService); 84 | blePeripheral.addAttribute(valueCharacteristic); 85 | blePeripheral.addAttribute(configCharacteristic); 86 | blePeripheral.addAttribute(versionCharacteristic); 87 | versionCharacteristic.setValue(version); 88 | 89 | // assign event handlers for connected, disconnected to peripheral 90 | blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler); 91 | blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); 92 | valueCharacteristic.setEventHandler(BLESubscribed, bleNotificationSubscribeHandler); 93 | valueCharacteristic.setEventHandler(BLEUnsubscribed, bleNotificationUnsubscribeHandler); 94 | configCharacteristic.setEventHandler(BLEWritten, bleConfigChangeHandler); 95 | 96 | ble_addr_t _local_bda; 97 | char _device_name[BLE_MAX_DEVICE_NAME+1]; 98 | ble_client_get_factory_config(&_local_bda, _device_name); 99 | sprintf(BleLongName, "Sci%02x%02x", _local_bda.addr[0], _local_bda.addr[1]); 100 | DEBUG_PRINT("Address is: "); 101 | DEBUG_PRINTLN(BleLongName); 102 | blePeripheral.setLocalName(BleLongName); 103 | 104 | // advertise the service 105 | blePeripheral.begin(); 106 | } 107 | 108 | 109 | void loop() { 110 | if (Serial) { 111 | if (!serialConnected) { 112 | serialConnected = true; 113 | DEBUG_PRINT(F("LongName: ")); 114 | DEBUG_PRINTLN(BleLongName); 115 | } 116 | } else { 117 | if (serialConnected) 118 | serialConnected = false; 119 | } 120 | 121 | // poll peripheral 122 | blePeripheral.poll(); 123 | 124 | if (valueCharacteristic.subscribed()) { 125 | int sensorValue = 0; 126 | if (pin_type == ANALOG) { 127 | sensorValue = analogRead(pin); 128 | } else if (pin_type == DIGITAL) { 129 | sensorValue = digitalRead(pin); 130 | } else { 131 | sensorValue = 666; 132 | } 133 | send_data(valueCharacteristic, millis(), sensorValue); 134 | } 135 | #ifdef GOOSCI_DEVELOPER_MODE 136 | heartbeat(); 137 | #endif 138 | } 139 | -------------------------------------------------------------------------------- /src/blend/science-journal-arduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * Generic analog sensor for Whistlepunk. Reads values from A0 and 17 | * sends them to Whistlepunk via BLE. 18 | */ 19 | 20 | #include "Arduino.h" 21 | 22 | #include "GoosciBleGatt.h" 23 | #include "goosci_utility.h" 24 | #include "arduino_nrf_pins.h" 25 | #include "heartbeat.h" 26 | #include "sensor.pb.h" 27 | #include "debug_print.h" 28 | #include "config_change.h" 29 | 30 | #include 31 | 32 | GoosciBleGatt goosciBle = GoosciBleGatt(REQ, RDY, RESET); 33 | 34 | unsigned long timestamp; 35 | bool serialConnected = false; 36 | 37 | // Sketches 38 | void setup(void) { 39 | wait_for_serial(); 40 | // Set long name. 41 | goosciBle.setLongName("Generic Analog"); // 20 chars max! 42 | 43 | // Set device description. 44 | goosciBle.setDeviceDescription("Generic Analog"); // 20 chars max! 45 | 46 | goosciBle.begin(); 47 | } 48 | 49 | extern PinType pin_type; 50 | extern int pin; 51 | 52 | void loop() { 53 | // always respond to something over serial it makes it easier to 54 | // identify our firmware from a pc 55 | if (Serial) { 56 | if (!serialConnected) { 57 | goosciBle.print_address(); 58 | serialConnected = true; 59 | } 60 | } else { 61 | if (serialConnected) 62 | serialConnected = false; 63 | } 64 | goosciBle.pollACI(); 65 | if (goosciBle.isReadyToSend()) { 66 | int sensorValue = 0; 67 | if (pin_type == ANALOG) { 68 | sensorValue = analogRead(pin); 69 | } else if (pin_type == DIGITAL) { 70 | sensorValue = digitalRead(pin); 71 | } else { 72 | sensorValue = 666; 73 | } 74 | send_data(goosciBle, millis(), sensorValue); 75 | } 76 | #ifdef GOOSCI_DEVELOPER_MODE 77 | heartbeat(); 78 | #endif 79 | } 80 | --------------------------------------------------------------------------------