device configuration prepared
This commit is contained in:
parent
f22c821ca3
commit
98c0a9d7a2
@ -44,5 +44,7 @@ void mbusCommRxCpltCallback(UART_HandleTypeDef *huart);
|
||||
void mbusCommErrorCallback(UART_HandleTypeDef *huart);
|
||||
void mbusCommSetStats(t_mbusCommStats stats);
|
||||
t_mbusCommStats *mbusCommGetStats();
|
||||
void mbusCommAddDevice(t_deviceBlock *deviceBlock);
|
||||
|
||||
|
||||
#endif // _MBUSCOMM_H_
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <config.h>
|
||||
#include <eeprom.h>
|
||||
#include <logger.h>
|
||||
#include <mbusComm.h>
|
||||
|
||||
|
||||
t_configBlock defaultConfigBlock = {
|
||||
.configMagic = CONFIG_MAGIC,
|
||||
@ -85,13 +87,18 @@ void configInit() {
|
||||
for (uint8_t i = 0; i < mainConfigBlock.numOfDeviceBlocks; i++) {
|
||||
t_deviceBlock tmpDeviceBlock;
|
||||
eepromReadDeviceBlock(i, &tmpDeviceBlock);
|
||||
coloredMsg(LOG_BLUE, false, "cfg ci device %d: ", i);
|
||||
coloredMsg(LOG_BLUE, false, " Name: %s, Address: %d, Period: %d",
|
||||
tmpDeviceBlock.deviceName, tmpDeviceBlock.address, tmpDeviceBlock.period);
|
||||
coloredMsg(LOG_BLUE, false, " Considered Fields: %d %d %d %d",
|
||||
tmpDeviceBlock.consideredField[0],
|
||||
tmpDeviceBlock.consideredField[1],
|
||||
tmpDeviceBlock.consideredField[2],
|
||||
tmpDeviceBlock.consideredField[3]);
|
||||
if (tmpDeviceBlock.deviceMagic == DEVICE_MAGIC) {
|
||||
coloredMsg(LOG_BLUE, false, "cfg ci device %d: ", i);
|
||||
coloredMsg(LOG_BLUE, false, " Name: %s, Address: %d, Period: %d",
|
||||
tmpDeviceBlock.deviceName, tmpDeviceBlock.address, tmpDeviceBlock.period);
|
||||
coloredMsg(LOG_BLUE, false, " Considered Fields: %d %d %d %d",
|
||||
tmpDeviceBlock.consideredField[0],
|
||||
tmpDeviceBlock.consideredField[1],
|
||||
tmpDeviceBlock.consideredField[2],
|
||||
tmpDeviceBlock.consideredField[3]);
|
||||
mbusCommAddDevice(&tmpDeviceBlock);
|
||||
} else {
|
||||
coloredMsg(LOG_BLUE, false, " magic does not match, ignored");
|
||||
}
|
||||
}
|
||||
}
|
@ -607,7 +607,25 @@ static e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice) {
|
||||
|
||||
#define PERIOD 10
|
||||
|
||||
static uint8_t numOfDevices = 8;
|
||||
static uint8_t numOfDevices = 0;
|
||||
static t_mbusDevice *devices = NULL;
|
||||
|
||||
void mbusCommAddDevice(t_deviceBlock *deviceBlock) {
|
||||
devices = (t_mbusDevice*) realloc((void*) devices, (numOfDevices + 1) * sizeof(t_mbusDevice));
|
||||
strcpy(devices[numOfDevices].deviceName, deviceBlock->deviceName);
|
||||
devices[numOfDevices].address = deviceBlock->address;
|
||||
memcpy(devices[numOfDevices].consideredField, deviceBlock->consideredField, sizeof(deviceBlock->consideredField));
|
||||
devices[numOfDevices].period = deviceBlock->period;
|
||||
devices[numOfDevices].requests = 0;
|
||||
devices[numOfDevices].failures = 0;
|
||||
devices[numOfDevices].delay = 0;
|
||||
devices[numOfDevices].waiting = false;
|
||||
devices[numOfDevices].active = true;
|
||||
coloredMsg(LOG_YELLOW, true, "mbc mbcad device added %d %s %d", numOfDevices, devices[numOfDevices].deviceName, devices[numOfDevices].address);
|
||||
numOfDevices += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
static t_mbusDevice devices[] = {
|
||||
{
|
||||
.deviceName = "Total",
|
||||
@ -698,6 +716,9 @@ static t_mbusDevice devices[] = {
|
||||
.active = true
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
static void triggerMBusRequest(void *handle) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user