mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
-add magic number to memory
-add debug output to esp_platform -add more fine granular startup to Bau57B0
This commit is contained in:
parent
a7a48b4a7b
commit
649d831f7f
@ -39,7 +39,7 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
|
|||||||
len -= 1;
|
len -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16_t i; i < entries; i++)
|
for (uint16_t i = 0; i < entries; i++)
|
||||||
{
|
{
|
||||||
uint16_t entry = _assocTable[i];
|
uint16_t entry = _assocTable[i];
|
||||||
if (highByte(entry) == tsap)
|
if (highByte(entry) == tsap)
|
||||||
|
18
bau57B0.cpp
18
bau57B0.cpp
@ -2,6 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Bau57B0::Bau57B0(Platform& platform): _memoryReference((uint8_t*)&_deviceObj), _memory(platform), _addrTable(_memoryReference),
|
Bau57B0::Bau57B0(Platform& platform): _memoryReference((uint8_t*)&_deviceObj), _memory(platform), _addrTable(_memoryReference),
|
||||||
@ -19,8 +20,6 @@ Bau57B0::Bau57B0(Platform& platform): _memoryReference((uint8_t*)&_deviceObj), _
|
|||||||
_memory.addSaveRestore(&_addrTable);
|
_memory.addSaveRestore(&_addrTable);
|
||||||
_memory.addSaveRestore(&_assocTable);
|
_memory.addSaveRestore(&_assocTable);
|
||||||
_memory.addSaveRestore(&_groupObjTable);
|
_memory.addSaveRestore(&_groupObjTable);
|
||||||
_memory.readMemory();
|
|
||||||
_dlLayer.enabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bau57B0::loop()
|
void Bau57B0::loop()
|
||||||
@ -82,6 +81,11 @@ void Bau57B0::updateGroupObject(GroupObject & go, uint8_t * data, uint8_t length
|
|||||||
go.commFlag(cfUpdate);
|
go.commFlag(cfUpdate);
|
||||||
if (go.updateHandler)
|
if (go.updateHandler)
|
||||||
go.updateHandler(go);
|
go.updateHandler(go);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bau57B0::readMemory()
|
||||||
|
{
|
||||||
|
_memory.readMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceObject& Bau57B0::deviceObject()
|
DeviceObject& Bau57B0::deviceObject()
|
||||||
@ -105,6 +109,16 @@ bool Bau57B0::configured()
|
|||||||
&& _addrTable.loadState() == LS_LOADED
|
&& _addrTable.loadState() == LS_LOADED
|
||||||
&& _assocTable.loadState() == LS_LOADED
|
&& _assocTable.loadState() == LS_LOADED
|
||||||
&& _appProgram.loadState() == LS_LOADED;
|
&& _appProgram.loadState() == LS_LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bau57B0::enabled()
|
||||||
|
{
|
||||||
|
return _dlLayer.enabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bau57B0::enabled(bool value)
|
||||||
|
{
|
||||||
|
_dlLayer.enabled(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bau57B0::memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
|
void Bau57B0::memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
|
||||||
|
@ -24,6 +24,9 @@ public:
|
|||||||
GroupObjectTableObject& groupObjectTable();
|
GroupObjectTableObject& groupObjectTable();
|
||||||
ApplicationProgramObject& parameters();
|
ApplicationProgramObject& parameters();
|
||||||
bool configured();
|
bool configured();
|
||||||
|
bool enabled();
|
||||||
|
void enabled(bool value);
|
||||||
|
void readMemory();
|
||||||
protected:
|
protected:
|
||||||
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
|
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
|
||||||
uint16_t memoryAddress, uint8_t* data) override;
|
uint16_t memoryAddress, uint8_t* data) override;
|
||||||
|
@ -29,7 +29,7 @@ void EspPlatform::macAddress(uint8_t * addr)
|
|||||||
|
|
||||||
uint32_t EspPlatform::millis()
|
uint32_t EspPlatform::millis()
|
||||||
{
|
{
|
||||||
return millis();
|
return ::millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EspPlatform::mdelay(uint32_t millis)
|
void EspPlatform::mdelay(uint32_t millis)
|
||||||
@ -39,6 +39,7 @@ void EspPlatform::mdelay(uint32_t millis)
|
|||||||
|
|
||||||
void EspPlatform::restart()
|
void EspPlatform::restart()
|
||||||
{
|
{
|
||||||
|
Serial.println("restart");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +59,12 @@ void EspPlatform::setupMultiCast(uint32_t addr, uint16_t port)
|
|||||||
{
|
{
|
||||||
_mulitcastAddr = addr;
|
_mulitcastAddr = addr;
|
||||||
_mulitcastPort = port;
|
_mulitcastPort = port;
|
||||||
_udp.beginMulticast(WiFi.localIP(), addr, port);
|
IPAddress mcastaddr(htonl(addr));
|
||||||
|
|
||||||
|
Serial.printf("setup multicast addr: %s port: %d ip: %s\n", mcastaddr.toString().c_str(), port,
|
||||||
|
WiFi.localIP().toString().c_str());
|
||||||
|
uint8 result = _udp.beginMulticast(WiFi.localIP(), mcastaddr, port);
|
||||||
|
Serial.printf("result %d\n", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EspPlatform::closeMultiCast()
|
void EspPlatform::closeMultiCast()
|
||||||
@ -66,11 +72,24 @@ void EspPlatform::closeMultiCast()
|
|||||||
_udp.stop();
|
_udp.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printHex(const char* suffix, uint8_t *data, uint8_t length)
|
||||||
|
{
|
||||||
|
Serial.print(suffix);
|
||||||
|
for (int i = 0; i<length; i++) {
|
||||||
|
if (data[i]<0x10) { Serial.print("0"); }
|
||||||
|
Serial.print(data[i], HEX);
|
||||||
|
Serial.print(" ");
|
||||||
|
}
|
||||||
|
Serial.print("\n");
|
||||||
|
}
|
||||||
|
|
||||||
bool EspPlatform::sendBytes(uint8_t * buffer, uint16_t len)
|
bool EspPlatform::sendBytes(uint8_t * buffer, uint16_t len)
|
||||||
{
|
{
|
||||||
_udp.beginPacketMulticast(_mulitcastAddr, _mulitcastPort, WiFi.localIP());
|
printHex("-> ",buffer, len);
|
||||||
_udp.write(buffer, len);
|
int result = 0;
|
||||||
_udp.endPacket();
|
result = _udp.beginPacketMulticast(_mulitcastAddr, _mulitcastPort, WiFi.localIP());
|
||||||
|
result = _udp.write(buffer, len);
|
||||||
|
result = _udp.endPacket();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,11 +101,12 @@ int EspPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
|
|||||||
|
|
||||||
if (len > maxLen)
|
if (len > maxLen)
|
||||||
{
|
{
|
||||||
printf("udp buffer to small. was %d, needed %d\n", maxLen, len);
|
Serial.printf("udp buffer to small. was %d, needed %d\n", maxLen, len);
|
||||||
fatalError();
|
fatalError();
|
||||||
}
|
}
|
||||||
|
|
||||||
_udp.read(buffer, len);
|
_udp.read(buffer, len);
|
||||||
|
printHex("<- ", buffer, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
memory.cpp
39
memory.cpp
@ -16,25 +16,34 @@ bool Memory::isMemoryModified()
|
|||||||
|
|
||||||
void Memory::readMemory()
|
void Memory::readMemory()
|
||||||
{
|
{
|
||||||
//_data = _platform.getEepromBuffer(512);
|
_data = _platform.getEepromBuffer(512);
|
||||||
//uint8_t* buffer = _data;
|
|
||||||
//int size = _saveCount;
|
if (_data[0] != 0xDE || _data[1] != 0xAD || _data[2] != 0xAF || _data[3] != 0xFE)
|
||||||
//for (int i = 0; i < size; i++)
|
return;
|
||||||
//{
|
|
||||||
// buffer = _saveRestores[i]->restore(buffer);
|
uint8_t* buffer = _data + 4;
|
||||||
//}
|
int size = _saveCount;
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
buffer = _saveRestores[i]->restore(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::writeMemory()
|
void Memory::writeMemory()
|
||||||
{
|
{
|
||||||
//uint8_t* buffer = _data;
|
_data[0] = 0xDE;
|
||||||
//int size = _saveCount;
|
_data[1] = 0xAD;
|
||||||
//for (int i = 0; i < size; i++)
|
_data[2] = 0xAF;
|
||||||
//{
|
_data[3] = 0xFE;
|
||||||
// buffer = _saveRestores[i]->save(buffer);
|
|
||||||
//}
|
uint8_t* buffer = _data + 4;
|
||||||
//_platform.commitToEeprom();
|
int size = _saveCount;
|
||||||
//_modified = false;
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
buffer = _saveRestores[i]->save(buffer);
|
||||||
|
}
|
||||||
|
_platform.commitToEeprom();
|
||||||
|
_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::addSaveRestore(SaveRestore * obj)
|
void Memory::addSaveRestore(SaveRestore * obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user