deleteDevice
This commit is contained in:
parent
560b08e56c
commit
056a9e9edc
@ -225,6 +225,22 @@ static bool addDeviceCmd(uint8_t argc, char **args) {
|
|||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool deleteDeviceCmd(uint8_t argc, char **args) {
|
||||||
|
long int rawIndex = strtol(args[1], NULL, 10);
|
||||||
|
if (rawIndex < 0 || rawIndex > getConfig()->numOfDeviceBlocks) {
|
||||||
|
sendFormatString("illegal index, must be greater 0 and less %d\n\r", getConfig()->numOfDeviceBlocks);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uint8_t index = (uint8_t) rawIndex;
|
||||||
|
|
||||||
|
t_deviceBlock deviceBlock;
|
||||||
|
eepromReadDeviceBlock(index, &deviceBlock);
|
||||||
|
deviceBlock.period = -1;
|
||||||
|
eepromWriteDeviceBlock(index, &deviceBlock);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool changeDeviceCmd(uint8_t argc, char **args) {
|
static bool changeDeviceCmd(uint8_t argc, char **args) {
|
||||||
if (strcmp(args[1], "help") == 0) {
|
if (strcmp(args[1], "help") == 0) {
|
||||||
sendString("First argument: index of device in list\n\r");
|
sendString("First argument: index of device in list\n\r");
|
||||||
@ -265,7 +281,7 @@ static bool listDevicesCmd(uint8_t argc, char **args) {
|
|||||||
for (uint8_t i = 0; i < getConfig()->numOfDeviceBlocks; i++) {
|
for (uint8_t i = 0; i < getConfig()->numOfDeviceBlocks; i++) {
|
||||||
t_deviceBlock deviceBlock;
|
t_deviceBlock deviceBlock;
|
||||||
eepromReadDeviceBlock(i, &deviceBlock);
|
eepromReadDeviceBlock(i, &deviceBlock);
|
||||||
sendFormatString(" Index: %d\n\r", i);
|
sendFormatString("Index: %d\n\r", i);
|
||||||
sendFormatString(" Name: %s, Address: %d, Period: %d\n\r",
|
sendFormatString(" Name: %s, Address: %d, Period: %d\n\r",
|
||||||
deviceBlock.deviceName, deviceBlock.address, deviceBlock.period);
|
deviceBlock.deviceName, deviceBlock.address, deviceBlock.period);
|
||||||
for (uint8_t i = 0; i < MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS; i++) {
|
for (uint8_t i = 0; i < MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS; i++) {
|
||||||
@ -393,6 +409,11 @@ const cmd_t CONFIG_COMMANDS[] = {
|
|||||||
.help = \
|
.help = \
|
||||||
"listDevices .......................... List the configured devices\n\r"
|
"listDevices .......................... List the configured devices\n\r"
|
||||||
},
|
},
|
||||||
|
{ .name = "deleteDevice", .cmdFunc = deleteDeviceCmd,
|
||||||
|
.help = \
|
||||||
|
"deleteDevice ......................... Delete a device\n\r" \
|
||||||
|
" Argument: index\n\r"
|
||||||
|
},
|
||||||
{ .name = "restart", .cmdFunc = restartCmd,
|
{ .name = "restart", .cmdFunc = restartCmd,
|
||||||
.help = \
|
.help = \
|
||||||
"restart .............................. Restart the system,\n\r" \
|
"restart .............................. Restart the system,\n\r" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user