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.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include "MyGatewayTransport.h"
  20. extern bool transportSendRoute(MyMessage &message);
  21. // global variables
  22. extern MyMessage _msg;
  23. extern MyMessage _msgTmp;
  24. inline void gatewayTransportProcess(void)
  25. {
  26. if (gatewayTransportAvailable()) {
  27. _msg = gatewayTransportReceive();
  28. if (_msg.destination == GATEWAY_ADDRESS) {
  29. // Check if sender requests an ack back.
  30. if (mGetRequestAck(_msg)) {
  31. // Copy message
  32. _msgTmp = _msg;
  33. mSetRequestAck(_msgTmp,
  34. false); // Reply without ack flag (otherwise we would end up in an eternal loop)
  35. mSetAck(_msgTmp, true);
  36. _msgTmp.sender = getNodeId();
  37. _msgTmp.destination = _msg.sender;
  38. gatewayTransportSend(_msgTmp);
  39. }
  40. if (mGetCommand(_msg) == C_INTERNAL) {
  41. if (_msg.type == I_VERSION) {
  42. // Request for version. Create the response
  43. gatewayTransportSend(buildGw(_msgTmp, I_VERSION).set(MYSENSORS_LIBRARY_VERSION));
  44. #ifdef MY_INCLUSION_MODE_FEATURE
  45. } else if (_msg.type == I_INCLUSION_MODE) {
  46. // Request to change inclusion mode
  47. inclusionModeSet(atoi(_msg.data) == 1);
  48. #endif
  49. } else {
  50. (void)_processInternalCoreMessage();
  51. }
  52. } else {
  53. // Call incoming message callback if available
  54. if (receive) {
  55. receive(_msg);
  56. }
  57. }
  58. } else {
  59. #if defined(MY_SENSOR_NETWORK)
  60. transportSendRoute(_msg);
  61. #endif
  62. }
  63. }
  64. }