not yet working offsetof stuff
This commit is contained in:
@ -53,30 +53,33 @@ static bool showConfigCmd(uint8_t argc, char **args) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool setDeviceNameCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args, )
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static bool setStringParameterCmd(uint8_t argc, char **args, size_t offset) {
|
||||||
static bool setStringParameterCmd(uint8_t argc, char **args) {
|
|
||||||
bool retCode = true;
|
bool retCode = true;
|
||||||
|
|
||||||
t_configBlock configBlock;
|
t_configBlock configBlock;
|
||||||
char *parameterName = args[1];
|
char *parameterName = args[1];
|
||||||
char *newParameterValue = args[2];
|
char *newParameterValue = args[2];
|
||||||
if (strlen(newParameterValue) >= sizeof(configBlock.deviceName)) {
|
if (strlen(newParameterValue) >= sizeof(configBlock.deviceName)) {
|
||||||
sendFormatString("given new value for %s is too long\n\r", parameterMeter);
|
sendFormatString("given new value for %s is too long\n\r", parameterName);
|
||||||
retCode = false;
|
retCode = false;
|
||||||
} else {
|
} else {
|
||||||
sendFormatString("set %s to %s\n\r", parameterName, newParameterValue);
|
sendFormatString("set %s to %s\n\r", parameterName, newParameterValue);
|
||||||
|
|
||||||
eepromReadConfigBlock(&configBlock);
|
eepromReadConfigBlock(&configBlock);
|
||||||
strcpy(configBlock.deviceName, newParameterValue);
|
strcpy(((char*) (*(((char*)&configBlock) + offset))), newParameterValue);
|
||||||
eepromWriteConfigBlock(&configBlock);
|
eepromWriteConfigBlock(&configBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool setDeviceNameCmd(uint8_t argc, char **args) {
|
||||||
|
return setStringParameterCmd(argc, args, offsetof(t_configBlock, deviceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const static cmd_t SET_COMMANDS[] = {
|
const static cmd_t SET_COMMANDS[] = {
|
||||||
{ .name = "devicename", .cmdFunc = setDeviceNameCmd,
|
{ .name = "devicename", .cmdFunc = setDeviceNameCmd,
|
||||||
.help = \
|
.help = \
|
||||||
|
@ -58,11 +58,11 @@ void my_setup_2() {
|
|||||||
cmdHandlerInit();
|
cmdHandlerInit();
|
||||||
oledPrint(OLED_SCREEN0, "cmdhandler init");
|
oledPrint(OLED_SCREEN0, "cmdhandler init");
|
||||||
|
|
||||||
//frontendInit();
|
frontendInit();
|
||||||
//oledPrint(OLED_SCREEN0, "frontend init");
|
oledPrint(OLED_SCREEN0, "frontend init");
|
||||||
|
|
||||||
//mbusCommInit();
|
mbusCommInit();
|
||||||
//oledPrint(OLED_SCREEN0, "Meterbus init");
|
oledPrint(OLED_SCREEN0, "Meterbus init");
|
||||||
oledPrint(OLED_SCREEN0, "App running");
|
oledPrint(OLED_SCREEN0, "App running");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user