LWRP Example: Silence Detection & GPIO
# Requires https://github.com/anthonyeden/Livewire-Routing-Protocol-Client | |
import time | |
from LWRPClient import LWRPClient | |
# Connect to audio node | |
LWRP_Audio = LWRPClient("192.168.1.5", 93) | |
LWRP_Audio.login() | |
# Connect to GPIO node | |
LWRP_Logic = LWRPClient("192.168.1.5", 93) | |
LWRP_Logic.login() | |
def silence(data): | |
# TODO: Add some logic here to work out which channel is silent | |
print(data) | |
# Set the new GPO state | |
# 1 = Channel | |
# 2 = Pin | |
# 3 = State | |
LWRP_Logic.setGPO("1", "2", "low") | |
if __name__ == "__main__": | |
# Create a subscription for silence events | |
LWRP_Audio.levelAlertSub(silence) | |
# Loop forever while the callbacks execute in another thread | |
while True: | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment