Smart Home Automation Forum

Full Version: KC868-H16 TCP PHP sample code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using KC868-H16.
How to run tcp send and receive command using php?
see this guide about PHP tcp socket connection code:
https://www.php.net/manual/en/function.s...onnect.php
(03-13-2023, 04:35 AM)admin Wrote: [ -> ]see this guide about PHP tcp socket connection code:
https://www.php.net/manual/en/function.s...onnect.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)); 
yes, very easy.
$message = 'RELAY-SET-255,1,1'; //turn on relay1
$message = 'RELAY-SET-255,1,0'; //turn off relay1
(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.
ok, thanks, test with first controller. good luck.