From 518abe4e1cc66e92b8e4e3c86a57818985116532 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 27 Nov 2020 16:55:09 +0100 Subject: [PATCH] configuration --- cube/User/Inc/config.h | 15 ++++++++++++++- cube/User/Inc/mbusComm.h | 3 +-- cube/User/Src/config.c | 4 +++- cube/User/Src/mbusComm.c | 16 ++++++++-------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/cube/User/Inc/config.h b/cube/User/Inc/config.h index d85915d..62e9680 100644 --- a/cube/User/Inc/config.h +++ b/cube/User/Inc/config.h @@ -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(); diff --git a/cube/User/Inc/mbusComm.h b/cube/User/Inc/mbusComm.h index 3c9c4d2..6834c93 100644 --- a/cube/User/Inc/mbusComm.h +++ b/cube/User/Inc/mbusComm.h @@ -4,10 +4,9 @@ #include #include #include +#include -#define MBUSDEVICE_NAMELENGTH 24 -#define MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS 4 typedef struct { char deviceName[MBUSDEVICE_NAMELENGTH]; uint8_t address; diff --git a/cube/User/Src/config.c b/cube/User/Src/config.c index a10a263..5a482fd 100644 --- a/cube/User/Src/config.c +++ b/cube/User/Src/config.c @@ -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); } \ No newline at end of file diff --git a/cube/User/Src/mbusComm.c b/cube/User/Src/mbusComm.c index c18945f..08f2af3 100644 --- a/cube/User/Src/mbusComm.c +++ b/cube/User/Src/mbusComm.c @@ -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,