Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
foxvlad committed Nov 8, 2018
1 parent 91e58b5 commit eb5354c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
26 changes: 26 additions & 0 deletions modules/okbit/lib/send_udp_okbit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ public function udp_send($udpPacket){
}



public function udp_send_no_remote($udpPacket){
$this->data = $udpPacket;

//Отправка сообщения на шлюз
if(!($bytes = socket_sendto($this->sock, $this->data, strlen($this->data) , 0 , $this->ip_gate, $this->port_gate))){
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
if ($this->debug) DebMes ("Cannot send data to socket [$errorcode] $errormsg", 'okbit');

} else if ($this->debug){
DebMes (">>>>> $this->data", 'okbit');
DebMes (">>>>> Sent $bytes bytes to socket", 'okbit');
}

$buf = '';
$count = 0;

socket_shutdown($this->sock, 2);
socket_close($this->sock);
}





/**
* parsing_packege
*
Expand Down
6 changes: 3 additions & 3 deletions modules/okbit/okbit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
define ('DATA_6007', 'IND1,IND2,IND3,IND4,INA1,INA2,INA3,INA4');
define ('DATA_6008', 'IND1,IND2,IND3,IND4,INA1,INA2,INA3,INA4');

define ('DATA_7001', 'Lamp1,Lamp2,Lamp3');
define ('DATA_7001', 'Lamp1,Lamp2,Lamp3,Lamp4');
define ('DATA_7002', 'Temp,Humidity');
define ('DATA_7003', 'Reley');
define ('DATA_7004', 'Red,Green,Blue');
Expand Down Expand Up @@ -502,7 +502,7 @@ function propertySetHandle($object, $property, $value) {
$gate->sock_create(); //Создание UDP сокета
$gate->sockSetTimeout(1); //Установка таймаута для получения ответа
$gate->sock_bind();
$gate->udp_send($data_send); // отправка пакета
$gate->udp_send_no_remote($data_send); // отправка пакета
}

else if ($properties['ETHERNET'] == '0') {
Expand Down Expand Up @@ -546,7 +546,7 @@ function propertySetHandle($object, $property, $value) {
$gate->sock_create(); //Создание UDP сокета
$gate->sockSetTimeout(1); //Установка таймаута для получения ответа
$gate->sock_bind();
$gate->udp_send($data_send); // отправка пакета
$gate->udp_send_no_remote($data_send); // отправка пакета
}

}
Expand Down
1 change: 1 addition & 0 deletions modules/okbit/okbit_gate_edit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
elseif ($properties[$i]['TITLE'] == 'Lamp1') $properties[$i]['SDEVICE_TYPE'] = 'relay';
elseif ($properties[$i]['TITLE'] == 'Lamp2') $properties[$i]['SDEVICE_TYPE'] = 'relay';
elseif ($properties[$i]['TITLE'] == 'Lamp3') $properties[$i]['SDEVICE_TYPE'] = 'relay';
elseif ($properties[$i]['TITLE'] == 'Lamp4') $properties[$i]['SDEVICE_TYPE'] = 'relay';
elseif ($properties[$i]['TITLE'] == 'Reley') $properties[$i]['SDEVICE_TYPE'] = 'relay';
elseif ($properties[$i]['TITLE'] == 'Temp') $properties[$i]['SDEVICE_TYPE'] = 'sensor_temp';
elseif ($properties[$i]['TITLE'] == 'Humidity') $properties[$i]['SDEVICE_TYPE'] = 'sensor_humidity';
Expand Down

0 comments on commit eb5354c

Please sign in to comment.