Making a Crestron Module for HTTP API Control
#12
6. Upd Broadcast
//*******************************************************************************************
SOCKETRECEIVE FbUdp
{
STRING Sbuffer[16392];
INTEGER RcvLength, iEvent, iEventLevel, F[5];

Delay(5);
Sbuffer = FbUdp.SocketRxBuf;
ClearBuffer(FbUdp.SocketRxBuf);
If(Find(XbmcIp, Sbuffer) = 0) Terminateevent;
RcvLength = Len(Sbuffer);
print("\nUdp = %s\n\n", Sbuffer);

If(Find("OnAction", Sbuffer) > 0)
{
F[0] = Find(":", Sbuffer);
F[1] = Find(";", Sbuffer, F[0]);
If(F[1] = 0) F[1] = F[0];
F[2] = Find("<", Sbuffer, F[1]);
iEvent = Atoi(Mid(Sbuffer, F[0]+1, F[1]-F[0]-1));
iEventLevel = Atoi(Mid(Sbuffer, F[1]+1, F[2]-F[1]-1));
// print("iEvent = %u iEventLevel = %u\n", iEvent, iEventLevel);
}

Else If(Find("OnPlayBackStarted", Sbuffer) > 0)
{
PauseFb=0; StopFb=0; PlayFb=1; PlaySpeed=1; TransportIcon=1;
Makestring(PlayingSpeed$, "%ux", PlaySpeed);
Wait(100) { Call Connect("getcurrentlyplaying", 0); }
If(ActiveWindow = 10502) { Wait(150) { Call Connect("ExecBuiltIn(ActivateWindow(12006))", 0); } }
Wait(200) { Call Connect("getGUIStatus", 0); HaltSelect = 0;}
}
Else If(Find("OnPlayBackPaused", Sbuffer) > 0) {StopFb=0; PlayFb=0; PauseFb=1; PlayingSpeed$ = ""; TransportIcon=3; }
Else If(Find("OnPlayBackEnded", Sbuffer) > 0)
{
StopFb=1; PlayFb=0; PauseFb=0; PlayingSpeed$ = ""; TransportIcon=3;
ActiveWindow = 10025;
CurrXbmcWindow = 10025;
Call ClearCurrPlay();
Wait(200) { Call Connect("getGUIStatus", 0); HaltSelect = 0;}
}
Else If(Find("OnPlayBackResumed", Sbuffer) > 0)
{
PauseFb=0; StopFb=0; PlayFb=1; PlaySpeed=1; TransportIcon=1;
Makestring(PlayingSpeed$, "%ux", PlaySpeed);
HaltSelect = 1;
Wait(100) { Call Connect("getcurrentlyplaying", 0); }
If(ActiveWindow = 10502) { Wait(150) { Call Connect("ExecBuiltIn(ActivateWindow(12006))", 0); } }
Wait(200) { Call Connect("getGUIStatus", 0); HaltSelect = 0;}
}
Else If(Find("OnPlayBackStopped", Sbuffer) > 0)
{
PauseFb=0; PlayFb=0; StopFb=1; PlaySpeed=1; PlayingSpeed$ = ""; TransportIcon=2;
ActiveWindow = 10025;
CurrXbmcWindow = 10025;
Call ClearCurrPlay();
Wait(200) { Call Connect("getGUIStatus", 0); HaltSelect = 0;}
}

Else If(Find("StartUp", Sbuffer) > 0)//StartUp
{
Print("XbmcStarted\n");
Delay(300);
Call ClearCurrPlay();
Call Connect("ExecBuiltIn(ActivateWindow(12600))", 5);
}


Switch(iEventLevel)
{
Case(2): ;


}
}
7. Wakeup on Lan:

//*******************************************************************************************
FUNCTION WakeUpPC()
{
If(Enable)
{
If(PcPowerOffWaitFlag = 0)
{
PcPowerOffWaitFlag = 1;
Wait(300, PcPowerOffWait)
{
SocketUDP_Enable(WolSck, "255.255.255.255", 7);
If(Enable) SOCKETSEND(WolSck, WolPacket);
Delay(10);
SocketUDP_Disable(WolSck);
PcPowerOffWaitFlag = 0;
}
}
}
}

8. EventServer

#DEFINE_CONSTANT EventServerHeader "\x58\x42\x4D\x43\x02\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x01\x00"
#DEFINE_CONSTANT EventServerMid "\x4C\x17\x04\x91\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
#DEFINE_CONSTANT BtnPress 1
#DEFINE_CONSTANT BtnRelease 2
#DEFINE_CONSTANT ActionCmd 3
#DEFINE_CONSTANT PingCmd 4

//*******************************************************************************************/
Function SendEventServer(String Info, Integer Stat)//KeyboardStat_cpp XBMC-xbmcclient_py.mht
{
String SendBuffer[255];
String sLen[1], sFlag[1];

sLen = Chr(Len(Info)+10);
sFlag = "\x03";

Switch(Stat)
{
Case(BtnPress):
{
Makestring(SendBuffer, "%s%s%s%s\x00\x00KB\x00%s\x00", EventServerHeader, sLen, EventServerMid, sFlag, Info);
SOCKETSEND (EventServerUpd, SendBuffer);
// print("SendEventServer=%s\n",SendBuffer);
Call Connect("getGUIStatus", 0);
Delay(5);
sFlag = "\x05";
Makestring(SendBuffer, "%s%s%s%s\x00\x00KB\x00%s\x00", EventServerHeader, sLen, EventServerMid, sFlag, Info);
SOCKETSEND (EventServerUpd, SendBuffer);
}

}
}
Reply


Messages In This Thread
[No subject] - by greatant1337 - 2009-10-10, 01:58
[No subject] - by Legdiian - 2009-10-10, 02:59
Crestron Module - by nightwolf - 2010-04-20, 19:48
[No subject] - by Kabooga - 2010-04-21, 19:51
Crestron Interface - by tzya - 2010-06-14, 07:43
RE: Crestron Interface - by Cpassow - 2019-07-06, 21:03
[No subject] - by casentis - 2010-06-14, 12:47
[No subject] - by nightwolf - 2010-06-16, 04:58
Crestron Connection sample code - by tzya - 2010-06-16, 05:58
Crestron Code #2 - by tzya - 2010-06-16, 06:00
Crestron Code #3 - by tzya - 2010-06-16, 06:01
[No subject] - by nicola_leo - 2010-06-16, 20:46
[No subject] - by dacookster - 2010-06-21, 19:38
[No subject] - by dacookster - 2010-06-21, 21:11
[No subject] - by nightwolf - 2010-06-28, 00:22
[No subject] - by djatwork - 2010-07-05, 22:33
Rest of code? - by ppmcbiggs - 2010-07-16, 21:41
[No subject] - by bufferbuilder - 2010-07-16, 23:23
Crestron Simpl+ - by slimdog420 - 2010-08-01, 19:32
[No subject] - by Nero81 - 2010-08-03, 17:22
[No subject] - by slimdog420 - 2010-08-05, 18:03
[No subject] - by tyra - 2010-08-14, 08:56
[No subject] - by tyra - 2010-08-14, 08:57
[No subject] - by slimdog420 - 2010-08-16, 21:35
[No subject] - by slimdog420 - 2010-08-17, 05:41
[No subject] - by ncarthy - 2010-08-20, 02:18
[No subject] - by ncarthy - 2010-08-23, 13:08
[No subject] - by slimdog420 - 2010-08-24, 06:33
[No subject] - by Nero81 - 2010-08-24, 17:04
[No subject] - by ncarthy - 2010-08-24, 23:40
[No subject] - by thedroid - 2010-08-30, 05:03
New JSON module - by ncarthy - 2010-09-03, 01:58
[No subject] - by thedroid - 2010-09-03, 06:47
[No subject] - by ncarthy - 2010-09-03, 14:23
Corrected link - by ncarthy - 2010-09-04, 20:05
!!!! - by dacookster - 2010-09-22, 17:02
[No subject] - by ncarthy - 2010-09-27, 01:22
crestron module - by cruzinbum - 2010-11-14, 04:50
great - by Vultures - 2010-11-14, 06:56
[No subject] - by manulight - 2010-12-05, 01:34
[No subject] - by manulight - 2011-01-06, 22:47
Crestron JSON xbmc module - by ncarthy - 2011-01-06, 23:38
[No subject] - by KeN Rogiers - 2011-09-14, 16:15
Logout Mark Read Team Forum Stats Members Help
Making a Crestron Module for HTTP API Control0