configuration

This commit is contained in:
Wolfgang Hottgenroth 2020-11-27 16:55:09 +01:00
parent bc15e23f10
commit 518abe4e1c
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
4 changed files with 26 additions and 12 deletions

View File

@ -18,9 +18,22 @@ typedef struct __attribute__((__packed__)) s_configBlock {
char statusTopic[64];
char mbusDataTopic[64];
char syslogServerName[64];
uint8_t filler[2];
uint8_t numOfDeviceBlocks;
uint8_t filler[1];
} t_configBlock;
#define MBUSDEVICE_NAMELENGTH 16
#define MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS 4
typedef struct __attribute__((__packed__)) s_deviceBlock {
char deviceName[MBUSDEVICE_NAMELENGTH];
uint8_t address;
int8_t consideredField[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
int32_t period;
uint8_t filler[7];
} t_deviceBlock;
void configInit();
t_configBlock* getConfig();

View File

@ -4,10 +4,9 @@
#include <main.h>
#include <stdint.h>
#include <stdbool.h>
#include <config.h>
#define MBUSDEVICE_NAMELENGTH 24
#define MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS 4
typedef struct {
char deviceName[MBUSDEVICE_NAMELENGTH];
uint8_t address;

View File

@ -16,7 +16,8 @@ t_configBlock defaultConfigBlock = {
.statusTopic = "IoT/MBGW3/Status",
.mbusDataTopic = "IoT/MBGW3/Measurement",
.syslogServerName = "syslogserver",
.filler = { 0, 0 }
.numOfDeviceBlocks = 0,
.filler = { 0 }
};
@ -58,4 +59,5 @@ void configInit() {
coloredMsg(LOG_BLUE, false, "cfg ci statusTopic: %s", mainConfigBlock.statusTopic);
coloredMsg(LOG_BLUE, false, "cfg ci mbusDataTopic: %s", mainConfigBlock.mbusDataTopic);
coloredMsg(LOG_BLUE, false, "cfg ci syslog server: %s", mainConfigBlock.syslogServerName);
coloredMsg(LOG_BLUE, false, "cfg ci device block cnt: %d", mainConfigBlock.numOfDeviceBlocks);
}

View File

@ -610,7 +610,7 @@ static e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice) {
static uint8_t numOfDevices = 8;
static t_mbusDevice devices[] = {
{
.deviceName = "TotalPower",
.deviceName = "Total",
.address = 80,
.consideredField = { 0, 17, -1, -1 },
.requests = 0,
@ -621,7 +621,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "ComputerPower",
.deviceName = "Computer",
.address = 85,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -632,7 +632,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "DryerPower",
.deviceName = "Dryer",
.address = 81,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -643,7 +643,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "LaundryPower",
.deviceName = "Laundry",
.address = 82,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -654,7 +654,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "DishwasherPower",
.deviceName = "Dishwasher",
.address = 83,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -665,7 +665,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "LightPower",
.deviceName = "Light",
.address = 84,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -676,7 +676,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "FreezerPower",
.deviceName = "Freezer",
.address = 86,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
@ -687,7 +687,7 @@ static t_mbusDevice devices[] = {
.active = true
},
{
.deviceName = "FridgePower",
.deviceName = "Fridge",
.address = 87,
.consideredField = { 0, 4, 2, 3 },
.requests = 0,