Fix handling of PropDescRead for special case PID=0. Answer with found property id for given property index.

This commit is contained in:
nanosonde 2018-04-24 11:45:57 +02:00
parent 94cbbb8244
commit 7e440ae816
3 changed files with 7 additions and 5 deletions

View File

@ -181,15 +181,16 @@ void Bau57B0::userMemoryWriteIndication(Priority priority, HopCountType hopType,
void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t propertyIndex) uint8_t propertyId, uint8_t propertyIndex)
{ {
uint8_t pid = propertyId;
bool writeEnable = false; bool writeEnable = false;
uint8_t type = 0; uint8_t type = 0;
uint16_t numberOfElements = 0; uint16_t numberOfElements = 0;
uint8_t access = 0; uint8_t access = 0;
InterfaceObject* obj = getInterfaceObject(objectIndex); InterfaceObject* obj = getInterfaceObject(objectIndex);
if (obj) if (obj)
obj->readPropertyDescription(propertyId, propertyIndex, writeEnable, type, numberOfElements, access); obj->readPropertyDescription(pid, propertyIndex, writeEnable, type, numberOfElements, access);
_appLayer.propertyDescriptionReadResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, propertyIndex, _appLayer.propertyDescriptionReadResponse(AckRequested, priority, hopType, asap, objectIndex, pid, propertyIndex,
writeEnable, type, numberOfElements, access); writeEnable, type, numberOfElements, access);
} }

View File

@ -1,6 +1,6 @@
#include "interface_object.h" #include "interface_object.h"
void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access) void InterfaceObject::readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access)
{ {
PropertyDescription* descriptions = propertyDescriptions(); PropertyDescription* descriptions = propertyDescriptions();
uint8_t count = propertyCount(); uint8_t count = propertyCount();
@ -22,7 +22,7 @@ void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& prope
} }
else else
{ {
if (propertyIndex > 0 && propertyIndex < count) if (propertyIndex >= 0 && propertyIndex < count)
{ {
desc = &descriptions[propertyIndex]; desc = &descriptions[propertyIndex];
} }
@ -30,6 +30,7 @@ void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& prope
if (desc != nullptr) if (desc != nullptr)
{ {
propertyId = desc->Id;
writeEnable = desc->WriteEnable; writeEnable = desc->WriteEnable;
type = desc->Type; type = desc->Type;
numberOfElements = desc->MaxElements; numberOfElements = desc->MaxElements;

View File

@ -57,7 +57,7 @@ public:
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data) = 0; virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data) = 0;
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count) = 0; virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count) = 0;
virtual uint8_t propertySize(PropertyID id) = 0; virtual uint8_t propertySize(PropertyID id) = 0;
void readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access); void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
protected: protected:
virtual uint8_t propertyCount() = 0; virtual uint8_t propertyCount() = 0;
virtual PropertyDescription* propertyDescriptions() = 0; virtual PropertyDescription* propertyDescriptions() = 0;