mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
-answer correctly on missing objects/properties
-correct length of MAX_APDU_LENGTH -fix apci of propertyDescriptionReadResponse
This commit is contained in:
parent
2a169ee66b
commit
4479bc25dc
@ -11,7 +11,7 @@ AddressTableObject::AddressTableObject(uint8_t* memoryReference): TableObject(me
|
||||
|
||||
}
|
||||
|
||||
void AddressTableObject::readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void AddressTableObject::readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ class AddressTableObject: public TableObject
|
||||
{
|
||||
public:
|
||||
AddressTableObject(uint8_t* memoryReference);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
uint16_t entryCount();
|
||||
uint16_t getGa(uint16_t tsap);
|
||||
uint16_t getTsap(uint16_t ga);
|
||||
|
@ -394,7 +394,7 @@ void ApplicationLayer::propertyDescriptionReadResponse(AckType ack, Priority pri
|
||||
{
|
||||
CemiFrame frame(8);
|
||||
APDU& apdu = frame.apdu();
|
||||
apdu.type(PropertyDescriptionRead);
|
||||
apdu.type(PropertyDescriptionResponse);
|
||||
uint8_t* data = apdu.data();
|
||||
data[1] = objectIndex;
|
||||
data[2] = propertyId;
|
||||
|
@ -6,7 +6,7 @@ ApplicationProgramObject::ApplicationProgramObject(uint8_t* memoryReference): Ta
|
||||
|
||||
}
|
||||
|
||||
void ApplicationProgramObject::readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void ApplicationProgramObject::readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ class ApplicationProgramObject: public TableObject
|
||||
{
|
||||
public:
|
||||
ApplicationProgramObject(uint8_t* memoryReference);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
|
||||
uint8_t propertySize(PropertyID id);
|
||||
uint8_t* data(uint32_t addr);
|
||||
|
@ -11,7 +11,7 @@ AssociationTableObject::AssociationTableObject(uint8_t* memoryReference): TableO
|
||||
|
||||
}
|
||||
|
||||
void AssociationTableObject::readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void AssociationTableObject::readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ class AssociationTableObject: public TableObject
|
||||
{
|
||||
public:
|
||||
AssociationTableObject(uint8_t* memoryReference);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
uint16_t entryCount();
|
||||
uint16_t operator[](uint16_t idx);
|
||||
uint8_t* save(uint8_t* buffer);
|
||||
|
46
bau57B0.cpp
46
bau57B0.cpp
@ -7,7 +7,7 @@ using namespace std;
|
||||
|
||||
Bau57B0::Bau57B0(Platform& platform): _memoryReference((uint8_t*)&_deviceObj), _memory(platform), _addrTable(_memoryReference),
|
||||
_assocTable(_memoryReference), _groupObjTable(_memoryReference), _appProgram(_memoryReference),
|
||||
_ipParameters(_deviceObj, _platform), _platform(platform), _appLayer(_assocTable, *this),
|
||||
_ipParameters(_deviceObj, platform), _platform(platform), _appLayer(_assocTable, *this),
|
||||
_transLayer(_appLayer, _addrTable, _platform), _netLayer(_transLayer),
|
||||
_dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform)
|
||||
{
|
||||
@ -189,20 +189,30 @@ void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType
|
||||
void Bau57B0::propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
|
||||
uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length)
|
||||
{
|
||||
InterfaceObject& obj = getInterfaceObject(objectIndex);
|
||||
obj.writeProperty((PropertyID)propertyId, startIndex, data, numberOfElements);
|
||||
InterfaceObject* obj = getInterfaceObject(objectIndex);
|
||||
if(obj)
|
||||
obj->writeProperty((PropertyID)propertyId, startIndex, data, numberOfElements);
|
||||
propertyValueReadIndication(priority, hopType, asap, objectIndex, propertyId, numberOfElements, startIndex);
|
||||
}
|
||||
|
||||
void Bau57B0::propertyValueReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
|
||||
uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex)
|
||||
{
|
||||
InterfaceObject& obj = getInterfaceObject(objectIndex);
|
||||
uint8_t elementSize = obj.propertySize((PropertyID)propertyId);
|
||||
uint8_t size = elementSize * numberOfElements;
|
||||
uint8_t size = 0;
|
||||
uint32_t elementCount = numberOfElements;
|
||||
InterfaceObject* obj = getInterfaceObject(objectIndex);
|
||||
if (obj)
|
||||
{
|
||||
uint8_t elementSize = obj->propertySize((PropertyID)propertyId);
|
||||
size = elementSize * numberOfElements;
|
||||
}
|
||||
else
|
||||
elementCount = 0;
|
||||
|
||||
uint8_t data[size];
|
||||
obj.readProperty((PropertyID)propertyId, startIndex, numberOfElements, data);
|
||||
_appLayer.propertyValueReadResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, numberOfElements,
|
||||
if(obj)
|
||||
obj->readProperty((PropertyID)propertyId, startIndex, elementCount, data);
|
||||
_appLayer.propertyValueReadResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, elementCount,
|
||||
startIndex, data, size);
|
||||
}
|
||||
|
||||
@ -264,23 +274,25 @@ void Bau57B0::groupValueWriteIndication(uint16_t asap, Priority priority, HopCou
|
||||
updateGroupObject(go, data, dataLength);
|
||||
}
|
||||
|
||||
InterfaceObject& Bau57B0::getInterfaceObject(uint8_t idx)
|
||||
InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
return _deviceObj;
|
||||
return &_deviceObj;
|
||||
case 1:
|
||||
return _addrTable;
|
||||
return &_addrTable;
|
||||
case 2:
|
||||
return _assocTable;
|
||||
return &_assocTable;
|
||||
case 3:
|
||||
return _groupObjTable;
|
||||
return &_groupObjTable;
|
||||
case 4:
|
||||
return _appProgram;
|
||||
case 5:
|
||||
return _ipParameters;
|
||||
return &_appProgram;
|
||||
case 5: // would be app_program 2
|
||||
return nullptr;
|
||||
case 6:
|
||||
return &_ipParameters;
|
||||
default:
|
||||
return _deviceObj;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ protected:
|
||||
void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType,
|
||||
uint8_t* data, uint8_t dataLength);
|
||||
|
||||
InterfaceObject& getInterfaceObject(uint8_t idx);
|
||||
InterfaceObject* getInterfaceObject(uint8_t idx);
|
||||
void sendNextGroupTelegram();
|
||||
void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length);
|
||||
private:
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "device_object.h"
|
||||
#include "bits.h"
|
||||
|
||||
void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (propertyId)
|
||||
{
|
||||
@ -35,7 +35,7 @@ void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t
|
||||
*data = _prgMode;
|
||||
break;
|
||||
case PID_MAX_APDU_LENGTH:
|
||||
*data = 15;
|
||||
pushWord(15, data);
|
||||
break;
|
||||
case PID_SUBNET_ADDR:
|
||||
*data = ((_ownAddress >> 8) & 0xff);
|
||||
@ -58,6 +58,8 @@ void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t
|
||||
data[0] = 0x57;
|
||||
data[1] = 0xB0;
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,13 +87,13 @@ uint8_t DeviceObject::propertySize(PropertyID id)
|
||||
case PID_DEVICE_CONTROL:
|
||||
case PID_ROUTING_COUNT:
|
||||
case PID_PROG_MODE:
|
||||
case PID_MAX_APDU_LENGTH:
|
||||
case PID_SUBNET_ADDR:
|
||||
case PID_DEVICE_ADDR:
|
||||
return 1;
|
||||
case PID_MANUFACTURER_ID:
|
||||
case PID_VERSION:
|
||||
case PID_DEVICE_DESCRIPTOR:
|
||||
case PID_MAX_APDU_LENGTH:
|
||||
return 2;
|
||||
case PID_IO_LIST:
|
||||
return 4;
|
||||
|
@ -5,7 +5,7 @@
|
||||
class DeviceObject: public InterfaceObject
|
||||
{
|
||||
public:
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
|
||||
uint8_t propertySize(PropertyID id);
|
||||
uint8_t* save(uint8_t* buffer);
|
||||
|
@ -10,7 +10,7 @@ GroupObjectTableObject::GroupObjectTableObject(uint8_t* memoryReference): TableO
|
||||
_groupObjectCount = 0;
|
||||
}
|
||||
|
||||
void GroupObjectTableObject::readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void GroupObjectTableObject::readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ class GroupObjectTableObject: public TableObject
|
||||
|
||||
public:
|
||||
GroupObjectTableObject(uint8_t* memoryReference);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
uint16_t entryCount();
|
||||
GroupObject& get(uint16_t asap);
|
||||
GroupObject& nextUpdatedObject(bool& valid);
|
||||
|
@ -54,7 +54,7 @@ class InterfaceObject: public SaveRestore
|
||||
{
|
||||
public:
|
||||
virtual ~InterfaceObject() {}
|
||||
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 uint8_t propertySize(PropertyID id) = 0;
|
||||
protected:
|
||||
|
@ -10,7 +10,7 @@ IpParameterObject::IpParameterObject(DeviceObject& deviceObject, Platform& platf
|
||||
_platform(platform)
|
||||
{}
|
||||
|
||||
void IpParameterObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t count, uint8_t* data)
|
||||
void IpParameterObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t& count, uint8_t* data)
|
||||
{
|
||||
switch (propertyId)
|
||||
{
|
||||
@ -52,7 +52,7 @@ void IpParameterObject::readProperty(PropertyID propertyId, uint32_t start, uint
|
||||
break;
|
||||
case PID_MAC_ADDRESS:
|
||||
{
|
||||
uint8_t macAddr[6];
|
||||
uint8_t macAddr[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
_platform.macAddress(macAddr);
|
||||
pushByteArray(macAddr, 6, data);
|
||||
break;
|
||||
@ -73,6 +73,9 @@ void IpParameterObject::readProperty(PropertyID propertyId, uint32_t start, uint
|
||||
for (uint8_t i = start; i < start + count; i++)
|
||||
data[i-start] = _friendlyName[i-1];
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class IpParameterObject: public InterfaceObject
|
||||
{
|
||||
public:
|
||||
IpParameterObject(DeviceObject& deviceObject, Platform& platform);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t count, uint8_t* data);
|
||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
|
||||
uint8_t propertySize(PropertyID id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user