<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;

/**
 * 首页接口
 */
class Hkws extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    public function command()
	{
		$direction = $this->request->param('direction');
		if (!in_array($direction,['0',1,2,3,4,5,6,7,8,9,10,11])) {
		    $this->error('指令参数错误');
		}
		
		$url = 'https://open.ys7.com/api/lapp/device/ptz/start';
		$data = [
			'accessToken' => 'at.2209auyw505mjojoai0uc6q3dpn3sekk-1lankv9uq3-0yxxupl-yazzgmgdh',
			'deviceSerial'=>'F77587632',
			'channelNo'	=>1,
			'direction'	=> $direction,
			'speed' => 1
		];
		$res = json_decode(\fast\Http::post($url,$data));
		$this->success('',$res);
	}
	public function stopcommand()
	{
		$uri = 'https://open.ys7.com/api/lapp/device/ptz/stop';
		$data = [
			'accessToken' => 'at.2209auyw505mjojoai0uc6q3dpn3sekk-1lankv9uq3-0yxxupl-yazzgmgdh',
			'deviceSerial'=>'F77587632',
			'channelNo'	=>1,
		];
		$res = \fast\Http::post($uri,$data);
		//dump($res);
	}
}