diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index ab6f426..cf9e0be 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/stm32basic b/stm32basic
index b2fbccd..ea11d9f 160000
--- a/stm32basic
+++ b/stm32basic
@@ -1 +1 @@
-Subproject commit b2fbccdc9ddd701095912425f8f6f3eaaa47166a
+Subproject commit ea11d9f77beed2bf8145bbe490283c0830fa8a77
diff --git a/uappbase/appcfg/appcfg.hpp b/uappbase/appcfg/appcfg.hpp
index b3b070b..d3a93a8 100644
--- a/uappbase/appcfg/appcfg.hpp
+++ b/uappbase/appcfg/appcfg.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "project_configs.h"
-#define MAX_USR_NAME_SIZE 5
+#define MAX_USR_NAME_SIZE 10
#define MOTO_POWER_EN_IO PC2
#define MOTO1_CSN_IO PB3
diff --git a/uappbase/service/config_service_utils.cpp b/uappbase/service/config_service_utils.cpp
index 3ab42c9..564deb1 100644
--- a/uappbase/service/config_service_utils.cpp
+++ b/uappbase/service/config_service_utils.cpp
@@ -34,4 +34,41 @@ void setMotorULToTruns(int motorid, int32_t val) {
ZASSERT(0);
}
}
-}
\ No newline at end of file
+
+const char* getPasswd(const char* usrname, CfgItermCache* cache) {
+ static CfgItermCache cfgcache;
+ memset(cache, 0, sizeof(CfgItermCache));
+ if (strcmp(usrname, getCfgStr(kusr_name0)) == 0) {
+ getCfgStr(kusr_passwd0);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ if (strcmp(usrname, getCfgStr(kusr_name1)) == 0) {
+ getCfgStr(kusr_passwd1);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ if (strcmp(usrname, getCfgStr(kusr_name2)) == 0) {
+ getCfgStr(kusr_passwd2);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ if (strcmp(usrname, getCfgStr(kusr_name3)) == 0) {
+ getCfgStr(kusr_passwd3);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ if (strcmp(usrname, getCfgStr(kusr_name4)) == 0) {
+ getCfgStr(kusr_passwd4);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ if (strcmp(usrname, getCfgStr(kusr_name5)) == 0) {
+ getCfgStr(kusr_passwd5);
+ memcpy(cache, &cfgcache, sizeof(CfgItermCache));
+ return cache->buf;
+ }
+ return NULL;
+}
+
+} // namespace iflytop
\ No newline at end of file
diff --git a/uappbase/service/config_service_utils.hpp b/uappbase/service/config_service_utils.hpp
index 285a5ef..484c4f6 100644
--- a/uappbase/service/config_service_utils.hpp
+++ b/uappbase/service/config_service_utils.hpp
@@ -4,4 +4,6 @@ namespace iflytop {
int32_t getMotorULToTruns(int32_t motorid);
void setMotorULToTruns(int32_t motorid, int32_t val);
+const char* getPasswd(const char* usrname, CfgItermCache* cache);
+
} // namespace iflytop
diff --git a/usrc/service/page/Page_login.cpp b/usrc/service/page/Page_login.cpp
index c786fd6..2a1979c 100644
--- a/usrc/service/page/Page_login.cpp
+++ b/usrc/service/page/Page_login.cpp
@@ -63,37 +63,30 @@ void Page_login::OnInputFieldContentChange(uint8_t bid, const char* text) {
}
void Page_login::OnLoginButtonClick(uint8_t bid, const char* userName, const char* passwd) {
+ static CfgItermCache passwdcfgcache;
+
+ //
ZLOGI(TAG, "try login %s %s", userName, passwd);
- bool suc = false;
- bool isadmin = false;
- if (strcmp(userName, getCfgStr(kusr_name0)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd0)) == 0) {
- suc = true;
- isadmin = true;
- } else if (strcmp(userName, getCfgStr(kusr_name1)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd1)) == 0) {
- suc = true;
- } else if (strcmp(userName, getCfgStr(kusr_name2)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd2)) == 0) {
- suc = true;
- } else if (strcmp(userName, getCfgStr(kusr_name3)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd3)) == 0) {
- suc = true;
- } else if (strcmp(userName, getCfgStr(kusr_name4)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd4)) == 0) {
- suc = true;
- } else if (strcmp(userName, getCfgStr(kusr_name5)) == 0 && strcmp(passwd, getCfgStr(kusr_passwd5)) == 0) {
- suc = true;
+ const char* curUsrPasswd = getPasswd(userName, &passwdcfgcache);
+ if (!curUsrPasswd) {
+ UIS->alert("Óû§²»´æÔÚ");
+ UIS->setVal(PAGE, OBJ(txtPasswd), "");
+ return;
}
- if (suc) {
- GSM->setLogin(isadmin, userName);
- UIS->chpage(pg_main);
- } else {
+ if (strcmp(curUsrPasswd, passwd) != 0) {
UIS->alert("ÃÜÂë´íÎó");
+ UIS->setVal(PAGE, OBJ(txtPasswd), "");
+ return;
}
- UIS->setVal(PAGE, OBJ(txtPasswd), "");
-}
-#if 0
-void Page_login::unlogin() {
- ZLOGI(TAG, "unlogin");
- GSM->setUnLogin();
- UIS->chpage(PAGE);
+ if (strcmp(userName, getCfgStr(kusr_name0)) == 0) {
+ ZLOGI(TAG, "%s(admin) login success ", userName);
+ GSM->setLogin(true, userName);
+ } else {
+ ZLOGI(TAG, "%s login success ", userName);
+ GSM->setLogin(false, userName);
+ }
+ UIS->chpage(pg_main);
+ UIS->setVal(PAGE, OBJ(txtPasswd), "");
return;
}
-#endif
\ No newline at end of file