From 4d604935aa6c84ab0ef320f8e4914099692dfc26 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 17 Dec 2020 16:42:59 +0100 Subject: [PATCH] addDevice completed --- cube/User/Src/configCmds.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cube/User/Src/configCmds.c b/cube/User/Src/configCmds.c index 46e0157..566c479 100644 --- a/cube/User/Src/configCmds.c +++ b/cube/User/Src/configCmds.c @@ -222,6 +222,23 @@ static bool addDeviceCmd(uint8_t argc, char **args) { } } + uint8_t index = getConfig()->numOfDeviceBlocks; + for (uint8_t i = 0; i < getConfig()->numOfDeviceBlocks; i++) { + t_deviceBlock tmpDeviceBlock; + eepromReadDeviceBlock(i, &tmpDeviceBlock); + if (tmpDeviceBlock.period == -1) { + index = i; + break; + } + } + eepromWriteDeviceBlock(index, &deviceBlock); + if (index == getConfig()->numOfDeviceBlocks) { + t_configBlock configBlock; + eepromReadConfigBlock(&configBlock); + configBlock.numOfDeviceBlocks += 1; + eepromWriteConfigBlock(&configBlock); + } + return retCode; }