|
@@ -67,23 +67,28 @@ class IotCoreView(View):
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
|
|
|
- # CVM注册 :正使用
|
|
|
+ # 设备注册到aws iot core
|
|
|
def create_keys_and_certificate(self, request_dict, response, request):
|
|
|
- uid = request_dict.get('uid', '')
|
|
|
token = request_dict.get('token', None)
|
|
|
- uid_code = request_dict.get('uid_code', None)
|
|
|
language = request_dict.get('language', None)
|
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
|
device_version = request_dict.get('device_version', None).replace('.', '_') # 物品组命名不能包含'.'
|
|
|
|
|
|
- if not all([token, time_stamp, device_version, language]):
|
|
|
- return response.json(444, {'param': 'token, uid_code, time_stamp, device_version, language'})
|
|
|
+ if not all([token, language, time_stamp, device_version]):
|
|
|
+ return response.json(444, {'param': 'token, language, time_stamp, device_version'})
|
|
|
|
|
|
try:
|
|
|
+ no_rtc = request_dict.get('no_rtc', None)
|
|
|
# 时间戳token校验
|
|
|
- if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
- return response.json(13)
|
|
|
+ if no_rtc:
|
|
|
+ if not CommonService.check_time_stamp_token_without_distance(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
+ else:
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
+ uid = request_dict.get('uid', '')
|
|
|
+ uid_code = request_dict.get('uid_code', None)
|
|
|
if not uid:
|
|
|
# 使用序列号
|
|
|
serial_number = request_dict.get('serial_number', None)
|