|
@@ -6,14 +6,12 @@ import time
|
|
import uuid
|
|
import uuid
|
|
from collections import OrderedDict
|
|
from collections import OrderedDict
|
|
|
|
|
|
-import requests
|
|
|
|
from django.views import View
|
|
from django.views import View
|
|
|
|
|
|
from Ansjer.config import AWS_IOT_GETS3_PULL_CHINA_ID, AWS_IOT_GETS3_PULL_CHINA_SECRET, \
|
|
from Ansjer.config import AWS_IOT_GETS3_PULL_CHINA_ID, AWS_IOT_GETS3_PULL_CHINA_SECRET, \
|
|
AWS_IOT_GETS3_PULL_FOREIGN_ID, AWS_IOT_GETS3_PULL_FOREIGN_SECRET, AWS_ARN, AWS_IOT_SES_ACCESS_CHINA_REGION, \
|
|
AWS_IOT_GETS3_PULL_FOREIGN_ID, AWS_IOT_GETS3_PULL_FOREIGN_SECRET, AWS_ARN, AWS_IOT_SES_ACCESS_CHINA_REGION, \
|
|
AWS_IOT_SES_ACCESS_FOREIGN_REGION_ASIA, AWS_IOT_SES_ACCESS_FOREIGN_REGION_EUROPE, \
|
|
AWS_IOT_SES_ACCESS_FOREIGN_REGION_ASIA, AWS_IOT_SES_ACCESS_FOREIGN_REGION_EUROPE, \
|
|
- AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA, CONFIG_INFO, CONFIG_TEST, CONFIG_CN
|
|
|
|
-from Controller.DeviceConfirmRegion import Device_Region
|
|
|
|
|
|
+ AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA, REGION_ID_LIST
|
|
from Model.models import Device_Info, iotdeviceInfoModel, SerialNumberModel, UidSetModel
|
|
from Model.models import Device_Info, iotdeviceInfoModel, SerialNumberModel, UidSetModel
|
|
from Object.IOTCore.IotObject import IOTClient
|
|
from Object.IOTCore.IotObject import IOTClient
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -39,13 +37,13 @@ class IotCoreView(View):
|
|
response = ResponseObject()
|
|
response = ResponseObject()
|
|
lang = request_dict.get('lang', 'en')
|
|
lang = request_dict.get('lang', 'en')
|
|
response.lang = lang
|
|
response.lang = lang
|
|
- if operation == 'createKeysAndCertificate': # 设备注册到IoT core
|
|
|
|
|
|
+ if operation == 'createKeysAndCertificate': # 设备注册到IoT core
|
|
return self.create_key_and_certificate(request_dict, response)
|
|
return self.create_key_and_certificate(request_dict, response)
|
|
elif operation == 'requestPublishMessage':
|
|
elif operation == 'requestPublishMessage':
|
|
return self.request_publish_message(request_dict, response)
|
|
return self.request_publish_message(request_dict, response)
|
|
elif operation == 'getS3PullKey':
|
|
elif operation == 'getS3PullKey':
|
|
return self.get_s3_pull_key(request_dict, response, request)
|
|
return self.get_s3_pull_key(request_dict, response, request)
|
|
- elif operation == 'thingRegroup': # OTA升级成功重新分组
|
|
|
|
|
|
+ elif operation == 'thingRegroup': # OTA升级成功重新分组
|
|
return self.thing_regroup(request_dict, response)
|
|
return self.thing_regroup(request_dict, response)
|
|
elif operation == 'pcGetIotInfo':
|
|
elif operation == 'pcGetIotInfo':
|
|
return self.pcGetIotInfo(request_dict, response)
|
|
return self.pcGetIotInfo(request_dict, response)
|
|
@@ -131,7 +129,7 @@ class IotCoreView(View):
|
|
else:
|
|
else:
|
|
# 获取并判断region_id是否有效
|
|
# 获取并判断region_id是否有效
|
|
region_id = CommonService.confirm_region_id()
|
|
region_id = CommonService.confirm_region_id()
|
|
- if region_id not in [1, 2, 3, 4]:
|
|
|
|
|
|
+ if region_id not in REGION_ID_LIST:
|
|
return response.json(444, {'invalid region_id': region_id})
|
|
return response.json(444, {'invalid region_id': region_id})
|
|
|
|
|
|
iotClient = IOTClient(region_id)
|
|
iotClient = IOTClient(region_id)
|
|
@@ -198,7 +196,7 @@ class IotCoreView(View):
|
|
|
|
|
|
# 获取并判断region_id是否有效
|
|
# 获取并判断region_id是否有效
|
|
region_id = CommonService.confirm_region_id()
|
|
region_id = CommonService.confirm_region_id()
|
|
- if region_id not in [1, 2, 3, 4]:
|
|
|
|
|
|
+ if region_id not in REGION_ID_LIST:
|
|
return response.json(444, {'invalid region_id': region_id})
|
|
return response.json(444, {'invalid region_id': region_id})
|
|
|
|
|
|
company_mark = '11A'
|
|
company_mark = '11A'
|
|
@@ -271,7 +269,7 @@ class IotCoreView(View):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
|
|
try:
|
|
try:
|
|
- thing_name = CommonService.query_serial_with_uid(UID) # 存在序列号则为使用序列号作为物品名
|
|
|
|
|
|
+ thing_name = CommonService.query_serial_with_uid(UID) # 存在序列号则为使用序列号作为物品名
|
|
topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
msg = OrderedDict(
|
|
msg = OrderedDict(
|
|
[
|
|
[
|