/* main.cpp - TinyLora BMP280 Firmware Copyright (c) 2019, Stefan Brand All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include // secconfig.h Configures RF Module, TTN Keys / RF Networks and used Sensor #include "secconfig.h" #ifdef RF_LORA // Include LoRaWAN #include #define DIO0 PIN_B0 #define NSS PIN_B1 RFM95 rfm(DIO0,NSS); LoRaWAN lora = LoRaWAN(rfm); uint16_t Frame_Counter_Tx = 0x0000; #endif #ifdef RF_RFM69 // Include RFM69 #include RFM69 radio; #endif // Sensorclass and deepsleep interval (for measurement about every 10Min) #ifdef HAS_BME280 #include BME280 sensor; #define SLEEP_TIME 528 #endif #ifdef HAS_SHT21 #include SHT21 sensor; #define SLEEP_TIME 544 #endif // Global Variable used for deep sleep uint16_t sleep_interval; // Setup Wakeup Interrupt Timer void init_wdt() { MCUSR &= ~(1<