This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mqtt = require('mqtt'); | |
| var client = mqtt.connect('mqtt://test.mosquitto.org'); | |
| var led_blue; | |
| client.on('connect', function () { | |
| console.log('state'); | |
| client.subscribe('tito'); | |
| // client.publish('sensor', 'Hello mqtt'); | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{"id":"5a0fcc85.8a18fc","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"ba0797c3.ea734","type":"mqtt in","name":"","topic":"sensor","broker":"5a0fcc85.8a18fc","x":117,"y":296,"z":"62e753b5.43eaec","wires":[[]]},{"id":"ec99c32e.a2dd88","type":"debug","name":"","active":true,"console":"false","complete":"true","x":284,"y":298,"z":"62e753b5.43eaec","wires":[]},{"id":"c661f444.c7486","type":"inject","name":"","topic":"","payload":"red","payloadType":"string","repeat":"","crontab":"","once":false,"x":107,"y":381,"z":"62e753b5.43eaec","wires":[["895fa1e7.e2ae28"]]},{"id":"895fa1e7.e2ae28","type":"mqtt out","name":"","topic":"tito","qos":"","retain":"","broker":"5a0fcc85.8a18fc","x":258,"y":449,"z":"62e753b5.43eaec","wires":[]},{"id":"3bd2c74c.27277","type":"inject","name":"","topic":"","payload":"green","payloadType":"string","repeat":"","crontab":"","once":false,"x":107,"y":450,"z":"62e753b5.43eaec","wires":[["895fa1e7.e2ae28"]]},{"id":"c38d8bad.b52b78","type":"inject","name":"","top |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{"id":"6605445f.99fabc","type":"mqtt-broker","z":"120d4a4d.edf2b6","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"33417553.ccbe8a","type":"mqtt-broker","z":"120d4a4d.edf2b6","broker":"192.168.2.7","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"ce494925.31b6b8","type":"mqtt in","z":"120d4a4d.edf2b6","name":"","topic":"tito","broker":"33417553.ccbe8a","x":94,"y":377,"wires":[["54b6a986.ab4958","7a6d2f68.8592d"]]},{"id":"54b6a986.ab4958","type":"debug","z":"120d4a4d.edf2b6","name":"","active":true,"console":"false","complete":"true","x":226,"y":376 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // var mqtt = require('mqtt'); | |
| // var client = mqtt.connect('mqtt://localhost'); | |
| // client.on('connect', function () { | |
| // client.subscribe('tito'); | |
| // client.publish('tito', 'Hello mqtt'); | |
| // }); | |
| // client.on('message', function (topic, message) { | |
| // // message is Buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myhouse_homeServer | |
| [{"id":"fd66074f.816828","type":"mqtt-broker","z":"1dc064f.ec2a91b","broker":"52.35.4.229","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"1449c721.bdf031","type":"mqtt-broker","z":"1ebf091c.220137","broker":"192.168.2.7","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"6881728.539ed8c","type":"mqtt-broker","z":"1ebf091c.220137","broker":"52.35.4.229","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //download the file in a seperate thread. | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| NSLog(@"Downloading Started"); | |
| NSString *urlToDownload = @"http://www.somewhere.com/thefile.png"; | |
| NSURL *url = [NSURL URLWithString:urlToDownload]; | |
| NSData *urlData = [NSData dataWithContentsOfURL:url]; | |
| if ( urlData ) | |
| { | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *documentsDirectory = [paths objectAtIndex:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]); | |
| DLog(@"Caches Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void uncaughtExceptionHandler(NSException*); | |
| @implementation AppDelegate | |
| void uncaughtExceptionHandler(NSException *exception) | |
| { | |
| NSLog(@"CRASH: %@", exception); | |
| NSLog(@"Stack Trace: %@", [exception callStackSymbols]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifdef DEBUG | |
| # define DLog(fmt, ...) NSLog((@"\n%s [Line %d] \n" fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
| #else | |
| # define DLog(...) /* */ | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //define before implementation | |
| typedef void(^myCompletion)(BOOL); | |
| //method todo after implementation | |
| -(void) myMethod:(myCompletion) compblock{ | |
| //do stuff | |
| for (int i = 0; i < 100; i++) { | |
| NSLog(@"i :: %d", i); | |
| } | |