Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
4.0 KiB

  1. /*
  2. WIFI MODULE CONFIG
  3. Copyright (C) 2020 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
  4. */
  5. #pragma once
  6. #include "espurna.h"
  7. namespace wifi {
  8. namespace build {
  9. constexpr size_t NetworksMax { WIFI_MAX_NETWORKS };
  10. constexpr unsigned long staReconnectionInterval() {
  11. return WIFI_RECONNECT_INTERVAL;
  12. }
  13. constexpr unsigned long staConnectionInterval() {
  14. return WIFI_CONNECT_INTERVAL;
  15. }
  16. constexpr int staConnectionRetries() {
  17. return WIFI_CONNECT_RETRIES;
  18. }
  19. constexpr wifi::StaMode staMode() {
  20. return WIFI_STA_MODE;
  21. }
  22. constexpr bool softApCaptive() {
  23. return 1 == WIFI_AP_CAPTIVE_ENABLED;
  24. }
  25. constexpr wifi::ApMode softApMode() {
  26. return WIFI_AP_MODE;
  27. }
  28. constexpr uint8_t softApChannel() {
  29. return WIFI_AP_CHANNEL;
  30. }
  31. constexpr bool hasSoftApSsid() {
  32. return strlen(WIFI_AP_SSID);
  33. }
  34. const __FlashStringHelper* softApSsid() {
  35. return F(WIFI_AP_SSID);
  36. }
  37. constexpr bool hasSoftApPassphrase() {
  38. return strlen(WIFI_AP_PASS);
  39. }
  40. const __FlashStringHelper* softApPassphrase() {
  41. return F(WIFI_AP_PASS);
  42. }
  43. constexpr unsigned long softApFallbackTimeout() {
  44. return WIFI_FALLBACK_TIMEOUT;
  45. }
  46. constexpr bool scanNetworks() {
  47. return 1 == WIFI_SCAN_NETWORKS;
  48. }
  49. constexpr int8_t scanRssiThreshold() {
  50. return WIFI_SCAN_RSSI_THRESHOLD;
  51. }
  52. constexpr unsigned long scanRssiCheckInterval() {
  53. return WIFI_SCAN_RSSI_CHECK_INTERVAL;
  54. }
  55. constexpr int8_t scanRssiChecks() {
  56. return WIFI_SCAN_RSSI_CHECKS;
  57. }
  58. constexpr unsigned long garpIntervalMin() {
  59. return WIFI_GRATUITOUS_ARP_INTERVAL_MIN;
  60. }
  61. constexpr unsigned long garpIntervalMax() {
  62. return WIFI_GRATUITOUS_ARP_INTERVAL_MAX;
  63. }
  64. constexpr WiFiSleepType_t sleep() {
  65. return WIFI_SLEEP_MODE;
  66. }
  67. constexpr float outputDbm() {
  68. return WIFI_OUTPUT_POWER_DBM;
  69. }
  70. constexpr bool hasSsid(size_t index) {
  71. return (
  72. (index == 0) ? (strlen(WIFI1_SSID) > 0) :
  73. (index == 1) ? (strlen(WIFI2_SSID) > 0) :
  74. (index == 2) ? (strlen(WIFI3_SSID) > 0) :
  75. (index == 3) ? (strlen(WIFI4_SSID) > 0) :
  76. (index == 4) ? (strlen(WIFI5_SSID) > 0) : false
  77. );
  78. }
  79. constexpr bool hasIp(size_t index) {
  80. return (
  81. (index == 0) ? (strlen(WIFI1_IP) > 0) :
  82. (index == 1) ? (strlen(WIFI2_IP) > 0) :
  83. (index == 2) ? (strlen(WIFI3_IP) > 0) :
  84. (index == 3) ? (strlen(WIFI4_IP) > 0) :
  85. (index == 4) ? (strlen(WIFI5_IP) > 0) : false
  86. );
  87. }
  88. const __FlashStringHelper* ssid(size_t index) {
  89. return (
  90. (index == 0) ? F(WIFI1_SSID) :
  91. (index == 1) ? F(WIFI2_SSID) :
  92. (index == 2) ? F(WIFI3_SSID) :
  93. (index == 3) ? F(WIFI4_SSID) :
  94. (index == 4) ? F(WIFI5_SSID) : nullptr
  95. );
  96. }
  97. const __FlashStringHelper* passphrase(size_t index) {
  98. return (
  99. (index == 0) ? F(WIFI1_PASS) :
  100. (index == 1) ? F(WIFI2_PASS) :
  101. (index == 2) ? F(WIFI3_PASS) :
  102. (index == 3) ? F(WIFI4_PASS) :
  103. (index == 4) ? F(WIFI5_PASS) : nullptr
  104. );
  105. }
  106. const __FlashStringHelper* ip(size_t index) {
  107. return (
  108. (index == 0) ? F(WIFI1_IP) :
  109. (index == 1) ? F(WIFI2_IP) :
  110. (index == 2) ? F(WIFI3_IP) :
  111. (index == 3) ? F(WIFI4_IP) :
  112. (index == 4) ? F(WIFI5_IP) : nullptr
  113. );
  114. }
  115. const __FlashStringHelper* gateway(size_t index) {
  116. return (
  117. (index == 0) ? F(WIFI1_GW) :
  118. (index == 1) ? F(WIFI2_GW) :
  119. (index == 2) ? F(WIFI3_GW) :
  120. (index == 3) ? F(WIFI4_GW) :
  121. (index == 4) ? F(WIFI5_GW) : nullptr
  122. );
  123. }
  124. const __FlashStringHelper* mask(size_t index) {
  125. return (
  126. (index == 0) ? F(WIFI1_MASK) :
  127. (index == 1) ? F(WIFI2_MASK) :
  128. (index == 2) ? F(WIFI3_MASK) :
  129. (index == 3) ? F(WIFI4_MASK) :
  130. (index == 4) ? F(WIFI5_MASK) : nullptr
  131. );
  132. }
  133. const __FlashStringHelper* dns(size_t index) {
  134. return (
  135. (index == 0) ? F(WIFI1_DNS) :
  136. (index == 1) ? F(WIFI2_DNS) :
  137. (index == 2) ? F(WIFI3_DNS) :
  138. (index == 3) ? F(WIFI4_DNS) :
  139. (index == 4) ? F(WIFI5_DNS) : nullptr
  140. );
  141. }
  142. } // namespace build
  143. } // namespace wifi