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.

MyTransportHAL.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 Henrik Ekblad <henrik.ekblad@mysensors.org>
  9. * Copyright (C) 2013-2018 Sensnology AB
  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. #ifndef MyTransportHAL_h
  20. #define MyTransportHAL_h
  21. #define INVALID_SNR ((int16_t)-256) //!< INVALID_SNR
  22. #define INVALID_RSSI ((int16_t)-256) //!< INVALID_RSSI
  23. #define INVALID_PERCENT ((int16_t)-100) //!< INVALID_PERCENT
  24. #define INVALID_LEVEL ((int16_t)-256) //!< INVALID_LEVEL
  25. #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
  26. #if defined(MY_RADIO_NRF5_ESB)
  27. #error Receive message buffering not supported for NRF5 radio! Please define MY_NRF5_RX_BUFFER_SIZE
  28. #endif
  29. #if defined(MY_RADIO_RFM69)
  30. #error Receive message buffering not supported for RFM69!
  31. #endif
  32. #if defined(MY_RADIO_RFM95)
  33. #error Receive message buffering not supported for RFM95!
  34. #endif
  35. #if defined(MY_RS485)
  36. #error Receive message buffering not supported for RS485!
  37. #endif
  38. #elif defined(MY_RX_MESSAGE_BUFFER_SIZE)
  39. #error Receive message buffering requires message buffering feature enabled!
  40. #endif
  41. /**
  42. * @brief Signal report selector
  43. */
  44. typedef enum {
  45. SR_RX_RSSI, //!< SR_RX_RSSI
  46. SR_TX_RSSI, //!< SR_TX_RSSI
  47. SR_RX_SNR, //!< SR_RX_SNR
  48. SR_TX_SNR, //!< SR_TX_SNR
  49. SR_TX_POWER_LEVEL, //!< SR_TX_POWER_LEVEL
  50. SR_TX_POWER_PERCENT, //!< SR_TX_POWER_PERCENT
  51. SR_UPLINK_QUALITY, //!< SR_UPLINK_QUALITY
  52. SR_NOT_DEFINED //!< SR_NOT_DEFINED
  53. } signalReport_t;
  54. /**
  55. * @brief Initialize transport HW
  56. * @return true if initialization successful
  57. */
  58. bool transportInit(void);
  59. /**
  60. * @brief Set node address
  61. */
  62. void transportSetAddress(const uint8_t address);
  63. /**
  64. * @brief Retrieve node address
  65. */
  66. uint8_t transportGetAddress(void) __attribute__((unused));
  67. /**
  68. * @brief Send message
  69. * @param to recipient
  70. * @param data message to be sent
  71. * @param len length of message (header + payload)
  72. * @param noACK do not wait for ACK
  73. * @return true if message sent successfully
  74. */
  75. bool transportSend(const uint8_t to, const void *data, const uint8_t len,
  76. const bool noACK = false);
  77. /**
  78. * @brief Verify if RX FIFO has pending messages
  79. * @return true if message available in RX FIFO
  80. */
  81. bool transportAvailable(void);
  82. /**
  83. * @brief Sanity check for transport: is transport HW still responsive?
  84. * @return true if transport HW is ok
  85. */
  86. bool transportSanityCheck(void);
  87. /**
  88. * @brief Receive message from FIFO
  89. * @return length of received message (header + payload)
  90. */
  91. uint8_t transportReceive(void *data);
  92. /**
  93. * @brief Power down transport HW (if corresponding MY_XYZ_POWER_PIN defined)
  94. */
  95. void transportPowerDown(void);
  96. /**
  97. * @brief Power up transport HW (if corresponding MY_XYZ_POWER_PIN defined)
  98. */
  99. void transportPowerUp(void);
  100. /**
  101. * @brief Set transport HW to sleep (no power down)
  102. */
  103. void transportSleep(void);
  104. /**
  105. * @brief Set transport HW to standby
  106. */
  107. void transportStandBy(void);
  108. /**
  109. * @brief transportGetSendingRSSI
  110. * @return RSSI of outgoing message (via ACK packet)
  111. */
  112. int16_t transportGetSendingRSSI(void);
  113. /**
  114. * @brief transportGetReceivingRSSI
  115. * @return RSSI of incoming message
  116. */
  117. int16_t transportGetReceivingRSSI(void);
  118. /**
  119. * @brief transportGetSendingSNR
  120. * @return SNR of outgoing message (via ACK packet)
  121. */
  122. int16_t transportGetSendingSNR(void);
  123. /**
  124. * @brief transportGetReceivingSNR
  125. * @return SNR of incoming message
  126. */
  127. int16_t transportGetReceivingSNR(void);
  128. /**
  129. * @brief transportGetTxPowerPercent
  130. * @return TX power level in percent
  131. */
  132. int16_t transportGetTxPowerPercent(void);
  133. /**
  134. * @brief transportSetTxPowerPercent
  135. * @param powerPercent power level in percent
  136. * @return True if power level set
  137. */
  138. bool transportSetTxPowerPercent(const uint8_t powerPercent) __attribute__((unused));
  139. /**
  140. * @brief transportGetTxPowerLevel
  141. * @return TX power in dBm
  142. */
  143. int16_t transportGetTxPowerLevel(void);
  144. #endif // MyTransportHAL_h