|
@@ -128,6 +128,12 @@ class oa2TokenView(TemplateView):
|
|
|
client_id = request_dict.get("client_id", None)
|
|
|
refresh_token = request_dict.get("refresh_token", None)
|
|
|
from var_dump import var_dump
|
|
|
+ logger = logging.getLogger('django')
|
|
|
+ logger.info('token-------------begin')
|
|
|
+ logger.info(code)
|
|
|
+ logger.info(client_id)
|
|
|
+ logger.info(refresh_token)
|
|
|
+
|
|
|
|
|
|
print('tokenView---------------')
|
|
|
print('refresh_token:')
|
|
@@ -399,22 +405,25 @@ class oa2DiscoveryDevice(TemplateView):
|
|
|
region = request_dict.get("region", 'cn')
|
|
|
logger = logging.getLogger('django')
|
|
|
|
|
|
- # api_uri = 'http://api.amazonalexa.com/v3/events'
|
|
|
- # requests_data = {
|
|
|
+ # api_uri = 'https://api.amazonalexa.com/v3/events'
|
|
|
+ # messageId = str(uuid.uuid4())
|
|
|
+ # bearer_access_token = 'Bearer {access_token}'.format(access_token=access_token)
|
|
|
+ # headers = {'content-type': "application/json", 'Authorization': bearer_access_token}
|
|
|
+ # payload = {
|
|
|
# "event": {
|
|
|
# "header": {
|
|
|
# "namespace": "Alexa.Discovery",
|
|
|
# "name": "AddOrUpdateReport",
|
|
|
# "payloadVersion": "3",
|
|
|
- # "messageId": str(uuid.uuid4())
|
|
|
+ # "messageId": messageId
|
|
|
# },
|
|
|
# "payload": {
|
|
|
# "endpoints": [
|
|
|
# {
|
|
|
- # "endpointId": "LKFJM6KDTAF9",
|
|
|
- # "manufacturerName": "Zosi smart",
|
|
|
+ # "endpointId": "HVTLKFJM6KDTAF9J111A",
|
|
|
+ # "manufacturerName": "Sample Manufacturer",
|
|
|
# "description": "Smart Light by Sample Manufacturer",
|
|
|
- # "friendlyName": "Camera one",
|
|
|
+ # "friendlyName": "Kitchen Light",
|
|
|
# "displayCategories": [
|
|
|
# "CAMERA"
|
|
|
# ],
|
|
@@ -425,10 +434,10 @@ class oa2DiscoveryDevice(TemplateView):
|
|
|
# "version": "3",
|
|
|
# "cameraStreamConfigurations": [
|
|
|
# {
|
|
|
- # "protocols": ['RTSP'],
|
|
|
- # "resolutions": [{"width": 1280, "height": 720}],
|
|
|
+ # "protocols": ["RTSP"],
|
|
|
+ # "resolutions": [{"width": 1280, "height": 720}],
|
|
|
# "authorizationTypes": ["NONE"],
|
|
|
- # "videoCodecs": ["H264"],
|
|
|
+ # "videoCodecs": ["H264"],
|
|
|
# "audioCodecs": ["ACC"]
|
|
|
# }]
|
|
|
# },
|
|
@@ -436,81 +445,11 @@ class oa2DiscoveryDevice(TemplateView):
|
|
|
# "type": "AlexaInterface",
|
|
|
# "interface": "Alexa.MediaMetadata",
|
|
|
# "version": "3",
|
|
|
+ # "proactivelyReported": True,
|
|
|
+ # # "retrievable": True
|
|
|
+ #
|
|
|
# }
|
|
|
- # ],
|
|
|
- # "connections": [
|
|
|
- # ],
|
|
|
- # "cookie": {
|
|
|
- # }
|
|
|
- # }
|
|
|
- # ],
|
|
|
- # "scope": {
|
|
|
- # "type": "BearerToken",
|
|
|
- # "token": access_token
|
|
|
- # }
|
|
|
- # }
|
|
|
- # }
|
|
|
- # }
|
|
|
- # new_data = {
|
|
|
- # "event": {
|
|
|
- # "header": {
|
|
|
- # "namespace": "Alexa.Discovery",
|
|
|
- # "name": "AddOrUpdateReport",
|
|
|
- # "payloadVersion": "3",
|
|
|
- # "messageId": str(uuid.uuid4())
|
|
|
- # },
|
|
|
- # "payload": {
|
|
|
- # "endpoints": [
|
|
|
- # {
|
|
|
- # "endpointId": "HVTLKFJM6KDTAF9J111A",
|
|
|
- # "manufacturerName": "Sample Manufacturer",
|
|
|
- # "description": "Smart Light by Sample Manufacturer",
|
|
|
- # "friendlyName": "Kitchen Light",
|
|
|
- # "additionalAttributes": {
|
|
|
- # "manufacturer" : "Sample Manufacturer",
|
|
|
- # "model" : "Sample Model",
|
|
|
- # "serialNumber": "<the serial number of the device>",
|
|
|
- # "firmwareVersion" : "<the firmware version of the device>",
|
|
|
- # "softwareVersion": "<the software version of the device>",
|
|
|
- # "customIdentifier": "<your custom identifier for the device>"
|
|
|
- # },
|
|
|
- # "displayCategories": [
|
|
|
- # "LIGHT"
|
|
|
- # ],
|
|
|
- # "capabilities": [
|
|
|
- # {
|
|
|
- # "type": "AlexaInterface",
|
|
|
- # "interface": "Alexa.PowerController",
|
|
|
- # "version": "3",
|
|
|
- # "properties": {
|
|
|
- # "supported": [
|
|
|
- # {
|
|
|
- # "name": "powerState"
|
|
|
- # }
|
|
|
- # ],
|
|
|
- # # "proactivelyReported": true,
|
|
|
- # # "retrievable": true
|
|
|
- # }
|
|
|
- # },
|
|
|
- # {
|
|
|
- # "type": "AlexaInterface",
|
|
|
- # "interface": "Alexa.BrightnessController",
|
|
|
- # "version": "3",
|
|
|
- # "properties": {
|
|
|
- # "supported": [
|
|
|
- # {
|
|
|
- # "name": "brightness"
|
|
|
- # }
|
|
|
- # ],
|
|
|
- # # "proactivelyReported": True,
|
|
|
- # # "retrievable": True
|
|
|
- # }
|
|
|
- # }
|
|
|
- # ],
|
|
|
- # "connections": [
|
|
|
- # ],
|
|
|
- # "cookie": {
|
|
|
- # }
|
|
|
+ # ]
|
|
|
# }
|
|
|
# ],
|
|
|
# "scope": {
|
|
@@ -520,11 +459,12 @@ class oa2DiscoveryDevice(TemplateView):
|
|
|
# }
|
|
|
# }
|
|
|
# }
|
|
|
- # request_res = requests.post(url=api_uri, data=new_data)
|
|
|
- # request_json = request_res.json()
|
|
|
- # return JsonResponse({'res': request_json})
|
|
|
+ # response = requests.post(api_uri, data = payload, headers = headers)
|
|
|
+ # request_json = response.json()
|
|
|
# logger.info('1111-----request_json--------------------')
|
|
|
# logger.info(request_json)
|
|
|
+ # return JsonResponse({'res': request_json})
|
|
|
+ # logger.info(request_json)
|
|
|
|
|
|
|
|
|
try:
|