<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>KwartzLab Makerspace &#187; wireless</title>
	<atom:link href="http://www.kwartzlab.ca/tag/wireless/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kwartzlab.ca</link>
	<description>Home of Kwartzlab Makerspace in Kitchener/Waterloo, Ontario</description>
	<lastBuildDate>Sun, 19 May 2013 23:30:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
<!-- podcast_generator="Blubrry PowerPress/4.0.7" -->
	<itunes:summary>Regular discussions with hackers, makers and artists at the Kwartzlab Makerspace. We talk about what projects people are working on, what events are coming up and how you can get involved.</itunes:summary>
	<itunes:author>kwartzlab</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.kwartzlab.ca/wp-content/uploads/powerpress/light_box_logo.jpg" />
	<itunes:owner>
		<itunes:name>kwartzlab</itunes:name>
		<itunes:email>podcast@kwartzlab.ca</itunes:email>
	</itunes:owner>
	<managingEditor>podcast@kwartzlab.ca (kwartzlab)</managingEditor>
	<itunes:subtitle>A hackerspace radio show</itunes:subtitle>
	<itunes:keywords>kwartzlab, hackerspace, makerspace, diy, hardware, software, maker, hacker, artist, roundtable</itunes:keywords>
	<image>
		<title>KwartzLab Makerspace &#187; wireless</title>
		<url>http://www.kwartzlab.ca/wp-content/uploads/powerpress/light_box_logo.jpg</url>
		<link>http://www.kwartzlab.ca</link>
	</image>
	<itunes:category text="Technology" />
	<itunes:category text="Arts" />
	<itunes:category text="Games &amp; Hobbies">
		<itunes:category text="Hobbies" />
	</itunes:category>
		<rawvoice:location>Kitchener, ON</rawvoice:location>
		<item>
		<title>Analyzing Android App Traffic</title>
		<link>http://www.kwartzlab.ca/2010/12/analyzing-android-app-traffic/</link>
		<comments>http://www.kwartzlab.ca/2010/12/analyzing-android-app-traffic/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 22:12:50 +0000</pubDate>
		<dc:creator>Alex W</dc:creator>
				<category><![CDATA[Member Blogs]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[kismet]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Android, the increasingly popular operating system (OS) for mobile phones, goes to great lengths to protect users' data. From applications that run as their own userid, in their own group, to the permission mechanism that alerts users to the information an application can access, Android is a far more secure platform than any desktop OS. However, there is a significant difference between informing a user what an application can access, and what the application actually does with the information. An Android app downloaded from the Market may request access to the internet and to the user's address book, for example, but beyond that the user has no idea what the application does with those permissions. How do we guarantee that a malicious app isn't making a copy of a user's private data, and sending it to a secret sever operated by the application's author?</p>

<!--more-->

<p>This is a hands-on blog post describing how to capture and analyze internet traffic of an Android application. You will need a computer with Linux installed, and a wireless adapter that is <a href="http://www.kismetwireless.net/documentation.shtml">supported by Kismet</a> (see: 7. Supported capture source types). I assume that you know how to connect your Android device to a wireless network, and that you know how to download and install programming libraries and development packages in your Linux environment. This blog post was written based on my experiences with Ubuntu 10.10 on an IBM Thinkpad T42 using an upgraded Intel 2200ABG wi-fi adapter.</p>

<p>There are four phases to capturing Android traffic:<br />
1. Connect the Android device to a wi-fi network<br />
2. Install and configure Kismet<br />
3. Capture a log with Kismet<br />
4. Analyze the log with Wireshark</p>

<h2>1 Connect the Android Device to a Wi-fi Network</h2>

<p>I assume that you already know how to connect to a wi-fi network on your Android phone, though the choice of network is important. Because you will be capturing all wireless traffic on that network, you should make sure you have permission to do so - ideally, you'll be doing this at home, so the only people that can complain is your family or room mates. The network security is also a consideration. Wireshark can decrypt WEP and WPA/WPA2 (in personal mode only) traffic if you have the key, though WPA decryption also requires the capture of 4 EAPOL handshake packets. Since I don't know how to guarantee capture of those packets, I will recommend using WEP or no encryption for the purposes of this test.</p>

<p>At the same time, make a note of what channel your adapter is on, and the MAC addresses of your router and Android device.</p>

<h2>2 Install and Configure Kismet</h2>

<p><a href="http://www.kismetwireless.net/">Kismet</a> is a powerful, open-source application for capturing and analyzing IEEE 802.11 (wi-fi) traffic. I am new to the tool, and have only begun to scratch the surface of what can be done with it, but some of the uses include discovery of hidden wi-fi networks, passive WEP key cracking, identifying clients connected to a network (and monitoring their network usage), and logging all observed wireless traffic. The traffic logging feature is what we are interested in now, because we want to see what kind of data our Android applications are sending out over the internet.</p>

<p>The version of Kismet available in the Ubuntu repository is over two years old as of this post, so I recommend downloading the <a href="http://www.kismetwireless.net/download.shtml">latest version</a> from the website and compiling the program from source. Kismet uses the standard ./configure &#38;&#38; make &#38;&#38; make install pattern, making installation a snap, though it may require installing some libraries such as libpcap-dev and libnl-dev. The only gotcha is that it needs root access to configure the wireless adapter. For a short test in a safe environment, you can install and run the program as root, but it's important to be aware that the packet analysis code and all plugins will run with root privileges. Instructions to install and run Kismet more safely are available in the README file or on the <a href="http://www.kismetwireless.net/documentation.shtml">Kismet documentation page</a>.</p>

<p>By default, the Kismet configuration file can be found at /usr/local/etc/kismet.conf, though for this guide there is nothing in the configuration that needs to be changed.</p>

<h2>3 Capture a Log with Kismet</h2>

<p>Before launching Kismet on Ubuntu 10.10, I needed to manually disable wireless networking by right-clicking on the wi-fi icon on the Panel, and unchecking the "Enable Wireless" option.<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/wireless.png" alt="Turning off wireless networking" /></p>

<p>Launch Kismet from the command line by running "kismet", or "sudo kismet" if you installed it as root. There will be several dialog boxes when you first run the application. Navigate through the dialogs using tab/enter, or with the mouse. If running as root, the first will warn you that running Kismet as root is unsafe. Next, Kismet will ask if it should automatically start the Kismet Server (choose "Yes", then "Start"). Finally, there should be a warning that no capture sources are configured. Choose "Add Source". Next to "Intf", type the name of the wireless interface (On Ubuntu, the default is eth1). The "Name" field can be anything, but I'd suggest naming it after the manufacturer of your wireless adapter. Next to "Opts", tell Kismet not to hop to different wi-fi channels, then specify what channel it should monitor by writing "hop=false,channel=xx".<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/kismet.png" alt="Adding a packet source" /></p>

<p>On my machine, I eventually received a warning dialog stating that "All packet sources are in error state" - Kismet was unable to identify the type of wireless adapter I had, so I needed to manually specify this as an option when adding it as a source ("type=ipw2200").</p>

<p>Instead of adding the source on start-up, consider adding the source in Kismet's configuration file. Here is an example from my configuration file:</p>

<pre><code># See the README for full information on the new source format
# ncsource=interface:options
# for example:
# ncsource=wlan0
# ncsource=wifi0:type=madwifi
# ncsource=wlan0:name=intel,hop=false,channel=11
ncsource=eth1:type=ipw2200,name=intel,hop=false,channel=1
</code></pre>

<p>Once the source is added, logging should begin automatically. By default, log files are saved in the directory that Kismet was started in, though this can be changed in the configuration file or through command line arguments. Start up the Android app to be tested and generate some traffic. When enough data has been captured, quit Kismet and kill the Kismet Server.</p>

<h2>4    Analyze the Log with Wireshark</h2>

<p>Install Wireshark if it isn't on your machine. On Ubuntu, the version in the repository is mostly up-to-date, so that building from source isn't necessary.</p>

<p>Start Wireshark, click File -> Open, then navigate to the directory where Kismet saved the log files. Find and select the log ending with the extension ".pcapdump" - this is dump of the raw 802.11 packets captured by your wireless adapter. If the traffic was captured from a WEP-protected network, the hex decryption key can be sent under Edit -> Preferences -> IEEE 802.11 (see <a href="http://wiki.wireshark.org/HowToDecrypt802.11">The Wireshark Wiki - HowToDecrypt802.11</a>).</p>

<p>To find the specific packets for the application you're interested in, try using Wireshark's display filters. The filter "wlan.addr == xx:xx:xx:xx:xx:xx" will limit the displayed packets to only those that were sent by or sent to the specified MAC address (note that the filter for wired MAC "eth.addr" is different from the filter for wireless MAC!). The traffic you're looking for would likely be TCP, so the filter "tcp" can narrow things down further. Eventually, you should be able to find the IP address of the server that the app is communicating with, so the filter "ip.addr == xxx.xxx.xxx.xxx" would give you only packets between the Android phone and the destination.<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/wireshark.png" alt="Filtering packets in Wireshark" /></p>

<p>Happy hacking!</p>
]]></description>
				<content:encoded><![CDATA[<p>Android, the increasingly popular operating system (OS) for mobile phones, goes to great lengths to protect users&#8217; data. From applications that run as their own userid, in their own group, to the permission mechanism that alerts users to the information an application can access, Android is a far more secure platform than any desktop OS. However, there is a significant difference between informing a user what an application can access, and what the application actually does with the information. An Android app downloaded from the Market may request access to the internet and to the user&#8217;s address book, for example, but beyond that the user has no idea what the application does with those permissions. How do we guarantee that a malicious app isn&#8217;t making a copy of a user&#8217;s private data, and sending it to a secret sever operated by the application&#8217;s author?</p>
<p><span id="more-461"></span></p>
<p>This is a hands-on blog post describing how to capture and analyze internet traffic of an Android application. You will need a computer with Linux installed, and a wireless adapter that is <a href="http://www.kismetwireless.net/documentation.shtml">supported by Kismet</a> (see: 7. Supported capture source types). I assume that you know how to connect your Android device to a wireless network, and that you know how to download and install programming libraries and development packages in your Linux environment. This blog post was written based on my experiences with Ubuntu 10.10 on an IBM Thinkpad T42 using an upgraded Intel 2200ABG wi-fi adapter.</p>
<p>There are four phases to capturing Android traffic:<br />
1. Connect the Android device to a wi-fi network<br />
2. Install and configure Kismet<br />
3. Capture a log with Kismet<br />
4. Analyze the log with Wireshark</p>
<h2>1 Connect the Android Device to a Wi-fi Network</h2>
<p>I assume that you already know how to connect to a wi-fi network on your Android phone, though the choice of network is important. Because you will be capturing all wireless traffic on that network, you should make sure you have permission to do so &#8211; ideally, you&#8217;ll be doing this at home, so the only people that can complain is your family or room mates. The network security is also a consideration. Wireshark can decrypt WEP and WPA/WPA2 (in personal mode only) traffic if you have the key, though WPA decryption also requires the capture of 4 EAPOL handshake packets. Since I don&#8217;t know how to guarantee capture of those packets, I will recommend using WEP or no encryption for the purposes of this test.</p>
<p>At the same time, make a note of what channel your adapter is on, and the MAC addresses of your router and Android device.</p>
<h2>2 Install and Configure Kismet</h2>
<p><a href="http://www.kismetwireless.net/">Kismet</a> is a powerful, open-source application for capturing and analyzing IEEE 802.11 (wi-fi) traffic. I am new to the tool, and have only begun to scratch the surface of what can be done with it, but some of the uses include discovery of hidden wi-fi networks, passive WEP key cracking, identifying clients connected to a network (and monitoring their network usage), and logging all observed wireless traffic. The traffic logging feature is what we are interested in now, because we want to see what kind of data our Android applications are sending out over the internet.</p>
<p>The version of Kismet available in the Ubuntu repository is over two years old as of this post, so I recommend downloading the <a href="http://www.kismetwireless.net/download.shtml">latest version</a> from the website and compiling the program from source. Kismet uses the standard ./configure &amp;&amp; make &amp;&amp; make install pattern, making installation a snap, though it may require installing some libraries such as libpcap-dev and libnl-dev. The only gotcha is that it needs root access to configure the wireless adapter. For a short test in a safe environment, you can install and run the program as root, but it&#8217;s important to be aware that the packet analysis code and all plugins will run with root privileges. Instructions to install and run Kismet more safely are available in the README file or on the <a href="http://www.kismetwireless.net/documentation.shtml">Kismet documentation page</a>.</p>
<p>By default, the Kismet configuration file can be found at /usr/local/etc/kismet.conf, though for this guide there is nothing in the configuration that needs to be changed.</p>
<h2>3 Capture a Log with Kismet</h2>
<p>Before launching Kismet on Ubuntu 10.10, I needed to manually disable wireless networking by right-clicking on the wi-fi icon on the Panel, and unchecking the &#8220;Enable Wireless&#8221; option.<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/wireless.png" alt="Turning off wireless networking" /></p>
<p>Launch Kismet from the command line by running &#8220;kismet&#8221;, or &#8220;sudo kismet&#8221; if you installed it as root. There will be several dialog boxes when you first run the application. Navigate through the dialogs using tab/enter, or with the mouse. If running as root, the first will warn you that running Kismet as root is unsafe. Next, Kismet will ask if it should automatically start the Kismet Server (choose &#8220;Yes&#8221;, then &#8220;Start&#8221;). Finally, there should be a warning that no capture sources are configured. Choose &#8220;Add Source&#8221;. Next to &#8220;Intf&#8221;, type the name of the wireless interface (On Ubuntu, the default is eth1). The &#8220;Name&#8221; field can be anything, but I&#8217;d suggest naming it after the manufacturer of your wireless adapter. Next to &#8220;Opts&#8221;, tell Kismet not to hop to different wi-fi channels, then specify what channel it should monitor by writing &#8220;hop=false,channel=xx&#8221;.<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/kismet.png" alt="Adding a packet source" /></p>
<p>On my machine, I eventually received a warning dialog stating that &#8220;All packet sources are in error state&#8221; &#8211; Kismet was unable to identify the type of wireless adapter I had, so I needed to manually specify this as an option when adding it as a source (&#8220;type=ipw2200&#8243;).</p>
<p>Instead of adding the source on start-up, consider adding the source in Kismet&#8217;s configuration file. Here is an example from my configuration file:</p>
<pre><code># See the README for full information on the new source format
# ncsource=interface:options
# for example:
# ncsource=wlan0
# ncsource=wifi0:type=madwifi
# ncsource=wlan0:name=intel,hop=false,channel=11
ncsource=eth1:type=ipw2200,name=intel,hop=false,channel=1
</code></pre>
<p>Once the source is added, logging should begin automatically. By default, log files are saved in the directory that Kismet was started in, though this can be changed in the configuration file or through command line arguments. Start up the Android app to be tested and generate some traffic. When enough data has been captured, quit Kismet and kill the Kismet Server.</p>
<h2>4    Analyze the Log with Wireshark</h2>
<p>Install Wireshark if it isn&#8217;t on your machine. On Ubuntu, the version in the repository is mostly up-to-date, so that building from source isn&#8217;t necessary.</p>
<p>Start Wireshark, click File -> Open, then navigate to the directory where Kismet saved the log files. Find and select the log ending with the extension &#8220;.pcapdump&#8221; &#8211; this is dump of the raw 802.11 packets captured by your wireless adapter. If the traffic was captured from a WEP-protected network, the hex decryption key can be sent under Edit -> Preferences -> IEEE 802.11 (see <a href="http://wiki.wireshark.org/HowToDecrypt802.11">The Wireshark Wiki &#8211; HowToDecrypt802.11</a>).</p>
<p>To find the specific packets for the application you&#8217;re interested in, try using Wireshark&#8217;s display filters. The filter &#8220;wlan.addr == xx:xx:xx:xx:xx:xx&#8221; will limit the displayed packets to only those that were sent by or sent to the specified MAC address (note that the filter for wired MAC &#8220;eth.addr&#8221; is different from the filter for wireless MAC!). The traffic you&#8217;re looking for would likely be TCP, so the filter &#8220;tcp&#8221; can narrow things down further. Eventually, you should be able to find the IP address of the server that the app is communicating with, so the filter &#8220;ip.addr == xxx.xxx.xxx.xxx&#8221; would give you only packets between the Android phone and the destination.<br />
<img src="http://www.eng.uwaterloo.ca/~mawillia/images/android-kismet/wireshark.png" alt="Filtering packets in Wireshark" /></p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2010/12/analyzing-android-app-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tamagotchi Talk (Part III, Protocol Analysis)</title>
		<link>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-iii-proto/</link>
		<comments>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-iii-proto/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 04:08:47 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>
		<category><![CDATA[ir]]></category>
		<category><![CDATA[personal projects]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Looking at the decoded IR signals, we can start to understand the protocol.</p>

<p>Tamagotchis can have three possibile interactions: visits, presents and games. Starting with the simplest, visits, I recorded a number of interactions. I noted that each visit involved either singing, playing ball or chatting. Below is a sample visit.</p>

<p>Singing visit between JANIE and HELEN</p>

<p>JANIE: ac 0 24 d6 a 1 e 9 5 0 4 88 0 0 20 80 9 0 0 ff 1 ff ff 0 (request)</p>

<p>HELEN: ac 1 1f 96 8 5 c 5 e 0 4 88 20 5 10 0 1 0 0 ff 1 ff ff 4e (response)</p>

<p>JANIE: ac 1c 24 d6 a 1 20 1f c (request confirmation)</p>

<p>HELEN: ac 1d 1f 96 8 5 20 24 cf (response confirmation)</p>

<p>Based on this (and several other samples)I theorize the following protocol:</p>

<p>Request and response:</p>

<p><img src="http://kwartzlab.ca/sites/default/files/visit1_0.png" size="95%"></p>

<p>Confirmations</p>

<p><img src="http://kwartzlab.ca/sites/default/files/visit2_0.png" size="95%"></p>

<p>When the Tamagotchis play a game instead of just visit, the request and response are the same, but the confirmations are different:</p>

<p><img src="http://kwartzlab.ca/sites/default/files/game.png" size="95%"></p>

<p>Likewise, when they give a present, only the confirmation is different.</p>

<p><img src="http://kwartzlab.ca/sites/default/files/present.png" size="95%"></p>

<p>So that's a ten second guide to the protocol!</p>

<p>Up next:</p>

<ul>
<li>Set up IR to send stuff to Tamagotchi</li>
<li>Put a Tamagatchi into debug mode to better understand the physical attributes portion of the protocol</li>
<li>Play with the protocol :)</li>
</ul>
]]></description>
				<content:encoded><![CDATA[<p>Looking at the decoded IR signals, we can start to understand the protocol.</p>
<p>Tamagotchis can have three possibile interactions: visits, presents and games. Starting with the simplest, visits, I recorded a number of interactions. I noted that each visit involved either singing, playing ball or chatting. Below is a sample visit.</p>
<p>Singing visit between JANIE and HELEN</p>
<p>JANIE: ac 0 24 d6 a 1 e 9 5 0 4 88 0 0 20 80 9 0 0 ff 1 ff ff 0 (request)</p>
<p>HELEN: ac 1 1f 96 8 5 c 5 e 0 4 88 20 5 10 0 1 0 0 ff 1 ff ff 4e (response)</p>
<p>JANIE: ac 1c 24 d6 a 1 20 1f c (request confirmation)</p>
<p>HELEN: ac 1d 1f 96 8 5 20 24 cf (response confirmation)</p>
<p>Based on this (and several other samples)I theorize the following protocol:</p>
<p>Request and response:</p>
<p><img src="http://kwartzlab.ca/wp-content/uploads/visit1_0.png" size="95%"></p>
<p>Confirmations</p>
<p><img src="http://kwartzlab.ca/wp-content/uploads/visit2_0.png" size="95%"></p>
<p>When the Tamagotchis play a game instead of just visit, the request and response are the same, but the confirmations are different:</p>
<p><img src="http://kwartzlab.ca/wp-content/uploads/game.png" size="95%"></p>
<p>Likewise, when they give a present, only the confirmation is different.</p>
<p><img src="http://kwartzlab.ca/wp-content/uploads/present.png" size="95%"></p>
<p>So that&#8217;s a ten second guide to the protocol!</p>
<p>Up next:</p>
<ul>
<li>Set up IR to send stuff to Tamagotchi</li>
<li>Put a Tamagatchi into debug mode to better understand the physical attributes portion of the protocol</li>
<li>Play with the protocol <img src='http://www.kwartzlab.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-iii-proto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tamagotchi Talk (Part II, decoding IR on the Arduino)</title>
		<link>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-ii-decodi/</link>
		<comments>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-ii-decodi/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 02:40:08 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>
		<category><![CDATA[ir]]></category>
		<category><![CDATA[personal project]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Some success with decoding the IR signals in real time!</p>

<p><img src="/wp-content/uploads/u24/S6300498.JPG" width="80%" align="center">
<!--more-->
At first I attempted to do this using the Python script from Part I, but this means that the entire signal must be sent over serial, which is slow and can miss events.</p>

<p>Instead, I implemented decoding directly on the Arduino board. I used a simple state machine that polls the output of the IR receiver and changes state based on the amount of time the signal was one or zero before it changed. The Arduino has an internal timer (call <code>millis</code> or <code>micros</code>) that was used for timing.</p>

<p>Serial output is not printed until decoding is complete as to not interfere with timing.</p>

<p>I had to do some manual timing of signals to get the decoder to work correctly, but now it decodes both sides of the IR conversation quite cleanly.</p>

<p>Example output:</p>

<p><code>ac 00 0e d6 01 0c 05 18 00 00 03 88 00 00 10 00 02 00 00 ff 1 ff ff 55</code></p>

<p>From a Tamagotchi named "Alex" (01 0c 05 18 in IR).</p>

<!-- Images -->
]]></description>
				<content:encoded><![CDATA[<p>Some success with decoding the IR signals in real time!</p>
<p><img src="/wp-content/uploads/u24/S6300498.JPG" width="80%" align="center"><br />
<span id="more-282"></span><br />
At first I attempted to do this using the Python script from Part I, but this means that the entire signal must be sent over serial, which is slow and can miss events.</p>
<p>Instead, I implemented decoding directly on the Arduino board. I used a simple state machine that polls the output of the IR receiver and changes state based on the amount of time the signal was one or zero before it changed. The Arduino has an internal timer (call <code>millis</code> or <code>micros</code>) that was used for timing.</p>
<p>Serial output is not printed until decoding is complete as to not interfere with timing.</p>
<p>I had to do some manual timing of signals to get the decoder to work correctly, but now it decodes both sides of the IR conversation quite cleanly.</p>
<p>Example output:</p>
<p><code>ac 00 0e d6 01 0c 05 18 00 00 03 88 00 00 10 00 02 00 00 ff 1 ff ff 55</code></p>
<p>From a Tamagotchi named &#8220;Alex&#8221; (01 0c 05 18 in IR).</p>
<p><!-- Images --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2010/02/tamagotchi-talk-part-ii-decodi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tamagotchi Talk</title>
		<link>http://www.kwartzlab.ca/2009/11/tamagotchi-talk/</link>
		<comments>http://www.kwartzlab.ca/2009/11/tamagotchi-talk/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 19:54:49 +0000</pubDate>
		<dc:creator>Natalie Silvanovich</dc:creator>
				<category><![CDATA[Member Blogs]]></category>
		<category><![CDATA[ir]]></category>
		<category><![CDATA[personal project]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Tamagotchis are keychain virtual pets. They communicate ("visit each other") over IR. For the past few weeks, I've been trying to listen in on and understand this communication.</p>

<p>To start, I set up a liteon IR module to listen in on the transmission, and recorded the ouput with some help from <a href="http://kwartzlab.ca/blog/dw">DW</a> and his digital signal analyser.</p>

<p>Plotting the signal, you can see a request and a response:</p>

<p><img src="/sites/default/files/u24/sig1.png" alt="sig1.png" title="sig1.png" /></p>

<p>Looking more closely at the request:</p>

<p><img src="http://kwartzlab.ca/sites/default/files/u24/sig2.png" alt="signal" /></p>

<p>Googling a bit, this appears to be similar to NEC encoding, athough the periods of the bits are stretched out (in normal NEC encoding, 0 is a cycle of equal size, 1 is a cycle that is low twice as long as it is high. In this case, 0 is marked by a cycle that is low twice as much as it is high and 1 is marked by a cycle that is low four times as much as it is high. Note that the graph above has 1 and 0 inverted, a feature of the IR receiver.) The main point is that if you look at the graph, there are some waveforms that are squished together, and those are zeros. The ones that are spaced out at ones.</p>

<p>Assuming this, it is easy enough to write a Python script that extracts the bytes of the request, which are:</p>

<p>ac 00 26 d6 0e 01 0e 01 00 01 33 87 00 00 33 c0 0b 00 00 ff 01 ff ff 7d</p>

<p>Looking at this, there are bytes in the same pattern as my Tamagotchi's name (Nana):</p>

<p>ac 00 26 d6 <b>0e 01 0e 01 00 </b> 01 33 87 00 00 33 c0 0b 00 00 ff 01 ff ff 7d`</p>

<p><img src="/sites/default/files/u24/nana.png" alt="nana.png" title="nana.png" /></p>

<p>Note that 0x0e = 14 and 'N' is the fourteenth letter of the alphabet. So 1, 14, 1, 14 could represent the name Nana.</p>

<p><b>Update</b></p>

<p>Trying this with a Tamagotchi named Anna gives the following output:</p>

<p>ac 00 39 d6 <b>01 0e 0e 01 00</b> 00 34 87 00 00 20 80 8 00</p>

<p>so this is almost certainly the case.</p>

<p><!-- Links -->
<!-- Images --></p>
]]></description>
				<content:encoded><![CDATA[<p>Tamagotchis are keychain virtual pets. They communicate (&#8220;visit each other&#8221;) over IR. For the past few weeks, I&#8217;ve been trying to listen in on and understand this communication.</p>
<p>To start, I set up a liteon IR module to listen in on the transmission, and recorded the ouput with some help from <a href="http://kwartzlab.ca/blog/dw">DW</a> and his digital signal analyser.</p>
<p>Plotting the signal, you can see a request and a response:</p>
<p><img src="/wp-content/uploads/u24/sig1.png" alt="sig1.png" title="sig1.png" /></p>
<p>Looking more closely at the request:</p>
<p><img src="http://kwartzlab.ca/wp-content/uploads/u24/sig2.png" alt="signal" /></p>
<p>Googling a bit, this appears to be similar to NEC encoding, athough the periods of the bits are stretched out (in normal NEC encoding, 0 is a cycle of equal size, 1 is a cycle that is low twice as long as it is high. In this case, 0 is marked by a cycle that is low twice as much as it is high and 1 is marked by a cycle that is low four times as much as it is high. Note that the graph above has 1 and 0 inverted, a feature of the IR receiver.) The main point is that if you look at the graph, there are some waveforms that are squished together, and those are zeros. The ones that are spaced out at ones.</p>
<p>Assuming this, it is easy enough to write a Python script that extracts the bytes of the request, which are:</p>
<p>ac 00 26 d6 0e 01 0e 01 00 01 33 87 00 00 33 c0 0b 00 00 ff 01 ff ff 7d</p>
<p>Looking at this, there are bytes in the same pattern as my Tamagotchi&#8217;s name (Nana):</p>
<p>ac 00 26 d6 <b>0e 01 0e 01 00 </b> 01 33 87 00 00 33 c0 0b 00 00 ff 01 ff ff 7d`</p>
<p><img src="/wp-content/uploads/u24/nana.png" alt="nana.png" title="nana.png" /></p>
<p>Note that 0x0e = 14 and &#8216;N&#8217; is the fourteenth letter of the alphabet. So 1, 14, 1, 14 could represent the name Nana.</p>
<p><b>Update</b></p>
<p>Trying this with a Tamagotchi named Anna gives the following output:</p>
<p>ac 00 39 d6 <b>01 0e 0e 01 00</b> 00 34 87 00 00 20 80 8 00</p>
<p>so this is almost certainly the case.</p>
<p><!-- Links --><br />
<!-- Images --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2009/11/tamagotchi-talk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino XBee communication</title>
		<link>http://www.kwartzlab.ca/2009/11/arduino-xbee-communication/</link>
		<comments>http://www.kwartzlab.ca/2009/11/arduino-xbee-communication/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 06:07:21 +0000</pubDate>
		<dc:creator>Mattbee</dc:creator>
				<category><![CDATA[Member Blogs]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[XBee]]></category>
		<category><![CDATA[ZigBee]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>This past week, i finally got 2 Arduinos (Arduini?) to communicate with the XBee shield. I wasn’t happy with the <a href="http://www.arduino.cc/en/Main/ArduinoXbeeShield">tutorials online</a>, because these didn’t seem to tell you what you needed while at the same time included a lot of unnecessary info. Using ZNet 2.5 (Series 2) involves only one extra step.</p>

<p>The following parts were used:</p>

<table>
<thead>
<tr>
  <th>Quantity</th>
  <th>Part</th>
  <th align="right">Cost ea (CAD)</th>
</tr>
</thead>
<tbody>
<tr>
  <td>2</td>
  <td>Arduino Duemilanove</td>
  <td align="right">33</td>
</tr>
<tr>
  <td>2</td>
  <td>Arduino XBee Shield v1.1 (includes XBee Series 2 module)</td>
  <td align="right">87</td>
</tr>
<tr>
  <td>1</td>
  <td>USB A B cable (salvaged)</td>
  <td align="right">0</td>
</tr>
<tr>
  <td>1</td>
  <td>Power adapter (salvaged)</td>
  <td align="right">0</td>
</tr>
<tr>
  <td></td>
  <td>Total</td>
  <td align="right">240</td>
</tr>
</tbody>
</table>

<p><a href="http://www.flickr.com/photos/44415145@N00/4114324249/" title="PFZ20-09781 Arduino with XBee shield by mbells, on Flickr"><img src="http://farm3.static.flickr.com/2651/4114324249_b00d2c72ba.jpg" width="500" height="381" alt="PFZ20-09781 Arduino with XBee shield" /></a></p>

<hr />

<h2>Basic Setup</h2>

<p>The menu Tools --> Board --> Arduino Deumilanove w/ ATmega328 was selected.
The menu Tools --> Serial Post --> (appropriate port) was selected. Note the port needs to be selected each time a different Arduino is connected to USB. One automatically binds to COM3 and the other to COM4; there is most likely a setting somewhere to have these on the same COM port, but that would later preclude connecting both at the same time.</p>

<hr />

<h2>Testing the XBee</h2>

<p>The shield and wireless module were assembled onto the Arduino. The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB. The following sketch was uploaded:</p>

<p>Sketch: XBee_diagnostics</p>

<pre><code>void setup()
{
    Serial.begin(9600);
}

void loop()
{
    Serial.println("+++");
    delay(2000);
    echo();
    Serial.println("ATID");
    echo();
}

void echo() {
    byte incomingByte;

    // see if there's incoming serial data:
    delay(50);
    while (Serial.available() &#62; 0) {
        // read the oldest byte in the serial buffer:
        incomingByte = Serial.read();
        Serial.write(incomingByte);
        if(incomingByte != '\r') {
            Serial.write(' ');
        }
        delay(100);
    }
}
</code></pre>

<p>The Arduino was unplugged from USB, the jumpers switched to the inward position, then the serial monitor activated. The XBee should be responding with 234 as the ID (for Series 2).</p>

<hr />

<h2>Configuring</h2>

<p>Use <a href="http://www.digi.com/support/kbase/kbaseresultdetl.jsp?kb=125">X-CTU</a> to configure. Alternatively, any serial terminal will do. Note that the ATmega328 must be removed and the XBee shield pins placed in the outward position for this to work.</p>

<p>It may be preferred to configure the XBee module as part of a sketch and avoid removing the processor or finding a terminal program. The diagnostic sketch may be modified to with the following:</p>

<pre><code>void loop()
{
    delay(2000);
    Serial.println("+++");
    delay(2000);
    echo();
    Serial.println("ATDL FFFF");
    echo();
    Serial.println("ATWR");
    echo();
    delay(10000);
}
</code></pre>

<p>After configuring, the Arduino was unplugged fro USB.</p>

<hr />

<h2>Transmitter</h2>

<p>The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB. The following sketch was uploaded:</p>

<p>Sketch: Send_physical_pixel</p>

<pre><code>const int ledPin = 13;

void setup()
{
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
}

void loop()
{
    digitalWrite(ledPin, HIGH);
    Serial.print('H');
    delay(1000);

    digitalWrite(ledPin, LOW);
    Serial.print('L');
    delay(1000);
}
</code></pre>

<p>The Arduino was unplugged from USB, the jumpers switched to the inward position. Then the Arduino was plugged into USB and the serial monitor activated. The serial monitor showed a string of HLHL… The LED was flashing at 0.5 Hz.</p>

<p>The Arduino was unplugged from USB, and the plugged this into the power adapter. The LED continued to flash at 0.5 Hz.</p>

<hr />

<h2>Receiver</h2>

<p>Now for the second Arduino with XBee shield. The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB and the following sketch Sketchbook --> Examples --> Communication --> PhysicalPixel was uploaded (unchanged).</p>

<p>The LED on the receiver is observed going on and off. However, not at regular 1 second intervals – the XBee sometimes groups the H and L sends together so these will be read at irregular intervals.</p>

<hr />

<h1>More Details</h1>

<p>Note if you are in an area with ore XBee modules, then more configuration will be required to prevent all pairs from interfering with others.</p>

<h2>Jumper meanings</h2>

<p>When loading the Arduino while the XBee shield is attached, ensure the pins are in the USB position. Here’s a table of the <a href="http://www.arduino.cc/en/Main/ArduinoXbeeShield">explanation of jumper settings</a>:</p>

<table>
<thead>
<tr>
  <th>Position</th>
  <th>Meaning</th>
  <th>Connections</th>
  <th>Connections</th>
</tr>
</thead>
<tbody>
<tr>
  <td>Inward</td>
  <td>XBee</td>
  <td>Xbee.DOUT = Micro.RX = FTDI.TX</td>
  <td>Xbee.DIN = Micro.TX = FTDI.RX</td>
</tr>
<tr>
  <td>Outward</td>
  <td>USB</td>
  <td>Xbee.DOUT = FTDI.RX</td>
  <td>Xbee.DIN = FTDI.TX</td>
</tr>
</tbody>
</table>

<p><a href="http://www.flickr.com/photos/44415145@N00/4115096202/" title="XBee shield jumpers in XBee position "><img src="http://farm3.static.flickr.com/2753/4115096202_2fc8cfb962_m.jpg" width="240" height="135" alt="PFZ20-09787 XBee shield jumpers XBee" /></a></p>

<p><a href="http://www.flickr.com/photos/44415145@N00/4115095992/" title="XBee shield jumpers in USB position"><img src="http://farm3.static.flickr.com/2618/4115095992_d266af954f_m.jpg" width="240" height="135" alt="PFZ20-09786 XBee shield jumpers USB" /></a></p>
]]></description>
				<content:encoded><![CDATA[<p>This past week, i finally got 2 Arduinos (Arduini?) to communicate with the XBee shield. I wasn’t happy with the <a href="http://www.arduino.cc/en/Main/ArduinoXbeeShield">tutorials online</a>, because these didn’t seem to tell you what you needed while at the same time included a lot of unnecessary info. Using ZNet 2.5 (Series 2) involves only one extra step.</p>
<p>The following parts were used:</p>
<table>
<thead>
<tr>
<th>Quantity</th>
<th>Part</th>
<th align="right">Cost ea (CAD)</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>Arduino Duemilanove</td>
<td align="right">33</td>
</tr>
<tr>
<td>2</td>
<td>Arduino XBee Shield v1.1 (includes XBee Series 2 module)</td>
<td align="right">87</td>
</tr>
<tr>
<td>1</td>
<td>USB A B cable (salvaged)</td>
<td align="right">0</td>
</tr>
<tr>
<td>1</td>
<td>Power adapter (salvaged)</td>
<td align="right">0</td>
</tr>
<tr>
<td></td>
<td>Total</td>
<td align="right">240</td>
</tr>
</tbody>
</table>
<p><a href="http://www.flickr.com/photos/44415145@N00/4114324249/" title="PFZ20-09781 Arduino with XBee shield by mbells, on Flickr"><img src="http://farm3.static.flickr.com/2651/4114324249_b00d2c72ba.jpg" width="500" height="381" alt="PFZ20-09781 Arduino with XBee shield" /></a></p>
<hr />
<h2>Basic Setup</h2>
<p>The menu Tools &#8211;> Board &#8211;> Arduino Deumilanove w/ ATmega328 was selected.<br />
The menu Tools &#8211;> Serial Post &#8211;> (appropriate port) was selected. Note the port needs to be selected each time a different Arduino is connected to USB. One automatically binds to COM3 and the other to COM4; there is most likely a setting somewhere to have these on the same COM port, but that would later preclude connecting both at the same time.</p>
<hr />
<h2>Testing the XBee</h2>
<p>The shield and wireless module were assembled onto the Arduino. The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB. The following sketch was uploaded:</p>
<p>Sketch: XBee_diagnostics</p>
<pre><code>void setup()
{
    Serial.begin(9600);
}

void loop()
{
    Serial.println("+++");
    delay(2000);
    echo();
    Serial.println("ATID");
    echo();
}

void echo() {
    byte incomingByte;

    // see if there's incoming serial data:
    delay(50);
    while (Serial.available() &gt; 0) {
        // read the oldest byte in the serial buffer:
        incomingByte = Serial.read();
        Serial.write(incomingByte);
        if(incomingByte != '\r') {
            Serial.write(' ');
        }
        delay(100);
    }
}
</code></pre>
<p>The Arduino was unplugged from USB, the jumpers switched to the inward position, then the serial monitor activated. The XBee should be responding with 234 as the ID (for Series 2).</p>
<hr />
<h2>Configuring</h2>
<p>Use <a href="http://www.digi.com/support/kbase/kbaseresultdetl.jsp?kb=125">X-CTU</a> to configure. Alternatively, any serial terminal will do. Note that the ATmega328 must be removed and the XBee shield pins placed in the outward position for this to work.</p>
<p>It may be preferred to configure the XBee module as part of a sketch and avoid removing the processor or finding a terminal program. The diagnostic sketch may be modified to with the following:</p>
<pre><code>void loop()
{
    delay(2000);
    Serial.println("+++");
    delay(2000);
    echo();
    Serial.println("ATDL FFFF");
    echo();
    Serial.println("ATWR");
    echo();
    delay(10000);
}
</code></pre>
<p>After configuring, the Arduino was unplugged fro USB.</p>
<hr />
<h2>Transmitter</h2>
<p>The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB. The following sketch was uploaded:</p>
<p>Sketch: Send_physical_pixel</p>
<pre><code>const int ledPin = 13;

void setup()
{
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
}

void loop()
{
    digitalWrite(ledPin, HIGH);
    Serial.print('H');
    delay(1000);

    digitalWrite(ledPin, LOW);
    Serial.print('L');
    delay(1000);
}
</code></pre>
<p>The Arduino was unplugged from USB, the jumpers switched to the inward position. Then the Arduino was plugged into USB and the serial monitor activated. The serial monitor showed a string of HLHL… The LED was flashing at 0.5 Hz.</p>
<p>The Arduino was unplugged from USB, and the plugged this into the power adapter. The LED continued to flash at 0.5 Hz.</p>
<hr />
<h2>Receiver</h2>
<p>Now for the second Arduino with XBee shield. The jumpers on the XBee shield were put into the outward position. The Arduino was plugged into USB and the following sketch Sketchbook &#8211;> Examples &#8211;> Communication &#8211;> PhysicalPixel was uploaded (unchanged).</p>
<p>The LED on the receiver is observed going on and off. However, not at regular 1 second intervals – the XBee sometimes groups the H and L sends together so these will be read at irregular intervals.</p>
<hr />
<h1>More Details</h1>
<p>Note if you are in an area with ore XBee modules, then more configuration will be required to prevent all pairs from interfering with others.</p>
<h2>Jumper meanings</h2>
<p>When loading the Arduino while the XBee shield is attached, ensure the pins are in the USB position. Here’s a table of the <a href="http://www.arduino.cc/en/Main/ArduinoXbeeShield">explanation of jumper settings</a>:</p>
<table>
<thead>
<tr>
<th>Position</th>
<th>Meaning</th>
<th>Connections</th>
<th>Connections</th>
</tr>
</thead>
<tbody>
<tr>
<td>Inward</td>
<td>XBee</td>
<td>Xbee.DOUT = Micro.RX = FTDI.TX</td>
<td>Xbee.DIN = Micro.TX = FTDI.RX</td>
</tr>
<tr>
<td>Outward</td>
<td>USB</td>
<td>Xbee.DOUT = FTDI.RX</td>
<td>Xbee.DIN = FTDI.TX</td>
</tr>
</tbody>
</table>
<p><a href="http://www.flickr.com/photos/44415145@N00/4115096202/" title="XBee shield jumpers in XBee position "><img src="http://farm3.static.flickr.com/2753/4115096202_2fc8cfb962_m.jpg" width="240" height="135" alt="PFZ20-09787 XBee shield jumpers XBee" /></a></p>
<p><a href="http://www.flickr.com/photos/44415145@N00/4115095992/" title="XBee shield jumpers in USB position"><img src="http://farm3.static.flickr.com/2618/4115095992_d266af954f_m.jpg" width="240" height="135" alt="PFZ20-09786 XBee shield jumpers USB" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kwartzlab.ca/2009/11/arduino-xbee-communication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
