mirror of
https://github.com/thelsing/knx.git
synced 2025-08-13 13:46:20 +02:00
commit
f7e64b8c12
@ -58,8 +58,10 @@ void setup(void)
|
||||
if(knx.configured())
|
||||
goTriggerSample.callback(triggerCallback);
|
||||
|
||||
// depends on sensor board. Try BME680_I2C_ADDR_PRIMARY if it doen't work.
|
||||
|
||||
// Configure Wire pins before this call if needed.
|
||||
Wire.begin();
|
||||
// depends on sensor board. Try BME680_I2C_ADDR_PRIMARY if it doen't work.
|
||||
iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);
|
||||
checkIaqSensorStatus();
|
||||
|
||||
|
@ -22,8 +22,6 @@ void ApplicationLayer::transportLayer(TransportLayer& layer)
|
||||
|
||||
void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
|
||||
{
|
||||
uint16_t entries = _assocTable.entryCount();
|
||||
|
||||
uint8_t len = apdu.length();
|
||||
uint8_t dataArray[len];
|
||||
uint8_t* data = dataArray;
|
||||
@ -39,14 +37,12 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < entries; i++)
|
||||
uint16_t startIdx = 0;
|
||||
int32_t asap = _assocTable.nextAsap(tsap, startIdx);
|
||||
for (; asap != -1; asap = _assocTable.nextAsap(tsap, startIdx))
|
||||
{
|
||||
uint16_t entry = _assocTable[i];
|
||||
if (highByte(entry) == tsap)
|
||||
switch (apdu.type())
|
||||
{
|
||||
uint16_t asap = lowByte(entry);
|
||||
switch (apdu.type())
|
||||
{
|
||||
case GroupValueRead:
|
||||
_bau.groupValueReadIndication(asap, priority, hopType);
|
||||
break;
|
||||
@ -55,7 +51,6 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
|
||||
break;
|
||||
case GroupValueWrite:
|
||||
_bau.groupValueWriteIndication(asap, priority, hopType, data, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ uint16_t AssociationTableObject::operator[](uint16_t idx)
|
||||
if (idx < 0 || idx >= entryCount())
|
||||
return 0;
|
||||
|
||||
return ntohs(_tableData[idx + 1]);
|
||||
return ntohs(_tableData[2 * idx + 1]);
|
||||
}
|
||||
|
||||
uint8_t* AssociationTableObject::save(uint8_t* buffer)
|
||||
@ -49,18 +49,20 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// return type is int32 so that we can return uint16 and -1
|
||||
int32_t AssociationTableObject::translateAsap(uint16_t asap)
|
||||
{
|
||||
uint16_t entries = entryCount();
|
||||
for (uint16_t i = 0; i < entries; i++)
|
||||
for (uint16_t i = 0; i < entries * 2; i+=2)
|
||||
{
|
||||
uint16_t entry = operator[](i);
|
||||
if (lowByte(entry) == asap)
|
||||
return highByte(entry);
|
||||
if (operator[](i + 1) == asap)
|
||||
return operator[](i);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AssociationTableObject::beforeStateChange(LoadState& newState)
|
||||
{
|
||||
if (newState != LS_LOADED)
|
||||
@ -72,7 +74,7 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
|
||||
static PropertyDescription _propertyDescriptions[] =
|
||||
{
|
||||
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_TABLE, false, PDT_GENERIC_02, 254, ReadLv3 | WriteLv0 },
|
||||
{ PID_TABLE, false, PDT_GENERIC_04, 65535, ReadLv3 | WriteLv0 },
|
||||
{ PID_LOAD_STATE_CONTROL, true, PDT_CONTROL, 1, ReadLv3 | WriteLv3 },
|
||||
{ PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
|
||||
@ -88,4 +90,19 @@ uint8_t AssociationTableObject::propertyCount()
|
||||
PropertyDescription* AssociationTableObject::propertyDescriptions()
|
||||
{
|
||||
return _propertyDescriptions;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t& startIdx)
|
||||
{
|
||||
uint16_t entries = entryCount();
|
||||
for (uint16_t i = startIdx; i < entries; i++)
|
||||
{
|
||||
startIdx = i;
|
||||
|
||||
if (operator[](i) == tsap)
|
||||
{
|
||||
return operator[](i+1);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ class AssociationTableObject : public TableObject
|
||||
public:
|
||||
AssociationTableObject(Platform& platform);
|
||||
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);
|
||||
uint8_t* restore(uint8_t* buffer);
|
||||
|
||||
int32_t translateAsap(uint16_t asap);
|
||||
int32_t nextAsap(uint16_t tsap, uint16_t& startIdx);
|
||||
|
||||
protected:
|
||||
void beforeStateChange(LoadState& newState);
|
||||
@ -20,5 +20,7 @@ class AssociationTableObject : public TableObject
|
||||
PropertyDescription* propertyDescriptions();
|
||||
|
||||
private:
|
||||
uint16_t entryCount();
|
||||
uint16_t operator[](uint16_t idx);
|
||||
uint16_t* _tableData = 0;
|
||||
};
|
@ -528,4 +528,20 @@ struct tm KNXValue::timeValue() const
|
||||
}
|
||||
struct tm tmp;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
KNXValue::KNXValue(float value)
|
||||
{
|
||||
}
|
||||
|
||||
KNXValue& KNXValue::operator=(const float value)
|
||||
{
|
||||
_value.doubleValue = value;
|
||||
_type = DoubleType;
|
||||
return *this;
|
||||
}
|
||||
|
||||
KNXValue::operator float() const
|
||||
{
|
||||
return doubleValue();
|
||||
}
|
@ -18,6 +18,7 @@ class KNXValue
|
||||
KNXValue(double value);
|
||||
KNXValue(const char* value);
|
||||
KNXValue(struct tm value);
|
||||
KNXValue(float value);
|
||||
|
||||
operator bool() const;
|
||||
operator uint8_t() const;
|
||||
@ -31,6 +32,7 @@ class KNXValue
|
||||
operator double() const;
|
||||
operator const char*() const;
|
||||
operator struct tm() const;
|
||||
operator float() const;
|
||||
|
||||
KNXValue& operator=(const bool value);
|
||||
KNXValue& operator=(const uint8_t value);
|
||||
@ -44,6 +46,8 @@ class KNXValue
|
||||
KNXValue& operator=(const double value);
|
||||
KNXValue& operator=(const char* value);
|
||||
KNXValue& operator=(const struct tm value);
|
||||
KNXValue& operator=(const float value);
|
||||
|
||||
private:
|
||||
|
||||
bool boolValue() const;
|
||||
@ -88,7 +92,7 @@ class KNXValue
|
||||
LongType,
|
||||
DoubleType,
|
||||
StringType,
|
||||
TimeType
|
||||
TimeType,
|
||||
};
|
||||
|
||||
ValueType _type;
|
||||
|
@ -224,6 +224,7 @@
|
||||
</DebugSettingsOverride>
|
||||
<BuildSettingsExtension xsi:type="com.visualgdb.build.external.arduino.extension">
|
||||
<BoardID>esp8266:esp8266:nodemcuv2</BoardID>
|
||||
<COMPort>COM4</COMPort>
|
||||
<Properties>
|
||||
<Entries>
|
||||
<KeyValue>
|
||||
@ -240,7 +241,7 @@
|
||||
</KeyValue>
|
||||
<KeyValue>
|
||||
<Key>ssl</Key>
|
||||
<Value>all</Value>
|
||||
<Value>basic</Value>
|
||||
</KeyValue>
|
||||
<KeyValue>
|
||||
<Key>eesz</Key>
|
||||
|
Loading…
Reference in New Issue
Block a user