loraFiles.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // 1-channel LoRa Gateway for ESP8266
  2. // Copyright (c) 2016-2020 Maarten Westenberg version for ESP mcu's
  3. //
  4. // based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
  5. // and many others.
  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 that can be set on (=1) or off (=0)
  17. // The disadvantage of compile time is minor compared to the memory gain of not having
  18. // too much code compiled and loaded on your ESP8266.
  19. //
  20. // ----------------------------------------------------------------------------------------
  21. // This file describes the includes necessary for ESP Filesystem.
  22. // At this moment there is only one record written to the ESP8266
  23. // filesystem. We can add more info, which makes the gateway even more usable,
  24. // however for large data we should only append to the existing file used.
  25. // This also means we'll have to check for available space so we won't run out of
  26. // storage space to quickly.
  27. // One way would be to use let's say 10 files of each 10000 lines and when full
  28. // delete the first file and start writing on a new one (for example)
  29. //
  30. // Define Pattern debug settings, this allows debugging per
  31. // module rather than per level. See also pdebug.
  32. //
  33. // P_SCAN statemachine
  34. // P_CAD
  35. // P_RX received actions only
  36. // P_TX transmissions
  37. // P_MAIN for main program setup() and loop()
  38. // P_GUI for www server GUI related
  39. // P_PRE for statemachine
  40. // P_RADIO; For code in _loraModem and _sensor
  41. #define P_SCAN 0x01
  42. #define P_CAD 0x02
  43. #define P_RX 0x04
  44. #define P_TX 0x08
  45. #define P_PRE 0x10
  46. #define P_MAIN 0x20
  47. #define P_GUI 0x40
  48. #define P_RADIO 0x80
  49. // Definition of the configuration record that is read at startup and written
  50. // when settings are changed.
  51. struct espGwayConfig {
  52. int32_t txDelay; // Init 0 at setup
  53. uint32_t ntpErrTime; // Record the time of the last NTP error
  54. uint16_t fcnt; // =0 as init value XXX Could be 32 bit in size
  55. uint16_t boots; // Number of restarts made by the gateway after reset
  56. uint16_t resets; // Number of statistics resets
  57. uint16_t views; // Number of sendWebPage() calls
  58. uint16_t wifis; // Number of WiFi Setups
  59. uint16_t reents; // Number of re-entrant interrupt handler calls
  60. uint16_t ntpErr; // Number of UTP requests that failed
  61. uint16_t ntps;
  62. uint16_t logFileRec; // Logging File Record number
  63. uint16_t logFileNo; // Logging File Number
  64. uint16_t logFileNum; // Number of log files max
  65. uint8_t ch; // index to freqs array, freqs[gwayCofnig.ch]=868100000 default
  66. uint8_t sf; // range from SF7 to SF12
  67. uint8_t debug; // range 0 to 4
  68. uint8_t pdebug; // pattern debug,
  69. uint8_t trusted; // pattern debug,
  70. bool cad; // is CAD enabled?
  71. bool hop; // Is HOP enabled (Note: default be disabled)
  72. bool isNode; // Is gateway node enabled
  73. bool refresh; // Is WWW browser refresh enabled
  74. bool seen;
  75. bool expert;
  76. bool monitor;
  77. } gwayConfig;
  78. // Define a log record to be written to the log file
  79. // Keep logfiles SHORT in name! to save memory
  80. #if _STAT_LOG == 1
  81. // We do keep admin of logfiles by number
  82. //
  83. //uint32_t logFileNo = 0; // Included in struct espGwayConfig LogFile number
  84. //uint32_t logFileRec = 0; // Number of records in a single logfile
  85. //uint32_t logFileNum = 1; // Number of log files
  86. #define LOGFILEMAX 10
  87. #define LOGFILEREC 100
  88. #endif // _STAT_LOG
  89. // Define the node list structure
  90. //
  91. #define nSF6 0x01
  92. #define nSF7 0x02
  93. #define nSF8 0x04
  94. #define nSF9 0x08
  95. #define nSF10 0x10
  96. #define nSF11 0x20
  97. #define nSF12 0x40
  98. #define nFSK 0x80
  99. // define the Seen functon as when we have seen seen nodes last time
  100. struct nodeSeen {
  101. time_t timSeen;
  102. uint32_t idSeen;
  103. uint32_t cntSeen;
  104. uint8_t chnSeen;
  105. uint8_t sfSeen; // Encode the SF seen.This might differ per message!
  106. };
  107. struct nodeSeen listSeen[_MAXSEEN];
  108. // define the logging structure used for printout of error and warning messages
  109. // We use a string for these lines (only time) as it is convenient.
  110. struct moniLine {
  111. String txt;
  112. };
  113. struct moniLine monitor[_MAXMONITOR];