Smart Home Automation Forum
KC868-H16 TCP PHP sample code - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=1)
+--- Forum: KC868-HxB series Smart Controller (https://www.kincony.com/forum/forumdisplay.php?fid=2)
+--- Thread: KC868-H16 TCP PHP sample code (/showthread.php?tid=2673)



KC868-H16 TCP PHP sample code - jfementira - 03-13-2023

I'm using KC868-H16.
How to run tcp send and receive command using php?


RE: KC868-H16 TCP PHP sample code - admin - 03-13-2023

see this guide about PHP tcp socket connection code:
https://www.php.net/manual/en/function.socket-connect.php


RE: KC868-H16 TCP PHP sample code - jfementira - 03-13-2023

(03-13-2023, 04:35 AM)admin Wrote: see this guide about PHP tcp socket connection code:
https://www.php.net/manual/en/function.socket-connect.php

So it is just a string to send to the server/device?

Sample:  
PHP Code:
$message 'RELAY-SET-255,1,0';
socket_write($socket$messagestrlen($message)); 



RE: KC868-H16 TCP PHP sample code - admin - 03-13-2023

yes, very easy.
$message = 'RELAY-SET-255,1,1'; //turn on relay1
$message = 'RELAY-SET-255,1,0'; //turn off relay1


RE: KC868-H16 TCP PHP sample code - jfementira - 03-13-2023

(03-13-2023, 06:19 AM)admin Wrote: yes, very easy.
$message = 'RELAY-SET-255,1,1';    //turn on relay1
$message = 'RELAY-SET-255,1,0';    //turn off relay1

Awesome, Thank you.
I have a Smart City and BMS project this year. I will use this product from one of my integration.


RE: KC868-H16 TCP PHP sample code - admin - 03-13-2023

ok, thanks, test with first controller. good luck.