鉴权逻辑增加线程
authorp15692025051 <846603105@qq.com>
Thu, 8 May 2025 02:41:54 +0000 (10:41 +0800)
committerp15692025051 <846603105@qq.com>
Thu, 8 May 2025 02:41:54 +0000 (10:41 +0800)
2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c
2.code/aicos/app/AI_AMP_2_5/dev_authentication.c
2.code/aicos/app/AI_AMP_2_5/dev_authentication.h

index f24708f..91f1a95 100644 (file)
@@ -1369,7 +1369,7 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程
     }
     aic_srv_tele_radio_get_current_slot_imei_sync(dev_imei);
     bk_printf("IMEI:%s",dev_imei);
-    active_md5_sign_demo();
+    dev_authentication_init();
     
     aic_network_enable_pdp_nic_capdump();//打开网络调试log
     char *tts_str = "你好!我是小瑞";
@@ -1458,7 +1458,7 @@ int AI_AMP_2_5_init(void)
     //创建AI_AMP_task队列
     if(AI_AMP_task_queue == NULL)
     {
-        AI_AMP_task_queue = aos_create_queue("AI_VC_record_tmp_queue",
+        AI_AMP_task_queue = aos_create_queue("AI_AMP_task_queue",
             sizeof(AI_AMP_MSG_queue_t),
             200);
     }
index 63e2e57..7d3d58b 100644 (file)
@@ -23,6 +23,8 @@
 #define bk_free aic_free
 // static char * dev_key = "uKLrChwrxA1LklgBc3VwawYjUkbT3BgX" ;
 // static char * dev_pid = "cqxJZi5CNgzjS3mX21Zw";
+static char aut_token[50] ={0};
+
 void ase_encrypt_dome(void);
 //激活用的md5签名
 static int active_md5_sign(const char *dev_id,const char *pid,const char *timestamp,const char *productSecret,char*md5_str)
@@ -271,4 +273,114 @@ void ase_encrypt_dome(void)
         bk_free(Base64_data);
     if(decrypt_data)
         bk_free(decrypt_data);
-}
\ No newline at end of file
+}
+
+/****************************************************************************** */
+int set_token(char *token)
+{
+    if(strlen(token)>=sizeof(aut_token))
+    {
+        bk_printf("ERROR token to0 long");
+        return -1;
+    }
+    memset(aut_token,0,sizeof(aut_token));
+    strcpy(aut_token,token);
+    return 0;
+        
+}
+int get_token(char *token)
+{
+
+    strcpy(token,aut_token);
+    token[strlen(aut_token)] = 0;
+    return 0;
+        
+}
+void aut_active(void)//设备激活
+{
+
+}
+void aut_login(void)//登录
+{
+
+}
+void aut_chack_token(void)//检查token
+{
+
+}
+static aos_thread_id dev_authentication_id = 0;
+static aos_queue_ptr dev_authentication_task_queue = NULL;
+//鉴权消息发送
+aos_status dev_authentication_MSG_put(const char *data,u32 len,dev_authentication_MSG_Type MSG_Type)
+{
+    dev_authentication_MSG_queue_t dev_authentication_MSG_queue_data = {0};
+    //bk_msg_printf("dev_authentication_MSG_put1 MSG_Type:%d",MSG_Type);
+    if(len >0)
+    {
+        dev_authentication_MSG_queue_data.data = aic_malloc(len+1);
+        memset(dev_authentication_MSG_queue_data.data ,0,len+1);
+        if(!dev_authentication_MSG_queue_data.data)
+        {
+            //bk_msg_printf("AI_VC_send_data aic_malloc ERROR!!!!!!!!!!");
+            return AOS_ERROR;
+        }
+        memcpy(dev_authentication_MSG_queue_data.data,data,len);
+        dev_authentication_MSG_queue_data.len=len;
+    }
+    
+    dev_authentication_MSG_queue_data.MSG_Type=MSG_Type;
+    if(dev_authentication_task_queue && AOS_SUCCESS!=aos_send_to_queue(dev_authentication_task_queue,&dev_authentication_MSG_queue_data,AOS_NO_WAIT))
+    {
+       if(!dev_authentication_MSG_queue_data.data)
+            aic_free(dev_authentication_MSG_queue_data.data);
+        return AOS_ERROR;
+    }
+    //bk_msg_printf("dev_authentication_MSG_put2 MSG_Type:%d",MSG_Type);
+    return AOS_SUCCESS;
+}
+static void dev_authentication_task(void *thread_input)//鉴权逻辑线程
+{
+    dev_authentication_MSG_queue_t dev_authentication_msg = {0};
+    while (1) {
+        if(dev_authentication_task_queue)
+        {
+            aos_recv_from_queue(dev_authentication_task_queue,&dev_authentication_msg,AOS_WAIT_FOREVER) ;
+            switch (dev_authentication_msg.MSG_Type)
+            {
+                case AUT_ACTIVE://激活
+                    AI_VC_Close();
+                    break;
+                case AUT_LOGIN://登录
+                    AI_VC_start();
+                    break;
+                case AUT_CHACK_TOKEN://检查token
+                    AI_VC_start();
+                    break;
+            }
+            if(dev_authentication_msg.data)
+                aic_free(dev_authentication_msg.data);
+        }else
+        {
+            aos_sleep(10);
+        }
+    }
+}
+void dev_authentication_init(void)
+{
+    //创建设备激活队列
+    if(dev_authentication_queue == NULL)
+    {
+        dev_authentication_task_queue = aos_create_queue("dev_authentication_queue",
+            sizeof(dev_authentication_MSG_queue_t),
+            200);
+    }
+    dev_authentication_id = aos_create_thread(
+        "dev_authentication_task",
+        dev_authentication_task,
+        &dev_authentication_id,
+        4096u,
+        0,
+        NULL,
+        35,
+        AOS_AUTO_START);
+}
index c600e06..09b7555 100644 (file)
@@ -3,4 +3,18 @@
 #define __DEV_AUTHENTICATION_H__
 void active_md5_sign_demo(void);
 
+void dev_authentication_init(void);
+typedef enum dev_authentication_MSG
+{
+    AUT_ACTIVE,//激活
+    AUT_LOGIN,//登录
+    AUT_CHACK_TOKEN//检查令牌
+    
+} dev_authentication_MSG_Type;
+typedef struct
+{
+    char *data;
+    u32 len;
+    dev_authentication_MSG_Type MSG_Type;
+}dev_authentication_MSG_queue_t;
 #endif
\ No newline at end of file