IOControl/include/IO/RFSwitch/Request.h
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include <IO/Request.h>
25 #include "Device.h"
26 
27 namespace IO
28 {
29 namespace RFSwitch
30 {
31 class Request : public IO::Request
32 {
33  friend Device;
34  friend Controller;
35 
36 public:
38  {
39  // Only one command applicable, may as well be the default
40  setCommand(Command::set);
41  }
42 
43  const Device& getDevice() const
44  {
45  return reinterpret_cast<const Device&>(device);
46  }
47 
48  ErrorCode parseJson(JsonObjectConst json) override;
49 
50  void getJson(JsonObject json) const override;
51 
52  /*
53  * We'll get called with NODES_ALL because no nodes are explicitly specified.
54  */
55  bool setNode(DevNode node) override
56  {
57  return node == DevNode_ALL;
58  }
59 
60  void send(uint32_t code, uint8_t repeats = 0);
61 
62  uint32_t getCode() const
63  {
64  return code;
65  }
66 
68  {
69  return repeats;
70  }
71 
72 protected:
73  void callback()
74  {
75  // No response to interpret here, so we're done
77  }
78 
79 private:
80  uint32_t code{0};
81  uint8_t repeats{0};
82 };
83 
84 } // namespace RFSwitch
85 } // namespace IO
const Device & getDevice() const
Definition: IOControl/include/IO/RFSwitch/Request.h:43
Request(IO::Device &device)
Definition: IOControl/include/IO/RFSwitch/Request.h:37
void send(uint32_t code, uint8_t repeats=0)
uint8_t getRepeats() const
Definition: IOControl/include/IO/RFSwitch/Request.h:67
Identifies a device node.
Definition: DevNode.h:30
Definition: IOControl/include/IO/RFSwitch/Request.h:31
static constexpr DevNode DevNode_ALL
Definition: DevNode.h:53
Definition: Libraries/IOControl/include/IO/RFSwitch/Device.h:47
Definition: IOControl/include/IO/Controller.h:25
Handles requests for a specific device; the requests are executed by the relevant controller...
Definition: Libraries/IOControl/include/IO/Device.h:35
bool setNode(DevNode node) override
If nodes are supported, implemented this method.
Definition: IOControl/include/IO/RFSwitch/Request.h:55
uint32_t getCode() const
Definition: IOControl/include/IO/RFSwitch/Request.h:62
Json json
void getJson(JsonObject json) const override
Get result of a completed request in JSON format.
Request represents a single user request/response over a bus.
Definition: IOControl/include/IO/Request.h:75
void callback()
Definition: IOControl/include/IO/RFSwitch/Request.h:73
int16_t ErrorCode
Definition: Libraries/IOControl/include/IO/Error.h:27
Definition: Libraries/IOControl/include/IO/Error.h:70
void complete(ErrorCode err)
void setCommand(Command cmd)
Set the command code.
Definition: IOControl/include/IO/Request.h:163
Device & device
Definition: IOControl/include/IO/Request.h:259
Controller for 433MHz transmitter.
Definition: IOControl/include/IO/RFSwitch/Controller.h:40
ErrorCode parseJson(JsonObjectConst json) override
Fill this request from a JSON description.