diff --git a/cube/User/Src/configCmds.c b/cube/User/Src/configCmds.c index 1b8b82e..9fca54e 100644 --- a/cube/User/Src/configCmds.c +++ b/cube/User/Src/configCmds.c @@ -150,20 +150,27 @@ static bool setFrontendThresholdCmd(uint8_t argc, char **args) { 0, 1023); } -static bool addDeviceCmd(uint8_t argc, char **args) { +static bool makeDevice(uint8_t argc, char **args, t_deviceBlock *deviceBlock) { if (argc != 8) { sendString("wrong number of arguments\n\r"); return false; } char *deviceName = args[1]; + if (strlen(deviceName) >= sizeof(deviceBlock->deviceName)) { + sendString("devicename too long\n\r"); + return false; + } + strcpy(deviceBlock->deviceName, deviceName); long int rawAddress = strtol(args[2], NULL, 10); if (rawAddress < 1 || rawAddress > 254) { sendString("illegal address\n\r"); return false; } - uint8_t address = (uint8_t)rawAddress; + deviceBlock->address = (uint8_t)rawAddress; + +