├── examples ├── arduino_lorawan_esp32_example │ ├── .gitkeep │ ├── secrets.h.template │ └── ttn_decoder.js ├── header_test │ └── header_test.ino ├── header_test_lmic │ └── header_test_lmic.ino ├── header_test_ttn │ └── header_test_ttn.ino ├── header_test_network │ └── header_test_network.ino ├── simple │ └── simple.ino ├── simple_feather │ └── simple_feather.ino └── simple_sensor_bme280 │ └── simple_sensor_bme280.ino ├── src ├── lib │ ├── GetRegion.cpp │ ├── GetCountryCode.cpp │ ├── SetLinkCheckMode.cpp │ ├── arduino_lorawan_shutdown.cpp │ ├── arduino_lorawan_loop.cpp │ ├── senra_base_netjoin.cpp │ ├── generic_base_netjoin.cpp │ ├── actility_base_netjoin.cpp │ ├── swisscom_base_netjoin.cpp │ ├── chirpstack_base_netjoin.cpp │ ├── generic_us915_netjoin.cpp │ ├── actility_us915_netjoin.cpp │ ├── senet_base_netjoin.cpp │ ├── helium_base_netjoin.cpp │ ├── chirpstack_us915_netjoin.cpp │ ├── generic_au915_netjoin.cpp │ ├── senet_us915_netjoin.cpp │ ├── senra_in866_netjoin.cpp │ ├── actility_au915_netjoin.cpp │ ├── generic_as923_netjoin.cpp │ ├── generic_eu868_netjoin.cpp │ ├── actility_as923_netjoin.cpp │ ├── actility_eu868_netjoin.cpp │ ├── generic_in866_netjoin.cpp │ ├── swisscom_eu868_netjoin.cpp │ ├── actility_in866_netjoin.cpp │ ├── chirpstack_au915_netjoin.cpp │ ├── chirpstack_as923_netjoin.cpp │ ├── chirpstack_eu868_netjoin.cpp │ ├── chirpstack_in866_netjoin.cpp │ ├── ttn_au915_netjoin.cpp │ ├── generic_kr920_netjoin.cpp │ ├── actility_kr920_netjoin.cpp │ ├── chirpstack_kr920_netjoin.cpp │ ├── ttn_as923_netbeginregioninit.cpp │ ├── ttn_eu868_netbeginregioninit.cpp │ ├── ttn_in866_netbeginregioninit.cpp │ ├── ttn_kr920_netbeginregioninit.cpp │ ├── senra_in866_netbeginregioninit.cpp │ ├── generic_as923_netbeginregioninit.cpp │ ├── generic_eu868_netbeginregioninit.cpp │ ├── generic_in866_netbeginregioninit.cpp │ ├── generic_kr920_netbeginregioninit.cpp │ ├── actility_as923_netbeginregioninit.cpp │ ├── actility_eu868_netbeginregioninit.cpp │ ├── actility_in866_netbeginregioninit.cpp │ ├── actility_kr920_netbeginregioninit.cpp │ ├── swisscom_eu868_netbeginregioninit.cpp │ ├── chirpstack_as923_netbeginregioninit.cpp │ ├── chirpstack_eu868_netbeginregioninit.cpp │ ├── chirpstack_in866_netbeginregioninit.cpp │ ├── chirpstack_kr920_netbeginregioninit.cpp │ ├── helium_us915_netjoin.cpp │ ├── senet_us915_netbeginregioninit.cpp │ ├── ttn_us915_netbeginregioninit.cpp │ ├── machineq_us915_netbeginregioninit.cpp │ ├── ttn_as923_netjoin.cpp │ ├── ttn_in866_netjoin.cpp │ ├── machineq_base_netjoin.cpp │ ├── ttn_kr920_netjoin.cpp │ ├── GetRegionString.cpp │ ├── helium_us915_netbeginregioninit.cpp │ ├── generic_au915_netbeginregioninit.cpp │ ├── generic_us915_netbeginregioninit.cpp │ ├── ttn_us915_netjoin.cpp │ ├── actility_au915_netbeginregioninit.cpp │ ├── actility_us915_netbeginregioninit.cpp │ ├── chirpstack_au915_netbeginregioninit.cpp │ ├── chirpstack_us915_netbeginregioninit.cpp │ ├── ttn_base_netjoin.cpp │ ├── arduino_lorawan.cpp │ ├── machineq_us915_netjoin.cpp │ ├── ttn_eu868_netjoin.cpp │ ├── ttn_au915_netbeginregioninit.cpp │ ├── GetTxReady.cpp │ ├── LogPrintf.cpp │ ├── arduino_lorawan_cEventLog.cpp │ ├── SendBuffer.cpp │ └── arduino_lorawan_begin.cpp ├── Arduino_LoRaWAN_lmic.h ├── Arduino_LoRaWAN_Senra.h ├── Arduino_LoRaWAN_Swisscom.h ├── Arduino_LoRaWAN_Helium.h ├── Arduino_LoRaWAN_Senet.h ├── Arduino_LoRaWAN_machineQ.h ├── Arduino_LoRaWAN_network.h ├── Arduino_LoRaWAN_EventLog.h ├── Arduino_LoRaWAN_Generic.h ├── Arduino_LoRaWAN_ChirpStack.h ├── Arduino_LoRaWAN_Actility.h └── Arduino_LoRaWAN_ttn.h ├── .gitignore ├── library.properties ├── keywords.txt ├── library.json └── LICENSE /examples/arduino_lorawan_esp32_example/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/header_test/header_test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: header_test.ino 4 | 5 | Function: 6 | Simple hello-world (and compile-test) app 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | void setup() 19 | { 20 | } 21 | 22 | void loop() 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /examples/header_test_lmic/header_test_lmic.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: header_test_lmic.ino 4 | 5 | Function: 6 | Simple compile-test app for Arduino_LoRaWAN_lmic.h 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | void setup() 19 | { 20 | } 21 | 22 | void loop() 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/lib/GetRegion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: GetRegion.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::GetRegion() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation June 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | Arduino_LoRaWAN::Region 21 | Arduino_LoRaWAN::GetRegion(void) const 22 | { 23 | return Arduino_LoRaWAN::Region(CFG_region); 24 | } 25 | -------------------------------------------------------------------------------- /src/lib/GetCountryCode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: GetCountryCode.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::GetCountryCode() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation June 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | Arduino_LoRaWAN::CountryCode 21 | Arduino_LoRaWAN::GetCountryCode(void) const 22 | { 23 | return Arduino_LoRaWAN::CountryCode(LMIC_COUNTRY_CODE); 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | # Backup files 32 | *.BAK 33 | *.CKP 34 | 35 | # PlatformIO working dirs 36 | .pioenvs/ 37 | .piolibdeps/ 38 | 39 | # vscode 40 | .vscode/ 41 | -------------------------------------------------------------------------------- /examples/arduino_lorawan_esp32_example/secrets.h.template: -------------------------------------------------------------------------------- 1 | #define SECRETS 2 | 3 | // deveui, little-endian 4 | static const std::uint8_t deveui[] = { 0xAA, 0xBB, 0xCC, 0x00, 0x00, 0xDD, 0xEE, 0xFF }; 5 | 6 | // appeui, little-endian 7 | static const std::uint8_t appeui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 8 | 9 | // appkey: just a string of bytes, sometimes referred to as "big endian". 10 | static const std::uint8_t appkey[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }; 11 | -------------------------------------------------------------------------------- /examples/header_test_ttn/header_test_ttn.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: header_test_ttn.ino 4 | 5 | Function: 6 | Simple compile-test app for Arduino_LoRaWAN_ttn.h 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | // set up the data structures. 19 | Arduino_LoRaWAN_ttn myLoRaWAN {}; 20 | 21 | void setup() { 22 | myLoRaWAN.begin(); 23 | } 24 | 25 | void loop() { 26 | myLoRaWAN.loop(); 27 | } 28 | -------------------------------------------------------------------------------- /examples/header_test_network/header_test_network.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: header_test_ttn.ino 4 | 5 | Function: 6 | Simple compile-test app for Arduino_LoRaWAN_ttn.h 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | // set up the data structures. 19 | Arduino_LoRaWAN_network myLoRaWAN {}; 20 | 21 | void setup() { 22 | myLoRaWAN.begin(); 23 | } 24 | 25 | void loop() { 26 | myLoRaWAN.loop(); 27 | } 28 | -------------------------------------------------------------------------------- /src/lib/SetLinkCheckMode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: SetLinkCheckMode.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::SetLinkCheckMode() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation June 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | bool 21 | Arduino_LoRaWAN::SetLinkCheckMode(bool fEnable) 22 | { 23 | // remember current state. 24 | const bool result = LMIC.adrAckReq != LINK_CHECK_OFF; 25 | 26 | // set new state. 27 | LMIC_setLinkCheckMode(fEnable); 28 | return result; 29 | } 30 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=MCCI Arduino LoRaWAN Library 2 | version=0.10.0 3 | author=Terry Moore, ChaeHee Won 4 | maintainer=Terry Moore 5 | sentence=High-level library for LoRaWAN-based Arduino end-devices. 6 | paragraph=Implements many of the details of network interfacing and deployment, so that you can focus on your application rather than worrying about the network. Requires the arduino-lmic library from https://github.com/mcci-catena/ or The Things Network NY. 7 | category=Communication 8 | url=https://github.com/mcci-catena/arduino-lorawan/ 9 | architectures=* 10 | dot_a_linkage=true 11 | includes=Arduino_LoRaWAN.h 12 | depends=MCCI Arduino Development Kit ADK, MCCI LoRaWAN LMIC library 13 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ARDUINO_LORAWAN_PRINTF KEYWORD2 2 | Arduino_LoRaWAN KEYWORD1 3 | cLMIC KEYWORD1 4 | LOG_BASIC LITERAL1 5 | LOG_ERRORS LITERAL1 6 | LOG_VERBOSE LITERAL1 7 | kNone LITERAL1 8 | kAbp LITERAL1 9 | kOTAA LITERAL1 10 | AbpProvisioningInfo KEYWORD1 11 | OtaaProvisioningInfo KEYWORD1 12 | ProvisioningInfo KEYWORD1 13 | begin KEYWORD2 14 | loop KEYWORD2 15 | RegisterListener KEYWORD2 16 | DispatchEvent KEYWORD2 17 | GetDebugMask KEYWORD2 18 | SetDebugMask KEYWORD2 19 | LogPrintf KEYWORD2 20 | GetInstance KEYWORD2 21 | GetTxReady KEYWORD2 22 | SendBuffer KEYWORD2 23 | GetDevEUI KEYWORD2 24 | GetAppEUI KEYWORD2 25 | GetAppKey KEYWORD2 26 | Arduino_LoRaWAN_ttn_base KEYWORD1 27 | Arduino_LoRaWAN_ttn_eu868 KEYWORD1 28 | Arduino_LoRaWAN_ttn_as923 KEYWORD1 29 | Arduino_LoRaWAN_ttn_us915 KEYWORD1 30 | Arduino_LoRaWAN_REGION_TAG LITERAL1 31 | -------------------------------------------------------------------------------- /src/lib/arduino_lorawan_shutdown.cpp: -------------------------------------------------------------------------------- 1 | /* arduino_lorawan_shutdown.cpp Sat Mar 18 2017 00:50:33 tmm */ 2 | 3 | /* 4 | 5 | Module: arduino_lorawan_shutdown.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN::Shutdown() 9 | 10 | Version: 11 | V0.2.2 Sat Mar 18 2017 00:50:33 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.2.2 Sat Mar 18 2017 00:50:33 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | void Arduino_LoRaWAN::Shutdown(void) 39 | { 40 | LMIC_shutdown(); 41 | } 42 | -------------------------------------------------------------------------------- /src/lib/arduino_lorawan_loop.cpp: -------------------------------------------------------------------------------- 1 | /* arduino_lorawan_loop.cpp Sat Mar 18 2017 23:39:27 tmm */ 2 | 3 | /* 4 | 5 | Module: arduino_lorawan_loop.cpp 6 | 7 | Function: 8 | Handle processing for top-level loop() in sketch. 9 | 10 | Version: 11 | V0.2.2 Sat Mar 18 2017 23:39:27 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 17:05:50 tmm 30 | Module created. 31 | 32 | 0.2.2 Sat Mar 18 2017 23:39:27 tmm 33 | Renamed to match standards. 34 | 35 | */ 36 | 37 | #include 38 | #include 39 | 40 | void Arduino_LoRaWAN::loop() 41 | { 42 | os_runloop_once(); 43 | } 44 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MCCI Arduino LoRaWAN Library", 3 | "keywords": "ttn, lora, the things network, lorawan, helium, chirpstack", 4 | "description": "High-level library for LoRaWAN-based Arduino end-devices", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/mcci-catena/arduino-lorawan" 9 | }, 10 | "authors": 11 | [ 12 | { 13 | "name": "Terry Moore", 14 | "email": "tmm@mcci.com", 15 | "maintainer": true 16 | }, 17 | { 18 | "name": "ChaeHee Won" 19 | } 20 | ], 21 | "dependencies": 22 | [ 23 | { 24 | "name": "MCCI LoRaWAN LMIC library", 25 | "version": "https://github.com/mcci-catena/arduino-lmic.git", 26 | "authors": ["Matthijs Kooijman ", "Terry Moore "] 27 | }, 28 | { 29 | "name": "MCCI Arduino Development Kit ADK", 30 | "version": "https://github.com/mcci-catena/Catena-mcciadk.git", 31 | "authors": ["Terry Moore "] 32 | } 33 | ], 34 | "version": "0.10.0", 35 | "frameworks": "arduino", 36 | "platforms": "*" 37 | } 38 | -------------------------------------------------------------------------------- /src/lib/senra_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senra_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senra_base::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Senra_base::NetJoin() 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/generic_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_base::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Generic_base::NetJoin() 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/actility_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_base::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Actility_base::NetJoin() 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/swisscom_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: swisscom_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Swisscom_base::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Swisscom_base::NetJoin() 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/chirpstack_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_base::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_ChirpStack_base::NetJoin() 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2023 MCCI Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/generic_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_us915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_us915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_Generic_us915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/actility_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_us915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_us915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_Actility_us915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/senet_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senet_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senet_base::NetJoin() 7 | 8 | Copyright notice and License Information: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Senet_base::NetJoin() 43 | { 44 | // nothing special for Senet. 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/helium_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: helium_base_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Helium_base::NetJoin() 7 | 8 | Copyright notice and License Information: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Helium_base::NetJoin() 43 | { 44 | // nothing special for Helium. 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/chirpstack_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_us915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_us915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_ChirpStack_us915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/generic_au915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_au915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_au915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_Generic_au915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/senet_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senet_us915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senet_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_Senet_us915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/senra_in866_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senra_in866_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senra_in866::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Senra_in866::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/actility_au915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_au915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_au915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_Actility_au915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/generic_as923_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_as923_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_as923::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Generic_as923::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/generic_eu868_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_eu868_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_eu868::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Generic_eu868::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/actility_as923_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_as923_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_as923::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Actility_as923::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/actility_eu868_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_eu868_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_eu868::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Actility_eu868::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/generic_in866_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_in866_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_in866::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Generic_in866::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/swisscom_eu868_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: swisscom_eu868_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Swisscom_eu868::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Swisscom_eu868::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/actility_in866_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_in866_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_in866::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_Actility_in866::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/chirpstack_au915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_au915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_au915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | void Arduino_LoRaWAN_ChirpStack_au915::NetJoin() 42 | { 43 | // do the common work. 44 | this->Super::NetJoin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/lib/chirpstack_as923_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_as923_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_as923::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_ChirpStack_as923::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/chirpstack_eu868_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_eu868_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_eu868::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_ChirpStack_eu868::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/chirpstack_in866_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_in866_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_in866::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | void Arduino_LoRaWAN_ChirpStack_in866::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/ttn_au915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_au915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_au915::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation August 2017 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | #if defined(CFG_au915) 42 | void Arduino_LoRaWAN_ttn_au915::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | #endif // defined(CFG_au915) 48 | -------------------------------------------------------------------------------- /src/lib/generic_kr920_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_kr920_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_kr920::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_kr920::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/actility_kr920_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_kr920_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_kr920::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_kr920::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/chirpstack_kr920_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_kr920_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_kr920::NetJoin() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_kr920::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | } 47 | -------------------------------------------------------------------------------- /src/lib/ttn_as923_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_as923_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_as923::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation November 2016 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ttn_as923::NetBeginRegionInit() 43 | { 44 | // 45 | // for as923, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/ttn_eu868_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_eu868_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_eu868::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation November 2016 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ttn_eu868::NetBeginRegionInit() 43 | { 44 | // 45 | // for eu868, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/ttn_in866_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_in866_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_in866::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation November 2016 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ttn_in866::NetBeginRegionInit() 43 | { 44 | // 45 | // for in866, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/ttn_kr920_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_kr920_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_kr920::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation November 2016 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ttn_kr920::NetBeginRegionInit() 43 | { 44 | // 45 | // for kr920, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/senra_in866_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senra_in866_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senra_in866::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Senra_in866::NetBeginRegionInit() 43 | { 44 | // 45 | // for in866, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/generic_as923_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_as923_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_as923::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_as923::NetBeginRegionInit() 43 | { 44 | // 45 | // for as923, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/generic_eu868_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_eu868_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_eu868::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_eu868::NetBeginRegionInit() 43 | { 44 | // 45 | // for eu868, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/generic_in866_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_in866_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_in866::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_in866::NetBeginRegionInit() 43 | { 44 | // 45 | // for in866, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/generic_kr920_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_kr920_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_kr920::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_kr920::NetBeginRegionInit() 43 | { 44 | // 45 | // for kr920, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/actility_as923_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_as923_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_as923::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_as923::NetBeginRegionInit() 43 | { 44 | // 45 | // for as923, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/actility_eu868_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_eu868_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_eu868::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_eu868::NetBeginRegionInit() 43 | { 44 | // 45 | // for eu868, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/actility_in866_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_in866_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_in866::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_in866::NetBeginRegionInit() 43 | { 44 | // 45 | // for in866, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/actility_kr920_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_kr920_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_kr920::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_kr920::NetBeginRegionInit() 43 | { 44 | // 45 | // for kr920, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/swisscom_eu868_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: swisscom_eu868_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Swisscom_eu868::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Swisscom_eu868::NetBeginRegionInit() 43 | { 44 | // 45 | // for eu868, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/chirpstack_as923_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_as923_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_as923::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_as923::NetBeginRegionInit() 43 | { 44 | // 45 | // for as923, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/chirpstack_eu868_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_eu868_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_eu868::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_eu868::NetBeginRegionInit() 43 | { 44 | // 45 | // for eu868, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/chirpstack_in866_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_in866_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_in866::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_in866::NetBeginRegionInit() 43 | { 44 | // 45 | // for in866, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/chirpstack_kr920_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_kr920_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_kr920::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_kr920::NetBeginRegionInit() 43 | { 44 | // 45 | // for kr920, we don't need to do any special setup. 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /src/lib/helium_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: helium_us915_netjoin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Helium_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | #if defined(CFG_us915) 42 | void Arduino_LoRaWAN_Helium_us915::NetJoin() 43 | { 44 | // do the common work. 45 | this->Super::NetJoin(); 46 | 47 | // Helium is bog standard, and our DNW2 value is already right. 48 | } 49 | #endif // defined(CFG_us915) 50 | -------------------------------------------------------------------------------- /src/lib/senet_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: senet_us915_netbegin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Senet_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Senet_us915::NetBeginRegionInit() 43 | { 44 | // 45 | // Senet suggests either subband 0 for joins or all 64 channels. 46 | // 47 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1) 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | #endif 50 | } 51 | -------------------------------------------------------------------------------- /src/lib/ttn_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_us915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation November 2016 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | #ifdef CFG_us915 43 | void Arduino_LoRaWAN_ttn_us915::NetBeginRegionInit() 44 | { 45 | // Set data rate and transmit power 46 | // DR_SF7 is US DR3; 21 means 21 dBm 47 | 48 | LMIC_setDrTxpow(US915_DR_SF7, 21); 49 | 50 | // Select SubBand prejoin -- saves power for joining 51 | // This is specific to the US915 bandplan. 52 | cLMIC::SelectSubBand( 53 | cLMIC::SubBand::SubBand_2 // must align with subband on gateway. 54 | ); 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/lib/machineq_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* machineq_us915_netbeginregioninit.cpp Fri May 19 2017 23:58:34 tmm */ 2 | 3 | /* 4 | 5 | Module: machineq_us915_netbegin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_machineQ_us915::NetBeginRegionInit() 9 | 10 | Copyright notice: 11 | See LICENSE file accompanying this project. 12 | 13 | Author: 14 | Terry Moore, MCCI Corporation June 2018 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | /****************************************************************************\ 22 | | 23 | | Manifest constants & typedefs. 24 | | 25 | \****************************************************************************/ 26 | 27 | 28 | 29 | /****************************************************************************\ 30 | | 31 | | Read-only data. 32 | | 33 | \****************************************************************************/ 34 | 35 | 36 | 37 | /****************************************************************************\ 38 | | 39 | | Variables. 40 | | 41 | \****************************************************************************/ 42 | 43 | // protected virtual 44 | #ifdef CFG_us915 45 | void Arduino_LoRaWAN_machineQ_us915::NetBeginRegionInit() 46 | { 47 | // 48 | // machineQ is a 64-channel network. So we don't select 49 | // a subband. 50 | // 51 | // Set data rate and transmit power -- these ought to 52 | // be the defaults in lmic, but it's quicker to just 53 | // set them here. 54 | LMIC_setDrTxpow(US915_DR_SF10, 21); 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/lib/ttn_as923_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_as923_netjoin.cpp Mon Aug 07 2017 00:41:05 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_as923_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_as923::NetJoin() 9 | 10 | Version: 11 | V0.2.4 Fri May 19 2017 23:58:34 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation August 2017 27 | 28 | Revision history: 29 | 0.2.4 Mon Aug 07 2017 00:41:05 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | void Arduino_LoRaWAN_ttn_as923::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | } 65 | -------------------------------------------------------------------------------- /src/lib/ttn_in866_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_in866_netjoin.cpp Mon Aug 07 2017 00:41:05 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_in866_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_in866::NetJoin() 9 | 10 | Version: 11 | V0.2.4 Mon Aug 07 2017 00:41:05 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation August 2017 27 | 28 | Revision history: 29 | 0.2.4 Mon Aug 07 2017 00:41:05 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | void Arduino_LoRaWAN_ttn_in866::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | } 65 | -------------------------------------------------------------------------------- /src/lib/machineq_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* machineq_base_netjoin.cpp Tue Nov 1 2016 06:19:25 tmm */ 2 | 3 | /* 4 | 5 | Module: machineq_base_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_machineQ_base::NetJoin() 9 | 10 | Version: 11 | V0.2.0 Tue Nov 1 2016 06:19:25 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.2.0 Tue Nov 1 2016 06:19:25 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | void Arduino_LoRaWAN_machineQ_base::NetJoin() 61 | { 62 | // nothing special for machineQ. 63 | } 64 | -------------------------------------------------------------------------------- /src/lib/ttn_kr920_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_kr920_netjoin.cpp Mon Aug 07 2017 00:41:05 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_kr920_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_kr920::NetJoin() 9 | 10 | Version: 11 | V0.2.4 Mon Aug 07 2017 00:41:05 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation August 2017 27 | 28 | Revision history: 29 | 0.2.4 Mon Aug 07 2017 00:41:05 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | // protected virtual 60 | void Arduino_LoRaWAN_ttn_kr920::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | } 65 | -------------------------------------------------------------------------------- /src/lib/GetRegionString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: GetRegionString.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::GetRegionString() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation June 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | const char * 22 | Arduino_LoRaWAN::GetRegionString(char *pBuf, size_t nBuf) const 23 | { 24 | if (pBuf == nullptr || nBuf == 0) 25 | { 26 | static const char sNull[] = "<>"; 27 | return sNull; 28 | } 29 | 30 | const char *pString; 31 | 32 | switch (CFG_region) 33 | { 34 | case LMIC_REGION_eu868: pString = "eu868"; break; 35 | case LMIC_REGION_us915: pString = "us915"; break; 36 | case LMIC_REGION_cn783: pString = "cn783"; break; 37 | case LMIC_REGION_eu433: pString = "eu433"; break; 38 | case LMIC_REGION_au915: pString = "au915"; break; 39 | case LMIC_REGION_cn490: pString = "cn490"; break; 40 | case LMIC_REGION_as923: 41 | if (LMIC_COUNTRY_CODE == LMIC_COUNTRY_CODE_JP) 42 | pString = "as923jp"; 43 | else 44 | pString = "as923"; 45 | break; 46 | case LMIC_REGION_kr920: pString = "kr920"; break; 47 | case LMIC_REGION_in866: pString = "in866"; break; 48 | default: pString = "<>"; break; 49 | } 50 | 51 | (void) McciAdkLib_SafeCopyString(pBuf, nBuf, 0, pString); 52 | return pBuf; 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/helium_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: helium_us915_netbegin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Helium_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | #ifdef CFG_us915 43 | void Arduino_LoRaWAN_Helium_us915::NetBeginRegionInit() 44 | { 45 | // 46 | // Helium is an 8-channel network on subband 1 of [0..7]. Pre-join 47 | // we therefore want to limit to probing channels 8~15 / 65. 48 | // 49 | cLMIC::SelectSubBand(cLMIC::SubBand::SubBand_2); 50 | 51 | // 52 | // Set data rate and transmit power -- these ought to 53 | // be the defaults in lmic, but it's quicker to just 54 | // set them here. All this gets overridden post join, anyway. 55 | // 56 | LMIC_setDrTxpow(US915_DR_SF10, 21); 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /src/lib/generic_au915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_au915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_au915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_au915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the AU915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_GENERIC && defined(CFG_au915) 50 | # error "Subband out of range for AU915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/generic_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: generic_us915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Generic_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Generic_us915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the US915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_GENERIC && defined(CFG_us915) 50 | # error "Subband out of range for US915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/ttn_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_us915_netjoin.cpp Sat Mar 11 2017 18:42:29 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_us915_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_us915::NetJoin() 9 | 10 | Version: 11 | V0.2.2 Sat Mar 11 2017 18:42:29 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.2.0 Tue Nov 1 2016 06:19:25 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | #if defined(CFG_us915) 60 | void Arduino_LoRaWAN_ttn_us915::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | } 65 | #endif // defined(CFG_us915) 66 | -------------------------------------------------------------------------------- /src/lib/actility_au915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_au915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_au915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_au915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the AU915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_ACTILITY && defined(CFG_au915) 50 | # error "Subband out of range for AU915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/actility_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: actility_us915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_Actility_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_Actility_us915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the US915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_ACTILITY && defined(CFG_us915) 50 | # error "Subband out of range for US915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/chirpstack_au915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_au915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_au915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_au915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the AU915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK && defined(CFG_au915) 50 | # error "Subband out of range for AU915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/chirpstack_us915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: chirpstack_us915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ChirpStack_us915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | void Arduino_LoRaWAN_ChirpStack_us915::NetBeginRegionInit() 43 | { 44 | // Select SubBand prejoin -- saves power for joining 45 | // This is specific to the US915 bandplan. 46 | #if defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 47 | # if 0 <= ARDUINO_LMIC_CFG_SUBBAND && ARDUINO_LMIC_CFG_SUBBAND < 8 48 | LMIC_selectSubBand(ARDUINO_LMIC_CFG_SUBBAND); 49 | # elif ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK && defined(CFG_us915) 50 | # error "Subband out of range for US915" 51 | # endif 52 | #endif // defined(ARDUINO_LMIC_CFG_SUBBAND) && ARDUINO_LMIC_CFG_SUBBAND != -1 53 | } 54 | -------------------------------------------------------------------------------- /src/lib/ttn_base_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_base_netjoin.cpp Tue Nov 1 2016 06:19:25 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_base_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_base::NetJoin() 9 | 10 | Version: 11 | V0.2.0 Tue Nov 1 2016 06:19:25 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.2.0 Tue Nov 1 2016 06:19:25 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | void Arduino_LoRaWAN_ttn_base::NetJoin() 61 | { 62 | // we don't want to disable link-check mode on 63 | // current TTN networks with the current LMIC. 64 | // LMIC_setLinkCheckMode(0); 65 | } 66 | -------------------------------------------------------------------------------- /src/lib/arduino_lorawan.cpp: -------------------------------------------------------------------------------- 1 | /* arduino_lorawan.cpp Tue Oct 25 2016 03:59:08 tmm */ 2 | 3 | /* 4 | 5 | Module: arduino_lorawan.cpp 6 | 7 | Function: 8 | Constructor: Arduino_LoRaWAN::Arduino_LoRaWAN() 9 | 10 | Version: 11 | V0.1.0 Tue Oct 25 2016 03:59:08 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 03:59:08 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | 36 | /****************************************************************************\ 37 | | 38 | | Manifest constants & typedefs. 39 | | 40 | \****************************************************************************/ 41 | 42 | 43 | 44 | /****************************************************************************\ 45 | | 46 | | Read-only data. 47 | | 48 | \****************************************************************************/ 49 | 50 | 51 | /****************************************************************************\ 52 | | 53 | | Variables. 54 | | 55 | \****************************************************************************/ 56 | 57 | 58 | /****************************************************************************\ 59 | | 60 | | Code. 61 | | 62 | \****************************************************************************/ 63 | 64 | 65 | Arduino_LoRaWAN::Arduino_LoRaWAN() 66 | { 67 | } 68 | -------------------------------------------------------------------------------- /src/lib/machineq_us915_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* machineq_us915_netjoin.cpp Sat Mar 11 2017 18:42:29 tmm */ 2 | 3 | /* 4 | 5 | Module: machineq_us915_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_machineQ_us915::NetJoin() 9 | 10 | Version: 11 | V0.2.2 Sat Mar 11 2017 18:42:29 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.2.0 Tue Nov 1 2016 06:19:25 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | #if defined(CFG_us915) 60 | void Arduino_LoRaWAN_machineQ_us915::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | 65 | // machineQ is bog standard, and our DNW2 value is already right. 66 | } 67 | #endif // defined(CFG_us915) 68 | -------------------------------------------------------------------------------- /src/lib/ttn_eu868_netjoin.cpp: -------------------------------------------------------------------------------- 1 | /* ttn_eu868_netjoin.cpp Fri May 19 2017 23:58:34 tmm */ 2 | 3 | /* 4 | 5 | Module: ttn_eu868_netjoin.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN_ttn_eu868::NetJoin() 9 | 10 | Version: 11 | V0.2.3 Fri May 19 2017 23:58:34 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation May 2017 27 | 28 | Revision history: 29 | 0.2.3 Fri May 19 2017 23:58:34 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | void Arduino_LoRaWAN_ttn_eu868::NetJoin() 61 | { 62 | // do the common work. 63 | this->Super::NetJoin(); 64 | 65 | // then, for EU, if ABP, set the RX2 data rate, which is non-standard. 66 | // for OTAA, just do what we're told. 67 | if (this->GetProvisioningStyle() == this->ProvisioningStyle::kABP) 68 | LMIC.dn2Dr = LORAWAN_DR3; // this is SF9. 69 | } 70 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_lmic.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_lmic.h 4 | 5 | Function: 6 | Wrapper header file for LMIC internals. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation October 2016 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_LMIC_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_LMIC_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUINO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #include 26 | 27 | #if ! (defined(ARDUINO_LMIC_VERSION) && defined(ARDUINO_LMIC_VERSION_COMPARE_GE)) 28 | # error lmic library is out of date. Check ARDUINO_LMIC_VERSION. 29 | #elif ARDUINO_LMIC_VERSION_COMPARE_LT(ARDUINO_LMIC_VERSION, ARDUINO_LMIC_VERSION_CALC(3,99,0,2)) 30 | # error lmic library is out of date. Check ARDUINO_LMIC_VERSION. 31 | #endif 32 | 33 | class Arduino_LoRaWAN::cLMIC 34 | { 35 | public: 36 | enum class SubBand 37 | { 38 | SubBand_1 = 0, 39 | SubBand_2, 40 | SubBand_3, 41 | SubBand_4, 42 | SubBand_5, 43 | SubBand_6, 44 | SubBand_7, 45 | SubBand_8 46 | }; 47 | 48 | static inline void SelectSubBand(SubBand subBand) 49 | { 50 | #if CFG_LMIC_US_like 51 | LMIC_selectSubBand( 52 | static_cast(subBand) 53 | ); 54 | #else 55 | /* nothing */ 56 | #endif 57 | } 58 | 59 | static const char *GetEventName(uint32_t ev); 60 | }; 61 | 62 | /* the usual macro-based table for the strings. should be in lmic.h */ 63 | #define ARDUINO_LORAWAN_LMIC_EV_NAMES__BASE EV_SCAN_TIMEOUT 64 | 65 | #define ARDUINO_LORAWAN_LMIC_EV_NAMES_MZ__INIT \ 66 | "SCAN_TIMEOUT\0" "BEACON_FOUND\0" "BEACON_MISSED\0" \ 67 | "BEACON_TRACKED\0" "JOINING\0" "JOINED\0" "RFU1\0" \ 68 | "JOIN_FAILED\0" "REJOIN_FAILED\0" "TXCOMPLETE\0" \ 69 | "LOST_TSYNC\0" "RESET\0" "RXCOMPLETE\0" "LINK_DEAD\0" \ 70 | "LINK_ALIVE\0" "SCAN_FOUND\0" "TXSTART\0" \ 71 | "TXCANCELED\0" "RXSTART\0" "JOIN_TXCOMPLETE\0" 72 | 73 | /**** end of Arduino_LoRaWAN_lmic.h ****/ 74 | #endif /* _ARDUINO_LORAWAN_LMIC_H_ */ 75 | -------------------------------------------------------------------------------- /src/lib/ttn_au915_netbeginregioninit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: ttn_au915_netbeginregioninit.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN_ttn_au915::NetBeginRegionInit() 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation August 2017 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | /****************************************************************************\ 20 | | 21 | | Manifest constants & typedefs. 22 | | 23 | \****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Variables. 38 | | 39 | \****************************************************************************/ 40 | 41 | // protected virtual 42 | #ifdef CFG_au915 43 | void Arduino_LoRaWAN_ttn_au915::NetBeginRegionInit() 44 | { 45 | // Set data rate and transmit power 46 | // DR_SF7 is US DR3; 14 means 14 dBm 47 | 48 | // XXX (tmm@mcci.com) although LMIC.adrTxpow is set to 30, it's 49 | // never used inside the LMIC library. This is because LMIC's radio.c uses 50 | // LMIC.txpow, and in US-like, lmic.c::updatetx() sets LMIC.txpow to 30 51 | // for 125kHz channels, and 26 for 500kHz channels, ignoring 52 | // LMIC.adrTxpow. Then radio.c limits to the value for 10 dBm, and 53 | // apparently doesn't even turn on the +20 dBm option if over 10 dBm. 54 | // Really, this step should be eliminated and the library should do the 55 | // right thing at join time. 56 | LMIC_setDrTxpow(AU915_DR_SF7, 30); 57 | 58 | // Select SubBand prejoin -- saves power for joining 59 | // This is specific to the AU923 bandplan. 60 | cLMIC::SelectSubBand( 61 | cLMIC::SubBand::SubBand_2 // must align with subband on gateway. 62 | ); 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /src/lib/GetTxReady.cpp: -------------------------------------------------------------------------------- 1 | /* GetTxReady.cpp Tue Oct 25 2016 17:31:33 tmm */ 2 | 3 | /* 4 | 5 | Module: GetTxReady.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN::GetTxReady() 9 | 10 | Version: 11 | V0.1.0 Tue Oct 25 2016 17:31:33 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 17:31:33 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | /****************************************************************************\ 39 | | 40 | | Manifest constants & typedefs. 41 | | 42 | \****************************************************************************/ 43 | 44 | 45 | 46 | /****************************************************************************\ 47 | | 48 | | Read-only data. 49 | | 50 | \****************************************************************************/ 51 | 52 | 53 | 54 | /****************************************************************************\ 55 | | 56 | | Variables. 57 | | 58 | \****************************************************************************/ 59 | 60 | /* 61 | 62 | Name: Arduino_LoRaWAN::GetTxReady() 63 | 64 | Function: 65 | Return TRUE if the LMIC can accept a transmit operation. 66 | 67 | Definition: 68 | public bool Arduino_LoRaWAN::GetTxReady() const; 69 | 70 | Description: 71 | If the LMIC is already processing a message, or if there's 72 | a message in the Arduino_LoRaWAN queue being processed, 73 | then transmit is not ready. Otherwise, transmit is ready. 74 | 75 | Returns: 76 | true if ready for a message, false otherwise. 77 | 78 | */ 79 | 80 | bool Arduino_LoRaWAN::GetTxReady() const 81 | { 82 | if (LMIC.opmode & OP_TXRXPEND) 83 | return false; 84 | else 85 | return ! this->m_SendBufferData.fTxPending; 86 | } 87 | -------------------------------------------------------------------------------- /examples/simple/simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: simple.ino 4 | 5 | Function: 6 | Example app matching the documentation in the project 7 | README.md, showing how to use built-in LMIC configuration. 8 | 9 | Copyright notice and License: 10 | See LICENSE file accompanying this project. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation November 2018 14 | 15 | Notes: 16 | This app is not complete -- it only presents skeleton 17 | code for the methods you must provide in order to 18 | use this library. However, it compiles! 19 | 20 | */ 21 | 22 | #include 23 | 24 | class cMyLoRaWAN : public Arduino_LoRaWAN_network { 25 | public: 26 | cMyLoRaWAN() {}; 27 | 28 | protected: 29 | // you'll need to provide implementation for this. 30 | virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override; 31 | // if you have persistent storage, you can provide implementations for these: 32 | virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override; 33 | virtual void NetSaveSessionState(const SessionState &State) override; 34 | virtual bool NetGetSessionState(SessionState &State) override; 35 | }; 36 | 37 | // set up the data structures. 38 | cMyLoRaWAN myLoRaWAN {}; 39 | 40 | void setup() { 41 | // simply call begin() w/o parameters, and the LMIC's built-in 42 | // configuration for this board will be used. 43 | myLoRaWAN.begin(); 44 | } 45 | 46 | void loop() { 47 | myLoRaWAN.loop(); 48 | } 49 | 50 | // this method is called when the LMIC needs OTAA info. 51 | // return false to indicate "no provisioning", otherwise 52 | // fill in the data and return true. 53 | bool 54 | cMyLoRaWAN::GetOtaaProvisioningInfo( 55 | OtaaProvisioningInfo *pInfo 56 | ) { 57 | return false; 58 | } 59 | 60 | void 61 | cMyLoRaWAN::NetSaveSessionInfo( 62 | const SessionInfo &Info, 63 | const uint8_t *pExtraInfo, 64 | size_t nExtraInfo 65 | ) { 66 | // save Info somewhere. 67 | } 68 | 69 | 70 | void 71 | cMyLoRaWAN::NetSaveSessionState(const SessionState &State) { 72 | // save State somwwhere. Note that it's often the same; 73 | // often only the frame counters change. 74 | } 75 | 76 | bool 77 | cMyLoRaWAN::NetGetSessionState(SessionState &State) { 78 | // either fetch SessionState from somewhere and return true or... 79 | return false; 80 | } 81 | -------------------------------------------------------------------------------- /src/lib/LogPrintf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: LogPrintf.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::LogPrintf() 7 | 8 | Copyright notice: 9 | This file copyright (C) 2016, 2019 by 10 | 11 | MCCI Corporation 12 | 3520 Krums Corners Road 13 | Ithaca, NY 14850 14 | 15 | An unpublished work. All rights reserved. 16 | 17 | See accompanying LICENSE file. 18 | 19 | Author: 20 | Terry Moore, MCCI Corporation November 2016 21 | 22 | */ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | // Some Adafruit BSPs implement Serial.dtr(), which immediately returns true if 32 | // the USB port is connected and enabled. Others don't. If Serial.dtr() is provided, 33 | // we want to use it; if not, we want to fall back to the boolean approach (!! Serial). 34 | // 35 | // To do this, we use the approach given by https://stackoverflow.com/questions/87372/check-if-a-class-has-a-member-function-of-a-given-signature; 36 | // a pair of templates are given, only one of which will actually be implemented, based 37 | // on whether dtr() is a valid method. 38 | // 39 | // This first template will tell us if a given type has a dtr() method. 40 | // it works because "substitution failure is not an error". 41 | template 42 | struct HasDtrMethod 43 | { 44 | template struct SFINAE {}; 45 | template static char Test(SFINAE*); 46 | template static int Test(...); 47 | static const bool Has = sizeof(Test(0)) == sizeof(char); 48 | }; 49 | 50 | // this template will be instantiated if we discover that TMap has 51 | // a dtr() method. 52 | template 53 | static bool CheckDtrConcrete(TMap& m, std::true_type) 54 | { 55 | // We may call dtr() on m here. 56 | return m.dtr(); 57 | } 58 | 59 | // this template will be instantiated if we discover that TMap lacks 60 | // a dtr() method. 61 | template 62 | static bool CheckDtrConcrete(TMap& m, std::false_type) 63 | { 64 | // if no dtr() method, just do the boolean trick. 65 | return !!m; 66 | } 67 | 68 | // this template expands to the appropriate version of the specific 69 | // CheckDtr function. 70 | template 71 | static bool CheckDtr(TMap& m) 72 | { 73 | return CheckDtrConcrete( 74 | m, 75 | std::integral_constant::Has>() 76 | ); 77 | } 78 | 79 | void 80 | Arduino_LoRaWAN::LogPrintf( 81 | const char *fmt, 82 | ... 83 | ) 84 | { 85 | if (! CheckDtr(Serial)) 86 | return; 87 | 88 | char buf[128]; 89 | va_list ap; 90 | 91 | va_start(ap, fmt); 92 | (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap); 93 | va_end(ap); 94 | 95 | // in case we overflowed: 96 | buf[sizeof(buf) - 1] = '\0'; 97 | if (CheckDtr(Serial)) Serial.print(buf); 98 | } 99 | -------------------------------------------------------------------------------- /examples/simple_feather/simple_feather.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: simple_feather.ino 4 | 5 | Function: 6 | Example app matching the documentation in the project 7 | README.md, showing how to configure a board explicitly 8 | 9 | Copyright notice and License: 10 | See LICENSE file accompanying this project. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation November 2018 14 | 15 | Notes: 16 | This app is not complete -- it only presents skeleton 17 | code for the methods you must provide in order to 18 | use this library. However, it compiles! 19 | 20 | */ 21 | 22 | #include 23 | 24 | class cMyLoRaWAN : public Arduino_LoRaWAN_ttn { 25 | public: 26 | cMyLoRaWAN() {}; 27 | 28 | protected: 29 | // you'll need to provide implementation for this. 30 | virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override; 31 | // if you have persistent storage, you can provide implementations for these: 32 | virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override; 33 | virtual void NetSaveSessionState(const SessionState &State) override; 34 | virtual bool NetGetSessionState(SessionState &State) override; 35 | }; 36 | 37 | // set up the data structures. 38 | cMyLoRaWAN myLoRaWAN {}; 39 | 40 | // The pinmap. This form is convenient if the LMIC library 41 | // doesn't support your board and you don't want to add the 42 | // configuration to the library (perhaps you're just testing). 43 | // This pinmap matches the FeatherM0 LoRa. See the arduino-lmic 44 | // docs for more info on how to set this up. 45 | const cMyLoRaWAN::lmic_pinmap myPinMap = { 46 | .nss = 8, 47 | .rxtx = cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN, 48 | .rst = 4, 49 | .dio = { 3, 6, cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN }, 50 | .rxtx_rx_active = 0, 51 | .rssi_cal = 0, 52 | .spi_freq = 8000000, 53 | }; 54 | 55 | void setup() { 56 | // simply pass the pinmap to the begin() method. 57 | myLoRaWAN.begin(myPinMap); 58 | } 59 | 60 | void loop() { 61 | myLoRaWAN.loop(); 62 | } 63 | 64 | // this method is called when the LMIC needs OTAA info. 65 | // return false to indicate "no provisioning", otherwise 66 | // fill in the data and return true. 67 | bool 68 | cMyLoRaWAN::GetOtaaProvisioningInfo( 69 | OtaaProvisioningInfo *pInfo 70 | ) { 71 | return false; 72 | } 73 | 74 | void 75 | cMyLoRaWAN::NetSaveSessionInfo( 76 | const SessionInfo &Info, 77 | const uint8_t *pExtraInfo, 78 | size_t nExtraInfo 79 | ) { 80 | // save Info somewhere. 81 | } 82 | 83 | void 84 | cMyLoRaWAN::NetSaveSessionState(const SessionState &State) { 85 | // save State somwwhere. Note that it's often the same; 86 | // often only the frame counters change. 87 | } 88 | 89 | bool 90 | cMyLoRaWAN::NetGetSessionState(SessionState &State) { 91 | // either fetch SessionState from somewhere and return true or... 92 | return false; 93 | } 94 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Senra.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Senra.h 4 | 5 | Function: 6 | LoRaWAN network object for Senra. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_SENRA_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_SENRA_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUNIO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #ifndef _MCCIADK_ENV_H_ 26 | # include 27 | #endif 28 | 29 | #if !defined(PLATFORMIO) 30 | /* this is a bit of a hack, but... */ 31 | /* make sure we have the config variables in scope */ 32 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 33 | # include 34 | #endif 35 | 36 | class Arduino_LoRaWAN_Senra_base : public Arduino_LoRaWAN 37 | { 38 | public: 39 | Arduino_LoRaWAN_Senra_base() {}; 40 | using Super = Arduino_LoRaWAN; 41 | static constexpr NetworkID_t NetworkID = NetworkID_t::Senra; 42 | 43 | virtual const char *GetNetworkName() const override 44 | { 45 | return NetworkID_t_GetName(NetworkID); 46 | }; 47 | 48 | virtual NetworkID_t GetNetworkID() const override 49 | { 50 | return NetworkID; 51 | } 52 | 53 | protected: 54 | // Handle common NetJoin() operations for the network. 55 | virtual void NetJoin(); 56 | 57 | private: 58 | }; 59 | 60 | class Arduino_LoRaWAN_Senra_in866 : public Arduino_LoRaWAN_Senra_base 61 | { 62 | public: 63 | using Super = Arduino_LoRaWAN_Senra_base; 64 | Arduino_LoRaWAN_Senra_in866() {}; 65 | 66 | protected: 67 | // the NetBeginInit() function does specific work when starting 68 | // up. 69 | virtual void NetBeginRegionInit(); 70 | 71 | // Implement the NetJoin() operations for as923 72 | virtual void NetJoin(); 73 | 74 | private: 75 | }; 76 | 77 | #if defined(CFG_in866) 78 | # define Arduino_LoRaWAN_REGION_TAG in866 79 | #elif ARDUINO_LMIC_CFG_NETWORK_SENRA 80 | # error "Can't define Arduino_LoRaWAN_REGION_TAG: region not supported for Senra" 81 | #else 82 | // just ignore. 83 | #endif 84 | 85 | #define Arduino_LoRaWAN_Senra_LOCAL_(Region) \ 86 | Arduino_LoRaWAN_Senra_ ## Region 87 | 88 | #define Arduino_LoRaWAN_Senra_LOCAL(Region) \ 89 | Arduino_LoRaWAN_Senra_LOCAL_(Region) 90 | 91 | // 92 | // This header file might get compiled all the time ... and it's not 93 | // an error to have a region other than IN, unless we're actually targeting 94 | // Senra. So we just don't define Arduino_LoRaWAN_Senra unless we 95 | // have a valid region tag. 96 | // 97 | #if defined(Arduino_LoRaWAN_REGION_TAG) 98 | 99 | class Arduino_LoRaWAN_Senra : public Arduino_LoRaWAN_Senra_LOCAL(Arduino_LoRaWAN_REGION_TAG) 100 | { 101 | public: 102 | using Super = Arduino_LoRaWAN_Senra_LOCAL(Arduino_LoRaWAN_REGION_TAG); 103 | Arduino_LoRaWAN_Senra() {}; 104 | 105 | private: 106 | }; 107 | 108 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 109 | 110 | /**** end of Arduino_LoRaWAN_Senra.h ****/ 111 | #endif /* _ARDUINO_LORAWAN_SENRA_H_ */ 112 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Swisscom.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Swisscom.h 4 | 5 | Function: 6 | LoRaWAN network object for Swisscom. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_SWISSCOM_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_SWISSCOM_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUNIO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #ifndef _MCCIADK_ENV_H_ 26 | # include 27 | #endif 28 | 29 | #if !defined(PLATFORMIO) 30 | /* this is a bit of a hack, but... */ 31 | /* make sure we have the config variables in scope */ 32 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 33 | # include 34 | #endif 35 | 36 | class Arduino_LoRaWAN_Swisscom_base : public Arduino_LoRaWAN 37 | { 38 | public: 39 | Arduino_LoRaWAN_Swisscom_base() {}; 40 | using Super = Arduino_LoRaWAN; 41 | static constexpr NetworkID_t NetworkID = NetworkID_t::Swisscom; 42 | 43 | virtual const char *GetNetworkName() const override 44 | { 45 | return NetworkID_t_GetName(NetworkID); 46 | }; 47 | 48 | virtual NetworkID_t GetNetworkID() const override 49 | { 50 | return NetworkID; 51 | } 52 | 53 | protected: 54 | // Handle common NetJoin() operations for the network. 55 | virtual void NetJoin(); 56 | 57 | private: 58 | }; 59 | 60 | class Arduino_LoRaWAN_Swisscom_eu868 : public Arduino_LoRaWAN_Swisscom_base 61 | { 62 | public: 63 | using Super = Arduino_LoRaWAN_Swisscom_base; 64 | Arduino_LoRaWAN_Swisscom_eu868() {}; 65 | 66 | protected: 67 | // the NetBeginInit() function does specific work when starting 68 | // up. 69 | virtual void NetBeginRegionInit(); 70 | 71 | // Implement the NetJoin() operations for as923 72 | virtual void NetJoin(); 73 | 74 | private: 75 | }; 76 | 77 | #if defined(CFG_eu868) 78 | # define Arduino_LoRaWAN_REGION_TAG eu868 79 | #elif ARDUINO_LMIC_CFG_NETWORK_SWISSCOM 80 | # error "Can't define Arduino_LoRaWAN_REGION_TAG: region not supported for Swisscom" 81 | #else 82 | // just ignore. 83 | #endif 84 | 85 | #define Arduino_LoRaWAN_Swisscom_LOCAL_(Region) \ 86 | Arduino_LoRaWAN_Swisscom_ ## Region 87 | 88 | #define Arduino_LoRaWAN_Swisscom_LOCAL(Region) \ 89 | Arduino_LoRaWAN_Swisscom_LOCAL_(Region) 90 | 91 | // 92 | // This header file might get compiled all the time ... and it's not 93 | // an error to have a region other than EU868, unless we're actually targeting 94 | // Swisscom. So we just don't define Arduino_LoRaWAN_Swisscom unless we 95 | // have a valid region tag. 96 | // 97 | #if defined(Arduino_LoRaWAN_REGION_TAG) 98 | 99 | class Arduino_LoRaWAN_Swisscom : public Arduino_LoRaWAN_Swisscom_LOCAL(Arduino_LoRaWAN_REGION_TAG) 100 | { 101 | public: 102 | using Super = Arduino_LoRaWAN_Swisscom_LOCAL(Arduino_LoRaWAN_REGION_TAG); 103 | Arduino_LoRaWAN_Swisscom() {}; 104 | 105 | private: 106 | }; 107 | 108 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 109 | 110 | /**** end of Arduino_LoRaWAN_Swisscom.h ****/ 111 | #endif /* _ARDUINO_LORAWAN_SWISSCOM_H_ */ 112 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Helium.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Helium.h 4 | 5 | Function: 6 | LoRaWAN network object for Helium. 7 | 8 | Copyright notice: 9 | This file copyright (C) 2020. See accompanying 10 | LICENSE file for license information. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation February 2020 14 | 15 | */ 16 | 17 | #ifndef _ARDUINO_LORAWAN_HELIUM_H_ /* prevent multiple includes */ 18 | #define _ARDUINO_LORAWAN_HELIUM_H_ 19 | 20 | #pragma once 21 | 22 | #ifndef _ARDUNIO_LORAWAN_H_ 23 | # include 24 | #endif 25 | 26 | #ifndef _MCCIADK_ENV_H_ 27 | # include 28 | #endif 29 | 30 | #if !defined(PLATFORMIO) 31 | /* this is a bit of a hack, but... */ 32 | /* make sure we have the config variables in scope */ 33 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 34 | # include 35 | #endif 36 | 37 | class Arduino_LoRaWAN_Helium_base : public Arduino_LoRaWAN 38 | { 39 | public: 40 | Arduino_LoRaWAN_Helium_base() {}; 41 | using Super = Arduino_LoRaWAN; 42 | static constexpr NetworkID_t NetworkID = NetworkID_t::Helium; 43 | 44 | virtual const char *GetNetworkName() const override 45 | { 46 | return NetworkID_t_GetName(NetworkID); 47 | }; 48 | 49 | virtual NetworkID_t GetNetworkID() const override 50 | { 51 | return NetworkID; 52 | } 53 | 54 | protected: 55 | // Handle common NetJoin() operations for the network. 56 | virtual void NetJoin(); 57 | 58 | private: 59 | }; 60 | 61 | class Arduino_LoRaWAN_Helium_us915 : public Arduino_LoRaWAN_Helium_base 62 | { 63 | public: 64 | using Super = Arduino_LoRaWAN_Helium_base; 65 | Arduino_LoRaWAN_Helium_us915() {}; 66 | 67 | protected: 68 | // the NetBeginRegionInit() function allows us to override the LMIC 69 | // defaults when initializing for a region. Only provide code if LMIC 70 | // is doing something wrong. 71 | virtual void NetBeginRegionInit(); 72 | 73 | // Implement the NetJoin() operations for US915 74 | virtual void NetJoin(); 75 | 76 | private: 77 | }; 78 | 79 | 80 | #if ARDUINO_LMIC_CFG_NETWORK_HELIUM && defined(CFG_us915) 81 | # if defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1 || ARDUINO_LMIC_CFG_SUBBAND == 1) 82 | # error "Helium network in US915 region is fixed at subband channels 8~15/65" 83 | # endif 84 | # define Arduino_LoRaWAN_REGION_TAG us915 85 | #else 86 | // just be silent if we don't think we're targeting Helium 87 | #endif 88 | 89 | #define Arduino_LoRaWAN_Helium_LOCAL_(Region) \ 90 | Arduino_LoRaWAN_Helium_ ## Region 91 | 92 | #define Arduino_LoRaWAN_Helium_LOCAL(Region) \ 93 | Arduino_LoRaWAN_Helium_LOCAL_(Region) 94 | 95 | // 96 | // This header file might get compiled all the time ... and it's not 97 | // an error to have a region other than US, unless we're actually targeting 98 | // Helium. So we just don't define Arduino_LoRaWAN_Helium unless we 99 | // have a valid region tag. 100 | // 101 | #if defined(Arduino_LoRaWAN_REGION_TAG) 102 | 103 | class Arduino_LoRaWAN_Helium : public Arduino_LoRaWAN_Helium_LOCAL(Arduino_LoRaWAN_REGION_TAG) 104 | { 105 | public: 106 | using Super = Arduino_LoRaWAN_Helium_LOCAL(Arduino_LoRaWAN_REGION_TAG); 107 | Arduino_LoRaWAN_Helium() {}; 108 | 109 | private: 110 | }; 111 | 112 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 113 | 114 | /**** end of Arduino_LoRaWAN_Helium.h ****/ 115 | #endif /* _ARDUINO_LORAWAN_HELIUM_H_ */ 116 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Senet.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Senet.h 4 | 5 | Function: 6 | LoRaWAN network object for Senet. 7 | 8 | Copyright notice: 9 | This file copyright (C) 2020. See accompanying 10 | LICENSE file for license information. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation February 2020 14 | 15 | */ 16 | 17 | #ifndef _ARDUINO_LORAWAN_SENET_H_ /* prevent multiple includes */ 18 | #define _ARDUINO_LORAWAN_SENET_H_ 19 | 20 | #pragma once 21 | 22 | #ifndef _ARDUNIO_LORAWAN_H_ 23 | # include 24 | #endif 25 | 26 | #ifndef _MCCIADK_ENV_H_ 27 | # include 28 | #endif 29 | 30 | #if !defined(PLATFORMIO) 31 | /* this is a bit of a hack, but... */ 32 | /* make sure we have the config variables in scope */ 33 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 34 | # include 35 | #endif 36 | 37 | class Arduino_LoRaWAN_Senet_base : public Arduino_LoRaWAN 38 | { 39 | public: 40 | Arduino_LoRaWAN_Senet_base() {}; 41 | using Super = Arduino_LoRaWAN; 42 | static constexpr NetworkID_t NetworkID = NetworkID_t::Senet; 43 | 44 | virtual const char *GetNetworkName() const override 45 | { 46 | return NetworkID_t_GetName(NetworkID); 47 | }; 48 | 49 | virtual NetworkID_t GetNetworkID() const override 50 | { 51 | return NetworkID; 52 | } 53 | 54 | protected: 55 | // Handle common NetJoin() operations for the network. 56 | virtual void NetJoin(); 57 | 58 | private: 59 | }; 60 | 61 | class Arduino_LoRaWAN_Senet_us915 : public Arduino_LoRaWAN_Senet_base 62 | { 63 | public: 64 | using Super = Arduino_LoRaWAN_Senet_base; 65 | Arduino_LoRaWAN_Senet_us915() {}; 66 | 67 | protected: 68 | // the NetBeginRegionInit() function allows us to override the LMIC 69 | // defaults when initializing for a region. Only provide code if LMIC 70 | // is doing something wrong. 71 | virtual void NetBeginRegionInit(); 72 | 73 | // Implement the NetJoin() operations for US915 74 | virtual void NetJoin(); 75 | 76 | private: 77 | }; 78 | 79 | 80 | #if ARDUINO_LMIC_CFG_NETWORK_SENET && defined(CFG_us915) 81 | # if defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1 || ARDUINO_LMIC_CFG_SUBBAND == 0) 82 | # warning "Senet network in US915 region should use generic subband or subband zero (channels 0~7/64)" 83 | # endif 84 | # define Arduino_LoRaWAN_REGION_TAG us915 85 | #elif ARDUINO_LMIC_CFG_NETWORK_SENET 86 | # error "Configured region not supported for Senet: can't define Arduino_LoRaWAN_REGION_TAG" 87 | #else 88 | // just be silent if we don't think we're targeting Senet 89 | #endif 90 | 91 | #define Arduino_LoRaWAN_Senet_LOCAL_(Region) \ 92 | Arduino_LoRaWAN_Senet_ ## Region 93 | 94 | #define Arduino_LoRaWAN_Senet_LOCAL(Region) \ 95 | Arduino_LoRaWAN_Senet_LOCAL_(Region) 96 | 97 | // 98 | // This header file might get compiled all the time ... and it's not 99 | // an error to have a region other than US, unless we're actually targeting 100 | // Senet. So we just don't define Arduino_LoRaWAN_Senet unless we 101 | // have a valid region tag. 102 | // 103 | #if defined(Arduino_LoRaWAN_REGION_TAG) 104 | 105 | class Arduino_LoRaWAN_Senet : public Arduino_LoRaWAN_Senet_LOCAL(Arduino_LoRaWAN_REGION_TAG) 106 | { 107 | public: 108 | using Super = Arduino_LoRaWAN_Senet_LOCAL(Arduino_LoRaWAN_REGION_TAG); 109 | Arduino_LoRaWAN_Senet() {}; 110 | 111 | private: 112 | }; 113 | 114 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 115 | 116 | /**** end of Arduino_LoRaWAN_Senet.h ****/ 117 | #endif /* _ARDUINO_LORAWAN_SENET_H_ */ 118 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_machineQ.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_machineQ.h 4 | 5 | Function: 6 | LoRaWAN network object for machineQ. 7 | 8 | Copyright notice: 9 | This file copyright (C) 2016-2017, 2020. See accompanying 10 | LICENSE file for license information. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation October 2016 14 | 15 | */ 16 | 17 | #ifndef _ARDUINO_LORAWAN_MACHINEQ_H_ /* prevent multiple includes */ 18 | #define _ARDUINO_LORAWAN_MACHINEQ_H_ 19 | 20 | #pragma once 21 | 22 | #ifndef _ARDUNIO_LORAWAN_H_ 23 | # include 24 | #endif 25 | 26 | #ifndef _MCCIADK_ENV_H_ 27 | # include 28 | #endif 29 | 30 | #if !defined(PLATFORMIO) 31 | /* this is a bit of a hack, but... */ 32 | /* make sure we have the config variables in scope */ 33 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 34 | # include 35 | #endif 36 | 37 | class Arduino_LoRaWAN_machineQ_base : public Arduino_LoRaWAN 38 | { 39 | public: 40 | Arduino_LoRaWAN_machineQ_base() {}; 41 | using Super = Arduino_LoRaWAN; 42 | static constexpr NetworkID_t NetworkID = NetworkID_t::machineQ; 43 | 44 | virtual const char *GetNetworkName() const override 45 | { 46 | return NetworkID_t_GetName(NetworkID); 47 | }; 48 | 49 | virtual NetworkID_t GetNetworkID() const override 50 | { 51 | return NetworkID; 52 | } 53 | 54 | protected: 55 | // Handle common NetJoin() operations for the network. 56 | virtual void NetJoin(); 57 | 58 | private: 59 | }; 60 | 61 | class Arduino_LoRaWAN_machineQ_us915 : public Arduino_LoRaWAN_machineQ_base 62 | { 63 | public: 64 | using Super = Arduino_LoRaWAN_machineQ_base; 65 | Arduino_LoRaWAN_machineQ_us915() {}; 66 | 67 | protected: 68 | // the NetBeginRegionInit() function allows us to override the LMIC 69 | // defaults when initializing for a region. Only provide code if LMIC 70 | // is doing something wrong. 71 | virtual void NetBeginRegionInit(); 72 | 73 | // Implement the NetJoin() operations for US915 74 | virtual void NetJoin(); 75 | 76 | private: 77 | }; 78 | 79 | 80 | #if ARDUINO_LMIC_CFG_NETWORK_MACHINEQ && defined(CFG_us915) 81 | # if defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1) 82 | # error "machineQ is a 64-channel network; selecting a subband is not supported" 83 | # endif 84 | # define Arduino_LoRaWAN_REGION_TAG us915 85 | #elif ARDUINO_LMIC_CFG_NETWORK_MACHINEQ 86 | # error "Configured region not supported for machineQ: can't define Arduino_LoRaWAN_REGION_TAG" 87 | #else 88 | // just be silent if we don't think we're targeting MachineQ 89 | #endif 90 | 91 | #define Arduino_LoRaWAN_machineQ_LOCAL_(Region) \ 92 | Arduino_LoRaWAN_machineQ_ ## Region 93 | 94 | #define Arduino_LoRaWAN_machineQ_LOCAL(Region) \ 95 | Arduino_LoRaWAN_machineQ_LOCAL_(Region) 96 | 97 | // 98 | // This header file might get compiled all the time ... and it's not 99 | // an error to have a region other than US, unless we're actually targeting 100 | // machineQ. So we just don't define Arduino_LoRaWAN_machineQ unless we 101 | // have a valid region tag. 102 | // 103 | #if defined(Arduino_LoRaWAN_REGION_TAG) 104 | 105 | class Arduino_LoRaWAN_machineQ : public Arduino_LoRaWAN_machineQ_LOCAL(Arduino_LoRaWAN_REGION_TAG) 106 | { 107 | public: 108 | using Super = Arduino_LoRaWAN_machineQ_LOCAL(Arduino_LoRaWAN_REGION_TAG); 109 | Arduino_LoRaWAN_machineQ() {}; 110 | 111 | private: 112 | }; 113 | 114 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 115 | 116 | /**** end of Arduino_LoRaWAN_machineQ.h ****/ 117 | #endif /* _ARDUINO_LORAWAN_MACHINEQ_H_ */ 118 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_network.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_network.h 4 | 5 | Function: 6 | The upper-edge class for the network-specific LoRaWAN object. 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation October 2019 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_NETWORK_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_NETWORK_H_ 18 | 19 | #include "Arduino_LoRaWAN.h" 20 | 21 | // so we don't need to #ifdef, give all the ARDUINO_LMIC_CFG_ variables a value. 22 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_TTN) 23 | # define ARDUINO_LMIC_CFG_NETWORK_TTN 0 24 | #endif 25 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_ACTILITY) 26 | # define ARDUINO_LMIC_CFG_NETWORK_ACTILITY 0 27 | #endif 28 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_HELIUM) 29 | # define ARDUINO_LMIC_CFG_NETWORK_HELIUM 0 30 | #endif 31 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_MACHINEQ) 32 | # define ARDUINO_LMIC_CFG_NETWORK_MACHINEQ 0 33 | #endif 34 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_SENET) 35 | # define ARDUINO_LMIC_CFG_NETWORK_SENET 0 36 | #endif 37 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_SENRA) 38 | # define ARDUINO_LMIC_CFG_NETWORK_SENRA 0 39 | #endif 40 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_SWISSCOM) 41 | # define ARDUINO_LMIC_CFG_NETWORK_SWISSCOM 0 42 | #endif 43 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK) 44 | # define ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK 0 45 | #endif 46 | #if !defined(ARDUINO_LMIC_CFG_NETWORK_GENERIC) 47 | # define ARDUINO_LMIC_CFG_NETWORK_GENERIC 0 48 | #endif 49 | 50 | // count number of defined networks 51 | #define ARDUINO_LORAWAN_NETWORK_COUNT \ 52 | (ARDUINO_LMIC_CFG_NETWORK_TTN + \ 53 | ARDUINO_LMIC_CFG_NETWORK_ACTILITY + \ 54 | ARDUINO_LMIC_CFG_NETWORK_HELIUM + \ 55 | ARDUINO_LMIC_CFG_NETWORK_MACHINEQ + \ 56 | ARDUINO_LMIC_CFG_NETWORK_SENET + \ 57 | ARDUINO_LMIC_CFG_NETWORK_SENRA + \ 58 | ARDUINO_LMIC_CFG_NETWORK_SWISSCOM + \ 59 | ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK + \ 60 | ARDUINO_LMIC_CFG_NETWORK_GENERIC) 61 | 62 | #if ARDUINO_LORAWAN_NETWORK_COUNT == 0 63 | // none defined, query legacy symbols 64 | # ifdef ARDUINO_LORAWAN_NETWORK_TTN 65 | # undef ARDUINO_LMIC_CFG_NETWORK_TTN 66 | # define ARDUINO_LMIC_CFG_NETWORK_TTN 1 67 | # elif defined(ARDUINO_LORAWAN_NETWORK_MACHINEQ) 68 | # undef ARDUINO_LMIC_CFG_NETWORK_MACHINEQ 69 | # define ARDUINO_LMIC_CFG_NETWORK_MACHINEQ 1 70 | # else 71 | // no legacy and no BSP: use TTN. 72 | # undef ARDUINO_LMIC_CFG_NETWORK_TTN 73 | # define ARDUINO_LMIC_CFG_NETWORK_TTN 1 74 | # endif 75 | #endif 76 | 77 | #if ARDUINO_LORAWAN_NETWORK_COUNT > 1 78 | # error "Multiple ARDUINO_LMIC_CFG_NETWORK_* values defined" 79 | #endif 80 | 81 | #ifndef ARDUINO_LMIC_CFG_SUBBAND 82 | # define ARDUINO_LMIC_CFG_SUBBAND -1 83 | #endif 84 | 85 | #if ARDUINO_LMIC_CFG_NETWORK_TTN 86 | # include 87 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_ttn; 88 | #elif ARDUINO_LMIC_CFG_NETWORK_ACTILITY 89 | # include 90 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Actility; 91 | #elif ARDUINO_LMIC_CFG_NETWORK_HELIUM 92 | # include 93 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Helium; 94 | #elif ARDUINO_LMIC_CFG_NETWORK_MACHINEQ 95 | # include 96 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_machineQ; 97 | #elif ARDUINO_LMIC_CFG_NETWORK_SENET 98 | # include 99 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Senet; 100 | #elif ARDUINO_LMIC_CFG_NETWORK_SENRA 101 | # include 102 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Senra; 103 | #elif ARDUINO_LMIC_CFG_NETWORK_SWISSCOM 104 | # include 105 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Swisscom; 106 | #elif ARDUINO_LMIC_CFG_NETWORK_CHIRPSTACK 107 | # include 108 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_ChirpStack; 109 | #elif ARDUINO_LMIC_CFG_NETWORK_GENERIC 110 | # include 111 | using Arduino_LoRaWAN_network = Arduino_LoRaWAN_Generic; 112 | #else 113 | # error "Internal error defining ARDUINO_LMIC_CFG_NETWORK_*" 114 | #endif 115 | 116 | #endif /* _ARDUINO_LORAWAN_NETWORK_H_ */ 117 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_EventLog.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_EventLog.h 4 | 5 | Function: 6 | EventLog for Arduino_LoRaWAN 7 | 8 | Copyright and License: 9 | This file copyright (C) 2021 by 10 | 11 | MCCI Corporation 12 | 3520 Krums Corners Road 13 | Ithaca, NY 14850 14 | 15 | See accompanying LICENSE file for copyright and license information. 16 | 17 | Author: 18 | Terry Moore, MCCI Corporation May 2021 19 | 20 | */ 21 | 22 | #ifndef _Arduino_LoRaWAN_EventLog_h_ 23 | #define _Arduino_LoRaWAN_EventLog_h_ /* prevent multiple includes */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | /****************************************************************************\ 31 | | 32 | | The event log object 33 | | 34 | \****************************************************************************/ 35 | 36 | class Arduino_LoRaWAN::cEventLog 37 | { 38 | public: 39 | cEventLog() {}; 40 | ~cEventLog() {}; 41 | 42 | /// \brief do EventLog processing for Arduino \c setup(). 43 | void setup(); 44 | 45 | /// \brief do EventLog processig for Arduino \c loop(). 46 | void loop(); 47 | 48 | class EventNode_t; 49 | 50 | /// \brief abstract type for logging callbacks. 51 | typedef void (LogCallback_t)(const EventNode_t *); 52 | 53 | /// 54 | /// \brief LoRaWAN log entry 55 | /// 56 | /// \details generally, we try to hide the details from the deloggers; 57 | /// so the callback functions have to use the methods to get at the 58 | /// contents of this object. 59 | /// 60 | class EventNode_t 61 | { 62 | // allow cEventLog methods access to private fields. 63 | friend class cEventLog; 64 | 65 | private: 66 | std::uint32_t time; ///< timestamp for event -- really an ostime_t, but 67 | /// don't want to have the LMIC in scope. 68 | LogCallback_t *pCallBack; ///< callback function for delogging. 69 | void *pClientData; ///< client data for callback function 70 | std::uintptr_t data[3]; ///< arbitrary data 71 | 72 | public: 73 | /// \brief the constructor 74 | EventNode_t() {} 75 | 76 | /// \brief get timestamp from event node (ostime_t ticks) 77 | std::uint32_t getTime() const { return this->time; } 78 | 79 | /// \brief get client data pointer from event node 80 | void *getClientData() const { return this->pClientData; } 81 | 82 | /// \brief get a given data element from event node. 83 | std::uintptr_t getData(unsigned i) const { return this->data[i]; } 84 | }; 85 | 86 | /// 87 | /// \brief make a standard entry in the event log. 88 | /// 89 | /// \return 90 | /// If this function successfully allocates a log entry, returns a pointer to the 91 | /// entry. Otherwise returns \c nullptr. 92 | /// 93 | EventNode_t *logEvent(void *pClientData, std::uintptr_t arg1, std::uintptr_t arg2, std::uintptr_t arg3, LogCallback_t *pFn); 94 | 95 | /* convenience routines */ 96 | 97 | /// \brief print a channel number 98 | void printCh(std::uint8_t channel) const; 99 | 100 | /// \brief decode and display an LMIC \c rps_t value. 101 | void printRps(std::uint8_t rps) const; 102 | 103 | /// \brief given an LMIC \c rps_t, return the spreading-factor name 104 | const char *getSfName(std::uint8_t rps) const; 105 | /// \brief given an LMIC \c rps_t, return the bandwidth text 106 | const char *getBwName(std::uint8_t rps) const; 107 | /// \brief given an LMIC \c rps_t, return the coding scheme name 108 | const char *getCrName(std::uint8_t rps) const; 109 | /// \brief given an LMIC \c rps_t, return string saying whether CRC is enabled or disabled. 110 | const char *getCrcName(std::uint8_t rps) const; 111 | 112 | /// \brief print a value as a 2-digit hex number 113 | void printHex2(unsigned v) const; 114 | 115 | /// \brief print a value as a 4-digit hex number 116 | void printHex4(unsigned v) const; 117 | 118 | /// \brief print a space 119 | void printSpace(void) const; 120 | 121 | /// \brief print a frequency (given in Hz, but displayed in MHz) 122 | void printFreq(std::uint32_t freq) const; 123 | 124 | private: 125 | unsigned m_head; ///< index of first node in queue; queue is empty if head == tail 126 | unsigned m_tail; ///< index of last node in queue 127 | EventNode_t m_queue[8]; ///< queue of entries 128 | 129 | /// \brief called to despool and print a single event. 130 | bool processSingleEvent(); 131 | }; 132 | 133 | #endif /* _Arduino_LoRaWAN_EventLog_h_ */ 134 | -------------------------------------------------------------------------------- /src/lib/arduino_lorawan_cEventLog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: arduino_lorawan_cEventLog.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::cEventLog methods. 7 | 8 | Copyright and License: 9 | This file copyright (C) 2021 by 10 | 11 | MCCI Corporation 12 | 3520 Krums Corners Road 13 | Ithaca, NY 14850 14 | 15 | See accompanying LICENSE file for copyright and license information. 16 | 17 | Author: 18 | Terry Moore, MCCI Corporation May 2021 19 | 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | /****************************************************************************\ 26 | | 27 | | Log methods 28 | | 29 | \****************************************************************************/ 30 | 31 | void 32 | Arduino_LoRaWAN::cEventLog::setup() 33 | { 34 | // no setup needed. 35 | } 36 | 37 | void 38 | Arduino_LoRaWAN::cEventLog::loop() 39 | { 40 | if ((LMIC.opmode & OP_TXRXPEND) != 0) 41 | return; 42 | 43 | if (os_queryTimeCriticalJobs(ms2osticks(1000))) 44 | return; 45 | 46 | this->processSingleEvent(); 47 | } 48 | 49 | Arduino_LoRaWAN::cEventLog::EventNode_t * 50 | Arduino_LoRaWAN::cEventLog::logEvent( 51 | void *pClientData, 52 | std::uintptr_t arg1, 53 | std::uintptr_t arg2, 54 | std::uintptr_t arg3, 55 | LogCallback_t *pFn 56 | ) 57 | { 58 | auto i = this->m_tail + 1; 59 | 60 | if (i == sizeof(this->m_queue) / sizeof(this->m_queue[0])) 61 | { 62 | i = 0; 63 | } 64 | if (i == this->m_head) 65 | { 66 | // indicate failure. Callback won't be called! 67 | return nullptr; 68 | } 69 | 70 | auto const pEvent = &this->m_queue[this->m_tail]; 71 | 72 | // save log data 73 | pEvent->time = os_getTime(); 74 | pEvent->pCallBack = pFn; 75 | pEvent->pClientData = pClientData; 76 | pEvent->data[0] = arg1; 77 | pEvent->data[1] = arg2; 78 | pEvent->data[2] = arg3; 79 | 80 | // advance pointer 81 | this->m_tail = i; 82 | 83 | // indicate success (if anyone cares) 84 | return pEvent; 85 | } 86 | 87 | bool 88 | Arduino_LoRaWAN::cEventLog::processSingleEvent() 89 | { 90 | if (this->m_head == this->m_tail) 91 | { 92 | return false; 93 | } 94 | 95 | auto const pEvent = &this->m_queue[this->m_head]; 96 | 97 | Serial.print(osticks2ms(pEvent->time)); 98 | Serial.print(" ms:"); 99 | pEvent->pCallBack(pEvent); 100 | Serial.println(); 101 | 102 | if (++m_head == sizeof(m_queue) / sizeof(m_queue[0])) 103 | { 104 | m_head = 0; 105 | } 106 | 107 | return true; 108 | } 109 | 110 | void 111 | Arduino_LoRaWAN::cEventLog::printCh(std::uint8_t channel) const 112 | { 113 | Serial.print(F(" ch=")); 114 | Serial.print(std::uint32_t(channel)); 115 | } 116 | 117 | const char * 118 | Arduino_LoRaWAN::cEventLog::getSfName(std::uint8_t rps) const 119 | { 120 | const char * const t[] = { "FSK", "SF7", "SF8", "SF9", "SF10", "SF11", "SF12", "SFrfu" }; 121 | return t[getSf(rps)]; 122 | } 123 | 124 | const char * 125 | Arduino_LoRaWAN::cEventLog::getBwName(std::uint8_t rps) const 126 | { 127 | const char * const t[] = { "BW125", "BW250", "BW500", "BWrfu" }; 128 | return t[getBw(rps)]; 129 | } 130 | 131 | const char * 132 | Arduino_LoRaWAN::cEventLog::getCrName(std::uint8_t rps) const 133 | { 134 | const char * const t[] = { "CR 4/5", "CR 4/6", "CR 4/7", "CR 4/8" }; 135 | return t[getCr(rps)]; 136 | } 137 | 138 | const char * 139 | Arduino_LoRaWAN::cEventLog::getCrcName(std::uint8_t rps) const 140 | { 141 | return getNocrc(rps) ? "NoCrc" : "Crc"; 142 | } 143 | 144 | void 145 | Arduino_LoRaWAN::cEventLog::printHex2(unsigned v) const 146 | { 147 | v &= 0xff; 148 | if (v < 16) 149 | Serial.print('0'); 150 | Serial.print(v, HEX); 151 | } 152 | 153 | void 154 | Arduino_LoRaWAN::cEventLog::printHex4(unsigned v) const 155 | { 156 | printHex2(v >> 8u); 157 | printHex2(v); 158 | } 159 | 160 | void 161 | Arduino_LoRaWAN::cEventLog::printSpace(void) const 162 | { 163 | Serial.print(' '); 164 | } 165 | 166 | void 167 | Arduino_LoRaWAN::cEventLog::printFreq(u4_t freq) const 168 | { 169 | Serial.print(F(": freq=")); 170 | Serial.print(freq / 1000000); 171 | Serial.print('.'); 172 | Serial.print((freq % 1000000) / 100000); 173 | } 174 | 175 | void Arduino_LoRaWAN::cEventLog::printRps(std::uint8_t rps) const 176 | { 177 | Serial.print(F(" rps=0x")); printHex2(rps); 178 | Serial.print(F(" (")); Serial.print(getSfName(rps)); 179 | printSpace(); Serial.print(getBwName(rps)); 180 | printSpace(); Serial.print(getCrName(rps)); 181 | printSpace(); Serial.print(getCrcName(rps)); 182 | Serial.print(F(" IH=")); Serial.print(unsigned(getIh(rps))); 183 | Serial.print(')'); 184 | } 185 | -------------------------------------------------------------------------------- /src/lib/SendBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* SendBuffer.cpp Tue Oct 25 2016 17:25:44 tmm */ 2 | 3 | /* 4 | 5 | Module: SendBuffer.cpp 6 | 7 | Function: 8 | Arduino_LoRaWAN::SendBuffer() 9 | 10 | Version: 11 | V0.1.0 Tue Oct 25 2016 17:25:44 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 17:25:44 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /****************************************************************************\ 38 | | 39 | | Manifest constants & typedefs. 40 | | 41 | \****************************************************************************/ 42 | 43 | static lmic_txmessage_cb_t localSendBufferCb; 44 | 45 | /****************************************************************************\ 46 | | 47 | | Read-only data. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Variables 56 | | 57 | \****************************************************************************/ 58 | 59 | /* 60 | 61 | Name: Arduino_LoRaWAN::SendBuffer() 62 | 63 | Function: 64 | Send a message via the LMIC. 65 | 66 | Definition: 67 | public typedef void Arduino_LoRaWAN::SendBufferCbFn( 68 | void *pDoneCtx, 69 | bool fSuccess 70 | ); 71 | 72 | public bool Arduino_LoRaWAN::SendBuffer( 73 | const uint8_t *pBuffer, 74 | size_t nBuffer, 75 | SendBufferCbFn *pDoneFn, 76 | void *pDoneCtx, 77 | bool fConfirmed = false, 78 | uint8_t port = 1 79 | ); 80 | 81 | Description: 82 | The message is submitted to the LMIC for transmission to the network, 83 | if possible. When processing is finished, pDoneFn is called as follows: 84 | 85 | (*pDoneFn)(pDoneCtx, fSuccess); 86 | 87 | fSuccess will be true if (as far as we can tell) the message was successfully 88 | transmitted. For unconfirmed uplinks, as long as we sent the message, we 89 | return true. (Uplinks might be canceled due to link tracking or other issues.) 90 | 91 | If the LMIC is already processing a message, then the request 92 | is immediately completed, and this routine returns false. 93 | 94 | We guarantee that pDoneFn will be called once, when message 95 | processing is complete. 96 | 97 | Returns: 98 | The result is not very useful, because of the guarantees around 99 | completion processing. However, if false, then the transmit failed, 100 | and the completion routine has already been called. If true, then 101 | the transmit was started; the completion routine might already have 102 | been called. We don't recommend using this result. 103 | 104 | */ 105 | 106 | 107 | bool Arduino_LoRaWAN::SendBuffer( 108 | const uint8_t *pBuffer, 109 | size_t nBuffer, 110 | SendBufferCbFn *pDoneFn, 111 | void *pDoneCtx, 112 | bool fConfirmed, 113 | uint8_t port 114 | ) 115 | { 116 | if (! this->GetTxReady()) 117 | { 118 | if (pDoneFn) 119 | (*pDoneFn)(pDoneCtx, false); 120 | return false; 121 | } 122 | 123 | this->m_SendBufferData.pDoneFn = pDoneFn; 124 | this->m_SendBufferData.pDoneCtx = pDoneCtx; 125 | this->m_SendBufferData.fTxPending = true; 126 | this->m_SendBufferData.pSelf = this; 127 | 128 | const int iResult = LMIC_sendWithCallback( 129 | /* port: */ port != 0 ? port : 1, 130 | const_cast(pBuffer), 131 | nBuffer, 132 | /* confirmed? */ fConfirmed, 133 | localSendBufferCb, 134 | (void *)&this->m_SendBufferData 135 | ); 136 | 137 | if (iResult == 0) 138 | { 139 | // transmit was queued, will complete. 140 | return true; 141 | } 142 | else 143 | { 144 | this->m_SendBufferData.fTxPending = false; 145 | if (pDoneFn) 146 | (*pDoneFn)(pDoneCtx, false); 147 | return false; 148 | } 149 | } 150 | 151 | static void 152 | localSendBufferCb( 153 | void *pUserData, 154 | int fSuccess 155 | ) 156 | { 157 | auto const pSendBufferData = 158 | (Arduino_LoRaWAN::SendBufferData_t *)pUserData; 159 | auto const pDoneFn = pSendBufferData->pDoneFn; 160 | 161 | pSendBufferData->fTxPending = false; 162 | 163 | if (pDoneFn != nullptr) 164 | { 165 | pSendBufferData->pDoneFn = nullptr; 166 | pDoneFn(pSendBufferData->pDoneCtx, fSuccess); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Generic.h 4 | 5 | Function: 6 | LoRaWAN network object for Generic. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_GENERIC_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_GENERIC_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUNIO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #ifndef _MCCIADK_ENV_H_ 26 | # include 27 | #endif 28 | 29 | #if !defined(PLATFORMIO) 30 | /* this is a bit of a hack, but... */ 31 | /* make sure we have the config variables in scope */ 32 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 33 | # include 34 | #endif 35 | 36 | class Arduino_LoRaWAN_Generic_base : public Arduino_LoRaWAN 37 | { 38 | public: 39 | Arduino_LoRaWAN_Generic_base() {}; 40 | using Super = Arduino_LoRaWAN; 41 | static constexpr NetworkID_t NetworkID = NetworkID_t::Generic; 42 | 43 | virtual const char *GetNetworkName() const override 44 | { 45 | return NetworkID_t_GetName(NetworkID); 46 | }; 47 | 48 | virtual NetworkID_t GetNetworkID() const override 49 | { 50 | return NetworkID; 51 | } 52 | 53 | protected: 54 | // Handle common NetJoin() operations for the network. 55 | virtual void NetJoin(); 56 | 57 | private: 58 | }; 59 | 60 | class Arduino_LoRaWAN_Generic_eu868 : public Arduino_LoRaWAN_Generic_base 61 | { 62 | public: 63 | using Super = Arduino_LoRaWAN_Generic_base; 64 | Arduino_LoRaWAN_Generic_eu868() {}; 65 | 66 | protected: 67 | // the NetBeginInit() function does specific work for the common code 68 | // when starting up. 69 | virtual void NetBeginRegionInit(); 70 | 71 | // Implement the NetJoin() operations for eu868 72 | virtual void NetJoin(); 73 | 74 | private: 75 | }; 76 | 77 | class Arduino_LoRaWAN_Generic_us915 : public Arduino_LoRaWAN_Generic_base 78 | { 79 | public: 80 | using Super = Arduino_LoRaWAN_Generic_base; 81 | Arduino_LoRaWAN_Generic_us915() {}; 82 | 83 | protected: 84 | // the NetBeginInit() function does specific work when starting 85 | // up. 86 | virtual void NetBeginRegionInit(); 87 | 88 | // Implement the NetJoin() operations for US915 89 | virtual void NetJoin(); 90 | 91 | private: 92 | }; 93 | 94 | class Arduino_LoRaWAN_Generic_au915 : public Arduino_LoRaWAN_Generic_base 95 | { 96 | public: 97 | using Super = Arduino_LoRaWAN_Generic_base; 98 | Arduino_LoRaWAN_Generic_au915() {}; 99 | 100 | protected: 101 | // the NetBeginInit() function does specific work when starting 102 | // up. 103 | virtual void NetBeginRegionInit(); 104 | 105 | // Implement the NetJoin() operations for US915 106 | virtual void NetJoin(); 107 | 108 | private: 109 | }; 110 | 111 | 112 | class Arduino_LoRaWAN_Generic_as923 : public Arduino_LoRaWAN_Generic_base 113 | { 114 | public: 115 | using Super = Arduino_LoRaWAN_Generic_base; 116 | Arduino_LoRaWAN_Generic_as923() {}; 117 | 118 | protected: 119 | // the NetBeginInit() function does specific work when starting 120 | // up. 121 | virtual void NetBeginRegionInit(); 122 | 123 | // Implement the NetJoin() operations for as923 124 | virtual void NetJoin(); 125 | 126 | private: 127 | }; 128 | 129 | class Arduino_LoRaWAN_Generic_kr920 : public Arduino_LoRaWAN_Generic_base 130 | { 131 | public: 132 | using Super = Arduino_LoRaWAN_Generic_base; 133 | Arduino_LoRaWAN_Generic_kr920() {}; 134 | 135 | protected: 136 | // the NetBeginInit() function does specific work when starting 137 | // up. 138 | virtual void NetBeginRegionInit(); 139 | 140 | // Implement the NetJoin() operations for as923 141 | virtual void NetJoin(); 142 | 143 | private: 144 | }; 145 | 146 | class Arduino_LoRaWAN_Generic_in866 : public Arduino_LoRaWAN_Generic_base 147 | { 148 | public: 149 | using Super = Arduino_LoRaWAN_Generic_base; 150 | Arduino_LoRaWAN_Generic_in866() {}; 151 | 152 | protected: 153 | // the NetBeginInit() function does specific work when starting 154 | // up. 155 | virtual void NetBeginRegionInit(); 156 | 157 | // Implement the NetJoin() operations for as923 158 | virtual void NetJoin(); 159 | 160 | private: 161 | }; 162 | 163 | 164 | #if defined(CFG_eu868) 165 | # define Arduino_LoRaWAN_REGION_TAG eu868 166 | #elif defined(CFG_us915) 167 | # define Arduino_LoRaWAN_REGION_TAG us915 168 | #elif defined(CFG_au915) 169 | # define Arduino_LoRaWAN_REGION_TAG au915 170 | #elif defined(CFG_as923) 171 | # define Arduino_LoRaWAN_REGION_TAG as923 172 | #elif defined(CFG_in866) 173 | # define Arduino_LoRaWAN_REGION_TAG in866 174 | #elif defined(CFG_kr920) 175 | # define Arduino_LoRaWAN_REGION_TAG kr920 176 | #else 177 | # error "Can't define Arduino_LoRaWAN_REGION_TAG" 178 | #endif 179 | 180 | #define Arduino_LoRaWAN_Generic_LOCAL_(Region) \ 181 | Arduino_LoRaWAN_Generic_ ## Region 182 | 183 | #define Arduino_LoRaWAN_Generic_LOCAL(Region) \ 184 | Arduino_LoRaWAN_Generic_LOCAL_(Region) 185 | 186 | #if defined(Arduino_LoRaWAN_REGION_TAG) 187 | 188 | class Arduino_LoRaWAN_Generic : public Arduino_LoRaWAN_Generic_LOCAL(Arduino_LoRaWAN_REGION_TAG) 189 | { 190 | public: 191 | using Super = Arduino_LoRaWAN_Generic_LOCAL(Arduino_LoRaWAN_REGION_TAG); 192 | Arduino_LoRaWAN_Generic() {}; 193 | 194 | private: 195 | }; 196 | 197 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 198 | 199 | /**** end of Arduino_LoRaWAN_Generic.h ****/ 200 | #endif /* _ARDUINO_LORAWAN_GENERIC_H_ */ 201 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_ChirpStack.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_ChirpStack.h 4 | 5 | Function: 6 | LoRaWAN network object for ChirpStack. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_CHIRPSTACK_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_CHIRPSTACK_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUNIO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #ifndef _MCCIADK_ENV_H_ 26 | # include 27 | #endif 28 | 29 | #if !defined(PLATFORMIO) 30 | /* this is a bit of a hack, but... */ 31 | /* make sure we have the config variables in scope */ 32 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 33 | # include 34 | #endif 35 | 36 | class Arduino_LoRaWAN_ChirpStack_base : public Arduino_LoRaWAN 37 | { 38 | public: 39 | Arduino_LoRaWAN_ChirpStack_base() {}; 40 | using Super = Arduino_LoRaWAN; 41 | static constexpr NetworkID_t NetworkID = NetworkID_t::ChirpStack; 42 | 43 | virtual const char *GetNetworkName() const override 44 | { 45 | return NetworkID_t_GetName(NetworkID); 46 | }; 47 | 48 | virtual NetworkID_t GetNetworkID() const override 49 | { 50 | return NetworkID; 51 | } 52 | 53 | protected: 54 | // Handle common NetJoin() operations for the network. 55 | virtual void NetJoin(); 56 | 57 | private: 58 | }; 59 | 60 | class Arduino_LoRaWAN_ChirpStack_eu868 : public Arduino_LoRaWAN_ChirpStack_base 61 | { 62 | public: 63 | using Super = Arduino_LoRaWAN_ChirpStack_base; 64 | Arduino_LoRaWAN_ChirpStack_eu868() {}; 65 | 66 | protected: 67 | // the NetBeginInit() function does specific work for the common code 68 | // when starting up. 69 | virtual void NetBeginRegionInit(); 70 | 71 | // Implement the NetJoin() operations for eu868 72 | virtual void NetJoin(); 73 | 74 | private: 75 | }; 76 | 77 | class Arduino_LoRaWAN_ChirpStack_us915 : public Arduino_LoRaWAN_ChirpStack_base 78 | { 79 | public: 80 | using Super = Arduino_LoRaWAN_ChirpStack_base; 81 | Arduino_LoRaWAN_ChirpStack_us915() {}; 82 | 83 | protected: 84 | // the NetBeginInit() function does specific work when starting 85 | // up. 86 | virtual void NetBeginRegionInit(); 87 | 88 | // Implement the NetJoin() operations for US915 89 | virtual void NetJoin(); 90 | 91 | private: 92 | }; 93 | 94 | class Arduino_LoRaWAN_ChirpStack_au915 : public Arduino_LoRaWAN_ChirpStack_base 95 | { 96 | public: 97 | using Super = Arduino_LoRaWAN_ChirpStack_base; 98 | Arduino_LoRaWAN_ChirpStack_au915() {}; 99 | 100 | protected: 101 | // the NetBeginInit() function does specific work when starting 102 | // up. 103 | virtual void NetBeginRegionInit(); 104 | 105 | // Implement the NetJoin() operations for US915 106 | virtual void NetJoin(); 107 | 108 | private: 109 | }; 110 | 111 | 112 | class Arduino_LoRaWAN_ChirpStack_as923 : public Arduino_LoRaWAN_ChirpStack_base 113 | { 114 | public: 115 | using Super = Arduino_LoRaWAN_ChirpStack_base; 116 | Arduino_LoRaWAN_ChirpStack_as923() {}; 117 | 118 | protected: 119 | // the NetBeginInit() function does specific work when starting 120 | // up. 121 | virtual void NetBeginRegionInit(); 122 | 123 | // Implement the NetJoin() operations for as923 124 | virtual void NetJoin(); 125 | 126 | private: 127 | }; 128 | 129 | class Arduino_LoRaWAN_ChirpStack_kr920 : public Arduino_LoRaWAN_ChirpStack_base 130 | { 131 | public: 132 | using Super = Arduino_LoRaWAN_ChirpStack_base; 133 | Arduino_LoRaWAN_ChirpStack_kr920() {}; 134 | 135 | protected: 136 | // the NetBeginInit() function does specific work when starting 137 | // up. 138 | virtual void NetBeginRegionInit(); 139 | 140 | // Implement the NetJoin() operations for as923 141 | virtual void NetJoin(); 142 | 143 | private: 144 | }; 145 | 146 | class Arduino_LoRaWAN_ChirpStack_in866 : public Arduino_LoRaWAN_ChirpStack_base 147 | { 148 | public: 149 | using Super = Arduino_LoRaWAN_ChirpStack_base; 150 | Arduino_LoRaWAN_ChirpStack_in866() {}; 151 | 152 | protected: 153 | // the NetBeginInit() function does specific work when starting 154 | // up. 155 | virtual void NetBeginRegionInit(); 156 | 157 | // Implement the NetJoin() operations for as923 158 | virtual void NetJoin(); 159 | 160 | private: 161 | }; 162 | 163 | 164 | #if defined(CFG_eu868) 165 | # define Arduino_LoRaWAN_REGION_TAG eu868 166 | #elif defined(CFG_us915) 167 | # define Arduino_LoRaWAN_REGION_TAG us915 168 | #elif defined(CFG_au915) 169 | # define Arduino_LoRaWAN_REGION_TAG au915 170 | #elif defined(CFG_as923) 171 | # define Arduino_LoRaWAN_REGION_TAG as923 172 | #elif defined(CFG_in866) 173 | # define Arduino_LoRaWAN_REGION_TAG in866 174 | #elif defined(CFG_kr920) 175 | # define Arduino_LoRaWAN_REGION_TAG kr920 176 | #else 177 | # error "Can't define Arduino_LoRaWAN_REGION_TAG" 178 | #endif 179 | 180 | #define Arduino_LoRaWAN_ChirpStack_LOCAL_(Region) \ 181 | Arduino_LoRaWAN_ChirpStack_ ## Region 182 | 183 | #define Arduino_LoRaWAN_ChirpStack_LOCAL(Region) \ 184 | Arduino_LoRaWAN_ChirpStack_LOCAL_(Region) 185 | 186 | #if defined(Arduino_LoRaWAN_REGION_TAG) 187 | 188 | class Arduino_LoRaWAN_ChirpStack : public Arduino_LoRaWAN_ChirpStack_LOCAL(Arduino_LoRaWAN_REGION_TAG) 189 | { 190 | public: 191 | using Super = Arduino_LoRaWAN_ChirpStack_LOCAL(Arduino_LoRaWAN_REGION_TAG); 192 | Arduino_LoRaWAN_ChirpStack() {}; 193 | 194 | private: 195 | }; 196 | 197 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 198 | 199 | /**** end of Arduino_LoRaWAN_ChirpStack.h ****/ 200 | #endif /* _ARDUINO_LORAWAN_CHIRPSTACK_H_ */ 201 | -------------------------------------------------------------------------------- /examples/arduino_lorawan_esp32_example/ttn_decoder.js: -------------------------------------------------------------------------------- 1 | function ttn_decoder_fp(bytes) { 2 | // bytes is of type Buffer 3 | 4 | // IMPORTANT: paste code from src/decoder.js here 5 | var bytesToInt = function(bytes) { 6 | var i = 0; 7 | for (var x = 0; x < bytes.length; x++) { 8 | i |= +(bytes[x] << (x * 8)); 9 | } 10 | return i; 11 | }; 12 | 13 | var unixtime = function(bytes) { 14 | if (bytes.length !== unixtime.BYTES) { 15 | throw new Error('Unix time must have exactly 4 bytes'); 16 | } 17 | return bytesToInt(bytes); 18 | }; 19 | unixtime.BYTES = 4; 20 | 21 | var uint8 = function(bytes) { 22 | if (bytes.length !== uint8.BYTES) { 23 | throw new Error('int must have exactly 1 byte'); 24 | } 25 | return bytesToInt(bytes); 26 | }; 27 | uint8.BYTES = 1; 28 | 29 | var uint16 = function(bytes) { 30 | if (bytes.length !== uint16.BYTES) { 31 | throw new Error('int must have exactly 2 bytes'); 32 | } 33 | return bytesToInt(bytes); 34 | }; 35 | uint16.BYTES = 2; 36 | 37 | var uint16fp1 = function(bytes) { 38 | if (bytes.length !== uint16.BYTES) { 39 | throw new Error('int must have exactly 2 bytes'); 40 | } 41 | var res = bytesToInt(bytes) * 0.1; 42 | return res.toFixed(1); 43 | }; 44 | uint16fp1.BYTES = 2; 45 | 46 | var uint32 = function(bytes) { 47 | if (bytes.length !== uint32.BYTES) { 48 | throw new Error('int must have exactly 4 bytes'); 49 | } 50 | return bytesToInt(bytes); 51 | }; 52 | uint32.BYTES = 4; 53 | 54 | var latLng = function(bytes) { 55 | if (bytes.length !== latLng.BYTES) { 56 | throw new Error('Lat/Long must have exactly 8 bytes'); 57 | } 58 | 59 | var lat = bytesToInt(bytes.slice(0, latLng.BYTES / 2)); 60 | var lng = bytesToInt(bytes.slice(latLng.BYTES / 2, latLng.BYTES)); 61 | 62 | return [lat / 1e6, lng / 1e6]; 63 | }; 64 | latLng.BYTES = 8; 65 | 66 | var temperature = function(bytes) { 67 | if (bytes.length !== temperature.BYTES) { 68 | throw new Error('Temperature must have exactly 2 bytes'); 69 | } 70 | var isNegative = bytes[0] & 0x80; 71 | var b = ('00000000' + Number(bytes[0]).toString(2)).slice(-8) 72 | + ('00000000' + Number(bytes[1]).toString(2)).slice(-8); 73 | if (isNegative) { 74 | var arr = b.split('').map(function(x) { return !Number(x); }); 75 | for (var i = arr.length - 1; i > 0; i--) { 76 | arr[i] = !arr[i]; 77 | if (arr[i]) { 78 | break; 79 | } 80 | } 81 | b = arr.map(Number).join(''); 82 | } 83 | var t = parseInt(b, 2); 84 | if (isNegative) { 85 | t = -t; 86 | } 87 | t = t / 1e2; 88 | return t.toFixed(1); 89 | }; 90 | temperature.BYTES = 2; 91 | 92 | var humidity = function(bytes) { 93 | if (bytes.length !== humidity.BYTES) { 94 | throw new Error('Humidity must have exactly 2 bytes'); 95 | } 96 | 97 | var h = bytesToInt(bytes); 98 | return h / 1e2; 99 | }; 100 | humidity.BYTES = 2; 101 | 102 | // Based on https://stackoverflow.com/a/37471538 by Ilya Bursov 103 | // quoted by Arjan here https://www.thethingsnetwork.org/forum/t/decode-float-sent-by-lopy-as-node/8757 104 | function rawfloat(bytes) { 105 | if (bytes.length !== rawfloat.BYTES) { 106 | throw new Error('Float must have exactly 4 bytes'); 107 | } 108 | // JavaScript bitwise operators yield a 32 bits integer, not a float. 109 | // Assume LSB (least significant byte first). 110 | var bits = bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[0]; 111 | var sign = (bits>>>31 === 0) ? 1.0 : -1.0; 112 | var e = bits>>>23 & 0xff; 113 | var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000; 114 | var f = sign * m * Math.pow(2, e - 150); 115 | return f.toFixed(1); 116 | } 117 | rawfloat.BYTES = 4; 118 | 119 | var bitmap = function(byte) { 120 | if (byte.length !== bitmap.BYTES) { 121 | throw new Error('Bitmap must have exactly 1 byte'); 122 | } 123 | var i = bytesToInt(byte); 124 | var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean); 125 | return ['res4', 'res3', 'res2', 'res1', 'res0', 'runtime_exp', 'data_ok', 'battery_ok'] 126 | .reduce(function(obj, pos, index) { 127 | obj[pos] = bm[index]; 128 | return obj; 129 | }, {}); 130 | }; 131 | bitmap.BYTES = 1; 132 | 133 | var decode = function(bytes, mask, names) { 134 | 135 | var maskLength = mask.reduce(function(prev, cur) { 136 | return prev + cur.BYTES; 137 | }, 0); 138 | if (bytes.length < maskLength) { 139 | throw new Error('Mask length is ' + maskLength + ' whereas input is ' + bytes.length); 140 | } 141 | 142 | names = names || []; 143 | var offset = 0; 144 | return mask 145 | .map(function(decodeFn) { 146 | var current = bytes.slice(offset, offset += decodeFn.BYTES); 147 | return decodeFn(current); 148 | }) 149 | .reduce(function(prev, cur, idx) { 150 | prev[names[idx] || idx] = cur; 151 | return prev; 152 | }, {}); 153 | }; 154 | 155 | if (typeof module === 'object' && typeof module.exports !== 'undefined') { 156 | module.exports = { 157 | unixtime: unixtime, 158 | uint8: uint8, 159 | uint16: uint16, 160 | uint32: uint32, 161 | temperature: temperature, 162 | humidity: humidity, 163 | latLng: latLng, 164 | bitmap: bitmap, 165 | rawfloat: rawfloat, 166 | uint16fp1: uint16fp1, 167 | decode: decode 168 | }; 169 | } 170 | 171 | // see assignment to 'bitmap' variable for status bit names 172 | return decode( 173 | bytes, 174 | [bitmap, temperature, uint8, uint16, uint16 ], // types 175 | ['status', 'air_temp_c', 'humidity', 'supply_v', 'battery_v' ] // JSON elements 176 | ); 177 | 178 | } 179 | 180 | 181 | function decodeUplink(input) { 182 | return { 183 | data: { 184 | bytes: ttn_decoder_fp(input.bytes) 185 | }, 186 | warnings: [], 187 | errors: [] 188 | }; 189 | } 190 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_Actility.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Arduino_LoRaWAN_Actility.h 4 | 5 | Function: 6 | LoRaWAN network object for Actility. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation February 2020 13 | 14 | */ 15 | 16 | #ifndef _ARDUINO_LORAWAN_ACTILITY_H_ /* prevent multiple includes */ 17 | #define _ARDUINO_LORAWAN_ACTILITY_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _ARDUNIO_LORAWAN_H_ 22 | # include 23 | #endif 24 | 25 | #ifndef _MCCIADK_ENV_H_ 26 | # include 27 | #endif 28 | 29 | #if !defined(PLATFORMIO) 30 | /* this is a bit of a hack, but... */ 31 | /* make sure we have the config variables in scope */ 32 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 33 | # include 34 | #endif 35 | 36 | class Arduino_LoRaWAN_Actility_base : public Arduino_LoRaWAN 37 | { 38 | public: 39 | Arduino_LoRaWAN_Actility_base() {}; 40 | using Super = Arduino_LoRaWAN; 41 | static constexpr NetworkID_t NetworkID = NetworkID_t::Actility; 42 | 43 | virtual const char *GetNetworkName() const override 44 | { 45 | return NetworkID_t_GetName(NetworkID); 46 | }; 47 | 48 | virtual NetworkID_t GetNetworkID() const override 49 | { 50 | return NetworkID; 51 | } 52 | 53 | protected: 54 | // Handle common NetJoin() operations for the network. 55 | virtual void NetJoin(); 56 | 57 | private: 58 | }; 59 | 60 | class Arduino_LoRaWAN_Actility_eu868 : public Arduino_LoRaWAN_Actility_base 61 | { 62 | public: 63 | using Super = Arduino_LoRaWAN_Actility_base; 64 | Arduino_LoRaWAN_Actility_eu868() {}; 65 | 66 | protected: 67 | // the NetBeginInit() function does specific work for the common code 68 | // when starting up. 69 | virtual void NetBeginRegionInit(); 70 | 71 | // Implement the NetJoin() operations for eu868 72 | virtual void NetJoin(); 73 | 74 | private: 75 | }; 76 | 77 | class Arduino_LoRaWAN_Actility_us915 : public Arduino_LoRaWAN_Actility_base 78 | { 79 | public: 80 | using Super = Arduino_LoRaWAN_Actility_base; 81 | Arduino_LoRaWAN_Actility_us915() {}; 82 | 83 | protected: 84 | // the NetBeginInit() function does specific work when starting 85 | // up. 86 | virtual void NetBeginRegionInit(); 87 | 88 | // Implement the NetJoin() operations for US915 89 | virtual void NetJoin(); 90 | 91 | private: 92 | }; 93 | 94 | class Arduino_LoRaWAN_Actility_au915 : public Arduino_LoRaWAN_Actility_base 95 | { 96 | public: 97 | using Super = Arduino_LoRaWAN_Actility_base; 98 | Arduino_LoRaWAN_Actility_au915() {}; 99 | 100 | protected: 101 | // the NetBeginInit() function does specific work when starting 102 | // up. 103 | virtual void NetBeginRegionInit(); 104 | 105 | // Implement the NetJoin() operations for US915 106 | virtual void NetJoin(); 107 | 108 | private: 109 | }; 110 | 111 | 112 | class Arduino_LoRaWAN_Actility_as923 : public Arduino_LoRaWAN_Actility_base 113 | { 114 | public: 115 | using Super = Arduino_LoRaWAN_Actility_base; 116 | Arduino_LoRaWAN_Actility_as923() {}; 117 | 118 | protected: 119 | // the NetBeginInit() function does specific work when starting 120 | // up. 121 | virtual void NetBeginRegionInit(); 122 | 123 | // Implement the NetJoin() operations for as923 124 | virtual void NetJoin(); 125 | 126 | private: 127 | }; 128 | 129 | class Arduino_LoRaWAN_Actility_kr920 : public Arduino_LoRaWAN_Actility_base 130 | { 131 | public: 132 | using Super = Arduino_LoRaWAN_Actility_base; 133 | Arduino_LoRaWAN_Actility_kr920() {}; 134 | 135 | protected: 136 | // the NetBeginInit() function does specific work when starting 137 | // up. 138 | virtual void NetBeginRegionInit(); 139 | 140 | // Implement the NetJoin() operations for as923 141 | virtual void NetJoin(); 142 | 143 | private: 144 | }; 145 | 146 | class Arduino_LoRaWAN_Actility_in866 : public Arduino_LoRaWAN_Actility_base 147 | { 148 | public: 149 | using Super = Arduino_LoRaWAN_Actility_base; 150 | Arduino_LoRaWAN_Actility_in866() {}; 151 | 152 | protected: 153 | // the NetBeginInit() function does specific work when starting 154 | // up. 155 | virtual void NetBeginRegionInit(); 156 | 157 | // Implement the NetJoin() operations for as923 158 | virtual void NetJoin(); 159 | 160 | private: 161 | }; 162 | 163 | 164 | #if defined(CFG_eu868) 165 | # define Arduino_LoRaWAN_REGION_TAG eu868 166 | #elif defined(CFG_us915) 167 | # define Arduino_LoRaWAN_REGION_TAG us915 168 | #elif defined(CFG_au915) 169 | # define Arduino_LoRaWAN_REGION_TAG au915 170 | #elif defined(CFG_as923) 171 | # define Arduino_LoRaWAN_REGION_TAG as923 172 | #elif defined(CFG_in866) 173 | # define Arduino_LoRaWAN_REGION_TAG in866 174 | #elif defined(CFG_kr920) 175 | # define Arduino_LoRaWAN_REGION_TAG kr920 176 | #else 177 | # error "Can't define Arduino_LoRaWAN_REGION_TAG" 178 | #endif 179 | 180 | #define Arduino_LoRaWAN_Actility_LOCAL_(Region) \ 181 | Arduino_LoRaWAN_Actility_ ## Region 182 | 183 | #define Arduino_LoRaWAN_Actility_LOCAL(Region) \ 184 | Arduino_LoRaWAN_Actility_LOCAL_(Region) 185 | 186 | // 187 | // This header file might get compiled all the time ... and it's not 188 | // an error to have a region other than US, unless we're actually targeting 189 | // Actility. So we just don't define Arduino_LoRaWAN_Actility unless we 190 | // have a valid region tag. 191 | // 192 | #if defined(Arduino_LoRaWAN_REGION_TAG) 193 | 194 | class Arduino_LoRaWAN_Actility : public Arduino_LoRaWAN_Actility_LOCAL(Arduino_LoRaWAN_REGION_TAG) 195 | { 196 | public: 197 | using Super = Arduino_LoRaWAN_Actility_LOCAL(Arduino_LoRaWAN_REGION_TAG); 198 | Arduino_LoRaWAN_Actility() {}; 199 | 200 | private: 201 | }; 202 | 203 | #endif // defined(Arduino_LoRaWAN_REGION_TAG) 204 | 205 | /**** end of Arduino_LoRaWAN_Actility.h ****/ 206 | #endif /* _ARDUINO_LORAWAN_ACTILITY_H_ */ 207 | -------------------------------------------------------------------------------- /src/Arduino_LoRaWAN_ttn.h: -------------------------------------------------------------------------------- 1 | /* Arduino_LoRaWAN_ttn.h Fri May 19 2017 23:58:34 tmm */ 2 | 3 | /* 4 | 5 | Module: Arduino_LoRaWAN_ttn.h 6 | 7 | Function: 8 | LoRaWAN-variants for The Things Network. 9 | 10 | Version: 11 | V0.2.3 Fri May 19 2017 23:58:34 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.2.0 Mon Oct 31 2016 15:44:49 tmm 30 | Module created. 31 | 32 | 0.2.3 Fri May 19 2017 23:58:34 tmm 33 | Support eu868. 34 | 35 | */ 36 | 37 | #ifndef _ARDUINO_LORAWAN_TTN_H_ /* prevent multiple includes */ 38 | #define _ARDUINO_LORAWAN_TTN_H_ 39 | 40 | #ifndef _ARDUNIO_LORAWAN_H_ 41 | # include 42 | #endif 43 | 44 | #ifndef _MCCIADK_ENV_H_ 45 | # include 46 | #endif 47 | 48 | #if !defined(PLATFORMIO) 49 | /* this is a bit of a hack, but... */ 50 | /* make sure we have the config variables in scope */ 51 | /* Under PlatformIO use build_flags = -DCFG_ etc. in platformio.ini */ 52 | # include 53 | #endif 54 | 55 | class Arduino_LoRaWAN_ttn_base : public Arduino_LoRaWAN 56 | { 57 | public: 58 | Arduino_LoRaWAN_ttn_base() {}; 59 | using Super = Arduino_LoRaWAN; 60 | static constexpr NetworkID_t NetworkID = NetworkID_t::TheThingsNetwork; 61 | 62 | virtual const char *GetNetworkName() const override 63 | { 64 | return NetworkID_t_GetName(NetworkID); 65 | }; 66 | 67 | virtual NetworkID_t GetNetworkID() const override 68 | { 69 | return NetworkID; 70 | } 71 | 72 | protected: 73 | // Implement the NetJoin() operations common to all TTN regions. 74 | virtual void NetJoin(); 75 | 76 | private: 77 | }; 78 | 79 | class Arduino_LoRaWAN_ttn_eu868 : public Arduino_LoRaWAN_ttn_base 80 | { 81 | public: 82 | using Super = Arduino_LoRaWAN_ttn_base; 83 | Arduino_LoRaWAN_ttn_eu868() {}; 84 | 85 | protected: 86 | // the NetBeginInit() function does specific work for the common code 87 | // when starting up. 88 | virtual void NetBeginRegionInit(); 89 | 90 | // Implement the NetJoin() operations for eu868 91 | virtual void NetJoin(); 92 | 93 | private: 94 | }; 95 | 96 | class Arduino_LoRaWAN_ttn_us915 : public Arduino_LoRaWAN_ttn_base 97 | { 98 | public: 99 | using Super = Arduino_LoRaWAN_ttn_base; 100 | Arduino_LoRaWAN_ttn_us915() {}; 101 | 102 | protected: 103 | // the NetBeginInit() function does specific work when starting 104 | // up. For us915, we need to turn off the link check mode, and 105 | // select the subband. 106 | virtual void NetBeginRegionInit(); 107 | 108 | // Implement the NetJoin() operations for US915 109 | virtual void NetJoin(); 110 | 111 | private: 112 | }; 113 | 114 | class Arduino_LoRaWAN_ttn_au915 : public Arduino_LoRaWAN_ttn_base 115 | { 116 | public: 117 | using Super = Arduino_LoRaWAN_ttn_base; 118 | Arduino_LoRaWAN_ttn_au915() {}; 119 | 120 | protected: 121 | // the NetBeginInit() function does specific work when starting 122 | // up. For au915, we need to turn off the link check mode, and 123 | // select the subband. 124 | virtual void NetBeginRegionInit(); 125 | 126 | // Implement the NetJoin() operations for AU915 127 | virtual void NetJoin(); 128 | 129 | private: 130 | }; 131 | 132 | 133 | class Arduino_LoRaWAN_ttn_as923 : public Arduino_LoRaWAN_ttn_base 134 | { 135 | public: 136 | using Super = Arduino_LoRaWAN_ttn_base; 137 | Arduino_LoRaWAN_ttn_as923() {}; 138 | 139 | protected: 140 | // the NetBeginInit() function does specific work when starting 141 | // up. 142 | virtual void NetBeginRegionInit(); 143 | 144 | // Implement the NetJoin() operations for as923 145 | virtual void NetJoin(); 146 | 147 | private: 148 | }; 149 | 150 | class Arduino_LoRaWAN_ttn_kr920 : public Arduino_LoRaWAN_ttn_base 151 | { 152 | public: 153 | using Super = Arduino_LoRaWAN_ttn_base; 154 | Arduino_LoRaWAN_ttn_kr920() {}; 155 | 156 | protected: 157 | // the NetBeginInit() function does specific work when starting 158 | // up. 159 | virtual void NetBeginRegionInit(); 160 | 161 | // Implement the NetJoin() operations for as923 162 | virtual void NetJoin(); 163 | 164 | private: 165 | }; 166 | 167 | class Arduino_LoRaWAN_ttn_in866 : public Arduino_LoRaWAN_ttn_base 168 | { 169 | public: 170 | using Super = Arduino_LoRaWAN_ttn_base; 171 | Arduino_LoRaWAN_ttn_in866() {}; 172 | 173 | protected: 174 | // the NetBeginInit() function does specific work when starting 175 | // up. 176 | virtual void NetBeginRegionInit(); 177 | 178 | // Implement the NetJoin() operations for as923 179 | virtual void NetJoin(); 180 | 181 | private: 182 | }; 183 | 184 | 185 | #if defined(CFG_eu868) 186 | # define Arduino_LoRaWAN_REGION_TAG eu868 187 | #elif defined(CFG_us915) 188 | # if ARDUINO_LMIC_CFG_NETWORK_TTN && defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1 || ARDUINO_LMIC_CFG_SUBBAND == 1) 189 | # error "The Things Network network in US915 region is fixed at subband channels 8~15/65" 190 | # endif 191 | # define Arduino_LoRaWAN_REGION_TAG us915 192 | #elif defined(CFG_au915) 193 | # if ARDUINO_LMIC_CFG_NETWORK_TTN && defined(ARDUINO_LMIC_CFG_SUBBAND) && ! (ARDUINO_LMIC_CFG_SUBBAND == -1 || ARDUINO_LMIC_CFG_SUBBAND == 1) 194 | # error "The Things Network network in AU915 region is fixed at subband channels 8~15/65" 195 | # endif 196 | # define Arduino_LoRaWAN_REGION_TAG au915 197 | #elif defined(CFG_as923) 198 | # define Arduino_LoRaWAN_REGION_TAG as923 199 | #elif defined(CFG_in866) 200 | # define Arduino_LoRaWAN_REGION_TAG in866 201 | #elif defined(CFG_kr920) 202 | # define Arduino_LoRaWAN_REGION_TAG kr920 203 | #else 204 | # error "Can't define Arduino_LoRaWAN_REGION_TAG" 205 | #endif 206 | 207 | #define Arduino_LoRaWAN_ttn_LOCAL_(Region) \ 208 | Arduino_LoRaWAN_ttn_ ## Region 209 | 210 | #define Arduino_LoRaWAN_ttn_LOCAL(Region) \ 211 | Arduino_LoRaWAN_ttn_LOCAL_(Region) 212 | 213 | class Arduino_LoRaWAN_ttn : public Arduino_LoRaWAN_ttn_LOCAL(Arduino_LoRaWAN_REGION_TAG) 214 | { 215 | public: 216 | using Super = Arduino_LoRaWAN_ttn_LOCAL(Arduino_LoRaWAN_REGION_TAG); 217 | Arduino_LoRaWAN_ttn() {}; 218 | 219 | private: 220 | }; 221 | 222 | 223 | /**** end of Arduino_LoRaWAN_ttn.h ****/ 224 | #endif /* _ARDUINO_LORAWAN_TTN_H_ */ 225 | -------------------------------------------------------------------------------- /examples/simple_sensor_bme280/simple_sensor_bme280.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: simple_sensor_bme280.ino 4 | 5 | Function: 6 | Example app showing how to periodically poll a 7 | sensor. 8 | 9 | Copyright notice and License: 10 | See LICENSE file accompanying this project. 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation May 2021 14 | 15 | Notes: 16 | This app compiles and runs on an MCCI Catena 4610 board. 17 | 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /****************************************************************************\ 26 | | 27 | | The LoRaWAN object 28 | | 29 | \****************************************************************************/ 30 | 31 | class cMyLoRaWAN : public Arduino_LoRaWAN_network { 32 | public: 33 | cMyLoRaWAN() {}; 34 | using Super = Arduino_LoRaWAN_network; 35 | void setup(); 36 | 37 | protected: 38 | // you'll need to provide implementation for this. 39 | virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override; 40 | // if you have persistent storage, you can provide implementations for these: 41 | virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override; 42 | virtual void NetSaveSessionState(const SessionState &State) override; 43 | virtual bool NetGetSessionState(SessionState &State) override; 44 | }; 45 | 46 | 47 | /****************************************************************************\ 48 | | 49 | | The sensor object 50 | | 51 | \****************************************************************************/ 52 | 53 | class cSensor { 54 | public: 55 | /// \brief the constructor. Deliberately does very little. 56 | cSensor() {}; 57 | 58 | /// 59 | /// \brief set up the sensor object 60 | /// 61 | /// \param uplinkPeriodMs optional uplink interval. If not specified, 62 | /// transmit every six minutes. 63 | /// 64 | void setup(std::uint32_t uplinkPeriodMs = 6 * 60 * 1000); 65 | 66 | /// 67 | /// \brief update sensor loop. 68 | /// 69 | /// \details 70 | /// This should be called from the global loop(); it periodically 71 | /// gathers and transmits sensor data. 72 | /// 73 | void loop(); 74 | 75 | private: 76 | void doUplink(); 77 | 78 | bool m_fUplinkRequest; // set true when uplink is requested 79 | bool m_fBusy; // set true while sending an uplink 80 | std::uint32_t m_uplinkPeriodMs; // uplink period in milliseconds 81 | std::uint32_t m_tReference; // time of last uplink 82 | 83 | // The temperature/humidity sensor 84 | Adafruit_BME280 m_BME280; // The default initalizer creates an I2C connection 85 | }; 86 | 87 | /****************************************************************************\ 88 | | 89 | | Globals 90 | | 91 | \****************************************************************************/ 92 | 93 | // the global LoRaWAN instance. 94 | cMyLoRaWAN myLoRaWAN {}; 95 | 96 | // the global sensor instance 97 | cSensor mySensor {}; 98 | 99 | // the global event log instance 100 | Arduino_LoRaWAN::cEventLog myEventLog; 101 | 102 | /****************************************************************************\ 103 | | 104 | | Provisioning info for LoRaWAN OTAA 105 | | 106 | \****************************************************************************/ 107 | 108 | // 109 | // For normal use, we require that you edit the sketch to replace FILLMEIN_x 110 | // with values assigned by the your network. However, for regression tests, 111 | // we want to be able to compile these scripts. The regression tests define 112 | // COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN_x to non- 113 | // working but innocuous values. 114 | // 115 | // #define COMPILE_REGRESSION_TEST 1 116 | 117 | #ifdef COMPILE_REGRESSION_TEST 118 | # define FILLMEIN_8 1, 0, 0, 0, 0, 0, 0, 0 119 | # define FILLMEIN_16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 120 | #else 121 | # warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" 122 | # define FILLMEIN_8 (#dont edit this, edit the lines that use FILLMEIN_8) 123 | # define FILLMEIN_16 (#dont edit this, edit the lines that use FILLMEIN_16) 124 | #endif 125 | 126 | // deveui, little-endian 127 | static const std::uint8_t deveui[] = { FILLMEIN_8 }; 128 | 129 | // appeui, little-endian 130 | static const std::uint8_t appeui[] = { FILLMEIN_8 }; 131 | 132 | // appkey: just a string of bytes, sometimes referred to as "big endian". 133 | static const std::uint8_t appkey[] = { FILLMEIN_16 }; 134 | 135 | /****************************************************************************\ 136 | | 137 | | setup() 138 | | 139 | \****************************************************************************/ 140 | 141 | void setup() { 142 | // set baud rate, and wait for serial to be ready. 143 | Serial.begin(115200); 144 | while (! Serial) 145 | yield(); 146 | 147 | Serial.println(F("simple_sensor_bmi280.ino: setup()")); 148 | 149 | // set up the log; do this fisrt. 150 | myEventLog.setup(); 151 | 152 | // set up lorawan. 153 | myLoRaWAN.setup(); 154 | 155 | // similarly, set up the sensor. 156 | mySensor.setup(); 157 | } 158 | 159 | /****************************************************************************\ 160 | | 161 | | loop() 162 | | 163 | \****************************************************************************/ 164 | 165 | void loop() { 166 | // the order of these is arbitrary, but you must poll them all. 167 | myLoRaWAN.loop(); 168 | mySensor.loop(); 169 | myEventLog.loop(); 170 | } 171 | 172 | /****************************************************************************\ 173 | | 174 | | LoRaWAN methods 175 | | 176 | \****************************************************************************/ 177 | 178 | // our setup routine does the class setup and then registers an event handler so 179 | // we can see some interesting things 180 | void 181 | cMyLoRaWAN::setup() { 182 | // simply call begin() w/o parameters, and the LMIC's built-in 183 | // configuration for this board will be used. 184 | this->Super::begin(); 185 | 186 | // LMIC_selectSubBand(0); 187 | LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100); 188 | 189 | this->RegisterListener( 190 | // use a lambda so we're "inside" the cMyLoRaWAN from public/private perspective 191 | [](void *pClientInfo, uint32_t event) -> void { 192 | auto const pThis = (cMyLoRaWAN *)pClientInfo; 193 | 194 | // for tx start, we quickly capture the channel and the RPS 195 | if (event == EV_TXSTART) { 196 | // use another lambda to make log prints easy 197 | myEventLog.logEvent( 198 | (void *) pThis, 199 | LMIC.txChnl, 200 | LMIC.rps, 201 | 0, 202 | // the print-out function 203 | [](cEventLog::EventNode_t const *pEvent) -> void { 204 | Serial.print(F(" TX:")); 205 | myEventLog.printCh(std::uint8_t(pEvent->getData(0))); 206 | myEventLog.printRps(rps_t(pEvent->getData(1))); 207 | } 208 | ); 209 | } 210 | // else if (event == some other), record with print-out function 211 | else { 212 | // do nothing. 213 | } 214 | }, 215 | (void *) this // in case we need it. 216 | ); 217 | } 218 | 219 | // this method is called when the LMIC needs OTAA info. 220 | // return false to indicate "no provisioning", otherwise 221 | // fill in the data and return true. 222 | bool 223 | cMyLoRaWAN::GetOtaaProvisioningInfo( 224 | OtaaProvisioningInfo *pInfo 225 | ) { 226 | // these are the same constants used in the LMIC compliance test script; eases testing 227 | // with the RedwoodComm RWC5020B/RWC5020M testers. 228 | 229 | // initialize info 230 | memcpy(pInfo->DevEUI, deveui, sizeof(pInfo->DevEUI)); 231 | memcpy(pInfo->AppEUI, appeui, sizeof(pInfo->AppEUI)); 232 | memcpy(pInfo->AppKey, appkey, sizeof(pInfo->AppKey)); 233 | 234 | return true; 235 | } 236 | 237 | // save Info somewhere (if possible) 238 | // if not possible, just do nothing and make sure you return false 239 | // from NetGetSessionState(). 240 | void 241 | cMyLoRaWAN::NetSaveSessionInfo( 242 | const SessionInfo &Info, 243 | const uint8_t *pExtraInfo, 244 | size_t nExtraInfo 245 | ) { 246 | // in this example, we can't save, so we just return. 247 | } 248 | 249 | // save State somewhere. Note that it's often the same; 250 | // often only the frame counters change. 251 | // if not possible, just do nothing and make sure you return false 252 | // from NetGetSessionState(). 253 | void 254 | cMyLoRaWAN::NetSaveSessionState(const SessionState &State) { 255 | // in this example, we can't save, so we just return. 256 | } 257 | 258 | // either fetch SessionState from somewhere and return true or... 259 | // return false, which forces a re-join. 260 | bool 261 | cMyLoRaWAN::NetGetSessionState(SessionState &State) { 262 | // we didn't save earlier, so just tell the core we don't have data. 263 | return false; 264 | } 265 | 266 | 267 | /****************************************************************************\ 268 | | 269 | | Sensor methods 270 | | 271 | \****************************************************************************/ 272 | 273 | void 274 | cSensor::setup(std::uint32_t uplinkPeriodMs) { 275 | if (! this->m_BME280.begin(BME280_ADDRESS, Adafruit_BME280::OPERATING_MODE::Sleep)) { 276 | while (true) { 277 | // just loop forever, printing an error occasionally. 278 | Serial.println("BME280.begin failed"); 279 | delay(2000); 280 | } 281 | } 282 | 283 | // set the initial time. 284 | this->m_uplinkPeriodMs = uplinkPeriodMs; 285 | this->m_tReference = millis(); 286 | 287 | // uplink right away 288 | this->m_fUplinkRequest = true; 289 | } 290 | 291 | void 292 | cSensor::loop(void) { 293 | auto const tNow = millis(); 294 | auto const deltaT = tNow - this->m_tReference; 295 | 296 | if (deltaT >= this->m_uplinkPeriodMs) { 297 | // request an uplink 298 | this->m_fUplinkRequest = true; 299 | 300 | // keep trigger time locked to uplinkPeriod 301 | auto const advance = deltaT / this->m_uplinkPeriodMs; 302 | this->m_tReference += advance * this->m_uplinkPeriodMs; 303 | } 304 | 305 | // if an uplink was requested, do it. 306 | if (this->m_fUplinkRequest) { 307 | this->m_fUplinkRequest = false; 308 | this->doUplink(); 309 | } 310 | } 311 | 312 | void 313 | cSensor::doUplink(void) { 314 | // if busy uplinking, just skip 315 | if (this->m_fBusy) 316 | return; 317 | // if LMIC is busy, just skip 318 | if (LMIC.opmode & (OP_POLL | OP_TXDATA | OP_TXRXPEND)) 319 | return; 320 | 321 | // make a measurement on the BME280 322 | auto const m = this->m_BME280.readTemperaturePressureHumidity(); 323 | 324 | Serial.print("Sensor: T="); Serial.print(m.Temperature); 325 | Serial.print(" degC, P="); Serial.print(m.Pressure); 326 | Serial.print(" hPa, RH="); Serial.print(m.Humidity); 327 | Serial.println("%"); 328 | 329 | // format the uplink 330 | // temperature is 2 bytes from -0x80.00 to +0x7F.FF degrees C 331 | // humidity is 2 bytes, where 0 == 0% and 0xFFFF == 100%. 332 | // pressure is 3 bytes, Pa. 333 | // big-endian. 334 | 335 | std::uint8_t uplink[7]; 336 | auto const t = m.Temperature; 337 | auto const it = std::int16_t(floor(t * 256 + 0.5)); 338 | auto const up = std::uint32_t(floor(m.Pressure + 0.5)); 339 | auto const uh = std::uint16_t(m.Humidity / 100.0 * 65535 + 0.5); 340 | 341 | uplink[0] = std::uint8_t(std::uint16_t(it) >> 8); 342 | uplink[1] = std::uint8_t(it); 343 | uplink[2] = std::uint8_t(uh >> 8); 344 | uplink[3] = std::uint8_t(uh); 345 | uplink[4] = std::uint8_t(up >> 16); 346 | uplink[5] = std::uint8_t(up >> 8); 347 | uplink[6] = std::uint8_t(up); 348 | 349 | this->m_fBusy = true; 350 | 351 | if (! myLoRaWAN.SendBuffer( 352 | uplink, sizeof(uplink), 353 | // this is the completion function: 354 | [](void *pClientData, bool fSucccess) -> void { 355 | auto const pThis = (cSensor *)pClientData; 356 | pThis->m_fBusy = false; 357 | }, 358 | (void *)this, 359 | /* confirmed */ false, 360 | /* port */ 1 361 | )) { 362 | // sending failed; callback has not been called and will not 363 | // be called. Reset busy flag. 364 | this->m_fBusy = false; 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /src/lib/arduino_lorawan_begin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: arduino_lorawan_begin.cpp 4 | 5 | Function: 6 | Arduino_LoRaWAN::begin(); 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation October 2016 13 | 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* the global instance pointer */ 24 | Arduino_LoRaWAN *Arduino_LoRaWAN::pLoRaWAN = NULL; 25 | 26 | // if called with no arguments, ask the library 27 | bool Arduino_LoRaWAN::begin() 28 | { 29 | return this->begin(Arduino_LMIC::GetPinmap_ThisBoard()); 30 | } 31 | 32 | bool Arduino_LoRaWAN::begin( 33 | const Arduino_LMIC::HalPinmap_t * pPinmap 34 | ) 35 | { 36 | // record self in a static so that we can dispatch events 37 | ASSERT(Arduino_LoRaWAN::pLoRaWAN == this || 38 | Arduino_LoRaWAN::pLoRaWAN == NULL); 39 | 40 | Arduino_LoRaWAN::pLoRaWAN = this; 41 | 42 | // Initialize the LMIC -- need to pass a void* pointer through to the HAL, 43 | // but it must point to an instance of ArduinoLMIC::HalConfiguration_t. 44 | if (! os_init_ex(pPinmap)) 45 | return false; 46 | 47 | // Reset the MAC state. Session and pending data transfers will be 48 | // discarded. 49 | LMIC_reset(); 50 | 51 | // if we can get saved state, go on. 52 | auto const fHaveSavedState = this->RestoreSessionState(); 53 | if (! fHaveSavedState) 54 | { 55 | // Otherwise set data rate and transmit power, based on regional considerations. 56 | this->NetBeginRegionInit(); 57 | } 58 | 59 | // 60 | // If no provisioning info, return false. 61 | // 62 | if (this->GetProvisioningStyle() == ProvisioningStyle::kNone) 63 | return false; 64 | 65 | // 66 | // this will succeed either if provisioned for ABP, or if OTAA and we 67 | // have successfully joined. Note that ABP is just exactly the same 68 | // as what happens after a join, so we use this for fetching all the 69 | // required information. 70 | // 71 | AbpProvisioningInfo abpInfo; 72 | 73 | if ((fHaveSavedState || this->GetProvisioningStyle() == ProvisioningStyle::kABP) && 74 | this->GetAbpProvisioningInfo(&abpInfo)) 75 | { 76 | LMIC_setSession( 77 | abpInfo.NetID, 78 | abpInfo.DevAddr, 79 | abpInfo.NwkSKey, 80 | abpInfo.AppSKey 81 | ); 82 | 83 | // set the FCntUp and FCntDown 84 | // presumably if non-zero, somebody is stashing these 85 | // in NVR 86 | LMIC.seqnoUp = abpInfo.FCntUp; 87 | LMIC.seqnoDn = abpInfo.FCntDown; 88 | 89 | // because it's ABP, we need to set up the parameters we'd set 90 | // after an OTAA join. 91 | this->NetJoin(); 92 | } 93 | 94 | return true; 95 | } 96 | 97 | /****************************************************************************\ 98 | | 99 | | The event dispatcher. 100 | | 101 | \****************************************************************************/ 102 | 103 | void onEvent(ev_t ev) 104 | { 105 | Arduino_LoRaWAN * const pLoRaWAN = Arduino_LoRaWAN::GetInstance(); 106 | 107 | ASSERT(pLoRaWAN != NULL); 108 | 109 | pLoRaWAN->DispatchEvent(ev); 110 | } 111 | 112 | void Arduino_LoRaWAN::DispatchEvent( 113 | uint32_t ev 114 | ) 115 | { 116 | ARDUINO_LORAWAN_PRINTF( 117 | LogVerbose, 118 | "EV_%s\n", 119 | cLMIC::GetEventName(ev) 120 | ); 121 | 122 | // do the usual work in another function, for clarity. 123 | this->StandardEventProcessor(ev); 124 | 125 | // dispatch to the registered clients 126 | for (unsigned i = 0; i < this->m_nRegisteredListeners; ++i) 127 | { 128 | this->m_RegisteredListeners[i].ReportEvent(ev); 129 | } 130 | } 131 | 132 | bool Arduino_LoRaWAN::RegisterListener( 133 | ARDUINO_LORAWAN_EVENT_FN *pEventFn, 134 | void *pContext 135 | ) 136 | { 137 | if (this->m_nRegisteredListeners < 138 | MCCIADK_LENOF(this->m_RegisteredListeners)) 139 | { 140 | Arduino_LoRaWAN::Listener * const pListener = 141 | &this->m_RegisteredListeners[this->m_nRegisteredListeners]; 142 | ++this->m_nRegisteredListeners; 143 | 144 | pListener->pEventFn = pEventFn; 145 | pListener->pContext = pContext; 146 | return true; 147 | } 148 | else 149 | { 150 | return false; 151 | } 152 | } 153 | 154 | const char * 155 | Arduino_LoRaWAN::cLMIC::GetEventName(uint32_t ev) 156 | { 157 | static const char szEventNames[] = ARDUINO_LORAWAN_LMIC_EV_NAMES_MZ__INIT; 158 | const char *p; 159 | 160 | if (ev < ARDUINO_LORAWAN_LMIC_EV_NAMES__BASE) 161 | return "<>"; 162 | 163 | p = McciAdkLib_MultiSzIndex( 164 | szEventNames, 165 | ev - ARDUINO_LORAWAN_LMIC_EV_NAMES__BASE 166 | ); 167 | 168 | if (*p == '\0') 169 | return "<>"; 170 | else 171 | return p; 172 | } 173 | 174 | void 175 | Arduino_LoRaWAN::SaveSessionInfo() 176 | { 177 | SessionInfo Info; 178 | Info.V1.Tag = kSessionInfoTag_V2; 179 | Info.V1.Size = sizeof(Info); 180 | Info.V1.Rsv2 = 0; 181 | Info.V1.Rsv3 = 0; 182 | LMIC_getSessionKeys(&Info.V1.NetID, &Info.V1.DevAddr, Info.V1.NwkSKey, Info.V1.AppSKey); 183 | this->NetSaveSessionInfo(Info, nullptr, 0); 184 | } 185 | 186 | /* 187 | 188 | Name: Arduino_LoRaWAN::StandardEventProcessor() 189 | 190 | Function: 191 | Handle LMIC events. 192 | 193 | Definition: 194 | private: void Arduino_LoRaWAN::StandardEventProcessor( 195 | uint32_t ev 196 | ); 197 | 198 | Description: 199 | The simple events emitted from the LMIC core are processed, both 200 | to arrange for completions and notifications for asynchronous events, 201 | and to generate notifications to cause data to be pushed to the 202 | platform's persistent storage. 203 | 204 | Returns: 205 | No explicit result. 206 | 207 | */ 208 | 209 | void Arduino_LoRaWAN::StandardEventProcessor( 210 | uint32_t ev 211 | ) 212 | { 213 | // update our idea of the downlink counter. 214 | this->UpdateFCntDown(LMIC.seqnoDn); 215 | 216 | switch(ev) 217 | { 218 | case EV_SCAN_TIMEOUT: 219 | break; 220 | case EV_BEACON_FOUND: 221 | break; 222 | case EV_BEACON_MISSED: 223 | break; 224 | case EV_BEACON_TRACKED: 225 | break; 226 | case EV_JOINING: 227 | { 228 | // Set data rate and transmit power, based on regional considerations. 229 | // Allows regions to change the channel mask (which otherwise will 230 | // be reset to the region default -- possibly not what you want). 231 | this->NetBeginRegionInit(); 232 | 233 | // Update the session info 234 | this->SaveSessionInfo(); 235 | 236 | // save everything else of interest. 237 | this->SaveSessionState(); 238 | } 239 | break; 240 | 241 | case EV_JOINED: 242 | { 243 | // announce that we have joined; allows for 244 | // network-specific fixups, and saving keys. 245 | this->NetJoin(); 246 | 247 | this->SaveSessionInfo(); 248 | 249 | // save everything else of interest. 250 | this->SaveSessionState(); 251 | } 252 | break; 253 | 254 | case EV_RFU1: 255 | break; 256 | 257 | case EV_JOIN_FAILED: 258 | // we failed the join. But we keep trying; client must 259 | // do a reset to stop us. 260 | // TODO(tmm@mcci.com): this->NetJoinFailed(), and/or 261 | // an outcall 262 | break; 263 | 264 | case EV_REJOIN_FAILED: 265 | // after we join, if ABP is enabled (LMIC_setLinkCheck(true)), 266 | // if we don't get downlink messages for a while, we'll try to 267 | // rejoin. This message indicated that the rejoin failed. 268 | // TODO(tmm@mcci.com): this->NetRejoinFailed(), and/or 269 | // an outcall 270 | break; 271 | 272 | case EV_TXCOMPLETE: 273 | this->SaveSessionState(); 274 | 275 | // notify framework that RX may be available (because this happens 276 | // after every transmit). 277 | this->NetRxComplete(); 278 | 279 | // notify framework that tx is complete 280 | this->NetTxComplete(); 281 | break; 282 | 283 | case EV_LOST_TSYNC: 284 | // only for class-B or class-C: we lost beacon time synch. 285 | break; 286 | 287 | case EV_RESET: 288 | // the LoRaWAN MAC just got reset due to a pending frame rollover 289 | // on FCntDn or actual rollover on FCntUp. 290 | 291 | // Set default data rate, channels, and transmit power, based on regional considerations. 292 | // If we're configured for ABP, we're done; but if we're configured for OTAA, we'll 293 | // rejoin and the session data will be saved (again) at EV_JOIN. 294 | this->NetBeginRegionInit(); 295 | this->SaveSessionState(); 296 | break; 297 | 298 | case EV_RXCOMPLETE: 299 | // data received in ping slot 300 | // see TXCOMPLETE. 301 | this->SaveSessionState(); 302 | 303 | // follow protocol: 304 | this->NetRxComplete(); 305 | break; 306 | 307 | case EV_LINK_DEAD: 308 | break; 309 | 310 | case EV_LINK_ALIVE: 311 | break; 312 | 313 | case EV_SCAN_FOUND: 314 | break; 315 | 316 | case EV_TXSTART: 317 | break; 318 | 319 | case EV_TXCANCELED: 320 | this->SaveSessionState(); 321 | break; 322 | 323 | case EV_JOIN_TXCOMPLETE: 324 | break; 325 | 326 | default: 327 | break; 328 | } 329 | } 330 | 331 | void Arduino_LoRaWAN::NetRxComplete(void) 332 | { 333 | // notify client that RX is available 334 | if (LMIC.dataLen != 0 || LMIC.dataBeg != 0) 335 | { 336 | uint8_t port; 337 | port = 0; 338 | if (LMIC.txrxFlags & TXRX_PORT) 339 | port = LMIC.frame[LMIC.dataBeg - 1]; 340 | 341 | if (this->m_pReceiveBufferFn) 342 | { 343 | this->m_pReceiveBufferFn( 344 | this->m_pReceiveBufferCtx, 345 | port, 346 | LMIC.frame + LMIC.dataBeg, 347 | LMIC.dataLen 348 | ); 349 | } 350 | } 351 | } 352 | 353 | /****************************************************************************\ 354 | | 355 | | Getting provisioning info 356 | | 357 | \****************************************************************************/ 358 | 359 | void os_getArtEui(uint8_t* buf) 360 | { 361 | Arduino_LoRaWAN * const pLoRaWAN = Arduino_LoRaWAN::GetInstance(); 362 | 363 | ASSERT(pLoRaWAN != NULL); 364 | 365 | pLoRaWAN->GetAppEUI(buf); 366 | } 367 | 368 | bool Arduino_LoRaWAN::GetAppEUI( 369 | uint8_t *pBuf 370 | ) 371 | { 372 | OtaaProvisioningInfo otaaInfo; 373 | 374 | if (! this->GetOtaaProvisioningInfo(&otaaInfo)) 375 | return false; 376 | 377 | memcpy( 378 | pBuf, 379 | otaaInfo.AppEUI, 380 | sizeof(otaaInfo.AppEUI) 381 | ); 382 | 383 | return true; 384 | } 385 | 386 | void os_getDevEui(uint8_t* buf) 387 | { 388 | Arduino_LoRaWAN * const pLoRaWAN = Arduino_LoRaWAN::GetInstance(); 389 | 390 | ASSERT(pLoRaWAN != NULL); 391 | 392 | pLoRaWAN->GetDevEUI(buf); 393 | } 394 | 395 | bool Arduino_LoRaWAN::GetDevEUI( 396 | uint8_t *pBuf 397 | ) 398 | { 399 | OtaaProvisioningInfo otaaInfo; 400 | 401 | if (! this->GetOtaaProvisioningInfo(&otaaInfo)) 402 | return false; 403 | 404 | memcpy( 405 | pBuf, 406 | otaaInfo.DevEUI, 407 | sizeof(otaaInfo.DevEUI) 408 | ); 409 | 410 | return true; 411 | } 412 | 413 | 414 | 415 | void os_getDevKey(uint8_t* buf) 416 | { 417 | Arduino_LoRaWAN * const pLoRaWAN = Arduino_LoRaWAN::GetInstance(); 418 | 419 | ASSERT(pLoRaWAN != NULL); 420 | 421 | pLoRaWAN->GetAppKey(buf); 422 | } 423 | 424 | bool Arduino_LoRaWAN::GetAppKey( 425 | uint8_t *pBuf 426 | ) 427 | { 428 | OtaaProvisioningInfo otaaInfo; 429 | 430 | if (! this->GetOtaaProvisioningInfo(&otaaInfo)) 431 | return false; 432 | 433 | memcpy( 434 | pBuf, 435 | otaaInfo.AppKey, 436 | sizeof(otaaInfo.AppKey) 437 | ); 438 | 439 | return true; 440 | } 441 | 442 | --------------------------------------------------------------------------------