Merge pull request #4 from thelsing/master

update fork
This commit is contained in:
Bernator 2019-08-06 07:56:59 +02:00 committed by GitHub
commit f7e64b8c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 21 deletions

View File

@ -58,8 +58,10 @@ void setup(void)
if(knx.configured()) if(knx.configured())
goTriggerSample.callback(triggerCallback); 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. // 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); iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);
checkIaqSensorStatus(); checkIaqSensorStatus();

View File

@ -22,8 +22,6 @@ void ApplicationLayer::transportLayer(TransportLayer& layer)
void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
{ {
uint16_t entries = _assocTable.entryCount();
uint8_t len = apdu.length(); uint8_t len = apdu.length();
uint8_t dataArray[len]; uint8_t dataArray[len];
uint8_t* data = dataArray; uint8_t* data = dataArray;
@ -39,14 +37,12 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
len -= 1; 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]; switch (apdu.type())
if (highByte(entry) == tsap)
{ {
uint16_t asap = lowByte(entry);
switch (apdu.type())
{
case GroupValueRead: case GroupValueRead:
_bau.groupValueReadIndication(asap, priority, hopType); _bau.groupValueReadIndication(asap, priority, hopType);
break; break;
@ -55,7 +51,6 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
break; break;
case GroupValueWrite: case GroupValueWrite:
_bau.groupValueWriteIndication(asap, priority, hopType, data, len); _bau.groupValueWriteIndication(asap, priority, hopType, data, len);
}
} }
} }
} }

View File

@ -34,7 +34,7 @@ uint16_t AssociationTableObject::operator[](uint16_t idx)
if (idx < 0 || idx >= entryCount()) if (idx < 0 || idx >= entryCount())
return 0; return 0;
return ntohs(_tableData[idx + 1]); return ntohs(_tableData[2 * idx + 1]);
} }
uint8_t* AssociationTableObject::save(uint8_t* buffer) uint8_t* AssociationTableObject::save(uint8_t* buffer)
@ -49,18 +49,20 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer)
return buffer; return buffer;
} }
// return type is int32 so that we can return uint16 and -1
int32_t AssociationTableObject::translateAsap(uint16_t asap) int32_t AssociationTableObject::translateAsap(uint16_t asap)
{ {
uint16_t entries = entryCount(); 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 (operator[](i + 1) == asap)
if (lowByte(entry) == asap) return operator[](i);
return highByte(entry);
} }
return -1; return -1;
} }
void AssociationTableObject::beforeStateChange(LoadState& newState) void AssociationTableObject::beforeStateChange(LoadState& newState)
{ {
if (newState != LS_LOADED) if (newState != LS_LOADED)
@ -72,7 +74,7 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
static PropertyDescription _propertyDescriptions[] = static PropertyDescription _propertyDescriptions[] =
{ {
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 }, { 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_LOAD_STATE_CONTROL, true, PDT_CONTROL, 1, ReadLv3 | WriteLv3 },
{ PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 }, { PID_TABLE_REFERENCE, false, PDT_UNSIGNED_LONG, 1, ReadLv3 | WriteLv0 },
{ PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 }, { PID_ERROR_CODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
@ -89,3 +91,18 @@ PropertyDescription* AssociationTableObject::propertyDescriptions()
{ {
return _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;
}

View File

@ -7,12 +7,12 @@ class AssociationTableObject : public TableObject
public: public:
AssociationTableObject(Platform& platform); AssociationTableObject(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);
uint16_t entryCount();
uint16_t operator[](uint16_t idx);
uint8_t* save(uint8_t* buffer); uint8_t* save(uint8_t* buffer);
uint8_t* restore(uint8_t* buffer); uint8_t* restore(uint8_t* buffer);
int32_t translateAsap(uint16_t asap); int32_t translateAsap(uint16_t asap);
int32_t nextAsap(uint16_t tsap, uint16_t& startIdx);
protected: protected:
void beforeStateChange(LoadState& newState); void beforeStateChange(LoadState& newState);
@ -20,5 +20,7 @@ class AssociationTableObject : public TableObject
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint16_t entryCount();
uint16_t operator[](uint16_t idx);
uint16_t* _tableData = 0; uint16_t* _tableData = 0;
}; };

View File

@ -529,3 +529,19 @@ struct tm KNXValue::timeValue() const
struct tm tmp; struct tm tmp;
return 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();
}

View File

@ -18,6 +18,7 @@ class KNXValue
KNXValue(double value); KNXValue(double value);
KNXValue(const char* value); KNXValue(const char* value);
KNXValue(struct tm value); KNXValue(struct tm value);
KNXValue(float value);
operator bool() const; operator bool() const;
operator uint8_t() const; operator uint8_t() const;
@ -31,6 +32,7 @@ class KNXValue
operator double() const; operator double() const;
operator const char*() const; operator const char*() const;
operator struct tm() const; operator struct tm() const;
operator float() const;
KNXValue& operator=(const bool value); KNXValue& operator=(const bool value);
KNXValue& operator=(const uint8_t value); KNXValue& operator=(const uint8_t value);
@ -44,6 +46,8 @@ class KNXValue
KNXValue& operator=(const double value); KNXValue& operator=(const double value);
KNXValue& operator=(const char* value); KNXValue& operator=(const char* value);
KNXValue& operator=(const struct tm value); KNXValue& operator=(const struct tm value);
KNXValue& operator=(const float value);
private: private:
bool boolValue() const; bool boolValue() const;
@ -88,7 +92,7 @@ class KNXValue
LongType, LongType,
DoubleType, DoubleType,
StringType, StringType,
TimeType TimeType,
}; };
ValueType _type; ValueType _type;

View File

@ -224,6 +224,7 @@
</DebugSettingsOverride> </DebugSettingsOverride>
<BuildSettingsExtension xsi:type="com.visualgdb.build.external.arduino.extension"> <BuildSettingsExtension xsi:type="com.visualgdb.build.external.arduino.extension">
<BoardID>esp8266:esp8266:nodemcuv2</BoardID> <BoardID>esp8266:esp8266:nodemcuv2</BoardID>
<COMPort>COM4</COMPort>
<Properties> <Properties>
<Entries> <Entries>
<KeyValue> <KeyValue>
@ -240,7 +241,7 @@
</KeyValue> </KeyValue>
<KeyValue> <KeyValue>
<Key>ssl</Key> <Key>ssl</Key>
<Value>all</Value> <Value>basic</Value>
</KeyValue> </KeyValue>
<KeyValue> <KeyValue>
<Key>eesz</Key> <Key>eesz</Key>