|
|
@@ -0,0 +1,54 @@
|
|
|
+#include "stm32f10x.h"
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdarg.h>
|
|
|
+#include <string.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include "Tuoreniot.h"
|
|
|
+
|
|
|
+#include "mbedtls_util.h"
|
|
|
+#include "Log_Module.h"
|
|
|
+#include "At_Module.h"
|
|
|
+#include "Common_Util.h"
|
|
|
+#include "ec800m.h"
|
|
|
+
|
|
|
+unsigned char key[17]="tuorenzhinenghua";
|
|
|
+/**
|
|
|
+*
|
|
|
+*注册信息打包
|
|
|
+*/
|
|
|
+enum Result packRegistDataAnd(uint8_t *length,char * qcciddata,char *recvdata,uint8_t *mcu_id,uint16_t Version_data){
|
|
|
+ enum Result result = Result_None;
|
|
|
+ //
|
|
|
+// int i=0;
|
|
|
+ int datalen = 0;
|
|
|
+ char* dataPtr = recvdata+2; //dataPtr指针指向registData第三个字节
|
|
|
+ //复制muid,并转化为16进制
|
|
|
+
|
|
|
+ Log_Printf_Debug("mcu_id:%s,%d\r\n",mcu_id,sizeof(mcu_id));//串口打印
|
|
|
+ byteToHexStr(mcu_id, dataPtr, (int)length);
|
|
|
+ Log_Printf_Debug("device data:%s,%d\r\n",dataPtr,strlen(dataPtr));//串口打印
|
|
|
+ memcpy(dataPtr+strlen(dataPtr),"&",1);
|
|
|
+ //获取qccid
|
|
|
+ AT_Clear();
|
|
|
+ //get_qccid_flag=get_qccid(qcciddata);
|
|
|
+
|
|
|
+// result=ec800m.query_qccid_sync(qcciddata);
|
|
|
+
|
|
|
+ //获取复制qccid
|
|
|
+ memcpy(dataPtr+strlen(dataPtr),qcciddata,31);
|
|
|
+ //复制版本号
|
|
|
+ snprintf(dataPtr+strlen(dataPtr),10,"&%d.%03d",Version_data/1000,Version_data%1000);
|
|
|
+ Log_Printf_Debug("device data:%s,%d\r\n",dataPtr,strlen(dataPtr));//串口打印
|
|
|
+ Log_Printf_Debug("regist data:%s\r\n",recvdata+2);
|
|
|
+ datalen = utils_aes128_ECB_base64_enc_with_length((char *)key,(uint8_t *)dataPtr);
|
|
|
+
|
|
|
+ recvdata[0] = datalen>>8;//头2个字节赋值数据长度
|
|
|
+ recvdata[1] = datalen;
|
|
|
+ Log_Printf_Debug("strlendata:%d,datalen=%d\r\n",strlen(dataPtr),datalen);
|
|
|
+ *length=datalen+2;
|
|
|
+ return Result_Success;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|