<?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>Seaside &#187; Android</title> <atom:link href="http://blog.blackwhale.at/category/android/feed/" rel="self" type="application/rss+xml" /><link>http://blog.blackwhale.at</link> <description>A weblog by Blackwhale about design, code and random stuff we care about.</description> <lastBuildDate>Tue, 10 Aug 2010 15:29:48 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Android Bluetooth on steroids with the NDK and bluez</title><link>http://blog.blackwhale.at/2009/08/android-bluetooth-on-steroids-with-the-ndk-and-bluez/</link> <comments>http://blog.blackwhale.at/2009/08/android-bluetooth-on-steroids-with-the-ndk-and-bluez/#comments</comments> <pubDate>Thu, 06 Aug 2009 09:24:37 +0000</pubDate> <dc:creator>Johannes</dc:creator> <category><![CDATA[Android]]></category> <category><![CDATA[I talk code]]></category> <category><![CDATA[Bluetooth]]></category> <category><![CDATA[Bluez]]></category> <category><![CDATA[NDK]]></category> <category><![CDATA[Serial]]></category> <category><![CDATA[SPP]]></category><guid
isPermaLink="false">http://blog.blackwhale.at/?p=216</guid> <description><![CDATA[NOTE: this is not a general solution and might not work on every phone or future version of the DKs, but it is still a great way for any prototyping purposes Unfortunately the SDK currently only supports a small set of the Bluetooth stack. As we wanted to integrate some of our hardware gadgets (over [...]]]></description> <content:encoded><![CDATA[<p><em>NOTE: this is not a general solution and might not work on every phone or future version of the DKs, but it is still a great way for any prototyping purposes <img
src='http://blog.blackwhale.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br
/> </em></p><p>Unfortunately the SDK currently only supports a small set of the Bluetooth stack. As we wanted to integrate some of our hardware gadgets (over SPP/RFCOMM) with our Dev Phone 1, we needed to digg a little deeper. So here is what you want to do to get it working.</p><p><span
id="more-216"></span></p><p>1) Follow the great article by <a
href="http://blog.bruary.net/2009/07/android-bluetooth-hacking-using-ndk.html">Stephan</a>, to get all the necessary libraries in place. His Bluescan app also provides a good starting point both for SDK and NDK integration.</p><p>2) Adapt the NDK specific code to talk to your device.</p><p>First allocate a socket</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;">s <span style="color: #000080;">=</span> socket<span style="color: #008000;">&#40;</span>PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div><p>Next you need to set who to connect to</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">struct</span> sockaddr_rc addr1 <span style="color: #000080;">=</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">char</span> dest<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">18</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;00:06:66:02:9D:39&quot;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//Device ID of your Bluetooth device</span>
addr1.<span style="color: #007788;">rc_family</span> <span style="color: #000080;">=</span> AF_BLUETOOTH<span style="color: #008080;">;</span>
addr1.<span style="color: #007788;">rc_channel</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>uint8_t<span style="color: #008000;">&#41;</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
str2ba<span style="color: #008000;">&#40;</span> dest, <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>addr1.<span style="color: #007788;">rc_bdaddr</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div><p>Now you can connect to the device</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;">status <span style="color: #000080;">=</span> connect<span style="color: #008000;">&#40;</span>s, <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">struct</span> sockaddr <span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;</span>addr1, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>addr1<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div><p>Thats pretty much it, you can start sending and receiving stuff with</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> status <span style="color: #000080;">&gt;=</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
  __android_log_write<span style="color: #008000;">&#40;</span>ANDROID_LOG_INFO,<span style="color: #FF0000;">&quot;SPP_COMM&quot;</span>,<span style="color: #FF0000;">&quot;Successfully connected&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  status <span style="color: #000080;">=</span> write<span style="color: #008000;">&#40;</span>s, <span style="color: #FF0000;">&quot;L1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #0000dd;">4</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  sleep<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  len1 <span style="color: #000080;">=</span> recv<span style="color: #008000;">&#40;</span>s,buf,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>buf<span style="color: #008000;">&#41;</span>,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>len1 <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> 
    __android_log_write<span style="color: #008000;">&#40;</span>ANDROID_LOG_INFO,<span style="color: #FF0000;">&quot;SPP_COMM&quot;</span>,buf<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #0000ff;">else</span>
    __android_log_write<span style="color: #008000;">&#40;</span>ANDROID_LOG_ERROR,<span style="color: #FF0000;">&quot;SPP_COMM&quot;</span>,<span style="color: #FF0000;">&quot;Nothing was received from the device&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>HTH<br
/> Enjoy<br
/> J.</p> ]]></content:encoded> <wfw:commentRss>http://blog.blackwhale.at/2009/08/android-bluetooth-on-steroids-with-the-ndk-and-bluez/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Android NDK logging</title><link>http://blog.blackwhale.at/2009/08/android-ndk-logging/</link> <comments>http://blog.blackwhale.at/2009/08/android-ndk-logging/#comments</comments> <pubDate>Wed, 05 Aug 2009 14:38:58 +0000</pubDate> <dc:creator>Johannes</dc:creator> <category><![CDATA[Android]]></category> <category><![CDATA[I talk code]]></category> <category><![CDATA[logcat]]></category> <category><![CDATA[Logging]]></category> <category><![CDATA[NDK]]></category><guid
isPermaLink="false">http://blog.blackwhale.at/?p=218</guid> <description><![CDATA[So after the first few mini steps into the NDK the first thing you will probably notice missing, is a way to retrieve log messages through logcat. To be able to do this you need to do two things: 1. Include log.h in your source files #include &#60;android/log.h&#62; 2. Be sure to add llog to [...]]]></description> <content:encoded><![CDATA[<p>So after the first few mini steps into the NDK the first thing you will probably notice missing, is a way to retrieve log messages through logcat. To be able to do this you need to do two things:</p><p><span
id="more-218"></span></p><p>1. Include log.h in your source files</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;android/log.h&gt;</span></pre></div></div><p>2. Be sure to add llog to your LOCAL_LDLIBS in the Android.mk file of your NDK code</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">LOCAL_LDLIBS := <span style="color: #660033;">-llog</span></pre></div></div><p>Now you are ready to log to logcat from you NDK code, simply via</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;">__android_log_write<span style="color: #008000;">&#40;</span>ANDROID_LOG_ERROR,<span style="color: #FF0000;">&quot;Tag&quot;</span>,<span style="color: #FF0000;">&quot;Message&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div><p>Further loglevels are</p><div
class="wp_syntax"><div
class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">enum</span> android_LogPriority <span style="color: #008000;">&#123;</span>
    ANDROID_LOG_UNKNOWN <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span>,
    ANDROID_LOG_DEFAULT,    <span style="color: #ff0000; font-style: italic;">/* only for SetMinPriority() */</span>
    ANDROID_LOG_VERBOSE,
    ANDROID_LOG_DEBUG,
    ANDROID_LOG_INFO,
    ANDROID_LOG_WARN,
    ANDROID_LOG_ERROR,
    ANDROID_LOG_FATAL,
    ANDROID_LOG_SILENT,     <span style="color: #ff0000; font-style: italic;">/* only for SetMinPriority(); must be last */</span>
<span style="color: #008000;">&#125;</span> android_LogPriority<span style="color: #008080;">;</span></pre></div></div><p>all the other stuff you can look up under</p><pre> build/platforms/android-1.5/common/include/android/log.h</pre><p>HTH</p><p>Enjoy<br
/> J.</p> ]]></content:encoded> <wfw:commentRss>http://blog.blackwhale.at/2009/08/android-ndk-logging/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Android Firmware Upgrade 1.5 on MacOS</title><link>http://blog.blackwhale.at/2009/06/android-firmware-upgrade-1-5-on-macos/</link> <comments>http://blog.blackwhale.at/2009/06/android-firmware-upgrade-1-5-on-macos/#comments</comments> <pubDate>Tue, 30 Jun 2009 18:51:22 +0000</pubDate> <dc:creator>Johannes</dc:creator> <category><![CDATA[Android]]></category> <category><![CDATA[I talk process]]></category><guid
isPermaLink="false">http://blog.blackwhale.at/?p=115</guid> <description><![CDATA[After finally getting a G1 from T-Mobile for testing purposes I quickly realized it is pretty useless if you want to do edge development because you are not allowed to upgrade the latest firmware (at least not straightforward because you need a signed version from T-Mobile). So I ordered an Android Dev Phone 1 which [...]]]></description> <content:encoded><![CDATA[<p>After finally getting a G1 from T-Mobile for testing purposes I quickly realized it is pretty useless if you want to do edge development because you are not allowed to upgrade the latest firmware (at least not straightforward because you need a signed version from T-Mobile). So I ordered an Android Dev Phone 1 which arrived incredibly fast and came in an incredibly unimaginative box that smelled like gummy bears <img
src='http://blog.blackwhale.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p><p>After unboxing I started the upgrade process, and as there of course were some minor complications I will outline the detailed steps here.</p><p><span
id="more-115"></span></p><p>1. Go to the <a
href="http://www.htc.com/www/support/android/adp.html">HTC Page</a> and download the newest Radio and Recovery Image, place them wherever you want just be sure they stay the zip they are meant to be.</p><p>2. Connect your Android Phone to your Mac and do not mount the SD Card.</p><p>3. Check if your device is connected by using</p><p>adb devices</p><p>4. Copy the Radio image to the SD Card by using</p><p>adb push &lt;radioimagename&gt;.zip /sdcard/update.zip</p><p>5. Be sure it is copied by using</p><p>adb shell sync</p><p>after this is returned everything is done.</p><p>The next step is to turn your Phone of by holding down the power button. After its turned of hold down the home button and turn it on again. Some moments after the android sign a ! accompanied by a triangle should appear now your are in recovery mode. Slide out the keyboard and press ALT + L, you now should see the recovery console. Now press ALT + S and you should see some command verifying the package etc&#8230; and a progress bar. After that press the Home and Back button (just press do not hold) to reboot the device, note only if you do exactly so the new radio image will be installed. It will display another Image (arrow and a chip) and reboot the system to normal mode after it is done.</p><p>Now you are half way through just repeat the steps above with the Recovery Image and you are done <img
src='http://blog.blackwhale.at/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://blog.blackwhale.at/2009/06/android-firmware-upgrade-1-5-on-macos/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 10/19 queries in 0.002 seconds using disk

Served from: blog.blackwhale.at @ 2010-09-08 14:26:38 -->