LightingAppCommandDelegate.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. *
  3. * Copyright (c) 2023 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #pragma once
  19. #include "NamedPipeCommands.h"
  20. #include <json/json.h>
  21. #include <platform/DiagnosticDataProvider.h>
  22. class LightingAppCommandHandler
  23. {
  24. public:
  25. static LightingAppCommandHandler * FromJSON(const char * json);
  26. static void HandleCommand(intptr_t context);
  27. LightingAppCommandHandler(Json::Value && jasonValue) : mJsonValue(std::move(jasonValue)) {}
  28. private:
  29. Json::Value mJsonValue;
  30. bool IsClusterPresentOnAnyEndpoint(chip::ClusterId clusterId);
  31. /**
  32. * Should be called when a reason that caused the device to start-up has been set.
  33. */
  34. void OnRebootSignalHandler(chip::DeviceLayer::BootReasonType bootReason);
  35. /**
  36. * Should be called when a general fault takes place on the Node.
  37. */
  38. void OnGeneralFaultEventHandler(uint32_t eventId);
  39. /**
  40. * Should be called when a software fault takes place on the Node.
  41. */
  42. void OnSoftwareFaultEventHandler(uint32_t eventId);
  43. /**
  44. * Should be called when the latching switch is moved to a new position.
  45. */
  46. void OnSwitchLatchedHandler(uint8_t newPosition);
  47. /**
  48. * Should be called when the momentary switch starts to be pressed.
  49. */
  50. void OnSwitchInitialPressedHandler(uint8_t newPosition);
  51. /**
  52. * Should be called when the momentary switch has been pressed for a "long" time.
  53. */
  54. void OnSwitchLongPressedHandler(uint8_t newPosition);
  55. /**
  56. * Should be called when the momentary switch has been released.
  57. */
  58. void OnSwitchShortReleasedHandler(uint8_t previousPosition);
  59. /**
  60. * Should be called when the momentary switch has been released after having been pressed for a long time.
  61. */
  62. void OnSwitchLongReleasedHandler(uint8_t previousPosition);
  63. /**
  64. * Should be called to indicate how many times the momentary switch has been pressed in a multi-press
  65. * sequence, during that sequence.
  66. */
  67. void OnSwitchMultiPressOngoingHandler(uint8_t newPosition, uint8_t count);
  68. /**
  69. * Should be called to indicate how many times the momentary switch has been pressed in a multi-press
  70. * sequence, after it has been detected that the sequence has ended.
  71. */
  72. void OnSwitchMultiPressCompleteHandler(uint8_t previousPosition, uint8_t count);
  73. };
  74. class LightingAppCommandDelegate : public NamedPipeCommandDelegate
  75. {
  76. public:
  77. void OnEventCommandReceived(const char * json) override;
  78. };