34 #include "../Variable.h" 35 #include "../IEvents.h" 36 #include "../DeviceDescription/HomegearDevice.h" 37 #include "../Sockets/RpcClientInfo.h" 64 this->messageId = messageId;
68 this->messageId = messageId;
69 this->variables = variables;
79 virtual void onRemoveWebserverEventHandler(std::map<int32_t, PEventHandler> &eventHandlers) = 0;
81 virtual void onRPCEvent(std::string &source, uint64_t
id, int32_t
channel, std::string &deviceAddress, std::shared_ptr<std::vector<std::string>> &valueKeys, std::shared_ptr<std::vector<PVariable>> &values) = 0;
82 virtual void onRPCUpdateDevice(uint64_t
id, int32_t channel, std::string address, int32_t hint) = 0;
83 virtual void onRPCNewDevices(std::vector<uint64_t> &ids,
PVariable deviceDescriptions) = 0;
84 virtual void onRPCDeleteDevices(std::vector<uint64_t> &ids,
PVariable deviceAddresses,
PVariable deviceInfo) = 0;
85 virtual void onEvent(std::string &source, uint64_t
peerId, int32_t channel, std::shared_ptr<std::vector<std::string>> &variables, std::shared_ptr<std::vector<std::shared_ptr<BaseLib::Variable>>> &values) = 0;
86 virtual void onServiceMessageEvent(
const PServiceMessage &serviceMessage) = 0;
89 virtual uint64_t onGetRoomIdByName(std::string &
name) = 0;
96 virtual void dispose(
bool wait =
true);
99 virtual void save(
bool full);
104 virtual void homegearStarted();
109 virtual void homegearShuttingDown();
111 virtual int32_t deviceFamily();
115 virtual uint64_t
getId() {
return _deviceId; }
118 std::vector<std::shared_ptr<Peer>> getPeers();
119 std::shared_ptr<Peer> getPeer(int32_t address);
120 std::shared_ptr<Peer> getPeer(uint64_t
id);
121 std::shared_ptr<Peer> getPeer(std::string serialNumber);
123 virtual bool peerExists(int32_t address);
124 virtual bool peerExists(std::string serialNumber);
125 virtual bool peerExists(uint64_t
id);
126 virtual uint64_t getPeerIdFromSerial(std::string &serialNumber);
130 "Method not implemented for this central.");
135 virtual PVariable addChannelToBuildingPart(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t buildingPartId);
136 virtual PVariable addChannelToRoom(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t roomId);
137 virtual PVariable addLink(
PRpcClientInfo clientInfo, std::string senderSerialNumber, int32_t senderChannel, std::string receiverSerialNumber, int32_t receiverChannel, std::string
name, std::string description) {
139 "Method not implemented for this central.");
141 virtual PVariable addLink(
PRpcClientInfo clientInfo, uint64_t senderId, int32_t senderChannel, uint64_t receiverId, int32_t receiverChannel, std::string
name, std::string description) {
143 "Method not implemented for this central.");
147 "Method not implemented for this central.");
154 virtual PVariable getChannelsInBuildingPart(
PRpcClientInfo clientInfo, uint64_t buildingPartId,
bool checkAcls);
158 virtual PVariable getConfigParameter(
PRpcClientInfo clientInfo, uint64_t peerId, uint32_t channel, std::string name);
159 virtual PVariable getDeviceDescription(
PRpcClientInfo clientInfo, std::string serialNumber, int32_t channel, std::map<std::string, bool> fields);
160 virtual PVariable getDeviceDescription(
PRpcClientInfo clientInfo, uint64_t
id, int32_t channel, std::map<std::string, bool> fields);
161 virtual PVariable getDeviceInfo(
PRpcClientInfo clientInfo, uint64_t
id, std::map<std::string, bool> fields,
bool checkAcls);
162 virtual PVariable getDevicesInBuildingPart(
PRpcClientInfo clientInfo, uint64_t buildingPartId,
bool checkAcls);
165 virtual PVariable getPeerId(
PRpcClientInfo clientInfo, int32_t filterType, std::string filterValue,
bool checkAcls);
169 virtual PVariable getLinkInfo(
PRpcClientInfo clientInfo, std::string senderSerialNumber, int32_t senderChannel, std::string receiverSerialNumber, int32_t receiverChannel);
170 virtual PVariable getLinkInfo(
PRpcClientInfo clientInfo, uint64_t senderId, int32_t senderChannel, uint64_t receiverId, int32_t receiverChannel);
173 virtual PVariable getLinks(
PRpcClientInfo clientInfo, std::string serialNumber, int32_t channel, int32_t flags);
174 virtual PVariable getLinks(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, int32_t flags,
bool checkAcls);
183 virtual PVariable getRolesInRoom(
PRpcClientInfo clientInfo, uint64_t roomId,
bool checkDeviceAcls,
bool checkVariableAcls);
184 virtual PVariable getServiceMessages(
PRpcClientInfo clientInfo,
bool returnId,
const std::string &language,
bool checkAcls);
186 virtual PVariable getValue(
PRpcClientInfo clientInfo, std::string serialNumber, uint32_t channel, std::string valueKey,
bool requestFromDevice,
bool asynchronous);
187 virtual PVariable getValue(
PRpcClientInfo clientInfo, uint64_t
id, uint32_t channel, std::string valueKey,
bool requestFromDevice,
bool asynchronous);
188 virtual PVariable getVariableDescription(
PRpcClientInfo clientInfo, uint64_t
id, uint32_t channel, std::string valueKey,
const std::unordered_set<std::string> &fields);
189 virtual PVariable getVariablesInBuildingPart(
PRpcClientInfo clientInfo, uint64_t buildingPartId,
bool returnDeviceAssigned,
bool checkDeviceAcls,
bool checkVariableAcls);
190 virtual PVariable getVariablesInCategory(
PRpcClientInfo clientInfo, uint64_t categoryId,
bool checkDeviceAcls,
bool checkVariableAcls);
191 virtual PVariable getVariablesInRole(
PRpcClientInfo clientInfo, uint64_t roleId,
bool checkDeviceAcls,
bool checkVariableAcls);
192 virtual PVariable getVariablesInRoom(
PRpcClientInfo clientInfo, uint64_t roomId,
bool returnDeviceAssigned,
bool checkDeviceAcls,
bool checkVariableAcls);
194 virtual PVariable listDevices(
PRpcClientInfo clientInfo,
bool channels, std::map<std::string, bool> fields,
bool checkAcls);
195 virtual PVariable listDevices(
PRpcClientInfo clientInfo,
bool channels, std::map<std::string, bool> fields, std::shared_ptr<std::set<uint64_t>> knownDevices,
bool checkAcls);
200 virtual PVariable removeCategoryFromChannel(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t categoryId);
201 virtual PVariable removeChannelFromBuildingPart(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t buildingPartId);
202 virtual PVariable removeChannelFromRoom(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t roomId);
205 "Method not implemented for this central.");
220 virtual std::shared_ptr<BaseLib::Variable> setId(
PRpcClientInfo clientInfo, uint64_t oldPeerId, uint64_t newPeerId);
221 virtual std::shared_ptr<BaseLib::Variable> setSerialNumber(
PRpcClientInfo clientInfo, uint64_t peer_id,
const std::string &new_serial_number);
224 virtual PVariable setLinkInfo(
PRpcClientInfo clientInfo, std::string senderSerialNumber, int32_t senderChannel, std::string receiverSerialNumber, int32_t receiverChannel, std::string name, std::string description);
225 virtual PVariable setLinkInfo(
PRpcClientInfo clientInfo, uint64_t senderId, int32_t senderChannel, uint64_t receiverId, int32_t receiverChannel, std::string name, std::string description);
227 virtual PVariable setTeam(
PRpcClientInfo clientInfo, std::string serialNumber, int32_t channel, std::string teamSerialNumber, int32_t teamChannel,
bool force =
false,
bool burst =
true) {
229 "Method not implemented for this central.");
231 virtual PVariable setTeam(
PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t teamId, int32_t teamChannel,
bool force =
false,
bool burst =
true) {
233 "Method not implemented for this central.");
242 int32_t _deviceFamily = -1;
243 uint64_t _deviceId = 0;
244 int32_t _address = 0;
251 std::unordered_map<int32_t, std::shared_ptr<Peer>>
_peers;
270 virtual void raiseRemoveWebserverEventHandler(std::map<int32_t, PEventHandler> &eventHandlers);
272 virtual void raiseRPCEvent(std::string &source, uint64_t
id, int32_t channel, std::string &deviceAddress, std::shared_ptr<std::vector<std::string>> &valueKeys, std::shared_ptr<std::vector<PVariable>> &values);
273 virtual void raiseRPCUpdateDevice(uint64_t
id, int32_t channel, std::string address, int32_t hint);
274 virtual void raiseRPCNewDevices(std::vector<uint64_t> &ids,
PVariable deviceDescriptions);
275 virtual void raiseRPCDeleteDevices(std::vector<uint64_t> &ids,
PVariable deviceAddresses,
PVariable deviceInfo);
276 virtual void raiseEvent(std::string &source, uint64_t peerID, int32_t channel, std::shared_ptr<std::vector<std::string>> &variables, std::shared_ptr<std::vector<std::shared_ptr<BaseLib::Variable>>> &values);
277 virtual void raiseServiceMessageEvent(
const PServiceMessage &serviceMessage);
280 virtual uint64_t raiseGetRoomIdByName(std::string &name);
284 bool onPacketReceived(std::string &senderID, std::shared_ptr<Packet> packet)
override = 0;
290 void onRemoveWebserverEventHandler(std::map<int32_t, PEventHandler> &eventHandlers)
override;
292 void onRPCEvent(std::string &source, uint64_t
id, int32_t channel, std::string &deviceAddress, std::shared_ptr<std::vector<std::string>> &valueKeys, std::shared_ptr<std::vector<PVariable>> &values)
override;
293 void onRPCUpdateDevice(uint64_t
id, int32_t channel, std::string address, int32_t hint)
override;
294 void onEvent(std::string &source, uint64_t peerID, int32_t channel, std::shared_ptr<std::vector<std::string>> &variables, std::shared_ptr<std::vector<std::shared_ptr<BaseLib::Variable>>> &values)
override;
295 void onServiceMessageEvent(
const PServiceMessage &serviceMessage)
override;
300 virtual void setPeerId(uint64_t oldPeerId, uint64_t newPeerId);
301 virtual void setPeerSerialNumber(
const std::string &old_serial_number,
const std::string &new_serial_number);
302 virtual void deletePeersFromDatabase();
303 virtual void loadVariables() = 0;
306 virtual void saveVariables() = 0;
307 virtual void saveVariable(uint32_t index, int64_t intValue);
308 virtual void saveVariable(uint32_t index, std::string &stringValue);
309 virtual void saveVariable(uint32_t index, std::vector<uint8_t> &binaryValue);
314 std::map<int64_t, std::list<PPairingState>> _newPeersDefault;
std::string messageId
Definition: ICentral.h:54
std::list< std::string > variables
Definition: ICentral.h:55
virtual PVariable removeLink(PRpcClientInfo clientInfo, std::string senderSerialNumber, int32_t senderChannel, std::string receiverSerialNumber, int32_t receiverChannel)
Definition: ICentral.h:203
Definition: BinaryPayload.cpp:36
virtual PVariable setTeam(PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t teamId, int32_t teamChannel, bool force=false, bool burst=true)
Definition: ICentral.h:231
std::unordered_map< std::string, std::shared_ptr< Peer > > _peersBySerial
Definition: ICentral.h:252
int32_t deviceId
Definition: Licensing.h:381
virtual PVariable deleteDevice(PRpcClientInfo clientInfo, std::string serialNumber, int32_t flags)
Definition: ICentral.h:150
std::mutex _peersMutex
Definition: ICentral.h:254
std::shared_ptr< PairingState > PPairingState
Definition: ICentral.h:57
This is the base library main class.
Definition: BaseLib.h:95
virtual PVariable searchInterfaces(PRpcClientInfo clientInfo, PVariable metadata)
Definition: ICentral.h:210
std::list< PPairingMessage > _pairingMessages
Definition: ICentral.h:260
Definition: ICentral.h:75
std::map< int64_t, std::list< PPairingState > > _newPeers
Definition: ICentral.h:259
Definition: BaseLib.cpp:34
virtual PVariable activateLinkParamset(PRpcClientInfo clientInfo, std::string serialNumber, int32_t channel, std::string remoteSerialNumber, int32_t remoteChannel, bool longPress)
Definition: ICentral.h:128
virtual std::string handleCliCommand(std::string command)
Definition: ICentral.h:117
virtual std::string getSerialNumber()
Definition: ICentral.h:116
std::shared_ptr< Array > PArray
Definition: Variable.h:72
std::shared_ptr< RpcClientInfo > PRpcClientInfo
Definition: ScriptInfo.h:47
std::map< uint64_t, std::shared_ptr< Peer > > _peersById
Definition: ICentral.h:253
std::mutex _newPeersMutex
Definition: ICentral.h:258
std::shared_ptr< DeviceDescription::DeviceTranslations > _translations
Definition: ICentral.h:250
Definition: IPhysicalInterface.h:74
virtual PVariable updateFirmware(PRpcClientInfo clientInfo, std::vector< uint64_t > ids, bool manual)
Definition: ICentral.h:239
std::shared_ptr< ScriptInfo > PScriptInfo
Definition: ScriptInfo.h:56
std::list< std::string > variables
Definition: ICentral.h:61
PVariable value
Definition: UiElements.h:217
std::string _serialNumber
Definition: ICentral.h:245
virtual PVariable startSniffing(PRpcClientInfo clientInfo)
Definition: ICentral.h:237
virtual PVariable setInterface(PRpcClientInfo clientInfo, uint64_t peerId, std::string interfaceId)
Definition: ICentral.h:223
virtual PVariable addLink(PRpcClientInfo clientInfo, std::string senderSerialNumber, int32_t senderChannel, std::string receiverSerialNumber, int32_t receiverChannel, std::string name, std::string description)
Definition: ICentral.h:137
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
int32_t channel
Definition: UiElements.h:215
virtual PVariable setTeam(PRpcClientInfo clientInfo, std::string serialNumber, int32_t channel, std::string teamSerialNumber, int32_t teamChannel, bool force=false, bool burst=true)
Definition: ICentral.h:227
std::atomic_bool _initialized
Definition: ICentral.h:247
virtual PVariable getSniffedDevices(PRpcClientInfo clientInfo)
Definition: ICentral.h:185
std::atomic_bool _pairing
Definition: ICentral.h:256
Enum
Definition: ParameterGroup.h:63
Definition: ICentral.h:49
uint64_t peerId
Definition: UiElements.h:214
virtual PVariable stopSniffing(PRpcClientInfo clientInfo)
Definition: ICentral.h:238
virtual PVariable removeLink(PRpcClientInfo clientInfo, uint64_t senderId, int32_t senderChannel, uint64_t receiverId, int32_t receiverChannel)
Definition: ICentral.h:207
virtual uint64_t getId()
Definition: ICentral.h:115
virtual PVariable setInstallMode(PRpcClientInfo clientInfo, bool on, uint32_t duration, BaseLib::PVariable metadata, bool debugOutput=true)
Definition: ICentral.h:222
static PVariable createError(int32_t faultCode, const std::string &faultString, bool retry=false)
Definition: Variable.cpp:224
Definition: ICentral.h:59
std::atomic_bool _disposing
Definition: ICentral.h:248
std::map< uint32_t, uint32_t > _variableDatabaseIds
Definition: ICentral.h:246
Definition: ICentral.h:51
std::atomic_int _timeLeftInPairingMode
Definition: ICentral.h:257
PairingMessage(std::string messageId)
Definition: ICentral.h:63
std::unordered_map< int32_t, std::shared_ptr< Peer > > _peers
Definition: ICentral.h:251
std::shared_ptr< PairingMessage > PPairingMessage
Definition: ICentral.h:72
std::string state
Definition: ICentral.h:53
virtual PVariable deleteDevice(PRpcClientInfo clientInfo, uint64_t peerId, int32_t flags)
Definition: ICentral.h:151
virtual PVariable createDevice(PRpcClientInfo clientInfo, int32_t deviceType, std::string serialNumber, int32_t address, int32_t firmwareVersion, std::string interfaceId)
Definition: ICentral.h:145
virtual PVariable createDevice(PRpcClientInfo clientInfo, const std::string &code)
Definition: ICentral.h:149
virtual PVariable searchDevices(PRpcClientInfo clientInfo, const std::string &interfaceId)
Definition: ICentral.h:209
virtual int32_t getAddress()
Definition: ICentral.h:114
This class provides hooks into the web server so get and post requests can be passed into family modu...
Definition: IWebserverEventSink.h:43
std::string name
Definition: UiElements.h:216
virtual void loadPeers()
Definition: ICentral.h:304
std::string messageId
Definition: ICentral.h:60
virtual PVariable invokeFamilyMethod(PRpcClientInfo clientInfo, std::string &methodName, PArray parameters)
Definition: ICentral.h:193
virtual PVariable addLink(PRpcClientInfo clientInfo, uint64_t senderId, int32_t senderChannel, uint64_t receiverId, int32_t receiverChannel, std::string name, std::string description)
Definition: ICentral.h:141
virtual PVariable activateLinkParamset(PRpcClientInfo clientInfo, uint64_t peerId, int32_t channel, uint64_t remoteId, int32_t remoteChannel, bool longPress)
Definition: ICentral.h:132
virtual void savePeers(bool full)
Definition: ICentral.h:305
std::shared_ptr< DeviceTranslations > getTranslations()
Definition: ICentral.h:113
std::shared_ptr< ServiceMessage > PServiceMessage
Definition: ServiceMessage.h:74
virtual PVariable addDevice(PRpcClientInfo clientInfo, std::string serialNumber)
Definition: ICentral.h:134
PairingMessage(std::string messageId, std::list< std::string > variables)
Definition: ICentral.h:67
std::map< std::string, PEventHandler > _physicalInterfaceEventhandlers
Definition: ICentral.h:263