Modified API calls and subprocess calls to work with the new system

master
Jared 8 years ago
parent b680ddf512
commit 9c7bf52e8f

@ -73,6 +73,7 @@ if __name__ == '__main__':
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW) GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
wait = False wait = False
# Open tools # Open tools
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x30", shell=True)
if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0: if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0:
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW) GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)
GPIO.output(pin_config['tools_grn_LED'], GPIO.LOW) GPIO.output(pin_config['tools_grn_LED'], GPIO.LOW)
@ -80,7 +81,7 @@ if __name__ == '__main__':
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW) GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
wait = False wait = False
# Open fridge # Open fridge
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge", shell=True) subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x20", shell=True)
if time.time() > timeout: if time.time() > timeout:
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW) GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)

@ -26,7 +26,7 @@ def requires_auth(f):
@app.route('/') @app.route('/')
def index(): def index():
return '{"onFire": false}' return '{"onFire": false}\nGo to <a href="status">status</a>.'
@app.route('/status') @app.route('/status')
@requires_auth @requires_auth
@ -37,8 +37,9 @@ def status():
@requires_auth @requires_auth
def users(what): def users(what):
if what == "fridge": if what == "fridge":
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge", shell=True) subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x20", shell=True)
elif what == "tools":
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x30", shell=True)
print 'opened', what print 'opened', what
return redirect(url_for('status')) return redirect(url_for('status'))

@ -24,7 +24,7 @@ function save() {
authCode += 1; authCode += 1;
if ($('#tools').is(':checked')) if ($('#tools').is(':checked'))
authCode += 2; authCode += 2;
$.getJSON('http://127.0.0.1:5000/addcard/' + cardID + '/' + name + '/' + authCode, function(data) { $.getJSON('http://130.237.3.207/addcard/' + cardID + '/' + name + '/' + authCode, function(data) {
}); });
overlay_out(); overlay_out();
@ -32,7 +32,7 @@ function save() {
$(document).ready(function() { $(document).ready(function() {
jQuery.ajaxSetup({ cache: false }); jQuery.ajaxSetup({ cache: false });
$.getJSON('http://127.0.0.1:5000/gethistory', function(data) { $.getJSON('http://130.237.3.207/gethistory', function(data) {
eventHistory = data.reverse(); eventHistory = data.reverse();
var newHistory = '<div class="event-wrapper">'; var newHistory = '<div class="event-wrapper">';
@ -57,7 +57,7 @@ $(document).ready(function() {
$('.recent').on('click', '.event', function() { $('.recent').on('click', '.event', function() {
var cardID = $(this).attr('card-id'); var cardID = $(this).attr('card-id');
$('.card-id').text(cardID); $('.card-id').text(cardID);
$.getJSON('http://127.0.0.1:5000/getcardinfo/' + cardID, function(data) { $.getJSON('http://130.237.3.207/getcardinfo/' + cardID, function(data) {
$('#name').val(data.name); $('#name').val(data.name);
if (data.fridge) if (data.fridge)
$('#fridge').prop('checked', true); $('#fridge').prop('checked', true);

Loading…
Cancel
Save