Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
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.

MyGatewayTransport.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * The MySensors Arduino library handles the wireless radio link and protocol
  3. * between your home built sensors/actuators and HA controller of choice.
  4. * The sensors forms a self healing radio network with optional repeaters. Each
  5. * repeater and gateway builds a routing tables in EEPROM which keeps track of the
  6. * network topology allowing messages to be routed to nodes.
  7. *
  8. * Created by Tomas Hozza <thozza@gmail.com>
  9. * Copyright (C) 2015 Tomas Hozza
  10. * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
  11. *
  12. * Documentation: http://www.mysensors.org
  13. * Support Forum: http://forum.mysensors.org
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * version 2 as published by the Free Software Foundation.
  18. */
  19. /**
  20. * @file MyGatewayTransport.h
  21. *
  22. * @defgroup MyGatewayTransportgrp MyGatewayTransport
  23. * @ingroup internals
  24. * @{
  25. *
  26. * Gateway transport-related log messages, format: [!]SYSTEM:[SUB SYSTEM:]MESSAGE
  27. * - [!] Exclamation mark is prepended in case of error
  28. * - SYSTEM:
  29. * - <b>GWT</b>: messages emitted by MyGatewayTransport
  30. * - SUB SYSTEMS:
  31. * - GWT:<b>TIN</b> from @ref gatewayTransportInit()
  32. * - GWT:<b>TPS</b> from @ref gatewayTransportSend()
  33. * - GWT:<b>IMQ</b> from incomingMQTT()
  34. * - GWT:<b>RMQ</b> from reconnectMQTT()
  35. * - GWT:<b>TPC</b> from gatewayTransportConnect()
  36. * - GWT:<b>RFC</b> from _readFromClient()
  37. * - GWT:<b>TSA</b> from @ref gatewayTransportAvailable()
  38. * - GWT:<b>TRC</b> from @ref gatewayTransportReceive()
  39. *
  40. * Gateway transport debug log messages :
  41. *
  42. * |E| SYS | SUB | Message | Comment
  43. * |-|-----|-------|---------------------------|---------------------------------------------------------------------
  44. * | | GWT | TIN | CONNECTING... | Connecting to router
  45. * | | GWT | TIN | IP=%%s | IP address [%%s] obtained
  46. * |!| GWT | TIN | DHCP FAIL | DHCP request failed
  47. * | | GWT | TIN | ETH OK | Connected to network
  48. * |!| GWT | TIN | ETH FAIL | Connection failed
  49. * | | GWT | TPS | TOPIC=%%s,MSG SENT | MQTT message sent on topic [%%s]
  50. * | | GWT | TPS | ETH OK | Connected to network
  51. * |!| GWT | TPS | ETH FAIL | Connection failed
  52. * | | GWT | IMQ | TOPIC=%%s,MSG RECEIVE | MQTT message received on topic [%%s]
  53. * | | GWT | RMQ | MQTT RECONNECT | Reconnecting to MQTT broker
  54. * | | GWT | RMQ | MQTT CONNECTED | Connected to MQTT broker
  55. * | | GWT | TPC | CONNECTING... | Connecting to MQTT broker
  56. * | | GWT | TPC | IP=%%s | IP address [%%s] obtained
  57. * |!| GWT | TPC | DHCP FAIL | DHCP request failed
  58. * | | GWT | RFC | C=%%d,MSG=%%s | Received message [%%s] from client [%%d]
  59. * |!| GWT | RFC | C=%%d,MSG TOO LONG | Received message from client [%%d] too long
  60. * | | GWT | TSA | UDP MSG=%%s | Received UDP message [%%s]
  61. * | | GWT | TSA | ETH OK | Connected to network
  62. * |!| GWT | TSA | ETH FAIL | Connection failed
  63. * | | GWT | TSA | C=%d,DISCONNECTED | Client [%%d] disconnected
  64. * | | GWT | TSA | C=%d,CONNECTED | Client [%%d] connected
  65. * |!| GWT | TSA | NO FREE SLOT | No free slot for client
  66. * |!| GWT | TRC | IP RENEW FAIL | IP renewal failed
  67. *
  68. * @brief API declaration for MyGatewayTransport
  69. *
  70. */
  71. #ifndef MyGatewayTransport_h
  72. #define MyGatewayTransport_h
  73. #include "MyProtocol.h"
  74. #include "MySensorsCore.h"
  75. #define MSG_GW_STARTUP_COMPLETE "Gateway startup complete." //!< Gateway startup message
  76. #if defined(MY_DEBUG_VERBOSE_GATEWAY)
  77. #define GATEWAY_DEBUG(x,...) DEBUG_OUTPUT(x, ##__VA_ARGS__) //!< debug output
  78. #else
  79. #define GATEWAY_DEBUG(x,...) //!< debug NULL
  80. #endif
  81. /**
  82. * @brief Process gateway-related messages
  83. */
  84. void gatewayTransportProcess(void);
  85. /**
  86. * @brief Initialize gateway transport driver
  87. * @return true if transport initialized
  88. */
  89. bool gatewayTransportInit(void);
  90. /**
  91. * @brief Send message to controller
  92. * @param message to send
  93. * @return true if message delivered
  94. */
  95. bool gatewayTransportSend(MyMessage &message);
  96. /**
  97. * @brief Check if a new message is available from controller
  98. * @return true if message available
  99. */
  100. bool gatewayTransportAvailable(void);
  101. /**
  102. * @brief Pick up last message received from controller
  103. * @return message
  104. */
  105. MyMessage& gatewayTransportReceive(void);
  106. #endif /* MyGatewayTransportEthernet_h */
  107. /** @}*/