<?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>Techronicles</title>
	<atom:link href="http://infinilogix.com/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://infinilogix.com/wordpress</link>
	<description>A Software Developer's Journal</description>
	<lastBuildDate>Mon, 22 Feb 2010 20:28:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Broadcom Bluetooth SDK Programming with Perl and Inline C++</title>
		<link>http://infinilogix.com/wordpress/perl/broadcom-bluetooth-sdk-programming-with-perl-and-inline-c</link>
		<comments>http://infinilogix.com/wordpress/perl/broadcom-bluetooth-sdk-programming-with-perl-and-inline-c#comments</comments>
		<pubDate>Thu, 11 Feb 2010 04:49:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Bluetooth Programming]]></category>
		<category><![CDATA[Broadcom SDK]]></category>
		<category><![CDATA[Perl Inline CPP]]></category>
		<category><![CDATA[Syba Bluetooth]]></category>

		<guid isPermaLink="false">http://infinilogix.com/wordpress/?p=55</guid>
		<description><![CDATA[Broadcom Bluetooth SDK can be used to program Broadcom based bluetooth adapters.]]></description>
			<content:encoded><![CDATA[<p>I bought a <a title="Syba Bluetooth Adapter" href="http://www.amazon.com/Syba-SD-ADA23006-Bluetooth-Broadcom-Chipset/dp/B002S53IHM" target="_blank">Syba USB Bluetooth 2.0 dongle adapter</a> from Amazon recently in an attempt to bluetooth enable my aging home PC. This adapter has a Broadcom 2045 wireless chip. If you have one of those new bluetooth enabled smartphones, you can do a lot of cool things with a bluetooth connection to your PC like synchronizing messages, tasks and contacts with Outlook, transfer files with the help of an OBEX file transfer client on your phone, play music from your phone on the PC speakers among other things.</p>
<p>Broadcom has published their bluetooth SDK which can be downloaded at:</p>
<p><a href="http://www.broadcom.com/support/bluetooth/sdk.php">http://www.broadcom.com/support/bluetooth/sdk.php</a></p>
<p>using which you can do quite a bit of bluetooth programming to control Broadcom bluetooth adapters. Since the SDK has source header files for C++ it is most natural to use C++ to call the APIs &#8211; but you don&#8217;t have to. Perl is my choice scripting language for this kind of explorations. I found that Perl has an inline CPP module that will allow you to embed C++ code snippets in your Perl program. Of course you need a C++ compiler installed on your PC to make use of this module. On Windows platform your inline  C++ code gets compiled into a DLL which will get called at run time by your Perl code.</p>
<p>I thought it is a cool way to do my bluetooth programming. I can write the core functionality in C++ classes and then instantiate those classes from Perl and call their methods. I use Microsoft Visual C++ 6.0 compiler. Below is the sample code for listing all bluetooth enabled devices in your PC&#8217;s neighborhood. To compile and run it you will need:</p>
<ul>
<li>Microsoft Visual C++ compiler (or any other suitable C++ compiler. Modify the include and library paths accordiningly.)</li>
<li>Perl with <a title="Perl Inline CPP Module" href="http://search.cpan.org/~neilw/Inline-CPP-0.25/lib/Inline/CPP.pod" target="_blank">Inline CPP</a> Module</li>
<li>Broadcom Bluetooth SDK and (of course)</li>
<li>Bluetooth Adapter with Broadcom chip connected to your PC</li>
</ul>
<p>Don&#8217;t forget to change the include and library paths to point to the appropriate locations in your environment. Download Perl source code here: <a title="Download Source Code" href="http://infinilogix.com/downloads/btoothcpp.zip" target="_blank">http://infinilogix.com/downloads/btoothcpp.zip</a></p>
<pre>#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE;

use Inline CPP =&gt; Config =&gt;

LIBS =&gt; '-l"T:\Widcomm\BTW DK\SDK\Release\WidcommSdklib.lib" \
 -L"C:\Program Files\Microsoft Visual Studio\VC98\Lib"',

INC =&gt; '-I"T:\Widcomm\BTW DK\SDK\Inc"',

CCFLAGS =&gt; '-TP -LD -I"T:\Widcomm\BTW DK\SDK\Inc" \
 -nologo -GF -W3 -D_M_M68K -O1 -DWIN32 -D_CONSOLE \
 -D_AFXDLL -D_BTWLIB -DNO_STRICT -DHAVE_DES_FCRYPT \
 -DNO_HASH_SEED  -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT \
 -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',

LDDLFLAGS =&gt; '/DLL /libpath:"C:\Perl\lib\CORE" \
 /libpath:"T:\Widcomm\BTW DK\SDK\Release" \
 /libpath:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" \
 /nodefaultlib:"msvcrt.lib"',

BUILD_NOISY =&gt;1;

use Inline CPP =&gt; &lt;&lt;'EOC';

//Some of the functionality below has been adapted from
//Broadcom Bluetooth SDK.
//Copyright (c) 2000-2006, Broadcom Corporation.

#include "BtIfDefinitions.h"
#include "BtIfClasses.h"
#define CHAR_0 '0'
#define CHAR_CAP_A 'A'
#define CHAR_CAP_F 'F'
#define CHAR_A 'a'
#define CHAR_F 'f'
class CDeviceInfo
{
public:
    CDeviceInfo(BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn)
 {
  memcpy (bd_addr, bda, BD_ADDR_LEN);
  memcpy (dev_class, dc, DEV_CLASS_LEN);
  memcpy (bd_name, bdn, BD_NAME_LEN);

  pNext       = NULL;
  m_nServices = 0;
  m_hFtp      = 0;
  m_sSPPPort  = 0;
  m_sLAPPort  = 0;
  m_sDUNPort  = 0;
  m_sFAXPort  = 0;
 }

    CDeviceInfo *pNext;

    BD_ADDR   bd_addr;
    DEV_CLASS dev_class;
    BD_NAME   bd_name;

    int       m_nServices;
    long      m_hFtp;
 short     m_sSPPPort;
 short     m_sLAPPort;
 short     m_sDUNPort;
 short     m_sFAXPort;
};

class Test : public CBtIf
{

public:
 Test():CBtIf() { }
 ~Test() { }

 /* init() will start the device enquiry */

 char* init()
 {
  ok = 0;
  pFirstDeviceInfo = NULL;
  StartInquiry();
  return "Success";
 }

 /* Are we done with all devices in the neighborhood? */
 int Done()
 {
   return ok;
 }

 /* Get the first device in the list of devices we found */
 char* GetFirstDevice()
 {
   return pFirstDeviceInfo?(LPSTR)pFirstDeviceInfo-&gt;bd_name:NULL;
 }

 /* Get the next device in the list of devices we found */
 char* GetNextDevice()
 {
   pCurrDeviceInfo = pCurrDeviceInfo-&gt;pNext?
                         pCurrDeviceInfo-&gt;pNext:NULL;
   return pCurrDeviceInfo?
               (LPSTR)pCurrDeviceInfo-&gt;bd_name:NULL;
 }

private:
 int ok;
 CDeviceInfo *pFirstDeviceInfo;
 CDeviceInfo *pCurrDeviceInfo;

 /* Callback method that gets called when
  a device responds to our query */

  void OnDeviceResponded(BD_ADDR p_bda,
 DEV_CLASS dev_class,
 BD_NAME bd_name,
 BOOL bConnected)
  {
    CDeviceInfo *pDeviceInfo;

// Check if this is an update for an already known device
    for (pDeviceInfo = pFirstDeviceInfo;
          pDeviceInfo;
          pDeviceInfo = pDeviceInfo-&gt;pNext)
    {
      if (!memcmp (pDeviceInfo-&gt;bd_addr, p_bda, BD_ADDR_LEN))
      break;
    }

    BOOL new_item = FALSE;

//We have found a new device. Add it to our linked list.
    if (!pDeviceInfo)
    {
      new_item = TRUE;

      pDeviceInfo = new CDeviceInfo (p_bda, dev_class, bd_name);
      if (!pFirstDeviceInfo)
        pFirstDeviceInfo = pCurrDeviceInfo = pDeviceInfo;
      else
      { CDeviceInfo *p;
        for (p = pFirstDeviceInfo; p-&gt;pNext; p = p-&gt;pNext)
        ;
        p-&gt;pNext = pDeviceInfo;
      }
    }
  }

  /* Callback method that gets called when
     the query has completed */
  void OnInquiryComplete (BOOL success,
        short num_responses)
  {
    ok = 1;
  }

  /* Utility method to convert from a hex string to int */
  WORD axtoi(char *pch)
  {
    register char ch;
    register WORD n = 0;

    while((ch = *pch++) != 0)
    {
      if (isdigit(ch))
       ch -= CHAR_0;
      else if (ch &gt;= CHAR_CAP_A &amp;&amp; ch &lt;= CHAR_CAP_F)
       ch += (char)(10 - CHAR_CAP_A);
      else if (ch &gt;= CHAR_A &amp;&amp; ch &lt;= CHAR_F)
       ch += (char)(10 - CHAR_A);
      else
       break; //ch = (char)0;
      n = 16 * n + ch;
    }
    return n;
  }

  BOOL string2BDAddr(BD_ADDR bdAddr, char *lpbdAddrString)
  {
    if ( strlen(lpbdAddrString) != (BD_ADDR_LEN * 3 - 1))
      return FALSE;

    for (int i = 0; i&lt;BD_ADDR_LEN; i++)
      bdAddr[i] = (char)axtoi(&amp;lpbdAddrString[i *3]);
    return TRUE;
  }

};
EOC

my $t = new Test;

my $result = $t-&gt;init();

while (!$t-&gt;Done())
{
 Win32::OLE-&gt;SpinMessageLoop();
}

my $dev = $t-&gt;GetFirstDevice();
while($dev)
{
 print "$dev\n";
 $dev = $t-&gt;GetNextDevice();
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://infinilogix.com/wordpress/perl/broadcom-bluetooth-sdk-programming-with-perl-and-inline-c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Dialing with Google Voice</title>
		<link>http://infinilogix.com/wordpress/web-programming/automated-dialing-with-google-voice</link>
		<comments>http://infinilogix.com/wordpress/web-programming/automated-dialing-with-google-voice#comments</comments>
		<pubDate>Wed, 10 Feb 2010 06:57:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Macros & Scripts]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Excel Macro]]></category>
		<category><![CDATA[Google Voice]]></category>
		<category><![CDATA[GV Dialer]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://infinilogix.com/wordpress/?p=50</guid>
		<description><![CDATA[I was able to get my Google Voice number last week. It is wonderful to be able to make free US and Canada calls with GV. The only downside being you have to first login to your GV account to use their dialer or select a contact from your Google Contacts address book. I thought [...]]]></description>
			<content:encoded><![CDATA[<p>I was able to get my Google Voice number last week. It is wonderful to be able to make free US and Canada calls with GV. The only downside being you have to first login to your GV account to use their dialer or select a contact from your Google Contacts address book. I thought it would be nice if I could dial a contact right from a spreadsheet on my PC desktop without first logging into my GV account.</p>
<p>To do that I created a Microsoft Excel spreadsheet which can store all my contacts. I wrote Excel VB macros to do the login and dialing using my GV account. Double clicking on any cell that contains a phone number would dial that number using my GV account.</p>
<p>You may download the spreadsheet from the link below. You have to have macros enabled in Excel to make use of this spreadsheet. First time you open the spreadsheet you will be prompted to enter your GV user id and password which will be stored in hidden cells for future use. So be careful not to share this spreadsheet with others. In case you don&#8217;t want to store your credentials in the spreadsheet, before you save the spreadsheet you can click the &#8216;Clear Credentials&#8217; button which will clear your user id and password.</p>
<p><a href="http://infinilogix.com/downloads/Contacts.xls" target="_blank">http://infinilogix.com/downloads/Contacts.xls</a></p>
<p>Disclaimer: The spreadsheet is provided as is without any warranty about its usability or performance. It has only been tested using MS Excel 2003 though it should work with other versions too. But I cannot guarantee that.</p>
]]></content:encoded>
			<wfw:commentRss>http://infinilogix.com/wordpress/web-programming/automated-dialing-with-google-voice/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Control Access Restriction Rules in Tomato by a Shell Script</title>
		<link>http://infinilogix.com/wordpress/network-programming/routers/how-to-control-access-restriction-rules-in-tomato-by-a-shell-script</link>
		<comments>http://infinilogix.com/wordpress/network-programming/routers/how-to-control-access-restriction-rules-in-tomato-by-a-shell-script#comments</comments>
		<pubDate>Mon, 01 Feb 2010 05:34:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[Routers]]></category>
		<category><![CDATA[Access Restriction]]></category>
		<category><![CDATA[ASUS WL-520GU]]></category>
		<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[Tomato firmware]]></category>

		<guid isPermaLink="false">http://infinilogix.com/wordpress/?p=32</guid>
		<description><![CDATA[We can write shell scripts to control featues of a router running Tomato firmware. Here is an example.]]></description>
			<content:encoded><![CDATA[<p>This week I got some time to delve deeper into the <em>Access Restriction</em> rules on my ASUS WL-520GU router running Tomato firmware version 1.27. I wanted to write a Bourne Shell script to turn any given <em>Access Restriction</em> rule on or off. Access Restriction rules are coded as pipe (|) separated strings and stored in nvram variables named rrule0, rrule1, rrule2 etc. To see what is in the first rule we can issue the following command at the shell prompt in Tomato:</p>
<pre>nvram get rrule0</pre>
<p>The returned string might look something like:</p>
<pre>1|540|1140|62|||block-site.com$|0|New Rule 1</pre>
<p>Let us take a closer look at what each of these nine fields separated by pipe (|) means.</p>
<p>The first field shows whether the rule is currently enabled or disabled &#8211; 1 means enabled, 0 means disabled.</p>
<p>The second field gives the start time, i.e. the time to start applying this rule, in minutes elapsed since midnight. In the above example start time is 540 meaning the router should enforce this rule starting at 9am.  The third field is the end time, i.e. the time to stop applying this rule, again coded the same way as the start time. Both the second and third fields will be -1 if you select the option <em>&#8216;All Day&#8217;</em> in the control panel.</p>
<p>The fourth field is the days of week on which the rule should be applied and is coded in binary &#8211; 1 for Sunday, 2 for Monday, 4 for Tuesday and so on. For multiple days, add the corresponding numbers for each day. In the above example the fourth field is 62 which is equal to 2+4+8+16+32 &#8211; meaning the rule should be active on Mon, Tue, Wed, Thu, and Fri i.e. only on week days. If you had checked the option <em>Everyday</em> this value would be 127.</p>
<p>The fifth field shows the ip or mac address range in your network for which the rule should be applied &#8211; in case you don&#8217;t want all the computers on the network to be affected by this rule. The sixth field has the <em>Port/Application</em> information coded in it i.e. which ports numbers, protocols, layer 7 and p2p applications should be blocked by this rule.</p>
<p>The seventh field contains the domains or URLs you want to block and it partially supports regular expressions. In the above example, domain names ending in <em>block-site.com</em> are blocked. The eighth field stores as a binary coded value if ActiveX, Flash or Java need to  be blocked &#8211; 1 for ActiveX, 2 for Flash and 4 for Java. And finally the ninth field stores the name that you gave to this rule.</p>
<p>Now with this basic understanding about how the Access Restriction rules in Tomato work, we can write shell scripts to control the rules. Below is the script I wrote to enable or disable a rule. Two values are passed on the command line &#8211; the rule number and either a 0 or a 1 to disable or enable the service respectively. If you have <strong>jffs</strong> enabled in control panel you can copy the script under jffs directory and schedule it to run, if you want, as a cron job.</p>
<pre>#!/bin/sh

#Wait if any service is currently being restarted

nvstat=`nvram get action_service`
while [ "$nvstat" != "" ]; do
echo
done

#Assume we are going to enable the rule
enable=1

#Was a 1 or 0 passed on the command line?
[ "$2" != "" ] &amp;&amp; enable=$2

#Get the current setting of the rule.
#Rule number is passed as the first parameter on the command line.
rr=`nvram get rrule$1`

#Set the first field to the value in variable $enable
rr=$(echo $rr|sed "s/^./$enable/")
echo $rr

#Replace the old rule with the new value
nvram set rrule$1="$rr"

#Prepare to restart the service by killing the init process
nvram set action_service=restrict-restart

#kill the init process
kill -USR1 1

#Wait for the service to restart
while [ "`nvram get action_service`" == "restrict-restart" ]; do
echo
done</pre>
]]></content:encoded>
			<wfw:commentRss>http://infinilogix.com/wordpress/network-programming/routers/how-to-control-access-restriction-rules-in-tomato-by-a-shell-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring ASUS WL-520GU with Tomato</title>
		<link>http://infinilogix.com/wordpress/network-programming/routers/configuring-asus-wl-520gu-with-tomato</link>
		<comments>http://infinilogix.com/wordpress/network-programming/routers/configuring-asus-wl-520gu-with-tomato#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:09:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[Routers]]></category>
		<category><![CDATA[ASUS WL-520GU]]></category>
		<category><![CDATA[Teddy Bear mod]]></category>
		<category><![CDATA[Tomato firmware]]></category>

		<guid isPermaLink="false">http://infinilogix.com/wordpress/?p=16</guid>
		<description><![CDATA[Lessons learned while configuring ASUS WL-520GU router with Tomato firmware.]]></description>
			<content:encoded><![CDATA[<p>I recently bought an ASUS WL-520GU router from Newegg.com since I had serious problems with my NetGear WNR1000 router.  WNR1000 was dropping WLAN connections frequently and making my Blackberry reboot very often (for some strange reason). I couldn&#8217;t talk on my VoIP phone for more than a few minutes before it got disconnected.</p>
<p>ASUS WG54U has a built-in USB port to connect network strorage or printer and is DD-WRT ready. It cost me about $30 after a $10 rebate. I was originally planning to flash it with DD-WRT and did so. Later I found on some internet forums that Tomato has similar features plus more and a mod&#8217;ed version of Tomato called <a title="Teddy Bear" href="http://www.linksysinfo.org/forums/showthread.php?t=60185" target="_blank">Teddy Bear</a> supports USB drives and printers out of the box - all of this with a smaller memory foot print than DD-WRT.</p>
<p>Like DD-WRT, Tomato also is built on top of <a title="BusyBox" href="http://www.busybox.net/" target="_blank">BusyBox</a> embedded Linux. But unlike DD-WRT, Tomato configuration was not as smooth for me. Here are some of the lessons I learned in the process:</p>
<ul>
<li>Before flashing with Tomato, I did not select the option to <em>&#8216;Reset to Defaults&#8217;</em> on DD-WRT upgrade screen and did not note down the web admin password from nvram by issuing:
<pre style="padding-left: 30px;">nvram get http_passwd</pre>
<p>After flashing I could not login to Tomato web admin page  since DD-WRT encrypts password stored in nvram but Tomato does not.  Had to reinstall DD-WRT and check the option <em>&#8216;Reset to Defaults&#8217; </em>before re-flashing with Tomato.</li>
<li>Another problem was setting access restrictions (&#8216;Access Restriction&#8217; link on Tomato web admin page). I created a rule to block internet access from all computers on the home network from 9am to 7pm. Little did I realize that it will block all kinds of internet access &#8211; not just web access &#8211; and undermine my ability to access my home PC from outside. Had a tough time trying to figure out why Remote Desktop and ssh clients from my work PC are not able to access my home PC. So if you select <em>&#8216;Block All Internet Access&#8217;</em> option while creating an Access Restriction rule all incoming and outgoing connections from your home network will be blocked.</li>
<p></p>
<li>Then there was another problem &#8211; but totally unrelated to Tomato &#8211; that prevented ssh connection to my router using Putty and public key authentication. Putty kept giving me &#8216;Server unexpectedly closed the connection&#8217; error. It turned out that I had a badly formatted public key in my authorized_keys file in my &lt;home&gt;/.ssh directory on my home Linux server.  Removing the offending public_key made everything work like a charm.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://infinilogix.com/wordpress/network-programming/routers/configuring-asus-wl-520gu-with-tomato/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

