|
@@ -470,6 +470,56 @@ class Lampcontrol extends Base_Controller {
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
+ // 重启设备
|
|
|
+ public function reboot_dev(){
|
|
|
+ $username = $this->input->post('username',true);
|
|
|
+ $role = $this->input->post('role',true);
|
|
|
+ $client_key = $this->input->post('client_key',true);
|
|
|
+ $token = $this->input->post('token',true);
|
|
|
+ $type = intval($this->input->post('type',true));
|
|
|
+ $lamp_id = $this->input->post('lamp_id',true);
|
|
|
+ $clientid = $this->input->post('clientid',true);
|
|
|
+ $version = $this->session->userdata('version');
|
|
|
+
|
|
|
+ $lampArr = explode(',', $lamp_id);
|
|
|
+
|
|
|
+ $url = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/api/lampcontrol/reboot_dev_asy';
|
|
|
+ foreach ($lampArr as $l) {
|
|
|
+ doAsyncRequest($url,['clientid'=>$clientid,'username'=>$username,'client_key'=>$client_key,'token'=>$token,'version'=>$version,'type'=>$type,'lamp_id'=>$l,'role'=>$role]);
|
|
|
+ }
|
|
|
+
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reboot_dev_asy(){
|
|
|
+ $lamp_id = intval($this->input->post('lamp_id',true));
|
|
|
+
|
|
|
+ if (empty($lamp_id)) {
|
|
|
+ $data = ['code'=>'0007','status'=>2,'msg'=>$this->response['0007'],'data'=>['number'=>'','type'=>'reboot_dev_asy','id'=>$lamp_id]];
|
|
|
+ exit(send_websocket($clientid,$data));
|
|
|
+ }
|
|
|
+
|
|
|
+ $lampData = $this->Lamp_model->get_one(['id'=>$lamp_id],'address,number,id');
|
|
|
+
|
|
|
+ $res = $this->send_cmd('1f',$lampData['address'],'01');
|
|
|
+
|
|
|
+ if (empty($res)) {
|
|
|
+ $data = ['code'=>'0016','status'=>2,'msg'=>$this->response['0016'],'data'=>['number'=>$lampData['number'],'type'=>'reboot_dev_asy','id'=>$lamp_id]];
|
|
|
+ exit(send_websocket($clientid,$data));
|
|
|
+ }else{
|
|
|
+ $res['msg'] = unpack('H*', $res['msg'])[1];
|
|
|
+
|
|
|
+ set_log('dimming_asy.txt',$res['msg']);
|
|
|
+ if (strtolower(crc16(pack('H*',substr($res['msg'], 0,-4)))) == strtolower(substr($res['msg'], -4)) && strtolower(substr($res['msg'], 18,2)) == '01') {
|
|
|
+
|
|
|
+ $data = ['code'=>'0000','status'=>2,'msg'=>$this->response['0000'],'data'=>['number'=>$lampData['number'],'type'=>'reboot_dev_asy','id'=>$lamp_id]];
|
|
|
+ exit(send_websocket($clientid,$data));
|
|
|
+ }else{
|
|
|
+ $data = ['code'=>'0010','status'=>2,'msg'=>$this->response['0010'],'data'=>['number'=>$lampData['number'],'type'=>'reboot_dev_asy','id'=>$lamp_id]];
|
|
|
+ exit(send_websocket($clientid,$data));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 灯控调光
|
|
|
public function dimming(){
|
|
|
$username = $this->input->post('username',true);
|