|
@@ -0,0 +1,110 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+"""
|
|
|
+"""
|
|
|
+import json
|
|
|
+import time
|
|
|
+import requests
|
|
|
+import uuid
|
|
|
+import logging
|
|
|
+from django.views.generic import TemplateView
|
|
|
+from django.shortcuts import render_to_response
|
|
|
+from django.http import JsonResponse
|
|
|
+from object.ResObject import ResObject
|
|
|
+import subprocess
|
|
|
+# from gevent.pool import Pool
|
|
|
+from model.models import UserModel,UidRtspModel
|
|
|
+from object.tkObject import tkObject
|
|
|
+from service.CommonService import CommonService
|
|
|
+from object.RedisObject import RedisObject
|
|
|
+from django.utils.decorators import method_decorator
|
|
|
+from django.views.decorators.csrf import csrf_exempt
|
|
|
+
|
|
|
+
|
|
|
+rtspServer = "rtsp.zositech.org,3.16.66.144"
|
|
|
+
|
|
|
+class deviceStatus(TemplateView):
|
|
|
+ @method_decorator(csrf_exempt)
|
|
|
+ def dispatch(self, *args, **kwargs):
|
|
|
+ return super(deviceStatus, self).dispatch(*args, **kwargs)
|
|
|
+
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
+ operation = kwargs.get('operation')
|
|
|
+ if operation == 'test':
|
|
|
+ return JsonResponse({'res': '11'})
|
|
|
+
|
|
|
+
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
+ request_dict = request.GET
|
|
|
+ operation = kwargs.get('operation')
|
|
|
+ if operation == 'test':
|
|
|
+ api_uri = 'https://api.amazonalexa.com/v3/events'
|
|
|
+ messageId = str(uuid.uuid4())
|
|
|
+ access_token = 'dEqVJw7g3wR4oXOTD6szvNebyKQEkCba'
|
|
|
+ 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": messageId
|
|
|
+ },
|
|
|
+ "payload": {
|
|
|
+ "endpoints": [
|
|
|
+ {
|
|
|
+ "endpointId": "HVTLKFJM6KDTAF9J111A",
|
|
|
+ "manufacturerName": "Sample Manufacturer",
|
|
|
+ "description": "Smart Light by Sample Manufacturer",
|
|
|
+ "friendlyName": "Kitchen Light",
|
|
|
+ "displayCategories": [
|
|
|
+ "CAMERA"
|
|
|
+ ],
|
|
|
+ "capabilities": [
|
|
|
+ {
|
|
|
+ "type": "AlexaInterface",
|
|
|
+ "interface": "Alexa.CameraStreamController",
|
|
|
+ "version": "3",
|
|
|
+ "cameraStreamConfigurations": [
|
|
|
+ {
|
|
|
+ "protocols": ["RTSP"],
|
|
|
+ "resolutions": [{"width": 1280, "height": 720}],
|
|
|
+ "authorizationTypes": ["NONE"],
|
|
|
+ "videoCodecs": ["H264"],
|
|
|
+ "audioCodecs": ["ACC"]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "AlexaInterface",
|
|
|
+ "interface": "Alexa.MediaMetadata",
|
|
|
+ "version": "3",
|
|
|
+ "proactivelyReported": True,
|
|
|
+ # "retrievable": True
|
|
|
+
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "scope": {
|
|
|
+ "type": "BearerToken",
|
|
|
+ "token": access_token
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response = requests.post(api_uri, data = payload, headers = headers)
|
|
|
+ request_json = response.json()
|
|
|
+ return JsonResponse({'res': request_json})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|