ph_sendudp PowerHome formula function
Description
Broadcast UDP data to the network using a socket
Syntax
ph_sendudp ( as_url, al_port, as_data )
ph_sendudp ( as_url, al_port, as_data, ai_flags )
Argument Description
as_url String. The URL or IP to send UDP data to
al_port Long. The port to send UDP data to
as_data String. The data you wish to send via UDP
ai_flags Integer (Optional). A flags parameter specifying how the data is sent. See Usage below for details. If this parameter is omitted, a value of 0 will be used
Return value
Integer. Returns 0 if the function is successful. Returns 1 if there is a problem connecting. Returns 2 if there is a problem sending 
Usage
Use this function to send data via UDP. If you need to broadcast non-typeable characters, use the overload that includes the ai_flags parameter and set it to 1. If your message doesnt contain special characters, set the ai_flags parameter to 0 or use the overload that does not include the ai_flags parameter

If the ai_flags parameter is 1, then escaped characters are allowed in the as_data parameter. Escaped characters can be coded as either hexadecimal or decimal. Escaped characters are preceeded by a backslash "\" character. If encoding in hexadecimal, follow the "\" character with "x" followed by two hexadecimal digits (0 - 9 and A-F) for an ASCII value of 0 to 255. If encoding in decimal, follow the "\" character with 3 decimal digits in the range of 0 to 255. The carriage return character can be escaped as either "\x0D" or "\013". If escaped characters are allowed (ai_flags = 1) then any backslash characters "\" you wish to send in the data MUST also be escaped as either "\x5C" or "\092".

Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_sendudp("192.168.0.255",8100,"First floor Thermostat Cool Setpoint changed to 78",0) - Returns 0 if successful. No special characters were included in the message so the ai_flags value was set to 0 or could have been omitted