Exemplo n.º 1
0
def api_controlleroff():
    # Check if an ID was provided as part of the URL.
    # If ID is provided, assign it to a variable.
    # If no ID is provided, display an error in the browser.
    jsondata = request.get_json()
        
    if 'id' in jsondata:
        id = int(jsondata['id'])
    else:
        return "Error: No id field provided. Please specify an id."

    conn = dbc.dbconnect()
    curselect = conn.cursor(buffered=False)
    
    dbquery = "SELECT MacAddress, IP FROM Riverside WHERE ID={0}".format(id)

    curselect.execute(dbquery)
    results = curselect.fetchone()
    curselect.close()
    conn.close()

    control_interface = xled.ControlInterface(results[1], results[0])
    hicontrol = xled.HighControlInterface(results[1])
    control_interface.set_mode('off')

    # Use the jsonify function from Flask to convert our list of
    # Python dictionaries to the JSON format.
    return 200
Exemplo n.º 2
0
def api_staticcolor():
    # Check if an ID was provided as part of the URL.
    # If ID is provided, assign it to a variable.
    # If no ID is provided, display an error in the browser.
    jsondata = request.get_json()
    
    if 'id' in jsondata:
        id = int(jsondata['id'])
    else:
        return "Error: No id field provided. Please specify an id."
    
    if 'red' in jsondata:
        red = int(jsondata['red'])
    else:
        return "Error: No red field provided. Please specify an red."
    
    if 'green' in jsondata:
        green = int(jsondata['green'])
    else:
        return "Error: No green field provided. Please specify an green."
    
    if 'blue' in jsondata:
        blue = int(jsondata['blue'])
    else:
        return "Error: No blue field provided. Please specify an blue."

    

    conn = dbc.dbconnect()
    dbquery = "SELECT MacAddress, IP FROM Riverside WHERE ID={0}".format(id)

    curselect.execute(dbquery)
    results = curselect.fetchone()
    curselect.close()
    conn.close()

    control_interface = xled.ControlInterface(results[1], results[0])
    hicontrol = xled.HighControlInterface(results[1])
    control_interface.set_mode('movie')
    hicontrol.set_static_color(red, green, blue)

    # Use the jsonify function from Flask to convert our list of
    # Python dictionaries to the JSON format.
    return 200
Exemplo n.º 3
0
import sys
import socket
import os
import time
import mmap

sys.path.append("/home/server/git/RXTNet/xled")
import xled

filename = '/tmp/fd0'
fd = os.open(filename, os.O_RDONLY)
buf = mmap.mmap(fd, 0, mmap.MAP_SHARED, mmap.PROT_READ)

#discovered_device = xled.discover.discover()
#print(discovered_device)

control_interface = xled.ControlInterface('192.168.3.218', '98:f4:ab:36:ae:39')
hicontrol = xled.HighControlInterface('192.168.3.218')
control_interface.set_mode('movie')
hicontrol.set_static_color(255, 255, 255)
Exemplo n.º 4
0
import sys
sys.path.append("/home/server/git/RXTNet/xled")
import xled
import mariadb
from contextlib import suppress

# Connect to MariaDB Platform
try:
    conn = mariadb.connect(
        user="******",
        password="******",
        host="127.0.0.1",
        port=3306,
        database="rxtnet"
    )
except mariadb.Error as e:
    print(f"Error connecting to MariaDB Platform: {e}")
    sys.exit(1)
    

curselect = conn.cursor(buffered=False)
conID = 43

curselect.execute("SELECT MacAddress, IP FROM Riverside WHERE ID=conID")
results = curselect.fetchone()

control_interface = xled.ControlInterface(results[1], results[0])
hicontrol = xled.HighControlInterface(results[1])
control_interface.set_mode('movie')
hicontrol.set_static_color(255,255,255)