I am trying to intercept arm/disarm messages from my A2PI so I can execute http post to enable/disable my cameras. I ready that I should use Ser2Sock calls because the /dev/ttyAMA0 port is already used by the web app but can use whatever method works. I have used python sample code to try and connect to the SocketDevice and read the output messages. I am running python right on the A2Pi and also am using SSL. The program runs but not I don't get any output. I tried telnet {IP} 10000 from a remote computer on the same network and it does not receive any messages either. Is the SSL cert preventing output? Not sure what I am doing wrong. However, the web app picks up all alarm panel messages.
Thanks!
import time
from alarmdecoder import AlarmDecoder
from alarmdecoder.devices import SocketDevice
#default AD2Pi device on Raspberry Pi
SERIAL_DEVICE='/dev/ttyAMA0'
BAUDRATE = 115200
SER2SOCK_HOST = 'localhost'
SER2SOCK_PORT = 10000
def main():
"""
Example application that prints messages from the panel to the terminal.
"""
try:
# Retrieved an AD2 device that has been exposed with ser2sock on localhost:10000
device = AlarmDecoder(SocketDevice(interface=(SER2SOCK_HOST,SER2SOCK_PORT)))
# Retrieve the first Serial device
#device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
# Set up an event handler and open the device
device.on_message += handle_message
print 'Running...'
with device.open(baudrate=BAUDRATE):
while True:
time.sleep(1)
except Exception, ex:
print 'Exception:', ex
def handle_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print sender, message.raw
if __name__ == '__main__':
main()