Răsfoiți Sursa

fix:修复华为云时间戳格式不正确问题

Dozingfiretruck 2 ani în urmă
părinte
comite
b2531a17e5
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      components/iotauth/luat_lib_iotauth.c

+ 3 - 3
components/iotauth/luat_lib_iotauth.c

@@ -261,9 +261,9 @@ static int l_iotauth_onenet(lua_State *L) {
 
 static void iotda_token(const char* device_id,const char* device_secret,long long cur_timestamp,int ins_timestamp,char* client_id,const char* password){
     char hmac[65] = {0};
-    char timestamp[13] = {0};
+    char timestamp[11] = {0};
     struct tm *timeinfo = localtime( &cur_timestamp );
-    if(snprintf_(timestamp, 12, "%04d%02d%02d%02d", (timeinfo->tm_year)+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour)<0){
+    if(snprintf_(timestamp, 11, "%04d%02d%02d%02d", (timeinfo->tm_year)+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour)<0){
         return;
     }
     snprintf_(client_id, CLIENT_ID_LEN, "%s_0_%d_%s", device_id,ins_timestamp,timestamp);
@@ -288,7 +288,7 @@ static int l_iotauth_iotda(lua_State *L) {
     char client_id[CLIENT_ID_LEN] = {0};
     char password[PASSWORD_LEN] = {0};
     size_t len = 0;
-    long long cur_timestamp = 0;
+    long long cur_timestamp = 32472115200;
     int ins_timestamp = 0;
     const char* device_id = luaL_checklstring(L, 1, &len);
     const char* device_secret = luaL_checklstring(L, 2, &len);