configNode.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // sensor.h; 1-channel LoRa Gateway for ESP8266
  2. // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
  3. //
  4. // based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
  5. // and many other contributors.
  6. //
  7. // All rights reserved. This program and the accompanying materials
  8. // are made available under the terms of the MIT License
  9. // which accompanies this distribution, and is available at
  10. // https://opensource.org/licenses/mit-license.php
  11. //
  12. // NO WARRANTY OF ANY KIND IS PROVIDED
  13. //
  14. // Author: Maarten Westenberg (mw12554@hotmail.com)
  15. //
  16. // This file contains a number of compile-time settings and declarations that are'
  17. // specific to the LoRa rfm95, sx1276, sx1272 radio of the gateway.
  18. //
  19. //
  20. // ------------------------------------------------------------------------------------
  21. // It is possible to use the gateway as a normal sensor node also. In this case,
  22. // substitute the node info below.
  23. #if GATEWAYNODE==1
  24. // Valid coding for internal sensors are LCODE and RAW.
  25. // Make sure to only select one.
  26. //#define _LCODE 1
  27. #define _RAW 1
  28. #define _CHECK_MIC 1
  29. #define _SENSOR_INTERVAL 300
  30. #define _DEVADDR { 0xAA, 0xAA, 0xAA, 0xAA }
  31. #define _APPSKEY { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB }
  32. #define _NWKSKEY { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }
  33. #define _SENSOR_INTERVAL 300
  34. // For ESP32 based T_BEAM/TTGO boards these two are normally included
  35. // If included make value 1, else if not, make them 0
  36. #define _GPS 1
  37. #define _BATTERY 1
  38. #endif //GATEWAYNODE
  39. #if _TRUSTED_NODES >= 1
  40. struct nodex {
  41. uint32_t id; // This is the LoRa ID (coded in 4 bytes uint32_t
  42. char nm[32]; // Name of the node
  43. };
  44. // Add all your named and trusted nodes to this list
  45. nodex nodes[] = {
  46. { 0x260116BD , "lora-34 PIR node" }, // F=0
  47. { 0x26011152 , "lora-35 temp+humi node" }, // F=0
  48. { 0x2601148C , "lora-36 test node" }, // F=0
  49. { 0x00000000 , "lora-00 well known sensor" } // F=0
  50. };
  51. #endif //_TRUSTED_NODES
  52. // In some cases we like to decode the lora message at the single channel gateway.
  53. // In thisase, we need the NkwSKey and the AppsSKey of the node so that we can decode
  54. // its messages.
  55. // Although this is probably overkill in normal gateway situations, it greatly helps
  56. // in debugging the node messages before they reach the TTN severs.
  57. //
  58. #if _LOCALSERVER==1
  59. struct codex {
  60. uint32_t id; // This is the device ID (coded in 4 bytes uint32_t
  61. char nm[32]; // A name string which is free to choose
  62. uint8_t nwkKey[16]; // The Network Session Key of 16 bytes
  63. uint8_t appKey[16]; // The Application Session Key of 16 bytes
  64. };
  65. // Sometimes we want to decode the sensor completely as we do in the TTN server
  66. // This means that for all nodes we want to view the data of, we need to provide
  67. // the AppsSKey and the NwkSKey
  68. // Definition of all nodes that we want to decode locally on the gateway.
  69. //
  70. codex decodes[] = {
  71. { 0xAAAAAAAA , "lora-EE", // F=0
  72. { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB },
  73. { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }
  74. },
  75. { 0xBBBBBBBB , "lora-FF", // F=0
  76. { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB },
  77. { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }
  78. },
  79. { 0x00000000 , "lora-00", // F=0
  80. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
  81. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
  82. }
  83. };
  84. #endif //_LOCALSERVER
  85. // If you have a second back-end server defined such as Semtech or loriot.io
  86. // your can define _THINGPORT and _THINGSERVER with your own value.
  87. // If not, make sure that you do not define these, which will save CPU time
  88. // Port is UDP port in this program
  89. //
  90. // Default for testing: Switched off
  91. // #define _THINGSERVER "your.extra.server" // Server URL of the LoRa-udp.js handler
  92. // #define _THINGPORT 1700 // Port 1700 is old compatibility
  93. // Wifi definitions
  94. // WPA is an array with SSID and password records. Set WPA size to number of entries in array
  95. // When using the WiFiManager, we will overwrite the first entry with the
  96. // accesspoint we last connected to with WifiManager
  97. // NOTE: Structure needs at least one (empty) entry.
  98. // So WPASIZE must be >= 1
  99. struct wpas {
  100. char login[32]; // Maximum Buffer Size (and allocated memory)
  101. char passw[64];
  102. };
  103. // Please fill in at least ONE SSID and password from your own WiFI network
  104. // below. This is needed to get the gateway working
  105. // Note: DO NOT use the first and the last line of the stucture, these should be empty strings and
  106. // the first line in te struct is reserved for WifiManager.
  107. //
  108. wpas wpa[] = {
  109. { "" , "" }, // Reserved for WiFi Manager
  110. { "yourSSID", "yourPassword" },
  111. { "Your2SSID", "your2Password" }
  112. };
  113. // Define the name of the accesspoint if the gateway is in accesspoint mode (is
  114. // getting WiFi SSID and password using WiFiManager)
  115. #define AP_NAME "ESP8266-Gway-Things4U"
  116. #define AP_PASSWD "ttnAutoPw"
  117. // For asserting and testing the following defines are used.
  118. //
  119. #if !defined(CFG_noassert)
  120. #define ASSERT(cond) if(!(cond)) gway_failed(__FILE__, __LINE__)
  121. #else
  122. #define ASSERT(cond) /**/
  123. #endif