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.

MyTransport.h 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. /**
  20. * @file MyTransport.h
  21. *
  22. * @defgroup MyTransportgrp MyTransport
  23. * @ingroup internals
  24. * @{
  25. *
  26. * Transport-related log messages, format: [!]SYSTEM:[SUB SYSTEM:]MESSAGE
  27. * - [!] Exclamation mark is prepended in case of error
  28. * - SYSTEM:
  29. * - <b>TSM</b>: messages emitted by the transport state machine
  30. * - <b>TSF</b>: messages emitted by transport support functions
  31. * - SUB SYSTEMS:
  32. * - Transport state machine (<b>TSM</b>)
  33. * - TSM:<b>INIT</b> from <b>stInit</b> Initialize transport and radio
  34. * - TSM:<b>FPAR</b> from <b>stParent</b> Find parent
  35. * - TSM:<b>ID</b> from <b>stID</b> Check/request node ID, if dynamic node ID set
  36. * - TSM:<b>UPL</b> from <b>stUplink</b> Verify uplink connection by pinging GW
  37. * - TSM:<b>READY</b> from <b>stReady</b> Transport is ready and fully operational
  38. * - TSM:<b>FAIL</b> from <b>stFailure</b> Failure in transport link or transport HW
  39. * - Transport support function (<b>TSF</b>)
  40. * - TSF:<b>CKU</b> from @ref transportCheckUplink(), checks connection to GW
  41. * - TSF:<b>SID</b> from @ref transportAssignNodeID(), assigns node ID
  42. * - TSF:<b>PNG</b> from @ref transportPingNode(), pings a node
  43. * - TSF:<b>WUR</b> from @ref transportWaitUntilReady(), waits until transport is ready
  44. * - TSF:<b>CRT</b> from @ref transportClearRoutingTable(), clears routing table stored in EEPROM
  45. * - TSF:<b>LRT</b> from @ref transportLoadRoutingTable(), loads RAM routing table from EEPROM (only GW/repeaters)
  46. * - TSF:<b>SRT</b> from @ref transportSaveRoutingTable(), saves RAM routing table to EEPROM (only GW/repeaters)
  47. * - TSF:<b>MSG</b> from @ref transportProcessMessage(), processes incoming message
  48. * - TSF:<b>SAN</b> from @ref transportInvokeSanityCheck(), calls transport-specific sanity check
  49. * - TSF:<b>RTE</b> from @ref transportRouteMessage(), sends message
  50. * - TSF:<b>SND</b> from @ref transportSendRoute(), sends message if transport is ready (exposed)
  51. * - TSF:<b>TDI</b> from @ref transportDisable()
  52. * - TSF:<b>TRI</b> from @ref transportReInitialise()
  53. * - TSF:<b>SIR</b> from @ref transportSignalReport()
  54. *
  55. * Transport debug log messages:
  56. *
  57. * |E| SYS | SUB | Message | Comment
  58. * |-|-----|-------|---------------------------|---------------------------------------------------------------------
  59. * | | TSM | INIT | | <b>Transition to stInit state</b>
  60. * | | TSM | INIT | STATID=%%d | Node ID is static
  61. * | | TSM | INIT | TSP OK | Transport device configured and fully operational
  62. * | | TSM | INIT | TSP PSM | Transport passive mode set
  63. * | | TSM | INIT | GW MODE | Node is set up as GW, thus omitting ID and findParent states
  64. * |!| TSM | INIT | TSP FAIL | Transport device initialization failed
  65. * | | TSM | FPAR | | <b>Transition to stParent state</b>
  66. * | | TSM | FPAR | STATP=%%d | Static parent set, skip finding parent
  67. * | | TSM | FPAR | OK | Parent node identified
  68. * |!| TSM | FPAR | NO REPLY | No potential parents replied to find parent request
  69. * |!| TSM | FPAR | FAIL | Finding parent failed
  70. * | | TSM | ID | | <b>Transition to stID state</b>
  71. * | | TSM | ID | OK,ID=%%d | Node ID is valid
  72. * | | TSM | ID | REQ | Request node ID from controller
  73. * |!| TSM | ID | FAIL,ID=%%d | ID verification failed, ID invalid, no ID received from controller
  74. * | | TSM | UPL | | <b>Transition to stUplink state</b>
  75. * | | TSM | UPL | OK | Uplink OK, GW returned ping
  76. * | | TSF | UPL | DGWC,O=%%d,N=%%d | Uplink check revealed changed network topology, old distance (O), new distance (N)
  77. * |!| TSM | UPL | FAIL | Uplink check failed, i.e. GW could not be pinged
  78. * | | TSM | READY | SRT | Save routing table
  79. * | | TSM | READY | ID=%%d,PAR=%%d,DIS=%%d | <b>Transition to stReady</b> Transport ready, node ID (ID), parent node ID (PAR), distance to GW (DIS)
  80. * |!| TSM | READY | UPL FAIL,SNP | Too many failed uplink transmissions, search new parent
  81. * |!| TSM | READY | FAIL,STATP | Too many failed uplink transmissions, static parent enforced
  82. * | | TSM | FAIL | CNT=%%d | <b>Transition to stFailure state</b>, consecutive failure counter (CNT)
  83. * | | TSM | FAIL | DIS | Disable transport
  84. * | | TSM | FAIL | RE-INIT | Attempt to re-initialize transport
  85. * | | TSF | CKU | OK | Uplink OK
  86. * | | TSF | CKU | OK,FCTRL | Uplink OK, flood control prevents pinging GW in too short intervals
  87. * | | TSF | CKU | DGWC,O=%%d,N=%%d | Uplink check revealed changed network topology, old distance (O), new distance (N)
  88. * | | TSF | CKU | FAIL | No reply received when checking uplink
  89. * | | TSF | SID | OK,ID=%%d | Node ID assigned
  90. * |!| TSF | SID | FAIL,ID=%%d | Assigned ID is invalid
  91. * | | TSF | PNG | SEND,TO=%%d | Send ping to destination (TO)
  92. * | | TSF | WUR | MS=%%lu | Wait until transport ready, timeout (MS)
  93. * | | TSF | MSG | ACK REQ | ACK message requested
  94. * | | TSF | MSG | ACK | ACK message, do not proceed but forward to callback
  95. * | | TSF | MSG | FPAR RES,ID=%%d,D=%%d | Response to find parent received from node (ID) with distance (D) to GW
  96. * | | TSF | MSG | FPAR PREF FOUND | Preferred parent found, i.e. parent defined via MY_PARENT_NODE_ID
  97. * | | TSF | MSG | FPAR OK,ID=%%d,D=%%d | Find parent response from node (ID) is valid, distance (D) to GW
  98. * | | TSF | MSG | FPAR INACTIVE | Find parent response received, but no find parent request active, skip response
  99. * | | TSF | MSG | FPAR REQ,ID=%%d | Find parent request from node (ID)
  100. * | | TSF | MSG | PINGED,ID=%%d,HP=%%d | Node pinged by node (ID) with (HP) hops
  101. * | | TSF | MSG | PONG RECV,HP=%%d | Pinged node replied with (HP) hops
  102. * | | TSF | MSG | BC | Broadcast message received
  103. * | | TSF | MSG | GWL OK | Link to GW ok
  104. * | | TSF | MSG | FWD BC MSG | Controlled broadcast message forwarding
  105. * | | TSF | MSG | RCV CB | Hand over message to @ref receive() callback function
  106. * | | TSF | MSG | REL MSG | Relay message
  107. * | | TSF | MSG | REL PxNG,HP=%%d | Relay PING/PONG message, increment hop counter (HP)
  108. * |!| TSF | MSG | LEN=%%d,EXP=%%d | Invalid message length (LEN), exptected length (EXP)
  109. * |!| TSF | MSG | PVER,%%d!=%%d | Message protocol version mismatch (actual!=expected)
  110. * |!| TSF | MSG | SIGN VERIFY FAIL | Signing verification failed
  111. * |!| TSF | MSG | REL MSG,NORP | Node received a message for relaying, but node is not a repeater, message skipped
  112. * |!| TSF | MSG | SIGN FAIL | Signing message failed
  113. * |!| TSF | MSG | GWL FAIL | GW uplink failed
  114. * |!| TSF | MSG | ID TK INVALID | Token for ID request invalid
  115. * | | TSF | SAN | OK | Sanity check passed
  116. * |!| TSF | SAN | FAIL | Sanity check failed, attempt to re-initialize radio
  117. * | | TSF | CRT | OK | Clearing routing table successful
  118. * | | TSF | LRT | OK | Loading routing table successful
  119. * | | TSF | SRT | OK | Saving routing table successful
  120. * |!| TSF | RTE | FPAR ACTIVE | Finding parent active, message not sent
  121. * |!| TSF | RTE | DST %%d UNKNOWN | Routing for destination (DST) unknown, send message to parent
  122. * | | TSF | RTE | N2N OK | Node-to-node communication succeeded
  123. * |!| TSF | RTE | N2N FAIL | Node-to-node communication failed, handing over to parent for re-routing
  124. * | | TSF | RRT | ROUTE N=%%d,R=%%d | Routing table, messages to node (N) are routed via node (R)
  125. * |!| TSF | SND | TNR | Transport not ready, message cannot be sent
  126. * | | TSF | TDI | TSL | Set transport to sleep
  127. * | | TSF | TDI | TPD | Power down transport
  128. * | | TSF | TRI | TRI | Reinitialise transport
  129. * | | TSF | TRI | TSB | Set transport to standby
  130. * | | TSF | SIR | CMD=%d,VAL=%d | Get signal report
  131. *
  132. *
  133. * Incoming / outgoing messages:
  134. *
  135. * See <a href="https://www.mysensors.org/download/serial_api_20">here</a> for more detail on the format and definitions.
  136. *
  137. * Receiving a message
  138. * - TSF:MSG:READ,sender-last-destination,s=%%d,c=%%d,t=%%d,pt=%%d,l=%%d,sg=%%d:%%s
  139. *
  140. * Sending a message
  141. * - [!/?]TSF:MSG:SEND,sender-last-next-destination,s=%%d,c=%%d,t=%%d,pt=%%d,l=%%d,sg=%%d,ft=%%d,st=%%s:%%s
  142. *
  143. * Prepended char:
  144. * - <b>none</b>=sending OK
  145. * - <b>!</b>=error sending
  146. * - <b>?</b>=sending status unknown
  147. * Message fields:
  148. * - <b>s</b>=sensor ID
  149. * - <b>c</b>=command
  150. * - <b>t</b>=msg type
  151. * - <b>pt</b>=payload type
  152. * - <b>l</b>=length
  153. * - <b>sg</b>=signing flag
  154. * - <b>ft</b>=failed uplink transmission counter
  155. * - <b>st</b>=send status, OK=success, NACK=no radio ACK received
  156. *
  157. * @brief API declaration for MyTransport
  158. *
  159. */
  160. #ifndef MyTransport_h
  161. #define MyTransport_h
  162. #include "hal/transport/MyTransportHAL.h"
  163. #ifndef MY_TRANSPORT_MAX_TX_FAILURES
  164. #if defined(MY_REPEATER_FEATURE)
  165. #define MY_TRANSPORT_MAX_TX_FAILURES (10u) //!< search for a new parent node after this many transmission failures, higher threshold for repeating nodes
  166. #else
  167. #define MY_TRANSPORT_MAX_TX_FAILURES (5u) //!< search for a new parent node after this many transmission failures, lower threshold for non-repeating nodes
  168. #endif
  169. #endif
  170. #ifndef MY_TRANSPORT_MAX_TSM_FAILURES
  171. #define MY_TRANSPORT_MAX_TSM_FAILURES (7u) //!< Max. number of consecutive TSM failure state entries (3bits)
  172. #endif
  173. #ifndef MY_TRANSPORT_TIMEOUT_FAILURE_STATE_MS
  174. #define MY_TRANSPORT_TIMEOUT_FAILURE_STATE_MS (10*1000ul) //!< Duration failure state (in ms)
  175. #endif
  176. #ifndef MY_TRANSPORT_TIMEOUT_EXT_FAILURE_STATE_MS
  177. #define MY_TRANSPORT_TIMEOUT_EXT_FAILURE_STATE_MS (60*1000ul) //!< Duration extended failure state (in ms)
  178. #endif
  179. #ifndef MY_TRANSPORT_STATE_TIMEOUT_MS
  180. #define MY_TRANSPORT_STATE_TIMEOUT_MS (2*1000ul) //!< general state timeout (in ms)
  181. #endif
  182. #ifndef MY_TRANSPORT_CHKUPL_INTERVAL_MS
  183. #define MY_TRANSPORT_CHKUPL_INTERVAL_MS (10*1000ul) //!< Interval to re-check uplink (in ms)
  184. #endif
  185. #ifndef MY_TRANSPORT_STATE_RETRIES
  186. #define MY_TRANSPORT_STATE_RETRIES (3u) //!< retries before switching to FAILURE
  187. #endif
  188. #define AUTO (255u) //!< ID 255 is reserved
  189. #define BROADCAST_ADDRESS (255u) //!< broadcasts are addressed to ID 255
  190. #define DISTANCE_INVALID (255u) //!< invalid distance when searching for parent
  191. #define MAX_HOPS (254u) //!< maximal number of hops for ping/pong
  192. #define INVALID_HOPS (255u) //!< invalid hops
  193. #define MAX_SUBSEQ_MSGS (5u) //!< Maximum number of subsequently processed messages in FIFO (to prevent transport deadlock if HW issue)
  194. #define UPLINK_QUALITY_WEIGHT (0.05f) //!< UPLINK_QUALITY_WEIGHT
  195. // parent node check
  196. #if defined(MY_PARENT_NODE_IS_STATIC) && !defined(MY_PARENT_NODE_ID)
  197. #error MY_PARENT_NODE_IS_STATIC but no MY_PARENT_NODE_ID defined!
  198. #endif
  199. #define _autoFindParent (bool)(MY_PARENT_NODE_ID == AUTO) //!< returns true if static parent id is undefined
  200. #define isValidDistance(_distance) (bool)(_distance!=DISTANCE_INVALID) //!< returns true if distance is valid
  201. #define isValidParent(_parent) (bool)(_parent != AUTO) //!< returns true if parent is valid
  202. /**
  203. * @brief Callback type
  204. */
  205. typedef void(*transportCallback_t)(void);
  206. /**
  207. * @brief Node configuration
  208. *
  209. * This structure stores node-related configurations
  210. */
  211. typedef struct {
  212. uint8_t nodeId; //!< Current node id
  213. uint8_t parentNodeId; //!< Where this node sends its messages
  214. uint8_t distanceGW; //!< This nodes distance to sensor net gateway (number of hops)
  215. uint8_t passiveMode : 1; //!< Passive mode
  216. uint8_t reserved : 7; //!< Reserved
  217. } transportConfig_t;
  218. /**
  219. * @brief SM state
  220. *
  221. * This structure stores SM state definitions
  222. */
  223. typedef struct {
  224. void(*Transition)(void); //!< state transition function
  225. void(*Update)(void); //!< state update function
  226. } transportState_t;
  227. /**
  228. * @brief Datatype for internal RSSI storage
  229. */
  230. typedef int16_t transportRSSI_t; //!< Datatype for internal RSSI storage
  231. // helper macro for conversion
  232. #define transportInternalToRSSI(__value) ((int16_t)__value>>4) //!< Convert internal RSSI to RSSI
  233. #define transportRSSItoInternal(__value) ((transportRSSI_t)__value<<4) //!< Convert RSSI to internal RSSI
  234. /**
  235. * @brief Status variables and SM state
  236. *
  237. * This structure stores transport status and SM variables
  238. */
  239. typedef struct {
  240. // SM variables
  241. transportState_t *currentState; //!< pointer to current FSM state
  242. uint32_t stateEnter; //!< state enter timepoint
  243. // general transport variables
  244. uint32_t lastUplinkCheck; //!< last uplink check, required to prevent GW flooding
  245. // 8 bits
  246. bool findingParentNode : 1; //!< flag finding parent node is active
  247. bool preferredParentFound : 1; //!< flag preferred parent found
  248. bool uplinkOk : 1; //!< flag uplink ok
  249. bool pingActive : 1; //!< flag ping active
  250. bool transportActive : 1; //!< flag transport active
  251. uint8_t stateRetries : 3; //!< retries / state re-enter (max 7)
  252. // 8 bits
  253. uint8_t failedUplinkTransmissions : 4; //!< counter failed uplink transmissions (max 15)
  254. uint8_t failureCounter : 3; //!< counter for TSM failures (max 7)
  255. bool msgReceived : 1; //!< flag message received
  256. uint8_t pingResponse; //!< stores I_PONG hops
  257. transportRSSI_t uplinkQualityRSSI; //!< Uplink quality, internal RSSI representation
  258. } transportSM_t;
  259. /**
  260. * @brief RAM routing table
  261. */
  262. typedef struct {
  263. uint8_t route[SIZE_ROUTES]; //!< route for node
  264. } routingTable_t;
  265. // PRIVATE functions
  266. /**
  267. * @brief Initialize SM variables and transport HW
  268. */
  269. void stInitTransition(void);
  270. /**
  271. * @brief Initialize transport
  272. */
  273. void stInitUpdate(void);
  274. /**
  275. * @brief Find parent
  276. */
  277. void stParentTransition(void);
  278. /**
  279. * @brief Verify find parent responses
  280. */
  281. void stParentUpdate(void);
  282. /**
  283. * @brief Send ID request
  284. */
  285. void stIDTransition(void);
  286. /**
  287. * @brief Verify ID response and GW link
  288. */
  289. void stIDUpdate(void);
  290. /**
  291. * @brief Send uplink ping request
  292. */
  293. void stUplinkTransition(void);
  294. /**
  295. * @brief Verify uplink response
  296. */
  297. void stUplinkUpdate(void);
  298. /**
  299. * @brief Set transport OK
  300. */
  301. void stReadyTransition(void);
  302. /**
  303. * @brief Monitor transport link
  304. */
  305. void stReadyUpdate(void);
  306. /**
  307. * @brief Transport failure and power down radio
  308. */
  309. void stFailureTransition(void);
  310. /**
  311. * @brief Re-initialize transport after timeout
  312. */
  313. void stFailureUpdate(void);
  314. /**
  315. * @brief Switch SM state
  316. * @param newState New state to switch SM to
  317. */
  318. void transportSwitchSM(transportState_t &newState);
  319. /**
  320. * @brief Update SM state
  321. */
  322. void transportUpdateSM(void);
  323. /**
  324. * @brief Request time in current SM state
  325. * @return ms in current state
  326. */
  327. uint32_t transportTimeInState(void);
  328. /**
  329. * @brief Call transport driver sanity check
  330. */
  331. void transportInvokeSanityCheck(void);
  332. /**
  333. * @brief Process all pending messages in RX FIFO
  334. */
  335. void transportProcessFIFO(void);
  336. /**
  337. * @brief Receive message from RX FIFO and process
  338. */
  339. void transportProcessMessage(void);
  340. /**
  341. * @brief Assign node ID
  342. * @param newNodeId New node ID
  343. * @return true if node ID is valid and successfully assigned
  344. */
  345. bool transportAssignNodeID(const uint8_t newNodeId);
  346. /**
  347. * @brief Wait and process messages for a defined amount of time until specified message received
  348. * @param waitingMS Time to wait and process incoming messages in ms
  349. * @param cmd Specific command
  350. * @param msgType Specific message type
  351. * @return true if specified command received within waiting time
  352. */
  353. bool transportWait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t msgType);
  354. /**
  355. * @brief Ping node
  356. * @param targetId Node to be pinged
  357. * @return hops from pinged node or 255 if no answer received within 2000ms
  358. */
  359. uint8_t transportPingNode(const uint8_t targetId);
  360. /**
  361. * @brief Send and route message according to destination
  362. *
  363. * This function is used in MyTransport and omits the transport state check, i.e. message can be sent even if transport is not ready
  364. *
  365. * @param message
  366. * @return true if message sent successfully
  367. */
  368. bool transportRouteMessage(MyMessage &message);
  369. /**
  370. * @brief Send and route message according to destination with transport state check
  371. * @param message
  372. * @return true if message sent successfully and false if sending error or transport !OK
  373. */
  374. bool transportSendRoute(MyMessage &message);
  375. /**
  376. * @brief Send message to recipient
  377. * @param to Recipient of message
  378. * @param message
  379. * @return true if message sent successfully
  380. */
  381. bool transportSendWrite(const uint8_t to, MyMessage &message);
  382. /**
  383. * @brief Check uplink to GW, includes flooding control
  384. * @param force to override flood control timer
  385. * @return true if uplink ok
  386. */
  387. bool transportCheckUplink(const bool force = false);
  388. // PUBLIC functions
  389. /**
  390. * @brief Wait until transport is ready
  391. * @param waitingMS timeout in MS, set 0 (default) for no timeout, i.e. wait indefinitely. For a node in standalone mode (optional network connection) set >0 to allow a node entering the main loop() function.
  392. * @return true if transport is ready
  393. */
  394. bool transportWaitUntilReady(const uint32_t waitingMS = 0);
  395. /**
  396. * @brief Initialize transport and SM
  397. */
  398. void transportInitialise(void);
  399. /**
  400. * @brief Process FIFO msg and update SM
  401. */
  402. void transportProcess(void);
  403. /**
  404. * @brief Flag transport ready
  405. * @return true if transport is initialized and ready
  406. */
  407. bool isTransportReady(void);
  408. /**
  409. * @brief Flag searching parent ongoing
  410. * @return true if transport is searching for parent
  411. */
  412. bool isTransportSearchingParent(void);
  413. /**
  414. * @brief Flag TSM extended failure
  415. * @return true if TSM had too many consecutive failure state entries
  416. */
  417. bool isTransportExtendedFailure(void);
  418. /**
  419. * @brief Flag valid message received
  420. * @return true if valid message received, needs to be reset if used
  421. */
  422. bool isMessageReceived(void);
  423. /**
  424. * @brief Reset message received flag
  425. */
  426. void resetMessageReceived(void);
  427. /**
  428. * @brief Clear routing table
  429. */
  430. void transportClearRoutingTable(void);
  431. /**
  432. * @brief Return heart beat
  433. * @return MS in current state
  434. */
  435. uint32_t transportGetHeartbeat(void);
  436. /**
  437. * @brief Load routing table from EEPROM to RAM.
  438. * Only for GW devices with enough RAM, i.e. ESP8266, RPI Sensebender GW, etc.
  439. * Atmega328 has only limited amount of RAM
  440. */
  441. void transportLoadRoutingTable(void);
  442. /**
  443. * @brief Save routing table to EEPROM.
  444. */
  445. void transportSaveRoutingTable(void);
  446. /**
  447. * @brief Update routing table
  448. * @param node
  449. * @param route
  450. */
  451. void transportSetRoute(const uint8_t node, const uint8_t route);
  452. /**
  453. * @brief Load route to node
  454. * @param node
  455. * @return route to node
  456. */
  457. uint8_t transportGetRoute(const uint8_t node);
  458. /**
  459. * @brief Reports content of routing table
  460. */
  461. void transportReportRoutingTable(void);
  462. /**
  463. * @brief Get node ID
  464. * @return node ID
  465. */
  466. uint8_t transportGetNodeId(void);
  467. /**
  468. * @brief Get parent node ID
  469. * @return parent node ID
  470. */
  471. uint8_t transportGetParentNodeId(void);
  472. /**
  473. * @brief Get distance to GW
  474. * @return distance (=hops) to GW
  475. */
  476. uint8_t transportGetDistanceGW(void);
  477. /**
  478. * @brief Toggle passive mode, i.e. transport does not wait for ACK
  479. * @param OnOff
  480. */
  481. void transportTogglePassiveMode(const bool OnOff);
  482. /**
  483. * @brief Disable transport, if xxx_POWER_PIN is defined, transport is powered down, else send to sleep
  484. */
  485. void transportDisable(void);
  486. /**
  487. * @brief Reinitialise transport. Put transport to standby - If xxx_POWER_PIN set, power up and go to standby
  488. */
  489. void transportReInitialise(void);
  490. /**
  491. * @brief Get transport signal report
  492. * @param command:
  493. * R = RSSI (if available) of incoming @ref I_SIGNAL_REPORT_REQUEST message (from last hop)
  494. * R! = RSSI (if available) of ACK to @ref I_SIGNAL_REPORT_REVERSE message received from last hop
  495. * S = SNR (if available) of incoming @ref I_SIGNAL_REPORT_REQUEST message (from last hop)
  496. * S! = SNR (if available) of ACK to @ref I_SIGNAL_REPORT_REVERSE message received from last hop
  497. * P = TX powerlevel in %
  498. * T = TX powerlevel in dBm
  499. * U = Uplink quality (via ACK from parent node), avg. RSSI
  500. * @return Signal report (if report is not available, INVALID_RSSI, INVALID_SNR, INVALID_PERCENT, or INVALID_LEVEL is sent instead)
  501. */
  502. int16_t transportSignalReport(const char command);
  503. /**
  504. * @brief Get transport signal report
  505. * @param signalReport
  506. * @return report
  507. */
  508. int16_t transportGetSignalReport(const signalReport_t signalReport);
  509. #endif // MyTransport_h
  510. /** @}*/