|
|
@@ -35,6 +35,8 @@ typedef struct {
|
|
|
int dlen;
|
|
|
int blen;
|
|
|
}node_t;
|
|
|
+static int set_net(NetworkInfo_t *para);
|
|
|
+
|
|
|
|
|
|
static int node_free(node_t *nd)
|
|
|
{
|
|
|
@@ -110,8 +112,30 @@ int sys_reboot(void)
|
|
|
#include "upgrade.h"
|
|
|
int sys_set_factory(void)
|
|
|
{
|
|
|
- paras_reset();
|
|
|
- return system("reboot -f");
|
|
|
+ int r=0;
|
|
|
+
|
|
|
+#ifdef KEY_PARAS_IN_FILE
|
|
|
+ r = paras_reset();
|
|
|
+#else
|
|
|
+ char dir[100],tmp[200];
|
|
|
+
|
|
|
+ extern GlobalDeviceManager __globalDeviceManage;
|
|
|
+ sqlite_deinit(&__globalDeviceManage.db);
|
|
|
+
|
|
|
+ sys_get_path(dir, "");
|
|
|
+ snprintf(tmp, "cp -f %s/%s %s/%s", dir, DATABASE_BAK_NAME, dir, DATABASE_NAME);
|
|
|
+
|
|
|
+ LOGD("___ %s\n", tmp);
|
|
|
+ r = system(tmp);
|
|
|
+ if(r==0) {
|
|
|
+ r = set_net(&DFLT_PARAS.dev._network_info);
|
|
|
+ if(r==0) {
|
|
|
+ exit(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -125,8 +149,10 @@ int sys_get_path(char *path, char *name)
|
|
|
char *p = strrchr(path, '/');
|
|
|
if(p && strlen(path)>1) {
|
|
|
*p = 0;
|
|
|
- strcat(path, "/");
|
|
|
- strcat(path, name);
|
|
|
+ if(p && strlen(name)>0) {
|
|
|
+ strcat(path, "/");
|
|
|
+ strcat(path, name);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return 0;
|