#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)
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);
+}