|
@@ -1,7 +1,9 @@
|
|
#!/usr/bin/env python3
|
|
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# -*- coding: utf-8 -*-
|
|
|
|
+import hashlib
|
|
import json
|
|
import json
|
|
import time
|
|
import time
|
|
|
|
+import uuid
|
|
|
|
|
|
import boto3
|
|
import boto3
|
|
from django.views import View
|
|
from django.views import View
|
|
@@ -122,7 +124,9 @@ class IotCoreView(View):
|
|
else:
|
|
else:
|
|
iotClient = AmericaIOTClient()
|
|
iotClient = AmericaIOTClient()
|
|
res = iotClient.create_keys_and_certificate(uid)
|
|
res = iotClient.create_keys_and_certificate(uid)
|
|
- Device_Info.objects.filter(UID=uid).update(endpoint=res[0]['endpoint'])
|
|
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ token_iot_number = hashlib.md5((str(uuid.uuid1()) + str(nowTime)).encode('utf-8')).hexdigest()
|
|
|
|
+ Device_Info.objects.filter(UID=uid).update(endpoint=res[0]['endpoint'], token_iot_number=token_iot_number )
|
|
iotdeviceInfoModel.objects.create(uid=uid, certificateId=res[0]['certificateId'],
|
|
iotdeviceInfoModel.objects.create(uid=uid, certificateId=res[0]['certificateId'],
|
|
certificatePem=res[0]['certificatePem'],
|
|
certificatePem=res[0]['certificatePem'],
|
|
publicKey=res[0]['publicKey'],
|
|
publicKey=res[0]['publicKey'],
|