Here is a section of code im using. i can log the result to the browser console and it returns true or false just fine but when i try to use the bootstrap switch to set the state it doesn't work.. im new to writing code so it might be something simple but i have tried all sorts of things and cant seem to figure it out.
here is a link to the full code. https://github.com/neileum/Pool-Automation Client Side Code: var socket = io.connect(); // Checkbox elements var checkboxes = { red: $('#checkbox-red'), green: $('#checkbox-green'), blue: $('#checkbox-blue'), yellow: $('#checkbox-yellow') } for(var color in checkboxes) { checkboxes[color].bootstrapSwitch(); } checkboxes['red'].on('switchChange.bootstrapSwitch', function(event, state) { socket.emit('red', { state: state }); console.log(callback); }); socket.on ('red', function (state) { $('#checkbox-red').bootstrapSwitch('setState', state); console.log(state); }); Server Side Code: Enter var mraa = require('mraa'); var m = require('mraa'); //require mraa console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console // Map GPIO block pins to MRAA pin numbers // Reference: https://learn.sparkfun.com/tutorials/installing-libmraa-on-ubilinux-for-edison var pins = { GP44: 31, GP45: 45, GP46: 32, GP47: 46 }; // Initialize LED controls var leds = { red : new mraa.Gpio(6), green : new mraa.Gpio(6), blue : new mraa.Gpio(6), yellow : new mraa.Gpio(6) }; // Set direction of LED controls to out for(var color in leds) { leds[color].dir(mraa.DIR_OUT); } function toggleLed(led, state) { led.write(state ? 1 : 0); } function toggleLeds(leds, state) { for(var color in leds) { leds[color].write(state ? 1 : 0); } } function printLedState(color, state) { console.log('color: ' + color + ', state: ' + state); } socket.on('red', function(data, state, callback) { toggleLed(leds['red'], data.state); printLedState('red', data.state); socket.broadcast.emit ('red', state); }); code here... -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/78ff76a1-0ea3-4a7e-894f-f794e63a1068%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.