<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ROBBIE TILTON</title>
	<atom:link href="http://robbietilton.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://robbietilton.com</link>
	<description></description>
	<lastBuildDate>Sat, 12 May 2012 19:22:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Digital Decay</title>
		<link>http://robbietilton.com/digital-decay/</link>
		<comments>http://robbietilton.com/digital-decay/#comments</comments>
		<pubDate>Wed, 09 May 2012 23:39:25 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[openFrameworks]]></category>
		<category><![CDATA[Video & Sound]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=1025</guid>
		<description><![CDATA[Implied in the act of digital mediation is the ability transmit a message, with faithful reproducibility and no degradation of quality, to someone else in the future. Johann Diedrick and I created Digital Decay to examine the nature of digital information as still retaining material qualities — it can wear, corrupt, disintegrate and decay much [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<iframe src="http://player.vimeo.com/video/41876067" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div class="post_rightcol">
Implied in the act of digital mediation is the ability transmit a message, with faithful reproducibility and no degradation of quality, to someone else in the future. <a href="http://andsuchandsu.ch/">Johann Diedrick</a> and I created Digital Decay to examine the nature of digital information as still retaining material qualities — it can wear, corrupt, disintegrate and decay much like any other physical material. If we (humans as a whole) decide to communicate through digital media, we risk the possibility of losing the content of the message and its meaning over time. The hallway becomes a metaphorical space to represent the linearity of time as well as the direction of one-to-one communication. By slowing down the process of digital mediation and representing its eventual decay through audio and visuals, we intended to make visitors rethink ideas of how digital media has a lifespan, how the quality of digital content degrades with newer and faster technologies, and whether or not we are comfortable with what this means for the future of our content.</p>
<p>The visuals and audio distortion were done with openFrameworks/C++.  We used 7 Plasma screens and 7 mac minis daisy-chained together through audio-in and audio-out cables.  We used the <a href="https://github.com/satoruhiga/ofxAUPlugin">ofxAUPlugin</a> to create an auditory delay to our audio-out jack and Kyle McDonald&#8217;s <a href="https://vimeo.com/41297608">cylinder mesh screen-cast</a> to inform the 3D wave-form.  Throughout this process Johann and I learned a lot about particle systems, wave-forms, and communication between multiple machines.
</div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/digital-decay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rehuddle &#8211; Telephony Web Application</title>
		<link>http://robbietilton.com/rehuddle-telephony-web-application/</link>
		<comments>http://robbietilton.com/rehuddle-telephony-web-application/#comments</comments>
		<pubDate>Thu, 03 May 2012 03:14:53 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=986</guid>
		<description><![CDATA[Rehuddle.com is a web application I built with Phil Groman that makes group calling as easy as individual calling. We built the web application in order to give small creative businesses the ability to setup conference calls without paying for enterprise level telephony systems. Our goal was to make conference rooms easier to create, easier [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<a href="http://robbietilton.com/rehuddle-telephony-web-application/rehuddle-homepage/" rel="attachment wp-att-1011"><img src="http://robbietilton.com/wp-content/uploads/2012/05/rehuddle-homepage-500x323.jpg" alt="" title="rehuddle-homepage" width="500" height="323" class="aligncenter size-medium wp-image-1011" /></a></p>
<p><a href="http://robbietilton.com/rehuddle-telephony-web-application/rehuddle-page/" rel="attachment wp-att-1022"><img src="http://robbietilton.com/wp-content/uploads/2012/05/rehuddle-page-500x323.jpg" alt="" title="rehuddle-page" width="500" height="323" class="aligncenter size-medium wp-image-1022" /></a>
</div>
<div class="post_rightcol">
<a href="http://rehuddle.com">Rehuddle.com</a> is a web application I built with <a href="http://philgroman.com/">Phil Groman</a> that makes group calling as easy as individual calling.  We built the web application in order to give small creative businesses the ability to setup conference calls without paying for enterprise level telephony systems.  Our goal was to make conference rooms easier to create, easier to join, and easier to share.  </p>
<p>Traditional conference rooms often come with frustrating user experiences where many callers can&#8217;t seem to get in, missed the invitation, or can&#8217;t seem to find the e-mail where the call details were provided.  With Rehuddle, users are given several super simple ways to share: 1) click to automatically copy the call details to your clipboard 2) click to auto generate an e-mail with the call details 3) text message someone to join the room 4) share the room via facebook and 5) generate a call that places a caller directly in the room (no extension needed).</p>
<p>The site is built with Ruby, Asterisk, Javascript, Node.js, and MySQL.  Each user that joins a &#8220;huddle&#8221; is provided an avatar based on the last four digits of their phone-number.  This allows each user to be uniquely identified and understand who is on the call.  The avatars are currently being generated using Node.js and Underscore.js.  Node is being used to ping our mySQL server every second and pipe the results into a socket that the client can read by parsing JSON.  Underscore.js is being used to compare the current list of callers with a previous list of callers.  This allows the client to know which callers to add for each browser and which callers to remove.  Each conference room also gets a unique URL.  If a user creates a room called &#8220;Sony Meeting&#8221; &#8211; Rehuddle will auto generate a URL Rehuddle.com/sony-meeting where the call can live.  This url generation is being done with Ruby utilizing Sinatra and Datamapper/MySQL.  Within the room our copy to clipboard share feature is using a JQuery library called <a href="http://www.steamdev.com/zclip/">zClip</a>.  The SMS messages are being routed through a <a href="http://www.twilio.com/">Twilio&#8217;s</a> Ruby API, the Facebook share call-to-action is using the standard <a href="http://developers.facebook.com/docs/share/">Facebook Developers</a> share button, and the call generator is happening in Asterisk, but is routed through <a href="https://www.flowroute.com/">Flowroute</a> through a SIP registry.</p>
<p>In future iterations Phil and I are looking to add document sharing features, editable name tags for each avatar, and potentially unique phone numbers for each room.  We both feel that there&#8217;s a huge gap in the market for conference systems that are simple, easy to use, easy to share, and provide an informative and enjoyable web interface.  We both look forward to more user testing to see where this product takes us.  A big thank you goes to Chris Kairalla for teaching us Asterisk and helping us debug throughout the build!
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/rehuddle-telephony-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google API &#8211; Voice Recognition and Synthesis</title>
		<link>http://robbietilton.com/google-api-voice-recognition-and-synthesis/</link>
		<comments>http://robbietilton.com/google-api-voice-recognition-and-synthesis/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 20:24:24 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Asterisk]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=980</guid>
		<description><![CDATA[This week in my redial class we learned out to integrate Google&#8217;s API for speech recognition and speech synthesis. Although official documentation for these API&#8217;s aren&#8217;t available &#8211; internet citizen Lefteris Zafiris has provided a great tutorial on how to tap into this powerful resource. Speech recognition for Asterisk can be found here. Once flac [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<a href="http://robbietilton.com/google-api-voice-recognition-and-synthesis/terminalscreenshot/" rel="attachment wp-att-983"><img src="http://robbietilton.com/wp-content/uploads/2012/04/terminalScreenshot-500x311.png" alt="" title="Speech Recognition - Terminal Screenshot" width="500" height="311" class="aligncenter size-medium wp-image-983" /></a>
</div>
<div class="post_rightcol">
This week in my redial class we learned out to integrate Google&#8217;s API for speech recognition and speech synthesis.  Although official documentation for these API&#8217;s aren&#8217;t available &#8211; internet citizen Lefteris Zafiris has provided a great tutorial on how to tap into this powerful resource.  </p>
<p>Speech recognition for Asterisk can be <a href="http://zaf.github.com/asterisk-speech-recog/">found here</a>.  Once flac and lib-perlwww are installed on your server all you need to do is grab <a href="https://github.com/zaf/asterisk-speech-recog/tarball/master">his gitHub files</a> and place speech-recog.agi in your share/asterisk/agi-bin folder.  This will allow you to run commands like the ones below:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>agi<span style="color: #009900;">&#40;</span>speech<span style="color: #339933;">-</span>recog.<span style="color: #202020;">agi</span><span style="color: #339933;">,</span>en<span style="color: #339933;">-</span>US<span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>Verbose<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>The text you just said is<span style="color: #339933;">:</span> $<span style="color: #009900;">&#123;</span>utterance<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>Verbose<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>The probability to be right is<span style="color: #339933;">:</span> $<span style="color: #009900;">&#123;</span>confidence<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>Hangup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>For speech synthesis &#8211; a very similar process is required.  With flac and libwww-perl already installed on your server you&#8217;ll just have to grab <a href="https://github.com/zaf/asterisk-speech-recog/tarball/master">his github files</a> and place the speech-recog.agi in your share/asterisk/agi-bin.  This will then allow you to run Asterisk commands like the ones below:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>AGI<span style="color: #009900;">&#40;</span>googletts.<span style="color: #202020;">agi</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;This is a simple google text to speech test in english.&quot;</span><span style="color: #339933;">,</span>en<span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>AGI<span style="color: #009900;">&#40;</span>googletts.<span style="color: #202020;">agi</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;hello\, I am a talking computer&quot;</span><span style="color: #339933;">,</span>en<span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>wait<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
exten <span style="color: #339933;">=&gt;</span> s<span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>Hangup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/google-api-voice-recognition-and-synthesis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jabber Mouth &#8211; Node and Sockets</title>
		<link>http://robbietilton.com/jabber-mouth-node-and-sockets/</link>
		<comments>http://robbietilton.com/jabber-mouth-node-and-sockets/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 20:12:53 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=975</guid>
		<description><![CDATA[Jabber Mouth is a website I made that uses Asterisk, Node, Socket.io, Ruby AGI, and JQuery in order to allow users to call into a website and control a mouth based on a users phones audio levels. The essence of this experiment is to understand how to control screens through your phone using Node.js. The [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<iframe src="http://player.vimeo.com/video/39723212" width="500" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div class="post_rightcol">
Jabber Mouth is a website I made that uses Asterisk, Node, Socket.io, Ruby AGI, and JQuery in order to allow users to call into a website and control a mouth based on a users phones audio levels.  The essence of this experiment is to understand how to control screens through your phone using Node.js.  The illustration I used was appropriated from an illustrator I love: <a href="http://blog.stuntkid.com/">Jason Levesque</a>.  In a future iteration I plan to record the audio coming into the call and play it back to the user through the mouth.  Overall, I found this code to be magical in the fact that one can pretty much send through anything once you open up a server port with node.js.  A huge thanks goes to Chris Kairalla who is teaching us asterisk and node.
</div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/jabber-mouth-node-and-sockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chatroom with Node.js and Socket.io</title>
		<link>http://robbietilton.com/node-js-and-socket-io/</link>
		<comments>http://robbietilton.com/node-js-and-socket-io/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 00:46:50 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=969</guid>
		<description><![CDATA[I&#8217;m currently learning node.js and was super excited to get a chat server to work. In this example I&#8217;m using telnet to connect to my server 3 times which generates three sockets where data is transfered in realtime between all parties. Below is the code: var net = require('net') //TCP Server &#160; var sockets = [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<a href="http://robbietilton.com/node-js-and-socket-io/screen-shot-2012-03-30-at-8-43-50-pm/" rel="attachment wp-att-970"><img src="http://robbietilton.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-30-at-8.43.50-PM-500x320.png" alt="" title="Telnet Chatroom - Node.js" width="500" height="320" class="aligncenter size-medium wp-image-970" /></a>
</div>
<div class="post_rightcol">
I&#8217;m currently learning node.js and was super excited to get a chat server to work.  In this example I&#8217;m using telnet to connect to my server 3 times which generates three sockets where data is transfered in realtime between all parties.  Below is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javscript" style="font-family:monospace;">var net = require('net') //TCP Server 
&nbsp;
var sockets = [] //empty array for ppl who connect to server
&nbsp;
var server = net.createServer(function(socket){
	sockets.push(socket); //add person to socket
&nbsp;
	socket.on('data', function(data){
		for(var i = 0; i&lt;sockets.length; i++){
			if(sockets[i] == socket) continue; //dont broadcast your own echo
			sockets[i].write(data); //when data is received write
		}
	});
&nbsp;
	//remove socket from arary
	socket.on('end', function(){
		var i = sockets.indexOf(socket);
		sockets.splice(i,1); //remove person from array
		//could also do-- delete socket.[0]
	});
});
&nbsp;
server.listen(8000);</pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/node-js-and-socket-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can a human ever love a computer?</title>
		<link>http://robbietilton.com/can-a-human-ever-love-a-computer/</link>
		<comments>http://robbietilton.com/can-a-human-ever-love-a-computer/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 18:38:35 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Algorithms]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=961</guid>
		<description><![CDATA[Through my research on emotional computers I&#8217;ve stumbled upon the thesis for my journal article: Can a human ever love a computer? It&#8217;s very clear to me that we&#8217;ll eventually be able to create computers that can genuinely love a human, but my real question is if a human can reciprocate these emotions knowing that [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<a href="http://robbietilton.com/can-a-human-ever-love-a-computer/lovehatebaby/" rel="attachment wp-att-962"><img src="http://robbietilton.com/wp-content/uploads/2012/03/lovehatebaby-500x332.jpg" alt="" title="Can a human love a computer" width="500" height="332" class="aligncenter size-medium wp-image-962" /></a>
</div>
<div class="post_rightcol">
Through my research on emotional computers I&#8217;ve stumbled upon the thesis for my journal article: Can a human ever love a computer?  It&#8217;s very clear to me that we&#8217;ll eventually be able to create computers that can genuinely love a human, but my real question is if a human can reciprocate these emotions knowing that they are coming from a machine?</p>
<p>This week I started reading Wired for Speech by Clifford Nass and Scott Brave.  They discuss the human-computer relationship in regards to speech and have conducted many interesting tests to prove theories.  Based on their studies humans have affiliations with computers that can speak which directly affects how they judge them and feel about them.  For instance, a computer with a feminine voice who is teaching a lesson is more likely to be thought of as emotional and less strict than a computer with a male voice (who teaches the exact same lesson).  Personalities are also generated based on how feminine or masculine a computers voice is even when synthetic.</p>
<p>Regarding the reciprocation of love to a computer &#8211; in December 2009 &#8211; a human for the first time <a href="http://articles.cnn.com/2009-12-16/world/japan.virtual.wedding_1_virtual-world-sal-marry?_s=PM:WORLD">attempted to marry a fictitious character from a video game</a>.  The character married was from a Nintendo DS game called &#8220;Love Plus.&#8221;  Sal, the human, stated &#8220;I love this character, not a machine&#8221;&#8230;&#8221;I understand 100 percent that this is a game.&#8221;  But does this love come from an addiction and are these feelings as &#8216;authentic&#8217; as the love one feels for a human?  Hiroshi Ashizaki, an author on internet and game addiction thinks that Sal&#8217;s relation is healthy and that the youth is feeling more and more comfortable expressing their true selves through virtual worlds rather than the real world.</p>
<p>Overall, there are a lot of mixed perceptions on this topic.  With an experiment of my own I&#8217;m looking to help shed some more light on the topic (experiment to be announced when results are collected).
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/can-a-human-ever-love-a-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling an Object with Node.js and Socket</title>
		<link>http://robbietilton.com/calling-an-object-with-node-js-and-socket/</link>
		<comments>http://robbietilton.com/calling-an-object-with-node-js-and-socket/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 04:01:19 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Ethernet Shield]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=951</guid>
		<description><![CDATA[The Arduino code is as follows: #define FORWARD 10 #define REVERSE 20 #define STOPPED 30 &#160; #define forwardPin 6 #define reversePin 7 #define leftPin 8 #define rightPin 9 &#160; #define pulseDuration 500 #include &#60;SPI.h&#62; #include &#60;Ethernet.h&#62; //setup 10 A5 DA 00 85 70 byte mac&#91;&#93; = &#123; 0x10, 0xA5, 0xDA, 0x00, 0x85, 0x70 &#125;; IPAddress [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<iframe src="http://player.vimeo.com/video/39307220" width="500" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>The Arduino code is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define FORWARD 10</span>
<span style="color: #339933;">#define REVERSE 20</span>
<span style="color: #339933;">#define STOPPED 30</span>
&nbsp;
<span style="color: #339933;">#define forwardPin 6</span>
<span style="color: #339933;">#define reversePin 7</span>
<span style="color: #339933;">#define leftPin  8</span>
<span style="color: #339933;">#define rightPin 9</span>
&nbsp;
<span style="color: #339933;">#define pulseDuration 500</span>
<span style="color: #339933;">#include &lt;SPI.h&gt;</span>
<span style="color: #339933;">#include &lt;Ethernet.h&gt;</span>
<span style="color: #666666; font-style: italic;">//setup          10    A5    DA    00    85    70</span>
byte mac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xA5</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xDA</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x85</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x70</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
IPAddress server <span style="color: #009900;">&#40;</span>XXX<span style="color: #339933;">,</span>XXX<span style="color: #339933;">,</span>XXX<span style="color: #339933;">,</span>XX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// my server</span>
<span style="color: #993333;">int</span> port <span style="color: #339933;">=</span> <span style="color: #0000dd;">12002</span><span style="color: #339933;">;</span>
EthernetClient client<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> startPulseTime <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> drivingState <span style="color: #339933;">=</span> STOPPED<span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> inByte <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>         <span style="color: #666666; font-style: italic;">// incoming serial byte</span>
<span style="color: #666666; font-style: italic;">// The setup() method runs once, when the sketch starts</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>   <span style="color: #009900;">&#123;</span> 
  <span style="color: #666666; font-style: italic;">// initialize the digital pin as an output:</span>
  pinMode<span style="color: #009900;">&#40;</span>forwardPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>reversePin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>leftPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>rightPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  Ethernet.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span>mac<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Ethernet.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span>mac<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Failed to configure Ethernet using DHCP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// no point in carrying on, so do nothing forevermore:</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> 
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Ethernet reday&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  serverConnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #993333;">void</span> serverConnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;connecting to remote server...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>client.<span style="color: #202020;">connect</span><span style="color: #009900;">&#40;</span>server<span style="color: #339933;">,</span> port<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;connected to remote server&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    client.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> 
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;remote connection failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// the loop() method runs over and over again,</span>
<span style="color: #666666; font-style: italic;">// as long as the Arduino has power</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// if we get a valid byte, read analog ins:</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>client.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// get incoming byte:</span>
    inByte <span style="color: #339933;">=</span> client.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Serial.print(inByte);</span>
    <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span>inByte<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'2'</span><span style="color: #339933;">:</span> 
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;forward&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      forward<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'8'</span><span style="color: #339933;">:</span> 
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;reverse&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      reverse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'4'</span><span style="color: #339933;">:</span> 
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      turnLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'6'</span><span style="color: #339933;">:</span> 
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;right&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      turnRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>drivingState <span style="color: #339933;">!=</span> STOPPED<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> startPulseTime<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> pulseDuration<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;pulse ended&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        powerStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> forward<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  drivingState <span style="color: #339933;">=</span> FORWARD<span style="color: #339933;">;</span>
  startPulseTime <span style="color: #339933;">=</span> millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>reversePin<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>forwardPin<span style="color: #339933;">,</span>HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> reverse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  drivingState <span style="color: #339933;">=</span> REVERSE<span style="color: #339933;">;</span>
  startPulseTime <span style="color: #339933;">=</span> millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>forwardPin<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>reversePin<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> turnLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>rightPin<span style="color: #339933;">,</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>leftPin<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> turnRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>leftPin<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>rightPin<span style="color: #339933;">,</span>HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<div class="post_rightcol">
This week for my telephony class we experimented with Node.js to create a socket where information could be passed on a Rackspace Ubuntu web server.  The socket essentially opened up two ports on my server to be able to transfer data to each other.  I used Arduino and an Ethernet shield to connect to the socket and read the numbers my phone pressed.  The phone presses got pushed into the open port via an AGI call.</p>
<p>The node code is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> agi_net <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'net'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> remote_net <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'net'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> REMOTE_PORT<span style="color: #339933;">=</span><span style="color: #CC0000;">12002</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> AGI_HOST <span style="color: #339933;">=</span> <span style="color: #3366CC;">'127.0.0.1'</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> AGI_PORT <span style="color: #339933;">=</span> <span style="color: #CC0000;">12001</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * AGI will only send key presses, and that's it.
 * There's no identifying characteristics, just raw press events.
*/</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/** Remote clients send no info to this server.
 * all they do is receive byte representations of digits.
 * (0-9, #, *) on the phone's keypad as ascii bytes*/</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//remote screens or physical objects</span>
<span style="color: #003366; font-weight: bold;">var</span> remoteClients <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
remote_net.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>sock<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'CONNECTED REMOTE CLIENT: '</span> <span style="color: #339933;">+</span> sock.<span style="color: #660066;">remoteAddress</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">':'</span><span style="color: #339933;">+</span> sock.<span style="color: #660066;">remotePort</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  remoteClients.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>sock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//add client</span>
      <span style="color: #006600; font-style: italic;">// Add a 'close' event handler to this instance of socket</span>
    sock.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'close'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> remoteClients.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>remoteClients<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> sock<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//remove client</span>
                remoteClients.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'DISCONNECTED REMOTE CLIENT: '</span> <span style="color: #339933;">+</span> sock.<span style="color: #660066;">remoteAddress</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">':'</span><span style="color: #339933;">+</span> sock.<span style="color: #660066;">remotePort</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Add a 'data' event handler to this instance of socket</span>
    sock.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> data.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            handleByte<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">function</span> handleByte<span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span>REMOTE_PORT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Server listening for remote connections on '</span> <span style="color: #339933;">+</span> REMOTE_PORT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
agi_net.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>sock<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'CONNECTED AGI CLIENT: '</span> <span style="color: #339933;">+</span> sock.<span style="color: #660066;">remoteAddress</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">':'</span><span style="color: #339933;">+</span> sock.<span style="color: #660066;">remotePort</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Add a 'close' event handler to this instance of socket</span>
    sock.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'close'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'CLOSED AGI CLIENT: '</span> <span style="color: #339933;">+</span> sock.<span style="color: #660066;">remoteAddress</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">':'</span><span style="color: #339933;">+</span> sock.<span style="color: #660066;">remotePort</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Add a 'data' event handler to this instance of socket</span>
    sock.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//broadcast data to all remote clients</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> remoteClients.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> client <span style="color: #339933;">=</span> remoteClients<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            client.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span>AGI_PORT<span style="color: #339933;">,</span> AGI_HOST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Server listening for AGI connections on '</span> <span style="color: #339933;">+</span> AGI_HOST <span style="color: #339933;">+</span><span style="color: #3366CC;">':'</span><span style="color: #339933;">+</span> AGI_PORT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The AGI script is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#very simple implementation of asterisk -&gt; server -&gt; client stack</span>
<span style="color:#008000; font-style:italic;">#only sends the digit and the caller id.</span>
<span style="color:#008000; font-style:italic;">#designed for very simple control, like arduino or web page</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'ruby-agi'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'socket'</span> 
&nbsp;
agi = AGI.<span style="color:#9900CC;">new</span>
host = <span style="color:#996600;">'localhost'</span>
port = <span style="color:#006666;">12001</span>
looping = <span style="color:#0000FF; font-weight:bold;">true</span>
s = TCPSocket.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>host, port<span style="color:#006600; font-weight:bold;">&#41;</span>
agi.<span style="color:#9900CC;">stream_file</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;vm-extension&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">while</span> looping
    result = agi.<span style="color:#9900CC;">wait_for_digit</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># wait forever</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> result.<span style="color:#9900CC;">digit</span>
        s.<span style="color:#9900CC;">write</span> <span style="color:#996600;">&quot;#{result.digit}&quot;</span>
	<span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#008000; font-style:italic;">#hangup broke the pending AGI request</span>
        looping = <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The asterisk dialplan is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>rtt233_socketIO_arduino<span style="color: #009900;">&#93;</span>
exten <span style="color: #339933;">=&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>Answer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
exten <span style="color: #339933;">=&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>AGI<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>home<span style="color: #339933;">/</span>rtilton1<span style="color: #339933;">/</span>asterisk_agi<span style="color: #339933;">/</span>socketIO_arduino.<span style="color: #202020;">rb</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
exten <span style="color: #339933;">=&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>n<span style="color: #339933;">,</span>Hangup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>All code examples and knowledge are curtesy to our awesome professor Chris Kairalla! I&#8217;m excited to continue on node and download the free book/pdf found here: http://visionmedia.github.com/masteringnode/
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/calling-an-object-with-node-js-and-socket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Object Calls You</title>
		<link>http://robbietilton.com/an-object-calls-you/</link>
		<comments>http://robbietilton.com/an-object-calls-you/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 22:43:13 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=942</guid>
		<description><![CDATA[My Ruby/Sinatra code is as noted below: require 'sinatra' &#160; #generates a call file that will connect to the arduino context def gencallfile&#40;numbertocall&#41; time = &#40;Time.now.to_f * 1000&#41;.to_i #current timestamp temp_dir = &#34;/tmp/&#34; callfile = &#34;call_&#34; + time.to_s + &#34;.call&#34; startcallfile = temp_dir + callfile end_dir = &#34;/var/spool/asterisk/outgoing/&#34; endcallfile = end_dir + callfile #write file [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol"><iframe src="http://player.vimeo.com/video/39231665" width="500" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>My Ruby/Sinatra code is as noted below:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#generates a call file that will connect to the arduino context</span>
<span style="color:#9966CC; font-weight:bold;">def</span> gencallfile<span style="color:#006600; font-weight:bold;">&#40;</span>numbertocall<span style="color:#006600; font-weight:bold;">&#41;</span>
  time = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#008000; font-style:italic;">#current timestamp</span>
  temp_dir = <span style="color:#996600;">&quot;/tmp/&quot;</span>
  callfile = <span style="color:#996600;">&quot;call_&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> time.<span style="color:#9900CC;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;.call&quot;</span>
  startcallfile = temp_dir <span style="color:#006600; font-weight:bold;">+</span> callfile
  end_dir = <span style="color:#996600;">&quot;/var/spool/asterisk/outgoing/&quot;</span>
  endcallfile = end_dir <span style="color:#006600; font-weight:bold;">+</span> callfile
  <span style="color:#008000; font-style:italic;">#write file to disk</span>
  file = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>startcallfile,<span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Channel: SIP/#{numbertocall}@flowroute<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;MaxRetries: 1<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;RetryTime: 60<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;WaitTime: 30<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;CallerID: Arduino &lt;2122738466&gt;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Context: rtt233_arduinocall<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Extension: s<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  file.<span style="color:#9900CC;">close</span>
  <span style="color:#008000; font-style:italic;">#change file permission</span>
  <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>0777, startcallfile<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">chown</span><span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'USER'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#996600;">'asterisk'</span>,startcallfile<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#008000; font-style:italic;">#move file to /var/spool/outgoing</span>
  <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">mv</span><span style="color:#006600; font-weight:bold;">&#40;</span>startcallfile,endcallfile<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Main route  - this is the form where we take the input</span>
get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
	call_number=params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:callnumber</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> call_number
		gencallfile<span style="color:#006600; font-weight:bold;">&#40;</span>call_number<span style="color:#006600; font-weight:bold;">&#41;</span>
  		<span style="color:#008000; font-style:italic;"># params[:callnumber] will be used to generate a call file</span>
  		<span style="color:#008000; font-style:italic;"># which will play back a message from the &quot;Arduino&quot;.</span>
  		<span style="color:#996600;">&quot;Called #{call_number}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
  		<span style="color:#996600;">&quot;missing <span style="color:#000099;">\&quot;</span>callnumber<span style="color:#000099;">\&quot;</span> param&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</div>
<div class="post_rightcol">
For my telephony class we experimented with creating a asterisk connection through an Arduino.  I used sinatra/ruby to create a webpage on my server that generates a call file in my /var/spool/asterisk/outgoing directory.  With asterisk installed on my rackspace ubuntu server &#8211; any file within my outgoing directory will automatically be routed for a call.  I also signed up with <a target="_blank" href="http://www.ipkall.com/">ipKall</a> for my inbound calls and <a href="www.flowroute.com" target="_blank">FlowRoute</a> for my outbound calls (which is being used in this example).</p>
<p>My Arduino code is noted below:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//state constants</span>
<span style="color: #339933;">#define HTTP_ACTIVE 10</span>
<span style="color: #339933;">#define HTTP_IDLE 20</span>
<span style="color: #339933;">#include &lt;SPI.h&gt;</span>
<span style="color: #339933;">#include &lt;Ethernet.h&gt;fa</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//setup          70    A5    DA    00    85    70</span>
byte mac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #208080;">0x70</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xA5</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xDA</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x85</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x70</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
IPAddress server <span style="color: #009900;">&#40;</span>XXX<span style="color: #339933;">,</span>XXX<span style="color: #339933;">,</span>XXX<span style="color: #339933;">,</span>XX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// my server</span>
<span style="color: #666666; font-style: italic;">//client stuff</span>
<span style="color: #993333;">char</span> httpCommand<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;GET /~rtilton1/sinatra/arduinocall/?callnumber=19174365310 HTTP/1.0&quot;</span><span style="color: #339933;">;</span>
EthernetClient client<span style="color: #339933;">;</span>
byte httpState <span style="color: #339933;">=</span> HTTP_IDLE<span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> httpDelay <span style="color: #339933;">=</span> <span style="color: #0000dd;">5000</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//wait at least this long in millis before sending another request</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> connectTime <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//button stuff</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">int</span> buttonPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> buttonState <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Ethernet.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span>mac<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Failed to configure Ethernet using DHCP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// no point in carrying on, so do nothing forevermore:</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// give the Ethernet shield a second to initialize:</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ready.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//read input from server, if any.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>client.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> c <span style="color: #339933;">=</span> client.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">//check button, only read if there are no active http connections and we're past minimum delay</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>httpState <span style="color: #339933;">==</span> HTTP_IDLE <span style="color: #339933;">&amp;&amp;</span> pastHttpDelay<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    buttonState <span style="color: #339933;">=</span> digitalRead<span style="color: #009900;">&#40;</span>buttonPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buttonState <span style="color: #339933;">==</span> HIGH<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      serverConnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">//close client if disconnected</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>client.<span style="color: #202020;">connected</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> httpState <span style="color: #339933;">==</span> HTTP_ACTIVE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    client.<span style="color: #202020;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    httpState <span style="color: #339933;">=</span> HTTP_IDLE<span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;disconnected.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
boolean pastHttpDelay<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> connectTime<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> httpDelay<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> serverConnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;connecting to stu.itp.nyu.edu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>client.<span style="color: #202020;">connect</span><span style="color: #009900;">&#40;</span>server<span style="color: #339933;">,</span> <span style="color: #0000dd;">80</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    httpState <span style="color: #339933;">=</span> HTTP_ACTIVE<span style="color: #339933;">;</span>
    connectTime <span style="color: #339933;">=</span> millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//when did we connect?</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;connected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    client.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>httpCommand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    client.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    httpState <span style="color: #339933;">=</span> HTTP_IDLE<span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;connection failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/an-object-calls-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EyeTracking Keyboard UI Research</title>
		<link>http://robbietilton.com/eyetracking-keyboard-ui-research/</link>
		<comments>http://robbietilton.com/eyetracking-keyboard-ui-research/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 00:42:53 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[openFrameworks]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=914</guid>
		<description><![CDATA[For appropriating new technologies I worked with Kyle McDonald&#8217;s new eyeTracking software that allows you to track where an eye is looking without any external device or accessory. To do the tracking, Kyle uses FaceOSC to get the points of each eye and then through image analysis -in tandem with a calibration routine- your cursor [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<a href="http://robbietilton.com/eyetracking-keyboard-ui-research/eyetracking/" rel="attachment wp-att-916"><img src="http://robbietilton.com/wp-content/uploads/2012/03/eyeTracking-500x272.png" alt="" title="eyeTracking Screenshot" width="500" height="272" class="aligncenter size-medium wp-image-916" /></a></p>
<p><a href="http://robbietilton.com/eyetracking-keyboard-ui-research/standardkeyboard/" rel="attachment wp-att-918"><img src="http://robbietilton.com/wp-content/uploads/2012/03/standardKeyboard-500x310.png" alt="" title="OF Standard EyeTracker Keyboard" width="500" height="310" class="aligncenter size-medium wp-image-918" /></a></p>
<p><a href="http://robbietilton.com/eyetracking-keyboard-ui-research/redesign/" rel="attachment wp-att-917"><img src="http://robbietilton.com/wp-content/uploads/2012/03/redesign-500x316.jpg" alt="" title="Redesign - Appropriating Apple Dock Lens Effect" width="500" height="316" class="aligncenter size-medium wp-image-917" /></a></p>
<p><a href="http://robbietilton.com/eyetracking-keyboard-ui-research/dasher/" rel="attachment wp-att-915"><img src="http://robbietilton.com/wp-content/uploads/2012/03/dasher-500x288.png" alt="" title="Dasher Screenshot" width="500" height="288" class="aligncenter size-medium wp-image-915" /></a>
</div>
<div class="post_rightcol">
For appropriating new technologies I worked with Kyle McDonald&#8217;s new eyeTracking software that allows you to track where an eye is looking without any external device or accessory.  To do the tracking, Kyle uses FaceOSC to get the points of each eye and then through image analysis -in tandem with a calibration routine- your cursor can automatically be controlled by your eyesight.  The current version requires that your head remain still as you use the software.  For the physically handicapt this is a truly revolutionary device at no cost greater than a standard computer and webcam.</p>
<p>With the software which you can download on <a href="https://github.com/kylemcdonald/AppropriatingNewTechnologies">Github here</a>- it comes with several standard applications &#8211; one of which is a keyboard that allows users to type.  For people like graffiti artist Temp, this is a truly amazing way to communicate to the outside world which once was not thought possible.  When viewing this keyboard (shown on the left &#8211; second image from the top) I initially felt there were several aspects of the keyboard that could be improved upon:<br />
1) The rollover/click state is indicated by the button fading into a saturated green.  This fading affect doesn&#8217;t give the user much of understanding to the amount of time required or remaining for the click to initiate.<br />
2) The window is jam packed with buttons and thus doesn&#8217;t give the user much space to rest there eyes after they typed or are waiting for a response.  Because of this there is also a limited amount of space where text is displayed.  I wanted to create a text area where more sentences (or even paragraphs) could be typed.<br />
3) The IA felt like there could potentially be some consolidating of features or even use of non screen real-estate.  Potentially numbers, shift, and delete functions could be removed from the main key area and placed on the external limits of the screen.<br />
4) I felt that typing required an increased up and down motion of the eyes to check what has been typed when it could potentially be displayed infront of a users eyes at all time.</p>
<p>With these problems in mind I created a design with the large black typing area and a green chalkboard keyboard selection area.  Overall I felt this redesigned keyboard organized the buttons in a more intuitive manner and allowed for clearer click state (with a black character filling effect), a cleaner work space with a single row navigation, and a reorganized UI with non key letter buttons (shift, numbers, delete) placed outside the screens width.  With this Apple Dock appropriated design finished &#8211; I seeked to create an app that would fulfill this image.  As it proved, the Apple Dock lens effect was more difficult to code than I anticipated.  After struggling to get the dock to function as I wanted, I decided that I needed to get something functional in code to begin user testing to determine if this interface actually worked or not.</p>
<p>When I began my tests I found that the standard keyboard that comes with the eyeTracking software performed fairly well even with it&#8217;s minimal design and button filled screen.  In comparison to a linear alphabet (similar to the one proposed in my design) &#8211; I could not type as fast.  The results from my tests are below:<br />
<strong>Standard Keyboard</strong><br />
Font-family: Helvetica Neue Med<br />
Font-size: 16<br />
Button Dimensions: 100&#215;100<br />
Type speed (&#8220;HELLO&#8221;): 17 seconds<br />
Errors: 4</p>
<p><strong>Single Line keyboard</strong><br />
Font-family: Hand Times<br />
Font-size: 48<br />
Button Dimensions: 50&#215;50<br />
Type speed (&#8220;HELLO&#8221;): 57.5 seconds<br />
Errors: 5</p>
<p><strong>Font-family: Hand Times</strong><br />
Font-size: 68<br />
Button Dimensions: 70&#215;70<br />
Type speed (&#8220;HELLO&#8221;): 49 seconds<br />
Errors: 4</p>
<p><strong>Font-family: Hand Times</strong><br />
Font-size: 90<br />
Button Dimensions: 90&#215;90<br />
Type speed (&#8220;HELLO&#8221;): 1:12 seconds<br />
Errors: 1</p>
<p>After reviewing my results I found that at a button size comprable to the standard keyboard I was able to achieve the same results with fewer errors, but it took me much longer to achieve this.  So is this a viable keyboard or not?  For now I think it is not the correct solution, but I do believe the error reduction is something that can be learned from in my next iteration.  Without a rowed approach it is more difficult to hit the wrong key.  I&#8217;m also interested in the <a href="http://www.inference.phy.cam.ac.uk/dasher/">Dasher</a> (bottom image on the left) software that Kyle and Greg showed me which claims to achieve 29 words per minute with eyetracking software.  Perhaps the predictive text route is the way to go&#8230; </p>
<p>Lastly, I&#8217;d like to thank everyone who helped me throughout this project.  ITP is truly a wonderful place where magic happens, but the support of everyone on the floor helps to keep everything flowing.  I plan to continue this research to one day have a better eyeTracking keyboard for the physically handicap.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/eyetracking-keyboard-ui-research/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glitch-alike with Kinect Depth Field</title>
		<link>http://robbietilton.com/glitch-alike-within-kinect-depth-field/</link>
		<comments>http://robbietilton.com/glitch-alike-within-kinect-depth-field/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 03:04:36 +0000</pubDate>
		<dc:creator>rtilton1</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[openFrameworks]]></category>

		<guid isPermaLink="false">http://robbietilton.com/?p=932</guid>
		<description><![CDATA[I created my first intentional glitch for appropriating new technologies. It uses the Kinect to pixelated and glitch-out a RGB feed when its within a specified depth range. The background colors which flicker a multitude of colors are an unintentional glitch which act as a filter for the RGB feed. These peculiar color changes are [...]]]></description>
			<content:encoded><![CDATA[<div class="post_leftcol">
<iframe src="http://player.vimeo.com/video/39029168" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div class="post_rightcol">
I created my first intentional glitch for appropriating new technologies.  It uses the Kinect to pixelated and glitch-out a RGB feed when its within a specified depth range.  The background colors which flicker a multitude of colors are an unintentional glitch which act as a filter for the RGB feed.  These peculiar color changes are due to an ofImage which is constantly having each pixel set to the latest color from the RGB feed.  If I were to set these pixels in update() rather than draw() this effect would not occur, but since I felt this offered a nice natural glitch to accompany my glitch-alike effect I kept it in the app.  openFrameworks was used with C++ for the app. The code can be found on my <a href="https://github.com/rtilton1/AppropriatingNewTechnologies/tree/master/week4">Github here</a>.</p>
<p>Audio was added in post-production.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://robbietilton.com/glitch-alike-within-kinect-depth-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

