The main entry point when interacting with Devices More...
Header: | #include <DeviceManager> |
Inherits: |
enum | DeviceError { DeviceErrorNoError, DeviceErrorPluginNotFound, DeviceErrorVendorNotFound, DeviceErrorDeviceNotFound, ..., DeviceErrorParameterNotWritable } |
enum | DeviceSetupStatus { DeviceSetupStatusSuccess, DeviceSetupStatusFailure, DeviceSetupStatusAsync } |
DeviceManager(HardwareManager * hardwareManager, const QLocale & locale, QObject * parent = nullptr) | |
~DeviceManager() | |
DeviceError | addConfiguredDevice(const DeviceClassId & deviceClassId, const QString & name, const ParamList & params, const DeviceId id = DeviceId::createDeviceId()) |
DeviceError | addConfiguredDevice(const DeviceClassId & deviceClassId, const QString & name, const DeviceDescriptorId & deviceDescriptorId, const ParamList & params = ParamList(), const DeviceId & deviceId = DeviceId::createDeviceId()) |
QList<Device *> | configuredDevices() const |
DeviceError | confirmPairing(const PairingTransactionId & pairingTransactionId, const QString & secret = QString()) |
DeviceError | discoverDevices(const DeviceClassId & deviceClassId, const ParamList & params) |
DeviceError | editDevice(const DeviceId & deviceId, const QString & name) |
QList<Device *> | findChildDevices(const DeviceId & id) const |
Device * | findConfiguredDevice(const DeviceId & id) const |
QList<Device *> | findConfiguredDevices(const DeviceClassId & deviceClassId) const |
QList<Device *> | findConfiguredDevices(const QString & interface) const |
DeviceClass | findDeviceClass(const DeviceClassId & deviceClassId) const |
Interface | findInterface(const QString & name) |
HardwareManager * | hardwareManager() const |
DeviceError | pairDevice(const PairingTransactionId & pairingTransactionId, const DeviceClassId & deviceClassId, const QString & name, const ParamList & params) |
DeviceError | pairDevice(const PairingTransactionId & pairingTransactionId, const DeviceClassId & deviceClassId, const QString & name, const DeviceDescriptorId & deviceDescriptorId) |
DevicePlugin * | plugin(const PluginId & id) const |
QList<DevicePlugin *> | plugins() const |
DeviceError | reconfigureDevice(const DeviceId & deviceId, const ParamList & params, bool fromDiscoveryOrAuto = false) |
DeviceError | reconfigureDevice(const DeviceId & deviceId, const DeviceDescriptorId & deviceDescriptorId) |
void | registerStaticPlugin(DevicePlugin * plugin, const QJsonObject & metaData) |
DeviceError | removeConfiguredDevice(const DeviceId & deviceId) |
DeviceError | setPluginConfig(const PluginId & pluginId, const ParamList & pluginConfig) |
QList<DeviceClass> | supportedDevices(const VendorId & vendorId = VendorId()) const |
Interfaces | supportedInterfaces() const |
QList<Vendor> | supportedVendors() const |
Translator * | translator() const |
DeviceError | verifyParam(const QList<ParamType> paramTypes, const Param & param) |
DeviceError | verifyParam(const ParamType & paramType, const Param & param) |
DeviceError | verifyParams(const QList<ParamType> paramTypes, ParamList & params, bool requireAll = true) |
DeviceError | executeAction(const Action & action) |
void | timeTick() |
void | actionExecutionFinished(const ActionId & actionId, DeviceManager::DeviceError status) |
void | deviceAdded(Device * device) |
void | deviceChanged(Device * device) |
void | deviceDisappeared(const DeviceId & deviceId) |
void | deviceReconfigurationFinished(Device * device, DeviceError status) |
void | deviceRemoved(const DeviceId & deviceId) |
void | deviceSetupFinished(Device * device, DeviceError status) |
void | deviceStateChanged(Device * device, const QUuid & stateTypeId, const QVariant & value) |
void | devicesDiscovered(const DeviceClassId & deviceClassId, const QList<DeviceDescriptor> & devices) |
void | eventTriggered(const Event & event) |
void | loaded() |
void | pairingFinished(const PairingTransactionId & pairingTransactionId, DeviceError status, const DeviceId & deviceId = DeviceId()) |
void | pluginConfigChanged(const PluginId & id, const ParamList & config) |
QStringList | pluginSearchDirs() |
QList<QJsonObject> | pluginsMetadata() |
The main entry point when interacting with Devices
The DeviceManager hold s all information about supported and configured Devices in the system.
It is also responsible for loading Plugins and managing common hardware resources between device plugins.
This enum type specifies the errors that can happen when working with Devices.
Constant | Value | Description |
---|---|---|
DeviceManager::DeviceErrorNoError | 0 | No Error. Everything went fine. |
DeviceManager::DeviceErrorPluginNotFound | 1 | Couldn't find the Plugin for the given id. |
DeviceManager::DeviceErrorVendorNotFound | 2 | Couldn't find the Vendor for the given id. |
DeviceManager::DeviceErrorDeviceNotFound | 3 | Couldn't find a Device for the given id. |
DeviceManager::DeviceErrorDeviceClassNotFound | 4 | Couldn't find a DeviceClass for the given id. |
DeviceManager::DeviceErrorActionTypeNotFound | 5 | Couldn't find the ActionType for the given id. |
DeviceManager::DeviceErrorStateTypeNotFound | 6 | Couldn't find the StateType for the given id. |
DeviceManager::DeviceErrorEventTypeNotFound | 7 | Couldn't find the EventType for the given id. |
DeviceManager::DeviceErrorDeviceDescriptorNotFound | 8 | Couldn't find the DeviceDescriptor for the given id. |
DeviceManager::DeviceErrorMissingParameter | 9 | Parameters do not comply to the template. |
DeviceManager::DeviceErrorInvalidParameter | 10 | One of the given parameter is not valid. |
DeviceManager::DeviceErrorSetupFailed | 11 | Error setting up the Device. It will not be functional. |
DeviceManager::DeviceErrorDuplicateUuid | 12 | Error setting up the Device. The given DeviceId already exists. |
DeviceManager::DeviceErrorCreationMethodNotSupported | 13 | Error setting up the Device. This CreateMethod is not supported for this Device. |
DeviceManager::DeviceErrorSetupMethodNotSupported | 14 | Error setting up the Device. This SetupMethod is not supported for this Device. |
DeviceManager::DeviceErrorHardwareNotAvailable | 15 | The Hardware of the Device is not available. |
DeviceManager::DeviceErrorHardwareFailure | 16 | The Hardware of the Device has an error. |
DeviceManager::DeviceErrorAsync | 18 | The response of the Device will be asynchronously. |
DeviceManager::DeviceErrorDeviceInUse | 19 | The Device is currently bussy. |
DeviceManager::DeviceErrorPairingTransactionIdNotFound | 22 | Couldn't find the PairingTransactionId for the given id. |
DeviceManager::DeviceErrorAuthentificationFailure | 17 | The device could not authentificate with something. |
DeviceManager::DeviceErrorDeviceIsChild | 21 | The device is a child device and can not be deleted directly. |
DeviceManager::DeviceErrorDeviceInRule | 20 | The device is in a rule and can not be deleted withou nymeaserver::RuleEngine::RemovePolicy. |
DeviceManager::DeviceErrorParameterNotWritable | 23 | One of the given device params is not writable. |
This enum type specifies the setup status of a Device.
Constant | Value | Description |
---|---|---|
DeviceManager::DeviceSetupStatusSuccess | 0 | No Error. Everything went fine. |
DeviceManager::DeviceSetupStatusFailure | 1 | Something went wrong during the setup. |
DeviceManager::DeviceSetupStatusAsync | 2 | The status of the Device setup will be emitted asynchronous. |
Constructs the DeviceManager with the given hardwareManager, locale and parent. There should only be one DeviceManager in the system created by nymeaserver::NymeaCore. Use nymeaserver::NymeaCore::instance()->deviceManager()
instead to access the DeviceManager.
Destructor of the DeviceManager. Each loaded DevicePlugin will be deleted.
[signal]
void DeviceManager::actionExecutionFinished(const ActionId & actionId, DeviceManager::DeviceError status)The DeviceManager will emit a this signal when the Action with the given actionId is finished. The status of the Action execution will be described as DeviceError.
Add a new configured device for the given DeviceClass, the given parameters, name and id. deviceClassId must refer to an existing {DeviceClass} and params must match the parameter description in the DeviceClass. Optionally you can supply an id yourself if you must keep track of the added device. If you don't supply it, a new one will be generated. Only devices with CreateMethodUser can be created using this method. Returns DeviceError to inform about the result.
Add a new configured device for the given DeviceClass the given DeviceDescriptorId and deviceId. Only devices with CreateMethodDiscovery can be created using this method. The deviceClassId must refer to an existing DeviceClass and the deviceDescriptorId must refer to an existing DeviceDescriptorId from the discovery. The name parameter should contain the device name. Optionally device params can be passed. By default the descriptor's params as found by the discovery are used but can be overridden here.
Returns DeviceError to inform about the result.
Returns all configured {Device}{Devices} in the system.
Confirms the pairing of a Device with the given pairingTransactionId and secret. Returns DeviceError to inform about the result.
[signal]
void DeviceManager::deviceAdded(Device * device)This signal is emitted when a device was added to the system. This signal will create the Devices.DeviceAdded notification.
[signal]
void DeviceManager::deviceChanged(Device * device)This signal is emitted when a device was changed in the system (by edit or rediscover). This signal will create the Devices.DeviceParamsChanged notification.
[signal]
void DeviceManager::deviceDisappeared(const DeviceId & deviceId)This signal is emitted when the automatically created Device with the given deviceId dissapeard. This signal will create the Devices.DeviceRemoved notification.
[signal]
void DeviceManager::deviceReconfigurationFinished(Device * device, DeviceError status)This signal is emitted when the edit process of a device is finished. The status parameter describes the DeviceError that occurred.
[signal]
void DeviceManager::deviceRemoved(const DeviceId & deviceId)This signal is emitted when the Device with the given deviceId was removed from the system. This signal will create the Devices.DeviceRemoved notification.
[signal]
void DeviceManager::deviceSetupFinished(Device * device, DeviceError status)This signal is emitted when the setup of a device is finished. The status parameter describes the DeviceError that occurred.
[signal]
void DeviceManager::deviceStateChanged(Device * device, const QUuid & stateTypeId, const QVariant & value)This signal is emitted when the State of a device changed. The stateTypeId parameter describes the StateType and the value parameter holds the new value.
[signal]
void DeviceManager::devicesDiscovered(const DeviceClassId & deviceClassId, const QList<DeviceDescriptor> & devices)This signal is emitted when the discovery of a deviceClassId is finished. The devices parameter describes the list of DeviceDescriptors of all discovered Devices.
See also discoverDevices().
Returns a certain DeviceError and starts the discovering process of the Device with the given deviceClassId and the given params.
Edit the name of the Device with the given deviceId. Returns DeviceError to inform about the result.
[signal]
void DeviceManager::eventTriggered(const Event & event)The DeviceManager will emit a Event described in event whenever a Device creates one. Normally only nymeaserver::NymeaCore should connect to this and execute actions after checking back with the {nymeaserver::RulesEngine}. Exceptions might be monitoring interfaces or similar, but you should never directly react to this in a DevicePlugin.
[slot]
DeviceError DeviceManager::executeAction(const Action & action)Execute the given Action. This will find the Device action refers to the deviceId() and its DevicePlugin. Then will dispatch the execution to the DevicePlugin.
Returns all child Devices of the Device with the given id.
Returns the Device with the given id. Null if the id couldn't be found.
Returns all Devices matching the DeviceClass referred by deviceClassId.
Returns all Devices with the given interface. See also interfaces.
For conveninece, this returns the DeviceClass with the id given by deviceClassId. Note: The returned DeviceClass may be invalid.
Returns the interface with the given name. If the interface can't be found it will return an invalid interface.
Returns the pointer to the HardwareManager of the system.
See also HardwareManager.
[signal]
void DeviceManager::loaded()The DeviceManager will emit this signal when all Devices are loaded.
Initiates a pairing with a Device with the given pairingTransactionId, deviceClassId, name and params. Returns DeviceError to inform about the result.
Initiates a pairing with a Device with the given pairingTransactionId, deviceClassId, name and deviceDescriptorId. Returns DeviceError to inform about the result.
[signal]
void DeviceManager::pairingFinished(const PairingTransactionId & pairingTransactionId, DeviceError status, const DeviceId & deviceId = DeviceId())The DeviceManager will emit a this signal when the pairing of a Device with the deviceId and pairingTransactionId is finished. The status of the pairing will be described as DeviceError.
Returns the DevicePlugin with the given id. Null if the id couldn't be found.
[signal]
void DeviceManager::pluginConfigChanged(const PluginId & id, const ParamList & config)The DeviceManager will emit this signal when the config Params of the plugin with the given id has changed.
[static]
QStringList DeviceManager::pluginSearchDirs()Returns the list of search direcorys where DevicePlugin will be searched.
Returns all the DevicePlugins loaded in the system.
[static]
QList<QJsonObject> DeviceManager::pluginsMetadata()Returns the list of json objects containing the metadata of the installed plugins.
Edit the Params of a configured device with the given deviceId to the new given params. The given parameter fromDiscovery specifies if the new params came from a discovery or if the user set them. If it came from discovery not writable parameters (readOnly) will be changed too.
Returns DeviceError to inform about the result.
Edit the Params of a configured device to the Params of the DeviceDescriptor with the given deviceId to the given DeviceDescriptorId. Only devices with CreateMethodDiscovery can be changed using this method. The deviceDescriptorId must refer to an existing DeviceDescriptorId from the discovery. This method allows to rediscover a device and update it's Params.
Returns DeviceError to inform about the result.
Register a DevicePlugin class. This can be used to create devices internally from the guh system without having to create a full plugin. The metaData contains the static plugin configurations. The DeviceManager takes ownership of the object plugin and will clean it up when exiting. Do not delete the object yourself.
Removes a Device with the given deviceId from the list of configured Devices. This method also deletes all saved settings of the Device. Returns DeviceError to inform about the result.
Returns a certain DeviceError and sets the configuration of the plugin with the given pluginId and the given pluginConfig.
Returns all the supported DeviceClasses by all DevicePlugins loaded in the system. Optionally filtered by vendorId.
Returns the list of all supported interfaces.
Returns all the Vendors loaded in the system.
[slot]
void DeviceManager::timeTick()Centralized time tick for the NymeaTimer resource. Ticks every second.
Returns the translator. The translator can be used to translate plugin data.
Verify if the given param matches one of the given paramTypes. Returns DeviceError to inform about the result.
Verify if the given param matches the given paramType. Returns DeviceError to inform about the result.
Verify if the given params matches the given paramTypes. Ith requireAll is true, all Params has to be valid. Returns DeviceError to inform about the result.