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) {
|
||||
static bool setStringParameterCmd(uint8_t argc, char **args, size_t offset) {
|
||||
bool retCode = true;
|
||||
|
||||
t_configBlock configBlock;
|
||||
char *parameterName = args[1];
|
||||
char *newParameterValue = args[2];
|
||||
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;
|
||||
} else {
|
||||
sendFormatString("set %s to %s\n\r", parameterName, newParameterValue);
|
||||
|
||||
eepromReadConfigBlock(&configBlock);
|
||||
strcpy(configBlock.deviceName, newParameterValue);
|
||||
strcpy(((char*) (*(((char*)&configBlock) + offset))), newParameterValue);
|
||||
eepromWriteConfigBlock(&configBlock);
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
|
||||
static bool setDeviceNameCmd(uint8_t argc, char **args) {
|
||||
return setStringParameterCmd(argc, args, offsetof(t_configBlock, deviceName));
|
||||
}
|
||||
|
||||
|
||||
const static cmd_t SET_COMMANDS[] = {
|
||||
{ .name = "devicename", .cmdFunc = setDeviceNameCmd,
|
||||
.help = \
|
||||
|
@ -58,11 +58,11 @@ void my_setup_2() {
|
||||
cmdHandlerInit();
|
||||
oledPrint(OLED_SCREEN0, "cmdhandler init");
|
||||
|
||||
//frontendInit();
|
||||
//oledPrint(OLED_SCREEN0, "frontend init");
|
||||
frontendInit();
|
||||
oledPrint(OLED_SCREEN0, "frontend init");
|
||||
|
||||
//mbusCommInit();
|
||||
//oledPrint(OLED_SCREEN0, "Meterbus init");
|
||||
mbusCommInit();
|
||||
oledPrint(OLED_SCREEN0, "Meterbus init");
|
||||
oledPrint(OLED_SCREEN0, "App running");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user