Newbie Question
kevsach
Posts: 1
Hi,
I'm working at a university that uses AMX across the campus in our lecture rooms. We want to connect an occupancy sensor to the IO ports on the controller, and have the controller do a HTTP Post request to the server when occupancy is detected. I have written the following by looking through some of our other programs written by integrators and some help file trawling! however it fails to compile saying the Channel_Event line is invalid syntax.... any help greatly appreciated!
PROGRAM_NAME='OCCUPANCY'
define_device
dvIO = 5001:17:0
dvServer = 0:5:0
CHANNEL_EVENT [dvIO,2]
{
OFF: {
IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP)
SEND_STRING dvServer,"'POST /pcav/senddata.php HTTP/1.0',13,10"
SEND_STRING dvServer,"'From: bob@thebuilder.com',13,10"
SEND_STRING dvServer,"'User-Agent: HTTPTool/1.0',13,10"
SEND_STRING dvServer,"'Content-Type: application/x-www-form-urlencoded',13,10"
SEND_STRING dvServer,"'Content-Length: 32',13,10"
SEND_STRING dvServer,"13,10"
SEND_STRING dvServer,"'Someones Here!!!!!'"
}
}
I'm working at a university that uses AMX across the campus in our lecture rooms. We want to connect an occupancy sensor to the IO ports on the controller, and have the controller do a HTTP Post request to the server when occupancy is detected. I have written the following by looking through some of our other programs written by integrators and some help file trawling! however it fails to compile saying the Channel_Event line is invalid syntax.... any help greatly appreciated!
PROGRAM_NAME='OCCUPANCY'
define_device
dvIO = 5001:17:0
dvServer = 0:5:0
CHANNEL_EVENT [dvIO,2]
{
OFF: {
IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP)
SEND_STRING dvServer,"'POST /pcav/senddata.php HTTP/1.0',13,10"
SEND_STRING dvServer,"'From: bob@thebuilder.com',13,10"
SEND_STRING dvServer,"'User-Agent: HTTPTool/1.0',13,10"
SEND_STRING dvServer,"'Content-Type: application/x-www-form-urlencoded',13,10"
SEND_STRING dvServer,"'Content-Length: 32',13,10"
SEND_STRING dvServer,"13,10"
SEND_STRING dvServer,"'Someones Here!!!!!'"
}
}
0
Comments
not having the rig right in front of me to test.... I'd suggest trying to combine the whole set of strings into one string.
something like:
This is very true Vinning. To be honest, I never try to go down the road on these posts because I just don't know the whole back story. But the OP should note Vinning on this. What I'd really do is create a separate routine for handling commands that will put IP comms into a queue and then let the routine handle when to send a message.
I think this is just good practice any time you have to leave the box for any type of input or output. I've found there's just a strange assumption that the timing of events is cut-and-dried and doesn't need to be handled. Sure, it can be a pain, but so is sussing out quirky problems with strings. It's worse when burning in systems that do IP communication. In burn-in you have a much tighter network under controlled conditions. I've always found IP networks slow down when in the actual installation. So, if I'm relying on the processor to be slow enough, I always get burned at install.
Consequently, I just queue everything. Once you get in the habit of doing it, it come naturally and quickly.