Add discoveryType thing class property
Some plugins may support network discovery, but may not be able to clearly identify a device and return a list of discovery results that may be the device, but also may not. As this breaks some app flows they will be marked as "weak" discovery and can be excluded from said setup wizards. NOTE: This commit does not bump the API version even though it should to avoid merge conflicts with other branches that do bump the version.
This commit is contained in:
parent
717b4f33cc
commit
5323ab2631
@ -58,6 +58,7 @@ IntegrationsHandler::IntegrationsHandler(ThingManager *thingManager, QObject *pa
|
|||||||
registerEnum<Thing::ThingSetupStatus>();
|
registerEnum<Thing::ThingSetupStatus>();
|
||||||
registerEnum<ThingClass::SetupMethod>();
|
registerEnum<ThingClass::SetupMethod>();
|
||||||
registerFlag<ThingClass::CreateMethod, ThingClass::CreateMethods>();
|
registerFlag<ThingClass::CreateMethod, ThingClass::CreateMethods>();
|
||||||
|
registerEnum<ThingClass::DiscoveryType>();
|
||||||
registerEnum<Types::Unit>();
|
registerEnum<Types::Unit>();
|
||||||
registerEnum<Types::InputType>();
|
registerEnum<Types::InputType>();
|
||||||
registerEnum<Types::IOType>();
|
registerEnum<Types::IOType>();
|
||||||
|
|||||||
@ -203,7 +203,8 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||||||
/*! Returns a list of all valid JSON properties a ThingClass JSON definition can have. */
|
/*! Returns a list of all valid JSON properties a ThingClass JSON definition can have. */
|
||||||
QStringList thingClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
|
QStringList thingClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
|
||||||
<< "interfaces" << "providedInterfaces" << "browsable" << "discoveryParamTypes"
|
<< "interfaces" << "providedInterfaces" << "browsable" << "discoveryParamTypes"
|
||||||
<< "paramTypes" << "settingsTypes" << "stateTypes" << "actionTypes" << "eventTypes" << "browserItemActionTypes";
|
<< "paramTypes" << "settingsTypes" << "stateTypes" << "actionTypes" << "eventTypes" << "browserItemActionTypes"
|
||||||
|
<< "discoveryType";
|
||||||
QStringList mandatoryThingClassProperties = QStringList() << "id" << "name" << "displayName";
|
QStringList mandatoryThingClassProperties = QStringList() << "id" << "name" << "displayName";
|
||||||
|
|
||||||
QPair<QStringList, QStringList> verificationResult = verifyFields(thingClassProperties, mandatoryThingClassProperties, thingClassObject);
|
QPair<QStringList, QStringList> verificationResult = verifyFields(thingClassProperties, mandatoryThingClassProperties, thingClassObject);
|
||||||
@ -260,6 +261,20 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||||||
}
|
}
|
||||||
thingClass.setCreateMethods(createMethods);
|
thingClass.setCreateMethods(createMethods);
|
||||||
|
|
||||||
|
if (thingClassObject.contains("discoveryType")) {
|
||||||
|
QString discoveryTypeString = thingClassObject.value("discoveryType").toString();
|
||||||
|
if (discoveryTypeString == "precise") {
|
||||||
|
thingClass.setDiscoveryType(ThingClass::DiscoveryTypePrecise);
|
||||||
|
} else if (discoveryTypeString == "weak") {
|
||||||
|
thingClass.setDiscoveryType(ThingClass::DiscoveryTypeWeak);
|
||||||
|
} else {
|
||||||
|
m_validationErrors.append("Unknown discoveryType \"" + discoveryTypeString + "\" in thingClass \"" + thingClass.name() + "\".");
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
thingClass.setDiscoveryType(ThingClass::DiscoveryTypePrecise);
|
||||||
|
}
|
||||||
|
|
||||||
// Read params
|
// Read params
|
||||||
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(thingClassObject.value("paramTypes").toArray());
|
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(thingClassObject.value("paramTypes").toArray());
|
||||||
if (!paramTypesVerification.first) {
|
if (!paramTypesVerification.first) {
|
||||||
|
|||||||
@ -79,9 +79,7 @@
|
|||||||
ThingClass::ThingClass(const PluginId &pluginId, const VendorId &vendorId, const ThingClassId &id):
|
ThingClass::ThingClass(const PluginId &pluginId, const VendorId &vendorId, const ThingClassId &id):
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_vendorId(vendorId),
|
m_vendorId(vendorId),
|
||||||
m_pluginId(pluginId),
|
m_pluginId(pluginId)
|
||||||
m_createMethods(CreateMethodUser),
|
|
||||||
m_setupMethod(SetupMethodJustAdd)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -342,6 +340,16 @@ void ThingClass::setSetupMethod(ThingClass::SetupMethod setupMethod)
|
|||||||
m_setupMethod = setupMethod;
|
m_setupMethod = setupMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThingClass::DiscoveryType ThingClass::discoveryType() const
|
||||||
|
{
|
||||||
|
return m_discoveryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThingClass::setDiscoveryType(DiscoveryType discoveryType)
|
||||||
|
{
|
||||||
|
m_discoveryType = discoveryType;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns the \l{Interfaces for DeviceClasses}{interfaces} of this \l{DeviceClass}.*/
|
/*! Returns the \l{Interfaces for DeviceClasses}{interfaces} of this \l{DeviceClass}.*/
|
||||||
QStringList ThingClass::interfaces() const
|
QStringList ThingClass::interfaces() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class LIBNYMEA_EXPORT ThingClass
|
|||||||
Q_PROPERTY(bool browsable READ browsable)
|
Q_PROPERTY(bool browsable READ browsable)
|
||||||
Q_PROPERTY(SetupMethod setupMethod READ setupMethod)
|
Q_PROPERTY(SetupMethod setupMethod READ setupMethod)
|
||||||
Q_PROPERTY(CreateMethods createMethods READ createMethods)
|
Q_PROPERTY(CreateMethods createMethods READ createMethods)
|
||||||
|
Q_PROPERTY(DiscoveryType discoveryType READ discoveryType)
|
||||||
Q_PROPERTY(StateTypes stateTypes READ stateTypes)
|
Q_PROPERTY(StateTypes stateTypes READ stateTypes)
|
||||||
Q_PROPERTY(EventTypes eventTypes READ eventTypes)
|
Q_PROPERTY(EventTypes eventTypes READ eventTypes)
|
||||||
Q_PROPERTY(ActionTypes actionTypes READ actionTypes)
|
Q_PROPERTY(ActionTypes actionTypes READ actionTypes)
|
||||||
@ -83,6 +84,12 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(SetupMethod)
|
Q_ENUM(SetupMethod)
|
||||||
|
|
||||||
|
enum DiscoveryType {
|
||||||
|
DiscoveryTypePrecise,
|
||||||
|
DiscoveryTypeWeak
|
||||||
|
};
|
||||||
|
Q_ENUM(DiscoveryType)
|
||||||
|
|
||||||
ThingClass(const PluginId &pluginId = PluginId(), const VendorId &vendorId = VendorId(), const ThingClassId &id = ThingClassId());
|
ThingClass(const PluginId &pluginId = PluginId(), const VendorId &vendorId = VendorId(), const ThingClassId &id = ThingClassId());
|
||||||
|
|
||||||
ThingClassId id() const;
|
ThingClassId id() const;
|
||||||
@ -134,6 +141,9 @@ public:
|
|||||||
SetupMethod setupMethod() const;
|
SetupMethod setupMethod() const;
|
||||||
void setSetupMethod(SetupMethod setupMethod);
|
void setSetupMethod(SetupMethod setupMethod);
|
||||||
|
|
||||||
|
DiscoveryType discoveryType() const;
|
||||||
|
void setDiscoveryType(DiscoveryType discoveryType);
|
||||||
|
|
||||||
QStringList interfaces() const;
|
QStringList interfaces() const;
|
||||||
void setInterfaces(const QStringList &interfaces);
|
void setInterfaces(const QStringList &interfaces);
|
||||||
|
|
||||||
@ -156,8 +166,9 @@ private:
|
|||||||
ParamTypes m_paramTypes;
|
ParamTypes m_paramTypes;
|
||||||
ParamTypes m_settingsTypes;
|
ParamTypes m_settingsTypes;
|
||||||
ParamTypes m_discoveryParamTypes;
|
ParamTypes m_discoveryParamTypes;
|
||||||
CreateMethods m_createMethods;
|
CreateMethods m_createMethods = CreateMethodUser;
|
||||||
SetupMethod m_setupMethod;
|
SetupMethod m_setupMethod = SetupMethodJustAdd;
|
||||||
|
DiscoveryType m_discoveryType = DiscoveryTypePrecise;
|
||||||
QStringList m_interfaces;
|
QStringList m_interfaces;
|
||||||
QStringList m_providedInterfaces;
|
QStringList m_providedInterfaces;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,6 +47,10 @@
|
|||||||
"CreateMethodAuto",
|
"CreateMethodAuto",
|
||||||
"CreateMethodDiscovery"
|
"CreateMethodDiscovery"
|
||||||
],
|
],
|
||||||
|
"DiscoveryType": [
|
||||||
|
"DiscoveryTypePrecise",
|
||||||
|
"DiscoveryTypeWeak"
|
||||||
|
],
|
||||||
"IOType": [
|
"IOType": [
|
||||||
"IOTypeNone",
|
"IOTypeNone",
|
||||||
"IOTypeDigitalInput",
|
"IOTypeDigitalInput",
|
||||||
@ -2620,6 +2624,7 @@
|
|||||||
"r:browserItemActionTypes": "$ref:ActionTypes",
|
"r:browserItemActionTypes": "$ref:ActionTypes",
|
||||||
"r:createMethods": "$ref:CreateMethods",
|
"r:createMethods": "$ref:CreateMethods",
|
||||||
"r:discoveryParamTypes": "$ref:ParamTypes",
|
"r:discoveryParamTypes": "$ref:ParamTypes",
|
||||||
|
"r:discoveryType": "$ref:DiscoveryType",
|
||||||
"r:displayName": "String",
|
"r:displayName": "String",
|
||||||
"r:eventTypes": "$ref:EventTypes",
|
"r:eventTypes": "$ref:EventTypes",
|
||||||
"r:id": "Uuid",
|
"r:id": "Uuid",
|
||||||
|
|||||||
Reference in New Issue
Block a user