|
@@ -489,7 +489,7 @@ class Lampcontrol extends Base_Controller {
|
|
$sendData = $address.'0300004646';
|
|
$sendData = $address.'0300004646';
|
|
|
|
|
|
if ($lampData['protocoltype'] == 4) {
|
|
if ($lampData['protocoltype'] == 4) {
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
}else{
|
|
}else{
|
|
// $cmd .= crc16(pack('H*',$sendData));
|
|
// $cmd .= crc16(pack('H*',$sendData));
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
@@ -662,11 +662,11 @@ class Lampcontrol extends Base_Controller {
|
|
|
|
|
|
}elseif ($lampData['lampprotocoltype'] == 1) {
|
|
}elseif ($lampData['lampprotocoltype'] == 1) {
|
|
$sendData = '0103000a0002e409';
|
|
$sendData = '0103000a0002e409';
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
if (!empty($res) && strtolower(crc16(pack('H*',mb_substr($res['msg'], 0,-4)))) == strtolower(mb_substr($res['msg'], -4))) {
|
|
if (!empty($res) && strtolower(crc16(pack('H*',mb_substr($res['msg'], 0,-4)))) == strtolower(mb_substr($res['msg'], -4))) {
|
|
$sysInfoStr = $res['msg'];
|
|
$sysInfoStr = $res['msg'];
|
|
$sendData = '010300fd003115ee';
|
|
$sendData = '010300fd003115ee';
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
if (!empty($res) && strtolower(crc16(pack('H*',mb_substr($res['msg'], 0,-4)))) == strtolower(mb_substr($res['msg'], -4))) {
|
|
if (!empty($res) && strtolower(crc16(pack('H*',mb_substr($res['msg'], 0,-4)))) == strtolower(mb_substr($res['msg'], -4))) {
|
|
$data = array();
|
|
$data = array();
|
|
$msg = $res['msg'];
|
|
$msg = $res['msg'];
|
|
@@ -870,20 +870,25 @@ class Lampcontrol extends Base_Controller {
|
|
$lampData = $this->Lamp_model->get_one(['id'=>$lamp_id],'number,address');
|
|
$lampData = $this->Lamp_model->get_one(['id'=>$lamp_id],'number,address');
|
|
|
|
|
|
$seq = get_seq();
|
|
$seq = get_seq();
|
|
|
|
+ $seq = '01';
|
|
|
|
|
|
$sendData = '12'.PROTOCOL_VERSION.$seq.'0000000000';
|
|
$sendData = '12'.PROTOCOL_VERSION.$seq.'0000000000';
|
|
|
|
+ $sendData .= $lightness > 0 ? '01' : '00';
|
|
$lightness2 = empty($lightness) ? '00' : '00'.base_convert($lightness, 10, 16);
|
|
$lightness2 = empty($lightness) ? '00' : '00'.base_convert($lightness, 10, 16);
|
|
$sendData .= strlen($lightness2) == 2 ? $lightness2 : substr($lightness2, -2);
|
|
$sendData .= strlen($lightness2) == 2 ? $lightness2 : substr($lightness2, -2);
|
|
$sendData .= '00';
|
|
$sendData .= '00';
|
|
|
|
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
-
|
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ var_dump($sendData);
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*',$sendData),30);
|
|
|
|
+ var_dump('/IDCOL/CmdInput/'.$lampData['address']);
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
$data = ['code'=>'0016','status'=>2,'msg'=>$this->response['0016'],'data'=>['number'=>$lampData['number'],'type'=>'dimming','id'=>$lamp_id]];
|
|
$data = ['code'=>'0016','status'=>2,'msg'=>$this->response['0016'],'data'=>['number'=>$lampData['number'],'type'=>'dimming','id'=>$lamp_id]];
|
|
exit(send_websocket($clientid,$data));
|
|
exit(send_websocket($clientid,$data));
|
|
}else{
|
|
}else{
|
|
- if (strtolower(crc16(pack('H*',substr($res['msg'], 0,-4)))) == strtolower(substr($res['msg'], -4))) {
|
|
|
|
|
|
+ $res['msg'] = unpack('H*', $res['msg'])[1];
|
|
|
|
+ var_dump($res['msg']);
|
|
|
|
+ if (strtolower(crc16(pack('H*',substr($res['msg'], 0,-4)))) == strtolower(substr($res['msg'], -4)) && strtolower(substr($res['msg'], 18,2)) == '01') {
|
|
if ($lightness != 0) {
|
|
if ($lightness != 0) {
|
|
$this->Lamp_model->update(array('id'=>$lampData['id']),array('status'=>1,'lighteness'=>$lightness));
|
|
$this->Lamp_model->update(array('id'=>$lampData['id']),array('status'=>1,'lighteness'=>$lightness));
|
|
}else{
|
|
}else{
|
|
@@ -1125,7 +1130,7 @@ class Lampcontrol extends Base_Controller {
|
|
$sendData = $address.$sendData;
|
|
$sendData = $address.$sendData;
|
|
|
|
|
|
if ($lampProData['protocoltype'] == 4) {
|
|
if ($lampProData['protocoltype'] == 4) {
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
}else{
|
|
}else{
|
|
device_cmd($lampProData['deviceid'],pack('H*',$sendData));
|
|
device_cmd($lampProData['deviceid'],pack('H*',$sendData));
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampProData['address'].'"}';
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampProData['address'].'"}';
|
|
@@ -1406,7 +1411,7 @@ class Lampcontrol extends Base_Controller {
|
|
if ($lampProData['protocoltype'] == 4 && $lampProData['lampprotocoltype'] == 1) {
|
|
if ($lampProData['protocoltype'] == 4 && $lampProData['lampprotocoltype'] == 1) {
|
|
$sendData = '0103e08d0027a23b';
|
|
$sendData = '0103e08d0027a23b';
|
|
|
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
return array('result'=>1,'msg'=>'0016');
|
|
return array('result'=>1,'msg'=>'0016');
|
|
}else{
|
|
}else{
|
|
@@ -1456,7 +1461,7 @@ class Lampcontrol extends Base_Controller {
|
|
$len = doubBitSubStr(base_convert(intval(mb_strlen($sendData)/4), 10, 16)).bitSubStr(base_convert(intval(mb_strlen($sendData)/2), 10, 16));
|
|
$len = doubBitSubStr(base_convert(intval(mb_strlen($sendData)/4), 10, 16)).bitSubStr(base_convert(intval(mb_strlen($sendData)/2), 10, 16));
|
|
$sendData = '0110e08d'.$len.$sendData;
|
|
$sendData = '0110e08d'.$len.$sendData;
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
return array('result'=>1,'msg'=>'0016');
|
|
return array('result'=>1,'msg'=>'0016');
|
|
}else{
|
|
}else{
|
|
@@ -1839,7 +1844,7 @@ class Lampcontrol extends Base_Controller {
|
|
$sendData = $address.$sendData;
|
|
$sendData = $address.$sendData;
|
|
|
|
|
|
if ($lampProData['protocoltype'] == 4) {
|
|
if ($lampProData['protocoltype'] == 4) {
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
}else{
|
|
}else{
|
|
device_cmd($lampProData['deviceid'],pack('H*',$sendData));
|
|
device_cmd($lampProData['deviceid'],pack('H*',$sendData));
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampProData['address'].'"}';
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampProData['address'].'"}';
|
|
@@ -2046,7 +2051,7 @@ class Lampcontrol extends Base_Controller {
|
|
if ($lampProData['protocoltype'] == 4 && $lampProData['lampprotocoltype'] == 1) {
|
|
if ($lampProData['protocoltype'] == 4 && $lampProData['lampprotocoltype'] == 1) {
|
|
$sendData = '0103e0020020d212';
|
|
$sendData = '0103e0020020d212';
|
|
|
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
return array('result'=>1,'msg'=>'0016');
|
|
return array('result'=>1,'msg'=>'0016');
|
|
}else{
|
|
}else{
|
|
@@ -2139,7 +2144,7 @@ class Lampcontrol extends Base_Controller {
|
|
$len = doubBitSubStr(base_convert(intval(mb_strlen($sendData)/4), 10, 16)).bitSubStr(base_convert(intval(mb_strlen($sendData)/2), 10, 16));
|
|
$len = doubBitSubStr(base_convert(intval(mb_strlen($sendData)/4), 10, 16)).bitSubStr(base_convert(intval(mb_strlen($sendData)/2), 10, 16));
|
|
$sendData = '0110e002'.$len.$sendData;
|
|
$sendData = '0110e002'.$len.$sendData;
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
$sendData .= crc16(pack('H*',$sendData));
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/lamp/TransOut/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampProData['address'],'/IDCOL/CmdOutput/'.$lampProData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
return array('result'=>1,'msg'=>'0016');
|
|
return array('result'=>1,'msg'=>'0016');
|
|
}else{
|
|
}else{
|
|
@@ -2535,7 +2540,7 @@ class Lampcontrol extends Base_Controller {
|
|
$sendData = $address.'0304001014';
|
|
$sendData = $address.'0304001014';
|
|
|
|
|
|
if ($lampData['protocoltype'] == 4) {
|
|
if ($lampData['protocoltype'] == 4) {
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
}else{
|
|
}else{
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampData['address'].'"}';
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampData['address'].'"}';
|
|
@@ -2650,7 +2655,7 @@ class Lampcontrol extends Base_Controller {
|
|
if ($lampData['protocoltype'] == 4 && $lampData['lampprotocoltype'] == 1) {
|
|
if ($lampData['protocoltype'] == 4 && $lampData['lampprotocoltype'] == 1) {
|
|
$sendData = '0103e08d0027a23b';
|
|
$sendData = '0103e08d0027a23b';
|
|
|
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
exit(json_result('0016', $this->response['0016']));
|
|
exit(json_result('0016', $this->response['0016']));
|
|
}else{
|
|
}else{
|
|
@@ -2922,7 +2927,7 @@ class Lampcontrol extends Base_Controller {
|
|
$sendData = $address.'030328204b';
|
|
$sendData = $address.'030328204b';
|
|
|
|
|
|
if ($lampData['protocoltype'] == 4) {
|
|
if ($lampData['protocoltype'] == 4) {
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
}else{
|
|
}else{
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampData['address'].'"}';
|
|
$cmd = '{"type":"cmd","deviceId":"'.$lampData['address'].'"}';
|
|
@@ -3064,7 +3069,7 @@ class Lampcontrol extends Base_Controller {
|
|
if ($lampData['protocoltype'] == 4 && $lampData['lampprotocoltype'] == 1) {
|
|
if ($lampData['protocoltype'] == 4 && $lampData['lampprotocoltype'] == 1) {
|
|
$sendData = '0103e0020020d212';
|
|
$sendData = '0103e0020020d212';
|
|
|
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/lamp/TransOut/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
+ $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
if (empty($res)) {
|
|
if (empty($res)) {
|
|
exit(json_result('0016', $this->response['0016']));
|
|
exit(json_result('0016', $this->response['0016']));
|
|
}else{
|
|
}else{
|