still incomplete makeDevice function

This commit is contained in:
2020-12-16 21:12:48 +01:00
parent f5400dc18f
commit 46afd83b4b

View File

@ -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;