-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Move system settings to SD and retain individual device settings (…
…#1203) This fix moves the `/appconfigs/system.json` to `/mnt/SDCARD/system.json`. On shutdown, the current `/mnt/SDCARD/system.json` will be moved to `/mnt/SDCARD/.tmp_update/config/system/{DEVICE_UUID}.json`. This file will be restored on boot. --------- Co-authored-by: tGecko <[email protected]>
- Loading branch information
Showing
13 changed files
with
161 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#ifdef PLATFORM_MIYOOMINI | ||
#include "mi_common_datatype.h" | ||
#include "mi_sys.h" | ||
#endif | ||
#define MAX_LINE_LENGTH 255 | ||
|
||
int main(void) | ||
void remove_0x_and_newline(char *str) | ||
{ | ||
#ifdef PLATFORM_MIYOOMINI | ||
char *src = str; | ||
char *dest = str; | ||
while (*src) { | ||
if (src[0] == '0' && src[1] == 'x') { | ||
src += 2; | ||
} | ||
else if (src[0] == '\n') { | ||
src++; | ||
} | ||
else { | ||
*dest = *src; | ||
dest++; | ||
src++; | ||
} | ||
} | ||
*dest = '\0'; | ||
} | ||
|
||
char *execute_command(const char *command) | ||
{ | ||
char buffer[MAX_LINE_LENGTH]; | ||
char *result = NULL; | ||
|
||
MI_U64 u64Uuid; | ||
MI_S32 s32Ret = MI_ERR_SYS_FAILED; | ||
FILE *pipe = popen(command, "r"); | ||
if (pipe == NULL) { | ||
fprintf(stderr, "Error executing command: %s\n", command); | ||
exit(1); | ||
} | ||
|
||
if (!(s32Ret = MI_SYS_ReadUuid(&u64Uuid))) | ||
printf("%llx\n", u64Uuid); | ||
while (fgets(buffer, sizeof(buffer), pipe) != NULL) { | ||
result = strdup(buffer); | ||
} | ||
|
||
#endif | ||
pclose(pipe); | ||
return result; | ||
} | ||
|
||
int main() | ||
{ | ||
char serial[22] = ""; | ||
const char *commands[] = { | ||
"/config/riu_r 20 18 | awk 'NR==2'", | ||
"/config/riu_r 20 17 | awk 'NR==2'", | ||
"/config/riu_r 20 16 | awk 'NR==2'"}; | ||
|
||
for (int i = 0; i < 3; i++) { | ||
char *output = execute_command(commands[i]); | ||
if (output != NULL) { | ||
strcat(serial, output); | ||
} | ||
else { | ||
fprintf(stderr, "Error executing command: %s\n", commands[i]); | ||
exit(1); | ||
} | ||
} | ||
remove_0x_and_newline(serial); | ||
printf("%s\n", serial); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.