├── .github └── workflows │ └── examples.yml ├── .gitignore ├── LICENSE ├── README.md ├── boards ├── cubecell_board.json ├── cubecell_board_plus.json ├── cubecell_board_pro.json ├── cubecell_board_v2.json ├── cubecell_capsule.json ├── cubecell_capsule_solar_sensor.json ├── cubecell_gps.json ├── cubecell_module.json ├── cubecell_module_plus.json ├── cubecell_module_v2.json └── cubecell_node.json ├── builder ├── frameworks │ └── arduino.py └── main.py ├── examples ├── LoRa │ ├── LoRaBasic │ │ └── PingPong │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── include │ │ │ └── README │ │ │ ├── lib │ │ │ └── README │ │ │ ├── platformio.ini │ │ │ ├── src │ │ │ └── PingPong.ino │ │ │ └── test │ │ │ └── README │ └── LoRaWAN │ │ ├── LoRaWAN │ │ ├── .gitignore │ │ ├── README.md │ │ ├── include │ │ │ └── README │ │ ├── lib │ │ │ └── README │ │ ├── platformio.ini │ │ ├── src │ │ │ └── LoRaWan.ino │ │ └── test │ │ │ └── README │ │ └── LoRaWAN_Interrupt │ │ ├── .gitignore │ │ ├── README.md │ │ ├── include │ │ └── README │ │ ├── lib │ │ └── README │ │ ├── platformio.ini │ │ ├── src │ │ └── LoRaWAN_Interrupt.ino │ │ └── test │ │ └── README ├── arduino-adc │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── ADC.ino │ └── test │ │ └── README ├── arduino-blink │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── Blink.cpp │ └── test │ │ └── README ├── arduino-lowpower │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── LowPower_WakeUpByTimer.ino │ └── test │ │ └── README └── arduino-rgb │ ├── .gitignore │ ├── README.md │ ├── include │ └── README │ ├── lib │ └── README │ ├── platformio.ini │ ├── src │ └── RGB.ino │ └── test │ └── README └── platform.json /.github/workflows/examples.yml: -------------------------------------------------------------------------------- 1 | name: Examples 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ubuntu-latest, windows-latest, macos-latest] 11 | example: 12 | - "examples/arduino-adc" 13 | - "examples/arduino-blink" 14 | - "examples/arduino-lowpower" 15 | - "examples/arduino-rgb" 16 | - "examples/LoRa/LoRaBasic/PingPong" 17 | - "examples/LoRa/LoRaWAN/LoRaWAN" 18 | - "examples/LoRa/LoRaWAN/LoRaWAN_Interrupt" 19 | runs-on: ${{ matrix.os }} 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | submodules: "recursive" 24 | - name: Set up Python 25 | uses: actions/setup-python@v3 26 | with: 27 | python-version: "3.9" 28 | - name: Install dependencies 29 | run: | 30 | pip install -U https://github.com/platformio/platformio/archive/develop.zip 31 | pio pkg install --global --platform symlink://. 32 | - name: Build examples 33 | run: | 34 | pio run -d ${{ matrix.example }} 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .pio 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Heltec CubeCell: development platform for [PlatformIO](https://platformio.org) 2 | 3 | [![Build Status](https://github.com/HelTecAutomation/heltec-cubecell/workflows/Examples/badge.svg)](https://github.com/HelTecAutomation/heltec-cubecell/actions) 4 | 5 | Heltec CubeCell is an easy-to-use LoRa Node series brand based on a highly integrated and ultra low power SoC and the LoRa SX1262 transceiver. 6 | 7 | * [Home](https://registry.platformio.org/platforms/heltecautomation/heltec-cubecell) (home page in the PlatformIO Registry) 8 | * [Documentation](https://docs.platformio.org/page/platforms/heltec-cubecell.html) (advanced usage, packages, boards, frameworks, etc.) 9 | 10 | # Usage 11 | 12 | 1. [Install PlatformIO](https://platformio.org) 13 | 2. Create PlatformIO project and configure a platform option in [platformio.ini](https://docs.platformio.org/page/projectconf.html) file: 14 | 15 | ## Stable version 16 | 17 | ```ini 18 | [env:stable] 19 | platform = heltec-cubecell 20 | board = ... 21 | ... 22 | ``` 23 | 24 | ## Development version 25 | 26 | ```ini 27 | [env:development] 28 | platform = https://github.com/HelTecAutomation/heltec-cubecell.git 29 | board = ... 30 | ... 31 | ``` 32 | 33 | # Configuration 34 | 35 | ## LoRaWAN 36 | 37 | LoRaWAN protocol can be configured in https://docs.platformio.org/en/latest/projectconf/index.html using the following syntax 38 | ``board_build.arduino.lorawan.*`` where ``*`` is an option from the following list: 39 | 40 | | Option | Description | Possible values | Default | 41 | | ----------- | ----------- | --------------- | ------- | 42 | | ``region`` | Region definition | ``AS923_AS1``, ``AS923_AS2``, ``AU915``, ``CN470``, ``CN779``, ``EU433``, ``EU868``, ``KR920``, ``IN865``, ``US915``, ``US915_HYBRID`` | ``US915`` | 43 | | ``class`` | Device class | ``CLASS_A``, ``CLASS_C`` | ``CLASS_A`` | 44 | | ``netmode`` | Activation method | ``OTAA``, ``ABP`` | ``OTAA`` | 45 | | ``adr`` | Adaptive Data Rate | ``ON``, ``OFF`` | ``ON`` | 46 | | ``uplinkmode`` | Uplink confirmed/unconfirmed messages | ``CONFIRMED``, ``UNCONFIRMED`` | ``CONFIRMED`` | 47 | | ``net_reserve`` | Don't rejoin after reset | ``ON``, ``OFF`` | ``OFF`` | 48 | | ``at_support`` | AT commands support | ``ON``, ``OFF`` | ``ON`` | 49 | | ``rgb`` | RGB light for LoRaWAN status | ``ACTIVE``, ``DEACTIVE`` | ``ACTIVE`` | 50 | | ``preamble_length`` | Preamble length | ``8``, ``16`` (For M00 and M00L) | ``8`` | 51 | | ``debug_level`` | Print LoRaWAN relevant messages print to serial port | ``NONE``, ``FREQ`` (Sending/receiving frequency), ``FREQ_AND_DIO`` (Sending/receiving frequency and DIO pin interrupt information) | ``NONE`` | 52 | 53 | 54 | **Example** 55 | 56 | ```ini 57 | [env:cubecell_board] 58 | platform = heltec-cubecell 59 | framework = arduino 60 | board = cubecell_board 61 | board_build.arduino.lorawan.region = EU433 62 | board_build.arduino.lorawan.adr = OFF 63 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 64 | ``` 65 | 66 | More information about LoRaWAN configuration can be found in 67 | [the official CubeCell documentation](https://docs.heltec.org/en/node/cubecell/index.html). 68 | -------------------------------------------------------------------------------- /boards/cubecell_board.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_Board", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6501", 8 | "variant": "CubeCell-Board" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell-Board (HTCC-AB01)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/project/htcc-ab01/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_board_plus.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_BoardPlus", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6502", 8 | "variant": "CubeCell-BoardPlus" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell-Board Plus (HTCC-AB02)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/project/htcc-ab02/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_board_pro.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "lorawan": { 5 | "class": "CLASS_B" 6 | } 7 | }, 8 | "core": "asr6601", 9 | "cpu": "cortex-m4", 10 | "extra_flags": "-DCubeCell_BoardPRO", 11 | "f_cpu": "48000000L", 12 | "mcu": "asr6601", 13 | "variant": "CubeCell-Board-PRO" 14 | }, 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "name": "Heltec CubeCell-Board PRO (HTCC-AB03)", 19 | "upload": { 20 | "maximum_ram_size": 229376, 21 | "maximum_size": 229376, 22 | "protocol": "serial", 23 | "require_upload_port": true 24 | }, 25 | "url": "https://heltec.org/proudct_center", 26 | "vendor": "Heltec" 27 | } 28 | -------------------------------------------------------------------------------- /boards/cubecell_board_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_Board_V2", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6502", 8 | "variant": "CubeCell-Board-V2" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell-Board-V2 (HTCC-AB01-V2)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/project/htcc-ab01-v2/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_capsule.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_Capsule", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6501", 8 | "variant": "CubeCell-Capsule" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell-Capsule (HTCC-AC01)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/product/htcc-ac01/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_capsule_solar_sensor.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_Capsule", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6051", 8 | "variant": "CubeCell-Capsule" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell Capsule Solar Sensor (HTCC-AC02)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/project/htcc-ac02/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_gps.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "asr650x", 4 | "cpu": "cortex-m0plus", 5 | "extra_flags": "-DCubeCell_GPS", 6 | "f_cpu": "48000000L", 7 | "mcu": "asr6502", 8 | "variant": "CubeCell-GPS" 9 | }, 10 | "frameworks": [ 11 | "arduino" 12 | ], 13 | "name": "Heltec CubeCell-GPS (HTCC-AB02S)", 14 | "upload": { 15 | "maximum_ram_size": 16384, 16 | "maximum_size": 131072, 17 | "protocol": "serial", 18 | "require_upload_port": true 19 | }, 20 | "url": "https://heltec.org/project/htcc-ab02s/", 21 | "vendor": "Heltec" 22 | } 23 | -------------------------------------------------------------------------------- /boards/cubecell_module.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "lorawan": { 5 | "rgb": "DEACTIVE" 6 | } 7 | }, 8 | "core": "asr650x", 9 | "cpu": "cortex-m0plus", 10 | "extra_flags": "-DCubeCell_Module", 11 | "f_cpu": "48000000L", 12 | "mcu": "asr6501", 13 | "variant": "CubeCell-Module" 14 | }, 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "name": "Heltec CubeCell-Module (HTCC-AM01)", 19 | "upload": { 20 | "maximum_ram_size": 16384, 21 | "maximum_size": 131072, 22 | "protocol": "serial", 23 | "require_upload_port": true 24 | }, 25 | "url": "https://heltec.org/project/htcc-am01/", 26 | "vendor": "Heltec" 27 | } 28 | -------------------------------------------------------------------------------- /boards/cubecell_module_plus.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "lorawan": { 5 | "rgb": "DEACTIVE" 6 | } 7 | }, 8 | "core": "asr650x", 9 | "cpu": "cortex-m0plus", 10 | "extra_flags": "-DCubeCell_ModulePlus", 11 | "f_cpu": "48000000L", 12 | "mcu": "asr6502", 13 | "variant": "CubeCell-ModulePlus" 14 | }, 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "name": "Heltec CubeCell-Module Plus (HTCC-AM02)", 19 | "upload": { 20 | "maximum_ram_size": 16384, 21 | "maximum_size": 131072, 22 | "protocol": "serial", 23 | "require_upload_port": true 24 | }, 25 | "url": "https://heltec.org/project/htcc-am02/", 26 | "vendor": "Heltec" 27 | } 28 | -------------------------------------------------------------------------------- /boards/cubecell_module_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "lorawan": { 5 | "rgb": "DEACTIVE" 6 | } 7 | }, 8 | "core": "asr650x", 9 | "cpu": "cortex-m0plus", 10 | "extra_flags": "-DCubeCell_Module_V2", 11 | "f_cpu": "48000000L", 12 | "mcu": "asr6501", 13 | "variant": "CubeCell-Module-V2" 14 | }, 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "name": "Heltec CubeCell-Module-V2 (HTCC-AM01-V2)", 19 | "upload": { 20 | "maximum_ram_size": 16384, 21 | "maximum_size": 131072, 22 | "protocol": "serial", 23 | "require_upload_port": true 24 | }, 25 | "url": "https://heltec.org/project/htcc-am01-v2/", 26 | "vendor": "Heltec" 27 | } 28 | -------------------------------------------------------------------------------- /boards/cubecell_node.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "lorawan": { 5 | "rgb": "DEACTIVE" 6 | } 7 | }, 8 | "core": "asr650x", 9 | "cpu": "cortex-m0plus", 10 | "extra_flags": "-DCubeCell_HalfAA", 11 | "f_cpu": "48000000L", 12 | "mcu": "asr6502", 13 | "variant": "CubeCell-HalfAA" 14 | }, 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "name": "Heltec CubeCell-1/2AA Node (HTCC-AB02A)", 19 | "upload": { 20 | "maximum_ram_size": 16384, 21 | "maximum_size": 131072, 22 | "protocol": "serial", 23 | "require_upload_port": true 24 | }, 25 | "url": "https://heltec.org/project/htcc-ab02a/", 26 | "vendor": "Heltec" 27 | } 28 | -------------------------------------------------------------------------------- /builder/frameworks/arduino.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | Arduino 17 | 18 | Arduino Wiring-based Framework allows writing cross-platform software to 19 | control devices attached to a wide range of Arduino boards to create all 20 | kinds of creative coding, interactive objects, spaces or physical experiences. 21 | 22 | http://arduino.cc/en/Reference/HomePage 23 | """ 24 | 25 | import os 26 | 27 | from SCons.Script import DefaultEnvironment 28 | 29 | 30 | env = DefaultEnvironment() 31 | platform = env.PioPlatform() 32 | board = env.BoardConfig() 33 | core = board.get("build.core") 34 | mcu = board.get("build.mcu", "") 35 | is_asr6601 = mcu.startswith("asr6601") 36 | arch = "asr6601" if is_asr6601 else "asr650x" 37 | 38 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduinocubecell") 39 | CORE_DIR = os.path.join(FRAMEWORK_DIR, "cores", core) 40 | assert os.path.isdir(FRAMEWORK_DIR) 41 | 42 | machine_flags = [ 43 | "-mcpu=%s" % board.get("build.cpu"), 44 | "-mthumb", 45 | "-mthumb-interwork", 46 | "-mapcs-frame", 47 | ] 48 | 49 | env.Append( 50 | ASFLAGS=machine_flags, 51 | ASPPFLAGS=[ 52 | "-x", "assembler-with-cpp", 53 | ], 54 | 55 | CPPDEFINES=[ 56 | ("ARDUINO", 10815), 57 | "ARDUINO_ARCH_%s" % arch.upper(), 58 | "__%s__" % mcu.upper(), 59 | "__%s__" % arch, 60 | ("CONFIG_MANUFACTURER", '\\"ASR\\"'), 61 | ("CONFIG_DEVICE_MODEL", '\\"%s\\"' % mcu), 62 | ("CONFIG_VERSION", '\\"v4.0\\"'), 63 | ("CY_CORE_ID", 0), 64 | "CONFIG_LORA_USE_TCXO", 65 | ("F_CPU", "$BOARD_F_CPU"), 66 | "SOFT_SE", 67 | ], 68 | CCFLAGS=machine_flags + [ 69 | "-w", 70 | "-Wall", 71 | "-Os", 72 | "-ffunction-sections", 73 | "-fdata-sections", 74 | "-ffat-lto-objects", 75 | "-fno-common", 76 | "-fno-builtin-printf", 77 | "-fno-builtin-fflush", 78 | "-fno-builtin-sprintf", 79 | "-fno-builtin-snprintf", 80 | "-Wno-strict-aliasing", 81 | ], 82 | CXXFLAGS=[ 83 | "-fno-exceptions", 84 | "-fno-rtti", 85 | ], 86 | LINKFLAGS=machine_flags + [ 87 | "-Os", 88 | "-Wl,--gc-sections", 89 | "-Wl,--wrap=printf", 90 | "-Wl,--wrap=fflush", 91 | "-Wl,--wrap=sprintf", 92 | "-Wl,--wrap=snprintf", 93 | "-specs=nano.specs", 94 | "-specs=nosys.specs", 95 | "-ffat-lto-objects", 96 | ], 97 | LIBS=["stdc++", "m"], 98 | LIBSOURCE_DIRS=[os.path.join(FRAMEWORK_DIR, "libraries")], 99 | ) 100 | 101 | env.Prepend( 102 | _LIBFLAGS='"%s" ' 103 | % ( 104 | os.path.join(CORE_DIR, "asr6601.a") 105 | if is_asr6601 106 | else os.path.join(CORE_DIR, "projects", "CubeCellLib.a") 107 | ), 108 | ) 109 | 110 | if is_asr6601: 111 | env.Append( 112 | CPPPATH=[ 113 | CORE_DIR, 114 | os.path.join(CORE_DIR, "drivers", "peripheral", "inc"), 115 | os.path.join(CORE_DIR, "drivers", "crypto", "inc"), 116 | os.path.join(CORE_DIR, "platform", "CMSIS"), 117 | os.path.join(CORE_DIR, "platform", "system"), 118 | os.path.join(CORE_DIR, "lora", "driver"), 119 | os.path.join(CORE_DIR, "lora", "radio"), 120 | os.path.join(CORE_DIR, "lora"), 121 | os.path.join(CORE_DIR, "lora", "radio", "sx126x"), 122 | os.path.join(CORE_DIR, "lora", "system"), 123 | os.path.join(CORE_DIR, "lora", "system", "crypto"), 124 | os.path.join(CORE_DIR, "base"), 125 | os.path.join(CORE_DIR, "peripheral"), 126 | ], 127 | ) 128 | else: 129 | env.Append( 130 | CPPPATH=[ 131 | CORE_DIR, 132 | os.path.join(CORE_DIR, "board"), 133 | os.path.join(CORE_DIR, "board", "src"), 134 | os.path.join(CORE_DIR, "board", "inc"), 135 | os.path.join(CORE_DIR, "device", "sx126x"), 136 | os.path.join(CORE_DIR, "lora"), 137 | os.path.join(CORE_DIR, "lora", "system"), 138 | os.path.join(CORE_DIR, "lora", "system", "crypto"), 139 | os.path.join(CORE_DIR, "port"), 140 | os.path.join(CORE_DIR, "port", "include"), 141 | os.path.join(CORE_DIR, "projects"), 142 | os.path.join(CORE_DIR, "projects", "PSoC4"), 143 | os.path.join(CORE_DIR, "cores"), 144 | os.path.join(CORE_DIR, "Serial"), 145 | os.path.join(CORE_DIR, "Wire"), 146 | os.path.join(CORE_DIR, "SPI"), 147 | ], 148 | ) 149 | 150 | 151 | if not board.get("build.ldscript", ""): 152 | env.Append( 153 | LIBPATH=[ 154 | CORE_DIR if is_asr6601 else os.path.join(CORE_DIR, "projects", "PSoC4"), 155 | ] 156 | ) 157 | env.Replace( 158 | LDSCRIPT_PATH=board.get( 159 | "build.arduino.ldscript", "gcc.ld" if is_asr6601 else "cm0plusgcc.ld" 160 | ) 161 | ) 162 | 163 | # 164 | # Configure LoRaWAN 165 | # 166 | 167 | lorawan_config = board.get("build.arduino.lorawan", {}) 168 | region = lorawan_config.get("region", "US915") 169 | debug_level = lorawan_config.get("debug_level", "NONE") 170 | 171 | env.Append( 172 | CPPDEFINES=[ 173 | "REGION_%s" % region, 174 | ("ACTIVE_REGION", "LORAMAC_REGION_%s" % region), 175 | ("LORAWAN_CLASS", lorawan_config.get("class", "CLASS_A")), 176 | ( 177 | "LORAWAN_NETMODE", 178 | "true" if lorawan_config.get("netmode", "OTAA") == "OTAA" else "false", 179 | ), 180 | ("LORAWAN_ADR", "true" if lorawan_config.get("adr", "ON") == "ON" else "false"), 181 | ( 182 | "LORAWAN_UPLINKMODE", 183 | "true" 184 | if lorawan_config.get("uplinkmode", "CONFIRMED") == "CONFIRMED" 185 | else "false", 186 | ), 187 | ( 188 | "LORAWAN_NET_RESERVE", 189 | "true" if lorawan_config.get("net_reserve", "OFF") == "ON" else "false", 190 | ), 191 | ("AT_SUPPORT", 1 if lorawan_config.get("at_support", "ON") == "ON" else 0), 192 | ( 193 | "LORAWAN_DEVEUI_AUTO", 194 | 0 if lorawan_config.get("deveui", "CUSTOM") == "CUSTOM" else 1, 195 | ), 196 | ("LoraWan_RGB", 1 if lorawan_config.get("rgb", "ACTIVE") == "ACTIVE" else 0), 197 | ("LORAWAN_PREAMBLE_LENGTH", lorawan_config.get("preamble_length", 8)), 198 | ( 199 | "LoRaWAN_DEBUG_LEVEL", 200 | 2 if debug_level == "FREQ_AND_DIO" else (1 if debug_level == "FREQ" else 0), 201 | ), 202 | ] 203 | ) 204 | 205 | # 206 | # Target: Build Core Library 207 | # 208 | 209 | libs = [] 210 | 211 | if "build.variant" in board: 212 | variants_dir = ( 213 | os.path.join("$PROJECT_DIR", board.get("build.variants_dir")) 214 | if board.get("build.variants_dir", "") 215 | else os.path.join(FRAMEWORK_DIR, "variants") 216 | ) 217 | env.Append(CPPPATH=[os.path.join(variants_dir, board.get("build.variant"))]) 218 | libs.append( 219 | env.BuildLibrary( 220 | os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"), 221 | os.path.join(variants_dir, board.get("build.variant")), 222 | ) 223 | ) 224 | 225 | libs.append( 226 | env.BuildLibrary( 227 | os.path.join("$BUILD_DIR", "FrameworkArduino"), 228 | CORE_DIR, 229 | # Only applicable to ASR6501 230 | src_filter=[ 231 | "+<*>", 232 | "-", 233 | "-", 234 | ], 235 | ) 236 | ) 237 | 238 | env.Prepend(LIBS=libs) 239 | -------------------------------------------------------------------------------- /builder/main.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from os.path import join 16 | 17 | from SCons.Script import ( 18 | AlwaysBuild, 19 | Builder, 20 | COMMAND_LINE_TARGETS, 21 | Default, 22 | DefaultEnvironment, 23 | ) 24 | 25 | 26 | env = DefaultEnvironment() 27 | platform = env.PioPlatform() 28 | 29 | 30 | env.Replace( 31 | AR="arm-none-eabi-ar", 32 | AS="arm-none-eabi-as", 33 | CC="arm-none-eabi-gcc", 34 | GDB="arm-none-eabi-gdb", 35 | CXX="arm-none-eabi-g++", 36 | OBJCOPY="arm-none-eabi-objcopy", 37 | RANLIB="arm-none-eabi-gcc-ranlib", 38 | SIZETOOL="arm-none-eabi-size", 39 | ARFLAGS=["rcs"], 40 | SIZEPROGREGEXP=r"^(?:\.text|\.data|\.rodata|\.text.align|\.ARM.exidx|\.cybootloader)\s+(\d+).*", 41 | SIZEDATAREGEXP=r"^(?:\.data|\.bss|\.noinit)\s+(\d+).*", 42 | SIZECHECKCMD="$SIZETOOL -A -d $SOURCES", 43 | SIZEPRINTCMD="$SIZETOOL -B -d $SOURCES", 44 | PROGSUFFIX=".elf", 45 | ) 46 | 47 | env.Append( 48 | BUILDERS=dict( 49 | ElfToHex=Builder( 50 | action=env.VerboseAction( 51 | " ".join(["$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET"]), 52 | "Building $TARGET", 53 | ), 54 | suffix=".hex", 55 | ), 56 | ElfToBin=Builder( 57 | action=env.VerboseAction( 58 | " ".join(["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), 59 | "Building $TARGET", 60 | ), 61 | suffix=".bin", 62 | ), 63 | GenerateCyacd=Builder( 64 | action=env.VerboseAction( 65 | " ".join( 66 | [ 67 | '"%s"' 68 | % join( 69 | platform.get_package_dir("tool-cubecellelftool") or "", 70 | "CubeCellelftool", 71 | ), 72 | "$OBJCOPY", 73 | "${SOURCES[0]}", 74 | "${SOURCES[1]}", 75 | "$TARGET", 76 | ] 77 | ), 78 | "Building $TARGET", 79 | ), 80 | suffix=".cyacd", 81 | ), 82 | ) 83 | ) 84 | 85 | # Allow user to override via pre:script 86 | if env.get("PROGNAME", "program") == "program": 87 | env.Replace(PROGNAME="firmware") 88 | 89 | # 90 | # Target: Build executable and linkable firmware 91 | # 92 | 93 | target_elf = None 94 | is_asr6601 = env.BoardConfig().get("build.mcu", "").startswith("asr6601") 95 | if "nobuild" in COMMAND_LINE_TARGETS: 96 | target_elf = join("$BUILD_DIR", "${PROGNAME}.elf") 97 | target_hex = join("$BUILD_DIR", "${PROGNAME}.hex") 98 | target_firm = join( 99 | "$BUILD_DIR", "${PROGNAME}" + (".bin" if is_asr6601 else ".cyacd") 100 | ) 101 | else: 102 | target_elf = env.BuildProgram() 103 | target_hex = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf) 104 | target_firm = ( 105 | env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf) 106 | if is_asr6601 107 | else env.GenerateCyacd( 108 | join("$BUILD_DIR", "${PROGNAME}"), [target_elf, target_hex] 109 | ) 110 | ) 111 | env.Depends(target_firm, "checkprogsize") 112 | 113 | AlwaysBuild(env.Alias("nobuild", target_firm)) 114 | target_buildprog = env.Alias("buildprog", target_firm, target_firm) 115 | 116 | # 117 | # Target: Print binary size 118 | # 119 | 120 | target_size = env.Alias( 121 | "size", target_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE") 122 | ) 123 | AlwaysBuild(target_size) 124 | 125 | # 126 | # Target: Upload by default .hex file 127 | # 128 | 129 | upload_protocol = env.subst("$UPLOAD_PROTOCOL") 130 | 131 | if upload_protocol == "serial": 132 | env.Replace( 133 | UPLOADER="flash6601" if is_asr6601 else "CubeCellflash", 134 | UPLOADERFLAGS=["-p", '"$UPLOAD_PORT"', "flash"] 135 | if is_asr6601 136 | else ["-serial", '"$UPLOAD_PORT"'], 137 | UPLOADCMD="$UPLOADER $UPLOADERFLAGS $SOURCES", 138 | ) 139 | upload_actions = [ 140 | env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."), 141 | env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE"), 142 | ] 143 | 144 | elif upload_protocol == "custom": 145 | upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] 146 | 147 | AlwaysBuild(env.Alias("upload", target_firm, upload_actions)) 148 | 149 | # 150 | # Target: Define targets 151 | # 152 | 153 | Default([target_buildprog, target_size]) 154 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/LoRa/LoRaBasic/PingPong 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:cubecell_board] 12 | platform = heltec-cubecell 13 | framework = arduino 14 | board = cubecell_board 15 | monitor_speed = 115200 16 | board_build.arduino.lorawan.region = EU868 17 | board_build.arduino.lorawan.adr = ON 18 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 19 | 20 | 21 | [env:cubecell_capsule] 22 | platform = heltec-cubecell 23 | framework = arduino 24 | board = cubecell_capsule 25 | monitor_speed = 115200 26 | board_build.arduino.lorawan.region = EU868 27 | board_build.arduino.lorawan.adr = ON 28 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 29 | 30 | [env:cubecell_gps] 31 | platform = heltec-cubecell 32 | framework = arduino 33 | board = cubecell_gps 34 | monitor_speed = 115200 35 | board_build.arduino.lorawan.region = EU868 36 | board_build.arduino.lorawan.adr = ON 37 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 38 | 39 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/src/PingPong.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Ping Pong communication test example 2 | * 3 | * Function: 4 | * 1. Ping Pong communication in two CubeCell device. 5 | * 6 | * Description: 7 | * 1. Only hardware layer communicate, no LoRaWAN protocol support; 8 | * 2. Download the same code into two CubeCell devices, then they will begin Ping Pong test each other; 9 | * 3. This example is for CubeCell hardware basic test. 10 | * 11 | * HelTec AutoMation, Chengdu, China 12 | * 成都惠利特自动化科技有限公司 13 | * www.heltec.org 14 | * 15 | * this project also realess in GitHub: 16 | * https://github.com/HelTecAutomation/ASR650x-Arduino 17 | * */ 18 | 19 | #include "LoRaWan_APP.h" 20 | #include "Arduino.h" 21 | 22 | /* 23 | * set LoraWan_RGB to 1,the RGB active in loraWan 24 | * RGB red means sending; 25 | * RGB green means received done; 26 | */ 27 | #ifndef LoraWan_RGB 28 | #define LoraWan_RGB 0 29 | #endif 30 | 31 | #define RF_FREQUENCY 868000000 // Hz 32 | 33 | #define TX_OUTPUT_POWER 5 // dBm 34 | 35 | #define LORA_BANDWIDTH 0 // [0: 125 kHz, 36 | // 1: 250 kHz, 37 | // 2: 500 kHz, 38 | // 3: Reserved] 39 | #define LORA_SPREADING_FACTOR 7 // [SF7..SF12] 40 | #define LORA_CODINGRATE 1 // [1: 4/5, 41 | // 2: 4/6, 42 | // 3: 4/7, 43 | // 4: 4/8] 44 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx 45 | #define LORA_SYMBOL_TIMEOUT 0 // Symbols 46 | #define LORA_FIX_LENGTH_PAYLOAD_ON false 47 | #define LORA_IQ_INVERSION_ON false 48 | 49 | 50 | #define RX_TIMEOUT_VALUE 1000 51 | #define BUFFER_SIZE 30 // Define the payload size here 52 | 53 | char txpacket[BUFFER_SIZE]; 54 | char rxpacket[BUFFER_SIZE]; 55 | 56 | static RadioEvents_t RadioEvents; 57 | void OnTxDone( void ); 58 | void OnTxTimeout( void ); 59 | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); 60 | 61 | typedef enum 62 | { 63 | LOWPOWER, 64 | RX, 65 | TX 66 | }States_t; 67 | 68 | int16_t txNumber; 69 | States_t state; 70 | bool sleepMode = false; 71 | int16_t Rssi,rxSize; 72 | 73 | 74 | void setup() { 75 | boardInitMcu( ); 76 | Serial.begin(115200); 77 | 78 | txNumber=0; 79 | Rssi=0; 80 | 81 | RadioEvents.TxDone = OnTxDone; 82 | RadioEvents.TxTimeout = OnTxTimeout; 83 | RadioEvents.RxDone = OnRxDone; 84 | 85 | Radio.Init( &RadioEvents ); 86 | Radio.SetChannel( RF_FREQUENCY ); 87 | Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, 88 | LORA_SPREADING_FACTOR, LORA_CODINGRATE, 89 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, 90 | true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 91 | 92 | Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, 93 | LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH, 94 | LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON, 95 | 0, true, 0, 0, LORA_IQ_INVERSION_ON, true ); 96 | state=TX; 97 | } 98 | 99 | 100 | 101 | void loop() 102 | { 103 | switch(state) 104 | { 105 | case TX: 106 | delay(1000); 107 | txNumber++; 108 | sprintf(txpacket,"%s","hello"); 109 | sprintf(txpacket+strlen(txpacket),"%d",txNumber); 110 | sprintf(txpacket+strlen(txpacket),"%s"," Rssi : "); 111 | sprintf(txpacket+strlen(txpacket),"%d",Rssi); 112 | turnOnRGB(COLOR_SEND,0); 113 | 114 | Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); 115 | 116 | Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); 117 | state=LOWPOWER; 118 | break; 119 | case RX: 120 | Serial.println("into RX mode"); 121 | Radio.Rx( 0 ); 122 | state=LOWPOWER; 123 | break; 124 | case LOWPOWER: 125 | lowPowerHandler(); 126 | break; 127 | default: 128 | break; 129 | } 130 | Radio.IrqProcess( ); 131 | } 132 | 133 | void OnTxDone( void ) 134 | { 135 | Serial.print("TX done......"); 136 | turnOnRGB(0,0); 137 | state=RX; 138 | } 139 | 140 | void OnTxTimeout( void ) 141 | { 142 | Radio.Sleep( ); 143 | Serial.print("TX Timeout......"); 144 | state=TX; 145 | } 146 | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) 147 | { 148 | Rssi=rssi; 149 | rxSize=size; 150 | memcpy(rxpacket, payload, size ); 151 | rxpacket[size]='\0'; 152 | turnOnRGB(COLOR_RECEIVED,0); 153 | Radio.Sleep( ); 154 | 155 | Serial.printf("\r\nreceived packet \"%s\" with Rssi %d , length %d\r\n",rxpacket,Rssi,rxSize); 156 | Serial.println("wait to send next packet"); 157 | 158 | state=TX; 159 | } -------------------------------------------------------------------------------- /examples/LoRa/LoRaBasic/PingPong/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/LoRa/LoRaWAN/LoRaWAN 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/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 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:cubecell_board] 11 | platform = heltec-cubecell 12 | framework = arduino 13 | board = cubecell_board 14 | monitor_speed = 115200 15 | board_build.arduino.lorawan.region = US915 16 | board_build.arduino.lorawan.uplinkmode = UNCONFIRMED 17 | 18 | [env:cubecell_board_plus] 19 | platform = heltec-cubecell 20 | framework = arduino 21 | board = cubecell_board_plus 22 | monitor_speed = 115200 23 | board_build.arduino.lorawan.region = EU433 24 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 25 | lib_deps = 26 | eiannone/Heltec_Esp32_Display@^0.1.0 27 | 28 | [env:cubecell_capsule] 29 | platform = heltec-cubecell 30 | framework = arduino 31 | board = cubecell_capsule 32 | monitor_speed = 115200 33 | board_build.arduino.lorawan.region = CN470 34 | board_build.arduino.lorawan.at_support = OFF 35 | 36 | [env:cubecell_gps] 37 | platform = heltec-cubecell 38 | framework = arduino 39 | board = cubecell_gps 40 | monitor_speed = 115200 41 | board_build.arduino.lorawan.region = CN779 42 | board_build.arduino.lorawan.net_reserve = ON 43 | lib_deps = 44 | eiannone/Heltec_Esp32_Display@^0.1.0 45 | 46 | [env:cubecell_module] 47 | platform = heltec-cubecell 48 | framework = arduino 49 | board = cubecell_module 50 | monitor_speed = 115200 51 | board_build.arduino.lorawan.region = EU868 52 | board_build.arduino.lorawan.rgb = DEACTIVE 53 | 54 | [env:cubecell_module_plus] 55 | platform = heltec-cubecell 56 | framework = arduino 57 | board = cubecell_module_plus 58 | monitor_speed = 115200 59 | board_build.arduino.lorawan.region = KR920 60 | board_build.arduino.lorawan.adr = OFF 61 | board_build.arduino.lorawan.rgb = DEACTIVE 62 | 63 | [env:cubecell_node] 64 | platform = heltec-cubecell 65 | framework = arduino 66 | board = cubecell_node 67 | monitor_speed = 115200 68 | board_build.arduino.lorawan.region = IN865 69 | board_build.arduino.lorawan.class = CLASS_C 70 | board_build.arduino.lorawan.rgb = DEACTIVE 71 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/src/LoRaWan.ino: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | #include "Arduino.h" 3 | 4 | /* 5 | * set LoraWan_RGB to Active,the RGB active in loraWan 6 | * RGB red means sending; 7 | * RGB purple means joined done; 8 | * RGB blue means RxWindow1; 9 | * RGB yellow means RxWindow2; 10 | * RGB green means received done; 11 | */ 12 | 13 | /* OTAA para*/ 14 | uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; 15 | uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 16 | uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; 17 | 18 | /* ABP para*/ 19 | uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; 20 | uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; 21 | uint32_t devAddr = ( uint32_t )0x007e6ae1; 22 | 23 | /*LoraWan channelsmask, default channels 0-7*/ 24 | uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 }; 25 | 26 | /*LoraWan region, select in arduino IDE tools*/ 27 | LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; 28 | 29 | /*LoraWan Class, Class A and Class C are supported*/ 30 | DeviceClass_t loraWanClass = LORAWAN_CLASS; 31 | 32 | /*the application data transmission duty cycle. value in [ms].*/ 33 | uint32_t appTxDutyCycle = 15000; 34 | 35 | /*OTAA or ABP*/ 36 | bool overTheAirActivation = LORAWAN_NETMODE; 37 | 38 | /*ADR enable*/ 39 | bool loraWanAdr = LORAWAN_ADR; 40 | 41 | /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ 42 | bool keepNet = LORAWAN_NET_RESERVE; 43 | 44 | /* Indicates if the node is sending confirmed or unconfirmed messages */ 45 | bool isTxConfirmed = LORAWAN_UPLINKMODE; 46 | 47 | /* Application port */ 48 | uint8_t appPort = 2; 49 | /*! 50 | * Number of trials to transmit the frame, if the LoRaMAC layer did not 51 | * receive an acknowledgment. The MAC performs a datarate adaptation, 52 | * according to the LoRaWAN Specification V1.0.2, chapter 18.4, according 53 | * to the following table: 54 | * 55 | * Transmission nb | Data Rate 56 | * ----------------|----------- 57 | * 1 (first) | DR 58 | * 2 | DR 59 | * 3 | max(DR-1,0) 60 | * 4 | max(DR-1,0) 61 | * 5 | max(DR-2,0) 62 | * 6 | max(DR-2,0) 63 | * 7 | max(DR-3,0) 64 | * 8 | max(DR-3,0) 65 | * 66 | * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease 67 | * the datarate, in case the LoRaMAC layer did not receive an acknowledgment 68 | */ 69 | uint8_t confirmedNbTrials = 4; 70 | 71 | /* Prepares the payload of the frame */ 72 | static void prepareTxFrame( uint8_t port ) 73 | { 74 | /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". 75 | *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. 76 | *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. 77 | *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. 78 | *for example, if use REGION_CN470, 79 | *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". 80 | */ 81 | appDataSize = 4; 82 | appData[0] = 0x00; 83 | appData[1] = 0x01; 84 | appData[2] = 0x02; 85 | appData[3] = 0x03; 86 | } 87 | 88 | 89 | void setup() { 90 | boardInitMcu(); 91 | Serial.begin(115200); 92 | #if(AT_SUPPORT) 93 | enableAt(); 94 | #endif 95 | deviceState = DEVICE_STATE_INIT; 96 | LoRaWAN.ifskipjoin(); 97 | } 98 | 99 | void loop() 100 | { 101 | switch( deviceState ) 102 | { 103 | case DEVICE_STATE_INIT: 104 | { 105 | #if(AT_SUPPORT) 106 | getDevParam(); 107 | #endif 108 | printDevParam(); 109 | LoRaWAN.init(loraWanClass,loraWanRegion); 110 | deviceState = DEVICE_STATE_JOIN; 111 | break; 112 | } 113 | case DEVICE_STATE_JOIN: 114 | { 115 | LoRaWAN.join(); 116 | break; 117 | } 118 | case DEVICE_STATE_SEND: 119 | { 120 | prepareTxFrame( appPort ); 121 | LoRaWAN.send(); 122 | deviceState = DEVICE_STATE_CYCLE; 123 | break; 124 | } 125 | case DEVICE_STATE_CYCLE: 126 | { 127 | // Schedule next packet transmission 128 | txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); 129 | LoRaWAN.cycle(txDutyCycleTime); 130 | deviceState = DEVICE_STATE_SLEEP; 131 | break; 132 | } 133 | case DEVICE_STATE_SLEEP: 134 | { 135 | LoRaWAN.sleep(); 136 | break; 137 | } 138 | default: 139 | { 140 | deviceState = DEVICE_STATE_INIT; 141 | break; 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/LoRa/LoRaWAN/LoRaWAN_Interrupt 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:cubecell_board] 12 | platform = heltec-cubecell 13 | board = cubecell_board 14 | framework = arduino 15 | monitor_speed = 115200 16 | board_build.arduino.lorawan.region = EU868 17 | board_build.arduino.lorawan.adr = ON 18 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 19 | 20 | [env:cubecell_board_plus] 21 | platform = heltec-cubecell 22 | framework = arduino 23 | board = cubecell_board_plus 24 | monitor_speed = 115200 25 | board_build.arduino.lorawan.region = EU868 26 | board_build.arduino.lorawan.adr = ON 27 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 28 | 29 | [env:cubecell_gps] 30 | platform = heltec-cubecell 31 | framework = arduino 32 | board = cubecell_gps 33 | monitor_speed = 115200 34 | board_build.arduino.lorawan.region = EU868 35 | board_build.arduino.lorawan.adr = ON 36 | board_build.arduino.lorawan.debug_level = FREQ_AND_DIO 37 | -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/src/LoRaWAN_Interrupt.ino: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | #include "Arduino.h" 3 | 4 | /* OTAA para*/ 5 | uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; 6 | uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 7 | uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; 8 | 9 | /* ABP para*/ 10 | uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; 11 | uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; 12 | uint32_t devAddr = ( uint32_t )0x007e6ae1; 13 | 14 | /*LoraWan channelsmask, default channels 0-7*/ 15 | uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 }; 16 | 17 | // The interrupt pin is attached to USER_KEY 18 | #define INT_PIN USER_KEY 19 | 20 | /* Application port */ 21 | #define DEVPORT 2 22 | #define APPPORT 1 23 | 24 | bool accelWoke = false; 25 | 26 | /*LoraWan region, select in arduino IDE tools*/ 27 | LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; 28 | 29 | /*LoraWan Class, Class A and Class C are supported*/ 30 | DeviceClass_t loraWanClass = LORAWAN_CLASS; 31 | 32 | /*the application data transmission duty cycle. value in [ms].*/ 33 | /*For this example, this is the frequency of the device status packets */ 34 | uint32_t appTxDutyCycle = (24 * 60 * 60 * 1000); // 24h; 35 | 36 | /*OTAA or ABP*/ 37 | bool overTheAirActivation = LORAWAN_NETMODE; 38 | 39 | /*ADR enable*/ 40 | bool loraWanAdr = LORAWAN_ADR; 41 | 42 | /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ 43 | bool keepNet = LORAWAN_NET_RESERVE; 44 | 45 | /* Indicates if the node is sending confirmed or unconfirmed messages */ 46 | bool isTxConfirmed = LORAWAN_UPLINKMODE; 47 | 48 | /* Application port */ 49 | uint8_t appPort = DEVPORT; 50 | /*! 51 | * Number of trials to transmit the frame, if the LoRaMAC layer did not 52 | * receive an acknowledgment. The MAC performs a datarate adaptation, 53 | * according to the LoRaWAN Specification V1.0.2, chapter 18.4, according 54 | * to the following table: 55 | * 56 | * Transmission nb | Data Rate 57 | * ----------------|----------- 58 | * 1 (first) | DR 59 | * 2 | DR 60 | * 3 | max(DR-1,0) 61 | * 4 | max(DR-1,0) 62 | * 5 | max(DR-2,0) 63 | * 6 | max(DR-2,0) 64 | * 7 | max(DR-3,0) 65 | * 8 | max(DR-3,0) 66 | * 67 | * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease 68 | * the datarate, in case the LoRaMAC layer did not receive an acknowledgment 69 | */ 70 | uint8_t confirmedNbTrials = 4; 71 | 72 | 73 | /* Prepares the payload of the frame */ 74 | static bool prepareTxFrame( uint8_t port ) 75 | { 76 | int head; 77 | appPort = port; 78 | switch (port) { 79 | case APPPORT: // woke up from interrupt 80 | Serial.println("Sending data packet"); 81 | appDataSize = 1;//AppDataSize max value is 64 82 | appData[0] = 0xFF; // set to something useful 83 | break; 84 | case DEVPORT: // daily wake up 85 | Serial.println("Sending dev status packet"); 86 | appDataSize = 1;//AppDataSize max value is 64 87 | appData[0] = 0xA0; // set to something else useful 88 | break; 89 | } 90 | return true; 91 | } 92 | 93 | void accelWakeup() 94 | { 95 | delay(10); 96 | if(digitalRead(INT_PIN)==HIGH) 97 | { 98 | accelWoke = true; 99 | } 100 | } 101 | 102 | void setup() { 103 | boardInitMcu(); 104 | Serial.begin(115200); 105 | #if(AT_SUPPORT) 106 | enableAt(); 107 | #endif 108 | deviceState = DEVICE_STATE_INIT; 109 | LoRaWAN.ifskipjoin(); 110 | 111 | accelWoke = false; 112 | pinMode(INT_PIN,INPUT); 113 | attachInterrupt(INT_PIN, accelWakeup, RISING); 114 | Serial.println("Interrupts attached"); 115 | } 116 | 117 | void loop() 118 | { 119 | if (accelWoke) { 120 | uint32_t now = TimerGetCurrentTime(); 121 | Serial.print(now); Serial.println("accel woke"); 122 | } 123 | 124 | switch( deviceState ) 125 | { 126 | case DEVICE_STATE_INIT: 127 | { 128 | #if(AT_SUPPORT) 129 | getDevParam(); 130 | #endif 131 | printDevParam(); 132 | LoRaWAN.init(loraWanClass,loraWanRegion); 133 | deviceState = DEVICE_STATE_JOIN; 134 | break; 135 | } 136 | case DEVICE_STATE_JOIN: 137 | { 138 | LoRaWAN.join(); 139 | break; 140 | } 141 | case DEVICE_STATE_SEND: 142 | { 143 | prepareTxFrame( DEVPORT ); 144 | LoRaWAN.send(); 145 | deviceState = DEVICE_STATE_CYCLE; 146 | break; 147 | } 148 | case DEVICE_STATE_CYCLE: 149 | { 150 | // Schedule next packet transmission 151 | txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); 152 | LoRaWAN.cycle(txDutyCycleTime); 153 | deviceState = DEVICE_STATE_SLEEP; 154 | break; 155 | } 156 | case DEVICE_STATE_SLEEP: 157 | { 158 | if (accelWoke) { 159 | if (IsLoRaMacNetworkJoined) { 160 | if(prepareTxFrame(APPPORT)) { 161 | LoRaWAN.send(); 162 | } 163 | } 164 | accelWoke = false; 165 | } 166 | LoRaWAN.sleep(); 167 | break; 168 | } 169 | default: 170 | { 171 | deviceState = DEVICE_STATE_INIT; 172 | break; 173 | } 174 | } 175 | } -------------------------------------------------------------------------------- /examples/LoRa/LoRaWAN/LoRaWAN_Interrupt/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-adc/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-adc/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/arduino-adc 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/arduino-adc/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-adc/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-adc/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 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:cubecell_board] 11 | platform = heltec-cubecell 12 | framework = arduino 13 | board = cubecell_board 14 | 15 | [env:cubecell_board_plus] 16 | platform = heltec-cubecell 17 | framework = arduino 18 | board = cubecell_board_plus 19 | 20 | [env:cubecell_capsule] 21 | platform = heltec-cubecell 22 | framework = arduino 23 | board = cubecell_capsule 24 | 25 | [env:cubecell_gps] 26 | platform = heltec-cubecell 27 | framework = arduino 28 | board = cubecell_gps 29 | 30 | [env:cubecell_module] 31 | platform = heltec-cubecell 32 | framework = arduino 33 | board = cubecell_module 34 | 35 | [env:cubecell_module_plus] 36 | platform = heltec-cubecell 37 | framework = arduino 38 | board = cubecell_module_plus 39 | 40 | [env:cubecell_node] 41 | platform = heltec-cubecell 42 | framework = arduino 43 | board = cubecell_node 44 | -------------------------------------------------------------------------------- /examples/arduino-adc/src/ADC.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | 4 | void setup() { 5 | // put your setup code here, to run once: 6 | Serial.begin(115200); 7 | } 8 | 9 | uint16_t voltage; 10 | 11 | void loop() { 12 | // put your main code here, to run repeatedly: 13 | 14 | //ADC == ADC1 15 | voltage=analogRead(ADC);//return the voltage in mV, max value can be read is 2400mV 16 | Serial.print(millis()); 17 | Serial.print(" "); 18 | Serial.println(voltage); 19 | delay(1000); 20 | } 21 | -------------------------------------------------------------------------------- /examples/arduino-adc/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-blink/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-blink/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/arduino-blink 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/arduino-blink/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-blink/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-blink/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 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:cubecell_board] 11 | platform = heltec-cubecell 12 | framework = arduino 13 | board = cubecell_board 14 | 15 | [env:cubecell_board_plus] 16 | platform = heltec-cubecell 17 | framework = arduino 18 | board = cubecell_board_plus 19 | 20 | [env:cubecell_capsule] 21 | platform = heltec-cubecell 22 | framework = arduino 23 | board = cubecell_capsule 24 | 25 | [env:cubecell_gps] 26 | platform = heltec-cubecell 27 | framework = arduino 28 | board = cubecell_gps 29 | 30 | [env:cubecell_board_pro] 31 | platform = heltec-cubecell 32 | framework = arduino 33 | board = cubecell_board_pro 34 | -------------------------------------------------------------------------------- /examples/arduino-blink/src/Blink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Blink 3 | * Turns on an LED on for one second, 4 | * then off for one second, repeatedly. 5 | */ 6 | 7 | #include 8 | 9 | void setup() 10 | { 11 | // initialize LED digital pin as an output. 12 | pinMode(RGB, OUTPUT); 13 | } 14 | 15 | void loop() 16 | { 17 | // turn the LED on (HIGH is the voltage level) 18 | digitalWrite(RGB, HIGH); 19 | // wait for a second 20 | delay(1000); 21 | // turn the LED off by making the voltage LOW 22 | digitalWrite(RGB, LOW); 23 | // wait for a second 24 | delay(1000); 25 | } -------------------------------------------------------------------------------- /examples/arduino-blink/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/arduino-lowpower 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/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 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env] 11 | platform = heltec-cubecell 12 | framework = arduino 13 | lib_ldf_mode = deep 14 | 15 | [env:cubecell_board] 16 | board = cubecell_board 17 | 18 | [env:cubecell_board_plus] 19 | board = cubecell_board_plus 20 | 21 | [env:cubecell_capsule] 22 | board = cubecell_capsule 23 | 24 | [env:cubecell_gps] 25 | board = cubecell_gps 26 | 27 | [env:cubecell_module] 28 | board = cubecell_module 29 | 30 | [env:cubecell_module_plus] 31 | board = cubecell_module_plus 32 | 33 | [env:cubecell_node] 34 | board = cubecell_node 35 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/src/LowPower_WakeUpByTimer.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "LoRa_APP.h" 3 | 4 | #define timetillsleep 5000 5 | #define timetillwakeup 5000 6 | static TimerEvent_t sleep; 7 | static TimerEvent_t wakeUp; 8 | uint8_t lowpower=1; 9 | 10 | void onSleep() 11 | { 12 | Serial.printf("Going into lowpower mode, %d ms later wake up.\r\n",timetillwakeup); 13 | lowpower=1; 14 | //timetillwakeup ms later wake up; 15 | TimerSetValue( &wakeUp, timetillwakeup ); 16 | TimerStart( &wakeUp ); 17 | } 18 | void onWakeUp() 19 | { 20 | Serial.printf("Woke up, %d ms later into lowpower mode.\r\n",timetillsleep); 21 | lowpower=0; 22 | //timetillsleep ms later into lowpower mode; 23 | TimerSetValue( &sleep, timetillsleep ); 24 | TimerStart( &sleep ); 25 | } 26 | 27 | void setup() { 28 | // put your setup code here, to run once: 29 | Serial.begin(115200); 30 | Radio.Sleep( ); 31 | TimerInit( &sleep, onSleep ); 32 | TimerInit( &wakeUp, onWakeUp ); 33 | onSleep(); 34 | } 35 | 36 | void loop() { 37 | if(lowpower){ 38 | lowPowerHandler(); 39 | } 40 | // put your main code here, to run repeatedly: 41 | } 42 | -------------------------------------------------------------------------------- /examples/arduino-lowpower/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-rgb/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-rgb/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/HelTecAutomation/heltec-cubecell/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd heltec-cubecell/examples/arduino-rgb 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e cubecell_capsule 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e cubecell_capsule --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/arduino-rgb/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-rgb/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-rgb/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 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:cubecell_board] 11 | platform = heltec-cubecell 12 | framework = arduino 13 | board = cubecell_board 14 | 15 | [env:cubecell_board_plus] 16 | platform = heltec-cubecell 17 | framework = arduino 18 | board = cubecell_board_plus 19 | 20 | [env:cubecell_capsule] 21 | platform = heltec-cubecell 22 | framework = arduino 23 | board = cubecell_capsule 24 | 25 | [env:cubecell_gps] 26 | platform = heltec-cubecell 27 | framework = arduino 28 | board = cubecell_gps 29 | -------------------------------------------------------------------------------- /examples/arduino-rgb/src/RGB.ino: -------------------------------------------------------------------------------- 1 | #include "CubeCell_NeoPixel.h" 2 | CubeCell_NeoPixel pixels(1, RGB, NEO_GRB + NEO_KHZ800); 3 | 4 | void setup() { 5 | // put your setup code here, to run once: 6 | pinMode(Vext,OUTPUT); 7 | digitalWrite(Vext,LOW); //SET POWER 8 | pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 9 | pixels.clear(); // Set all pixel colors to 'off' 10 | } 11 | uint8_t i=0; 12 | 13 | void loop() { 14 | // put your main code here, to run repeatedly: 15 | 16 | pixels.setPixelColor(0, pixels.Color(i, 0, 0)); 17 | 18 | pixels.show(); // Send the updated pixel colors to the hardware. 19 | 20 | delay(200); // Pause before next pass through loop 21 | 22 | pixels.setPixelColor(0, pixels.Color(0, i, 0)); 23 | 24 | pixels.show(); // Send the updated pixel colors to the hardware. 25 | 26 | 27 | delay(200); // Pause before next pass through loop 28 | 29 | pixels.setPixelColor(0, pixels.Color(0, 0, i)); 30 | 31 | pixels.show(); // Send the updated pixel colors to the hardware. 32 | 33 | delay(200); // Pause before next pass through loop 34 | 35 | i+=10; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /examples/arduino-rgb/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /platform.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "heltec-cubecell", 3 | "title": "Heltec CubeCell", 4 | "description": "Heltec CubeCell is an easy-to-use LoRa Node series brand based on a highly integrated and ultra low power SoC and the LoRa SX1262 transceiver.", 5 | "homepage": "https://heltec.org/", 6 | "keywords": [ 7 | "dev-platform", 8 | "ARM", 9 | "PSoC", 10 | "Semtech", 11 | "SX1262", 12 | "Heltec", 13 | "CubeCell", 14 | "LoRa", 15 | "ASR Microelectronics" 16 | ], 17 | "license": "Apache-2.0", 18 | "engines": { 19 | "platformio": "^6" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/HelTecAutomation/platform-heltec-cubecell.git" 24 | }, 25 | "version": "1.1.0", 26 | "frameworks": { 27 | "arduino": { 28 | "package": "framework-arduinocubecell", 29 | "script": "builder/frameworks/arduino.py" 30 | } 31 | }, 32 | "packages": { 33 | "toolchain-gccarmnoneeabi": { 34 | "type": "toolchain", 35 | "owner": "platformio", 36 | "version": "~1.90201.0" 37 | }, 38 | "framework-arduinocubecell": { 39 | "type": "framework", 40 | "owner": "heltecautomation", 41 | "version": "~1.6.0", 42 | "optional": true 43 | }, 44 | "tool-cubecellelftool": { 45 | "owner": "heltecautomation", 46 | "version": "~0.0.1" 47 | }, 48 | "tool-cubecellflash": { 49 | "type": "uploader", 50 | "optional": true, 51 | "owner": "heltecautomation", 52 | "version": "~0.0.1" 53 | }, 54 | "tool-cubecellflash6601": { 55 | "type": "uploader", 56 | "optional": true, 57 | "owner": "heltecautomation", 58 | "version": "~0.0.1" 59 | } 60 | } 61 | } 62 | --------------------------------------------------------------------------------