Hej!
Dzięki uprzejmości
homelogic od kilku dni bawię się Loxone i oczywiście podjąłem próbę integracji z wBox'ami. Pierwszy rezultat (na razie bardzo uproszczony) dla wLightBox działa bardzo fajnie. Chodzi też ze switchBoxem i shutterBoxem.
Załączam kod:
// wBox IP ADDRESS
char* IP_ADDRESS = "192.168.2.173";
// Port (80=http)
char* PORT = "80";
char szBuffer[128];
char deviceLink[256];
char res[256];
float f1,f2,f3,f4;
int nEvents;
char device[255];
sprintf(device, "/dev/tcp/%s/80", IP_ADDRESS);
void sendCommand(char * command) {
STREAM* TcpStream = stream_create(device,0,0);
if (TcpStream == NULL) {
printf("Creating Stream failed");
stream_close(TcpStream);
return;
}
char buffer[256];
sprintf(buffer, "GET /s/%s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\nContent-Length: %d\r\n\r\n\0", command, IP_ADDRESS, 0x00);
printf("request: %s", buffer);
stream_write(TcpStream,buffer,sizeof(buffer));
stream_flush(TcpStream);
stream_close(TcpStream);
}
sprintf(deviceLink, "http://%s:%s/", IP_ADDRESS, PORT);
printf("Device link is: %s", deviceLink);
while(TRUE)
{
nEvents = getinputevent();
if (nEvents & 0xe)
{
f1 = getinput(0);
float red,green,blue;
char command[16];
blue = floor(f1/1000000);
green = floor((f1-blue*1000000)/1000);
red = f1-blue*1000000-green*1000;
sprintf(command, "%02x%02x%02x00", (red*2.55), (green*2.55), (blue*2.55));
printf("command to send: %s", command);
sendCommand(command);
}
sleep(100);
}
Co sądzicie? Kto dziś zintegruje wBoxy z Loxone?
