<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8574775355704977298</id><updated>2026-04-16T00:18:43.879-07:00</updated><category term="BREW"/><category term="Android"/><category term="J2ME"/><category term="Debugging"/><title type='text'>Mobile Maniac</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-3334156873201937798</id><published>2010-05-06T05:30:00.001-07:00</published><updated>2010-05-06T05:44:46.401-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Linux - Accessing SPI Bus from User Space - Part II</title><content type='html'>In this post we will see how to send and receive SPI messages to the device from userspace.&lt;br /&gt;&lt;br /&gt;You can open the SPI device by using the below function call.&lt;blockquote&gt;&lt;br /&gt;int fd = 0;&lt;br /&gt;fd = open(&quot;/dev/spidev2.0&quot;, O_RDWR);&lt;br /&gt;if (fd &lt; 0)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;SPI : can&#39;t open device&quot;);&lt;br /&gt;    return -1;&lt;br /&gt;}&lt;/blockquote&gt;You can now set the configuration for the SPI using ioctl calls.&lt;br /&gt;&lt;br /&gt;To set the SPI mode&lt;blockquote&gt;ret = ioctl(fd, SPI_IOC_WR_MODE, &amp;mode);&lt;br /&gt;if (ret == -1)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;SPI : can&#39;t set spi mode&quot;);&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;/blockquote&gt;To get the SPI mode&lt;br /&gt;&lt;blockquote&gt;ret = ioctl(fd, SPI_IOC_RD_MODE, &amp;mode);&lt;br /&gt;if (ret == -1)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;SPI : can&#39;t get spi mode&quot;);&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;/blockquote&gt;Other SPI Bus properties can be manipulated in the same way.&lt;br /&gt;&lt;br /&gt;Now the send a message over SPI Bus, You will need to fill up the message structure and pass it down.&lt;blockquote&gt;struct spi_ioc_transfer mesg[1] = { 0, };&lt;br /&gt;&lt;br /&gt;mesg[0].tx_buf = (unsigned long)out_buffer;&lt;br /&gt;mesg[0].len = num_out_bytes;&lt;br /&gt;&lt;br /&gt;ret = ioctl(fd, SPI_IOC_MESSAGE(1), mesg);&lt;/blockquote&gt;To receive SPI message&lt;blockquote&gt;struct spi_ioc_transfer mesg[1] = { 0, };&lt;br /&gt;&lt;br /&gt;mesg[0].rx_buf = (unsigned long)out_buffer;&lt;br /&gt;mesg[0].len = num_out_bytes;&lt;br /&gt;&lt;br /&gt;ret = ioctl(fd, SPI_IOC_MESSAGE(1), mesg);&lt;/blockquote&gt;There may be requirements where a write has to be followed by a read without toggling the Chip Select signal. You can form 2 messages as below to handle such situations.&lt;blockquote&gt;int spidev_if_write_read(unsigned int num_out_bytes,&lt;br /&gt;    unsigned char *out_buffer,&lt;br /&gt;    unsigned int num_in_bytes,&lt;br /&gt;    unsigned char *in_buffer)&lt;br /&gt;{&lt;br /&gt;    struct spi_ioc_transfer mesg[2] = { 0, };&lt;br /&gt;    uint8_t num_tr = 0;&lt;br /&gt;    int ret;&lt;br /&gt;&lt;br /&gt;    if((out_buffer != NULL) &amp;&amp; (num_out_bytes != 0))&lt;br /&gt;    {&lt;br /&gt; mesg[0].tx_buf = (unsigned long)out_buffer;&lt;br /&gt; mesg[0].rx_buf = (unsigned long)NULL;&lt;br /&gt; mesg[0].len = num_out_bytes;&lt;br /&gt; mesg[0].cs_change = 0;&lt;br /&gt; num_tr++;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if((in_buffer != NULL) &amp;&amp; (num_in_bytes != 0))&lt;br /&gt;    {&lt;br /&gt; mesg[1].tx_buf = (unsigned long)NULL;&lt;br /&gt; mesg[1].rx_buf = (unsigned long)in_buffer;&lt;br /&gt; mesg[1].len = num_in_bytes;&lt;br /&gt; num_tr++;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if(num_tr &gt; 0)&lt;br /&gt;    {&lt;br /&gt;  ret = ioctl(fd, SPI_IOC_MESSAGE(num_tr), mesg);&lt;br /&gt; if(ret == 1)&lt;br /&gt; {&lt;br /&gt;         return 1;&lt;br /&gt; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;/blockquote&gt;The variable cs_change=0 disables the change in CS signal state between the two transactions.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/3334156873201937798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/3334156873201937798' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3334156873201937798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3334156873201937798'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/05/linux-accessing-spi-bus-from-user-space_06.html' title='Linux - Accessing SPI Bus from User Space - Part II'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-6589752115368220106</id><published>2010-05-06T05:11:00.000-07:00</published><updated>2010-05-06T05:44:46.401-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Linux - Accessing SPI Bus from User Space - Part I</title><content type='html'>There needs to be a way to communicate with your hardware to write a complex device driver. In this post we will see how we can use the SPI Bus to communicate with the device from the user space.&lt;br /&gt;&lt;br /&gt;You`ll need to configure your kernel to enable the SPI communication from userspace.&lt;br /&gt;&lt;br /&gt;Let&#39;s first see the basic Kernel Configs needed to enable SPI support.&lt;br /&gt;CONFIG_SPI &lt;br /&gt;CONFIG_SPI_MASTER &lt;br /&gt;CONFIG_SPI_SPIDEV &lt;br /&gt;&lt;br /&gt;The CONFIG_SPI_SPIDEV enables the Userspace SPI framework for us.&lt;br /&gt;&lt;br /&gt;Most Processors comes with a built in SPI Bus Module for greater performance and ease of use. If your platform happens to have one with a matching linux device driver. Enable the appropriate config.&lt;br /&gt;&lt;br /&gt;E.g) For OMAP24xx or OMAP34xx Platforms you`ll need to enable CONFIG_SPI_OMAP24XX to use the inbuilt McSPI module of the processor.&lt;br /&gt;&lt;br /&gt;You will now need to configure your board file to export the SPI bus to Userspace.&lt;br /&gt;&lt;br /&gt;Add this piece of code in your board*.c file.&lt;br /&gt;&lt;blockquote&gt;/* Structure for configuing McSPI */&lt;br /&gt;static struct spi_board_info board_spi3_board_info[] = {&lt;br /&gt; {&lt;br /&gt;  .modalias = &quot;spidev&quot;,    /* Expose spi to userspace */&lt;br /&gt;  .max_speed_hz = 500000,      /* SPI Speed. */ &lt;br /&gt;  .bus_num = 3,           /* McSPI Bus Number */  &lt;br /&gt;  .chip_select = 0,           /* ChipSelect for McSPI */  &lt;br /&gt;  .mode  = 0,           /* SPI Mode */  &lt;br /&gt; },&lt;br /&gt;};&lt;/blockquote&gt;&lt;br /&gt;and add register the SPI bus in the board_init function in the board*.c file.&lt;br /&gt;&lt;blockquote&gt;/*Register SPI device*/&lt;br /&gt;spi_register_board_info(board_spi3_board_info, ARRAY_SIZE(board_spi3_board_info));&lt;/blockquote&gt;&lt;br /&gt;Now, when you boot up your system. You should see your spi device in the filesystem at /dev path.&lt;br /&gt;e.g) /dev/spidev2.0 ( 2 - SPI bus number, 0 - Chip Select)&lt;br /&gt;&lt;br /&gt;We can use the standard open,read,write and close api&#39;s along with /dev/spidevx.y device to send and receive SPI messages to the device.&lt;br /&gt;&lt;br /&gt;In the next post we`ll see how to use the /dev/spidevx.y to send and receive messages.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/6589752115368220106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/6589752115368220106' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6589752115368220106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6589752115368220106'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/05/linux-accessing-spi-bus-from-user-space.html' title='Linux - Accessing SPI Bus from User Space - Part I'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-5719461357265863568</id><published>2010-03-24T00:01:00.000-07:00</published><updated>2010-03-24T00:25:34.152-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Linux - Accessing GPIO from User Space</title><content type='html'>The Linux Kernel offers the GPIOLIB interface to access the GPIO pins from the User Space. To enable the GPIOLIB interface make sure you compile your kernel with the following options.&lt;br /&gt;&lt;blockquote&gt;CONFIG_ARCH_REQUIRE_GPIOLIB&lt;br /&gt;CONFIG_GPIOLIB&lt;br /&gt;CONFIG_GPIO_SYSFS&lt;/blockquote&gt;Now, you can able to access and manipulate the GPIO&#39;s from the User Space using the standard C calls such as Open, Write, Read, Close etc.&lt;br /&gt;&lt;br /&gt;Before manipulating the GPIO the specific GPIO pins has to be exported and configured appropriately. Each GPIO on the Processor will have a unique number, please refer to the processor manual.&lt;br /&gt;&lt;br /&gt;To export an GPIO you need to open the export interface of the GPIOLIB and write the GPIO number you want to export.&lt;br /&gt;&lt;blockquote&gt;int exportfd;&lt;br /&gt;exportfd = open(&quot;/sys/class/gpio/export&quot;, O_WRONLY);&lt;br /&gt;if (exportfd &lt; 0)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;Cannot open GPIO to export it %d\n&quot;, errno);&lt;br /&gt;    return -1;&lt;br /&gt;}&lt;/blockquote&gt;&lt;br /&gt;Write the GPIO you want to export and close the export interface.&lt;br /&gt;&lt;blockquote&gt;write(exportfd, &quot;149&quot;, 4);&lt;br /&gt;close(exportfd)&lt;/blockquote&gt;&lt;br /&gt;Next, You will need to configure the direction of the GPIO using the direction interface of GPIOLIB.&lt;br /&gt;&lt;blockquote&gt;int directionfd;&lt;br /&gt;directionfd = open(&quot;/sys/class/gpio/gpio149/direction&quot;, O_RDWR);&lt;br /&gt;if (directionfd &lt; 0)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;Cannot open GPIO direction for 149\n&quot;);&lt;br /&gt;    return -1;&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Write &quot;in&quot; if the GPIO is input or &quot;out&quot; if the GPIO is output and close the interface.&lt;br /&gt;&lt;blockquote&gt;write(directionfd, &quot;out&quot;, 4);&lt;br /&gt;close(directionfd)&lt;/blockquote&gt;&lt;br /&gt;You can now use the value interface of GPIOLIB to set/clear the GPIO pin.&lt;br /&gt;To make the GPIO line High&lt;br /&gt;&lt;blockquote&gt;int valuefd;&lt;br /&gt;valuefd = open(&quot;/sys/class/gpio/gpio149/value&quot;, O_RDWR);&lt;br /&gt;if (valuefd &lt; 0)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;Cannot open GPIO value for 149\n&quot;);&lt;br /&gt;    return -1;&lt;br /&gt;}&lt;br /&gt;write(valuefd, &quot;1&quot;, 2);&lt;br /&gt;close(valuefd);&lt;/blockquote&gt;&lt;br /&gt;To make the GPIO line Low&lt;br /&gt;&lt;blockquote&gt;int valuefd;&lt;br /&gt;valuefd = open(&quot;/sys/class/gpio/gpio149/value&quot;, O_RDWR);&lt;br /&gt;if (valuefd &lt; 0)&lt;br /&gt;{&lt;br /&gt;    printf(&quot;Cannot open GPIO value for 149\n&quot;);&lt;br /&gt;    return -1;&lt;br /&gt;}&lt;br /&gt;write(valuefd, &quot;0&quot;, 2);&lt;br /&gt;close(valuefd);&lt;/blockquote&gt;&lt;br /&gt;You can use the read() function to read the state of the GPIO.&lt;br /&gt;&lt;br /&gt;In the next post we will see how to pass the interrupts from Kernel Space to User Space.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/5719461357265863568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/5719461357265863568' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5719461357265863568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5719461357265863568'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/03/linux-accessing-gpio-from-user-space.html' title='Linux - Accessing GPIO from User Space'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-6724171422778762833</id><published>2010-03-23T23:51:00.000-07:00</published><updated>2010-03-24T00:25:34.152-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Linux - User Space Device Drivers</title><content type='html'>The device drivers for Linux are best written in the Kernel Space to take advantage of the Kernel API&#39;s that are not available to the User space. However, there are reasons to write device drivers in user space. The advantage being you don&#39;t have to recompile and deploy the kernel for every change and possibility of having different licensing options etc.&lt;br /&gt;&lt;br /&gt;The Linux Kernel offers some basic infrastructure to write a device driver in the User Space. The common basic requirement to write an device driver is the access to Interrupts, GPIO and some form of communication Bus (SPI / I2C).&lt;br /&gt;&lt;br /&gt;In the subsequent posts we will see how to access each of hardware resource from the User Space.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/6724171422778762833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/6724171422778762833' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6724171422778762833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6724171422778762833'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/03/android-linux-user-space-device-drivers.html' title='Linux - User Space Device Drivers'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-5957601116061968364</id><published>2010-03-13T22:09:00.000-08:00</published><updated>2010-03-13T22:45:03.665-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Creating an Android Executable</title><content type='html'>Creating an Android executable is easy and straight forward with the Android source. Android is not GNU/Linux and it does not have access to standard glibc functions. Instead, android has its own C runtime called bionic. Your executable has to be linked with the bionic libraries instead of standard glibc.&lt;br /&gt;&lt;br /&gt;The Android Build System searches every sub folder for Android.mk and executes it. The  macros defined by the Android Build System makes sure that your executable are linked with the right libraries.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Steps for creating the android executable&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Create a folder for your program in the Android Tree. If you not sure on where to create it put it under system folder.&lt;br /&gt;&lt;br /&gt;2. Create a basic Android.mk file with the below contents.&lt;br /&gt;&lt;blockquote&gt;LOCAL_PATH:= $(call my-dir)&lt;br /&gt;include $(CLEAR_VARS)&lt;br /&gt;&lt;br /&gt;LOCAL_SRC_FILES:= \&lt;br /&gt; my_program.c \&lt;br /&gt; my_program_1.c &lt;br /&gt;&lt;br /&gt;LOCAL_SHARED_LIBRARIES := \&lt;br /&gt; libcutils \&lt;br /&gt; liblog&lt;br /&gt;&lt;br /&gt;LOCAL_MODULE:= myprogram&lt;br /&gt;&lt;br /&gt;include $(BUILD_EXECUTABLE)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;3. Add you program&#39;s C files in the macro LOCAL_SRC_FILES.&lt;br /&gt;&lt;br /&gt;4. Build and Flash the Android Source.&lt;br /&gt;&lt;br /&gt;You should see your program &quot;myprogram&quot; under /system/bin folder.&lt;br /&gt;&lt;br /&gt;You can launch you program using the Terminal Emulator application inside the Android Device OR connect the device with adb and execute from the adb shell.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/5957601116061968364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/5957601116061968364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5957601116061968364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5957601116061968364'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/03/creating-android-executable.html' title='Creating an Android Executable'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-6847838516164958357</id><published>2010-03-13T22:01:00.000-08:00</published><updated>2010-03-13T22:45:03.666-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Android on BeagleBoard</title><content type='html'>It has been a long long break and I am back with some experience on Android Device Drivers. I`ll follow up with more posts on writing code for Android Platform.&lt;br /&gt;&lt;br /&gt;Hardware:&lt;br /&gt;The BeagleBoard is a low cost OMAP3 developement platform from TI. Visit &lt;a href=&quot;http://www.beagleboard.org&quot;&gt;www.beagleboard.org&lt;/a&gt;. The BeagleBoard runs variety of software including Linux, Android, Symbian, Win CE etc. It comes with an expansion header for connecting your custom Hardware.&lt;br /&gt;&lt;br /&gt;Software:&lt;br /&gt;The Android distro that is used with BeagleBoard is called 0xdroid from 0xlabs. Visit &lt;a href=&quot;http://code.google.com/p/0xdroid/&quot;&gt;here&lt;/a&gt; for download and build instructions.&lt;br /&gt;&lt;br /&gt;You should be up and running in a day with your own build of 0xdroid on BeagleBoard.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/6847838516164958357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/6847838516164958357' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6847838516164958357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/6847838516164958357'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2010/03/android-on-beagleboard.html' title='Android on BeagleBoard'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-3866072875466532882</id><published>2009-05-01T01:46:00.000-07:00</published><updated>2009-05-01T02:28:28.607-07:00</updated><title type='text'>How to find the Java Platform of a Sony Ericsson Phone</title><content type='html'>The Java platform of the Sony Ericsson phones tells you about the capability and supported API&#39;s of Java Platform. e.g. the retrieval of cmcc, cmnc, lac and cellid using the System.getProperty is supported from Java Platform JP 7.3 and above. The Capuchin API&#39;s are supported from JP 8.4 and above.&lt;br /&gt;&lt;br /&gt;To find you Java Platform, Open the service menu by pressing the below key sequence from the standby screen&lt;br /&gt;&gt;*&lt;&lt;*&lt;*&lt;br /&gt;( &gt; - right key in the navigation keypad, &lt; - left key in navigation keypad )&lt;br /&gt;&lt;br /&gt;Service Menu -&gt; Service Info -&gt; Software Info -&gt; Scroll down for Java SW Version.&lt;br /&gt;&lt;br /&gt;In you Java program you can find the JP version using &lt;br /&gt;System.getProperty(&quot;com.sonyericsson.java.platform&quot;)&lt;br /&gt;This API, works from JP 7.1, for earlier JP it returns null.&lt;br /&gt;&lt;br /&gt;Check out this &lt;a href=&quot;http://developer.sonyericsson.com/getDocument.do?docId=97267&quot;&gt;document &lt;/a&gt;to find the capabilities of the various Java Platforms.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/3866072875466532882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/3866072875466532882' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3866072875466532882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3866072875466532882'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2009/05/how-to-find-java-platform-of-sony.html' title='How to find the Java Platform of a Sony Ericsson Phone'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-8271628867245550664</id><published>2009-04-30T23:56:00.000-07:00</published><updated>2009-05-01T00:45:48.567-07:00</updated><title type='text'>Project Capuchin by Sony Ericsson</title><content type='html'>Sony Ericsson&#39;s Project Capuchin offers a lot of promise. It is a bridge between J2ME and Flash Lite. You could design your application using Adobe Flash CS3 Studio with all platform access to JAVA JSR&#39;s. The possibilities are endless. Imagine springing up a cool app with flashy animated UI in a few days. I will do more posts on this technology sooner. &lt;br /&gt;&lt;br /&gt;You can also visit the &lt;a href=&quot;http://developer.sonyericsson.com/site/global/docstools/projectcapuchin/p_projectcapuchin.jsp&quot;&gt;Project Capuchin webpage&lt;/a&gt; at Sony Ericsson Developer World.&lt;br /&gt;&lt;br /&gt;A nice &lt;a href=&quot;https://www.adobe.com/cfusion/event/index.cfm?event=register%5Fno%5Fsession&amp;loc=en%5Fus&amp;id=1356373&quot;&gt;webminar on Project Capuchin&lt;/a&gt; is available in Adobe website.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/8271628867245550664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/8271628867245550664' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/8271628867245550664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/8271628867245550664'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2009/04/project-capuchin-by-sony-ericsson.html' title='Project Capuchin by Sony Ericsson'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-1840728888361618671</id><published>2008-07-19T02:07:00.000-07:00</published><updated>2008-07-19T02:10:49.767-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>Sample BREW Applications</title><content type='html'>I stumbled upon the below link while searching for something else and found it quite usefull. The link contains a lot of sample BREW Applications ranging from ICipher to GPS and many more complex interfaces.&lt;br /&gt;&lt;br /&gt;&lt;a href=http://www.s-cradle.com/developer/itmedia/ITmedia_Mobile_BREW_Programming.html&gt;http://www.s-cradle.com/developer/itmedia/ITmedia_Mobile_BREW_Programming.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I hope you too would find it usefull.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/1840728888361618671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/1840728888361618671' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1840728888361618671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1840728888361618671'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/07/sample-brew-applications.html' title='Sample BREW Applications'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-1178882589977768783</id><published>2008-05-22T23:11:00.001-07:00</published><updated>2008-05-22T23:46:51.366-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><category scheme="http://www.blogger.com/atom/ns#" term="Debugging"/><title type='text'>Memory Leaks in BREW Applications</title><content type='html'>&lt;p&gt;The memory leaks are one of the worst possible nightmare for any developer, so for an BREW developer. If your application has memory leaks, it will make your application gradually slow and eventually fail at a random point and at a random time which makes it very difficult to debug.&lt;/p&gt;&lt;p&gt;Fortunately, BREW Simulator provides debug messages that will help us find the memory leaks in the code. The BREW Simulator will show &quot;Module failed to free all memory&quot; warning if you exit the application without freeing all the memory that are allocated and also it will print the BPOINT debug messages in the Output log window indicating the place where the memory leak is happening. If you are running the code in the phone, you can connect the BREW Logger to see the debug messages.&lt;/p&gt;&lt;p&gt;The following messages tells you that in testapp.c at line 338 and 339 memory is allocated which is not freed.&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;*OEMOS.c:581 - BPOINT Type 1, Node 0x027EF708 testapp&lt;br /&gt;*AEEHeap.c:1253 - ------ App Heap Info ------&lt;br /&gt;*AEEHeap.c:1155 - 256 - testapp #1336 d:\source\testapp.c:338 (L)&lt;br /&gt;*OEMOS.c:581 - BPOINT Type 1, Node 0x027EF838 mobistream&lt;br /&gt;*AEEHeap.c:1155 - 64 - testapp #1337 d:\source\testapp.c:339 (L)&lt;br /&gt;*AEEHeap.c:1267 - -------------------------&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;The problem with the most of the new developers is they are keen to make the functionality work without paying attention to best practices and designing. A little time to design before coding can save you a great deal of debugging time.&lt;br /&gt;&lt;br /&gt;Now, The most common reasons for memory leaks are&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Allocating memory using MALLOC and failing to FREE it.&lt;/li&gt;&lt;li&gt;Creating an instance and failing to release it.&lt;/li&gt;&lt;li&gt;Loading an Image from the resource file and failing to release it.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Allocating memory using MALLOC and failing to FREE it.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When you allocate memory for a variable make sure you free it somewhere. Sometimes even if you have freed the variable you might get a leak at that point. In such cases, the MALLOC may be called multiple times and the FREE is called just once. Make sure the number of calls to MALLOC matches the number of calls to FREE.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Creating an instance and failing to release it.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Every BREW Instance created must be released before exiting the application. If you have falied to release a instance even the BPOINT messages will not be usefull as it will point to some AEE files. Whatever that have been written for MALLOC/FREE will apply to CreateInstance/Release pair. Make sure the number of calls for CreateInstance for a variable matches the number of calls to Release of that variable. Use the safe release macro mentioned &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/common-reasons-for-application-crash-in.html&quot;&gt;here&lt;/a&gt; to avoid dangling pointers.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Loading an Image from the resource file and failing to release it.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When you load an image from a resource file using ISHELL_LoadResImage() or a equivalent API make sure you release the IImage pointer it returns after use. It is one such case of API&#39;s returning instances, another API is IADDRBOOK_EnumNextRec() which returns the IAddrRec, which should be released after use. In short, if you are getting a instance pointer from an API you have to  release the instance pointer after using it. The only exception to this behaviour is IDISPLAY_SetFont() for which the handling is different (see API ref for details).&lt;br /&gt;&lt;br /&gt;Please leave me a comment, if you have any feedback.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/1178882589977768783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/1178882589977768783' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1178882589977768783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1178882589977768783'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/05/memory-leaks-in-brew-applications.html' title='Memory Leaks in BREW Applications'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-5208854437568184138</id><published>2008-05-13T00:04:00.000-07:00</published><updated>2008-11-02T00:29:31.860-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="J2ME"/><title type='text'>Finding your Location without GPS in J2ME</title><content type='html'>Off late, the Location Based Services are the talk of town and truly the potential for those services are enormous. But the limiting factor for the wide spread use of LBS is the means of delivering those services. The best means I would say is through their mobile phones, thanks to the ever increasing penetration of the mobiles and nowadays it is hard to find anyone who is not having a mobile phone. The issue here is the finding the location of the mobile phone to deliver the required services. Sure, there are phones with GPS but they are not widespread and the effective alternative would be to use the mobie phone network to find the location of the phone.&lt;br /&gt;&lt;br /&gt;A GSM mobile phone keeps track of four parameters that can be used to find the approximate location of the mobile they are MCC (Mobile Country Code), MNC (Mobile Network Code), LAC (Location Area Code) and CellID. Combining these four paramenter you can zero in on mobile phone&#39;s location with an accuracy of 1KM (Urban areas) to 3KM (Sub-urban and rural areas), which is quiet sufficient for some Loaction Based Services.&lt;br /&gt;&lt;br /&gt;There are some websites that collects the cellid&#39;s across the globe like &lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.cellspotting.com/&quot;&gt;http://www.cellspotting.com/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.opencellid.com/&quot;&gt;http://www.opencellid.com/&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;or you can sure hop into your vehicle and roam around the city to make your own database.&lt;br /&gt;&lt;br /&gt;Now the gotchas, there is no way to extract the cellid information from most of the phones in the J2ME environment. But the sony ericsson has thoughtfully made the cellid information accessible in the J2ME environment, refer Page 72 of &lt;a href=&quot;http://developer.sonyericsson.com/getDocument.do?docId=65067&quot;&gt;SE Developer Guidelines Document&lt;/a&gt;. But it will work only on Sony Ericsson phones that has JAVA Platform 7.3 and above.&lt;br /&gt;&lt;br /&gt;Now, using the below APIs&#39; you can get the CellID information in your J2ME Application&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;strong&gt;For Home Network&lt;br /&gt;&lt;/strong&gt;System.getProperty(&quot;com.sonyericsson.net.mcc&quot;);&lt;br /&gt;System.getProperty(&quot;com.sonyericsson.net.mnc&quot;);&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;For current Network&lt;br /&gt;&lt;/strong&gt;System.getProperty(&quot;com.sonyericsson.net.cmcc&quot;);&lt;br /&gt;System.getProperty(&quot;com.sonyericsson.net.cmnc&quot;);&lt;br /&gt;&lt;br /&gt;System.getProperty(&quot;com.sonyericsson.net.cellid&quot;);&lt;br /&gt;System.getProperty(&quot;com.sonyericsson.net.lac&quot;); &lt;/blockquote&gt;&lt;p&gt;Now, there is a small but usefull application called &lt;a href=&quot;http://www.getjar.com/products/15373/LocationAlarm&quot;&gt;Location Alarm&lt;/a&gt; written based on the cellID information. Try it out.&lt;br /&gt;&lt;br /&gt;Post a comment if you have any queries.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/5208854437568184138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/5208854437568184138' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5208854437568184138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5208854437568184138'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/05/finding-you-location-without-gps-in.html' title='Finding your Location without GPS in J2ME'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-2737194563071357447</id><published>2008-04-28T03:56:00.000-07:00</published><updated>2008-04-28T04:10:03.454-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="J2ME"/><title type='text'>J2ME - HelloWorld Application</title><content type='html'>Recently I have been experimenting J2ME with my Sony Ericsson w710i. The simplicity of J2ME application is amazing.&lt;br /&gt;&lt;br /&gt;Let’s create a J2ME project first. Hope you have already installed the &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/getting-started-with-j2me-application.html&quot;&gt;Sun Java Wirless Toolkit for CLDC&lt;/a&gt;. Launch the CLDC KToolbar application. Select New Project. Give HelloWorld as Project Name and MIDlet Class name. It will show the Settings screen, go to the Required section and set the MicroEdition-Configuration and MicroEdition-Profile as per your phone. Select OK.&lt;br /&gt;&lt;br /&gt;The KToolBar would have generated your application folder structure inside the apps folder of your installation, if it is not there check out in the Documents and Settings folder, under your &amp;lt;login&amp;gt; folder it would have created the j2mewtk folder and stored you application there. You have to put all you sources in the &amp;lt;app_name&amp;gt;\src directory.&lt;br /&gt;&lt;br /&gt;Let’s create the main application class file. Create a text file in the name of HelloWorld.java in the src folder. It is really simple, you just need to have a class that extends the MIDlet class, now you have to implement the three basic function startApp, destroyApp, pauseApp. As the name suggests these are called when you Start, Destroy or Pause your application.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;import javax.microedition.midlet.*;&lt;br /&gt;import javax.microedition.lcdui.*;&lt;br /&gt;&lt;br /&gt;public class HelloWorld extends MIDlet&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;private Display display;&lt;br /&gt;   &lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void startApp()&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;display = Display.getDisplay(this);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void destroyApp(boolean unconditional) &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;notifyDestroyed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void pauseApp() &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;The function startApp() is called when you launch your application, the destroyApp() function is called when you close is application, notifyDestroyed() is called to notify the system that the application is closed. The pauseApp() function is called when the application is pause by System due to a interruption like incoming call or sms.&lt;br /&gt;&lt;br /&gt;The Display class is the highest object in the application, using display class you can show a Form in the screen.&lt;br /&gt;&lt;br /&gt;The basic screen component in J2ME is a Form. A Form can show UI Components, a Form can be shown / hide. Let’s add a Form to the application.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;br /&gt;import javax.microedition.midlet.*;&lt;br /&gt;import javax.microedition.lcdui.*;&lt;br /&gt;&lt;br /&gt;public class MyFirstApp extends MIDlet &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;private Display display;&lt;br /&gt;&amp;nbsp;&amp;nbsp;private Form mForm;&lt;br /&gt;    &lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void startApp() &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;display = Display.getDisplay(this);&lt;br /&gt;         &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mForm = new Form(&quot;Sample Application&quot;); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mForm.append(&quot;Hello World&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;display.setCurrent(mForm);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void destroyApp(boolean unconditional) &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;notifyDestroyed();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected void pauseApp() &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;That’s it. Now we have added a Form with a title “Sample Application” and text “Hello World”. The form will be displayed when the display.setCurrent(mForm); is called.&lt;br /&gt;&lt;br /&gt;Now you can Build the application and Run the application in the simulator. To see your app in the phone select Project-&gt;Package-&gt;Create Package, it will create the jad and jar file in the &amp;lt;app_name&amp;gt;\bin folder. Download the jar file to your phone via cable or Bluetooth and select the file in the phone. Follow the steps given in your phone to install and run the application.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/2737194563071357447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/2737194563071357447' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2737194563071357447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2737194563071357447'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/j2me-helloworld-application.html' title='J2ME - HelloWorld Application'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-2966739904176552856</id><published>2008-04-24T04:44:00.000-07:00</published><updated>2008-04-25T06:42:03.514-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>BREW Extensions Demystified - Part IV</title><content type='html'>Please read this &lt;a href=http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-iii.html&gt;post&lt;/a&gt; for context before moving on.&lt;br /&gt;&lt;br /&gt;We are almost there, now we need to create the supporting file mcbxml.bid and mcbxml.mif.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Creation of mcbxml.bid&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;#ifndef IMCBXML_BID&lt;br /&gt;#define IMCBXML_BID&lt;br /&gt;&amp;nbsp;&amp;nbsp;#define AEECLSID_MCBXML      0x3434CD1D&lt;br /&gt;#endif //IMCBXML_BID&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;strong&gt;Creation of mcbxml.mif&lt;/strong&gt;&lt;br /&gt;Launch the mif editor, go to the Extensions tab. In the Exported Classes section add the Class ID of the MCBXML i.e. 0x3434CD1D.&lt;br /&gt;&lt;br /&gt;Congratulations, You have successfully converted the McbXML to an BREW Extension. The complete project can be downloaded here.&lt;br /&gt;&lt;br /&gt;Now that you have successfully created your extension you might as well want to use it. To use the McbXML extension in a applicaion, include the IMcbXML.h in the applet&#39;s source file.&lt;br /&gt;&lt;br /&gt;To create the extension, declare the necessary varibles&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;IMcbXML *pIMcbXML;&lt;br /&gt;McbXMLElement *pRoot  = NULL;&lt;br /&gt;McbXMLElement *pElement = NULL;&lt;br /&gt;McbXMLResults pResults;&lt;br /&gt;ISHELL_CreateInstance(pIShell, AEECLSID_MCBXML,(void**)&amp;pIMcbXML); &lt;/span&gt;&lt;/blockquote&gt;Once you have successfully instantiated the extension, you can call the API&#39;s&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;pRoot = IMCBXML_ParseXML(pIMcbXML, szXMLString,amp;pResults);&lt;br /&gt;pElement = IMCBXML_FindElement(pIMcbXML, pMe-&gt;pXMLRoot,&lt;br /&gt;&quot;xml/soapenv:Envelope/soapenv:Body/Response&quot;);&lt;br /&gt;IMCBXML_DeleteRoot(pIMcbXML, pRoot);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;You can now extend the functionalities of the extension by adding more functions like McbCreateXMLString to the IMCBXML interface and providing the wrapper function just like IMCBXML_ParseXML function.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/2966739904176552856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/2966739904176552856' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2966739904176552856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2966739904176552856'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-iv.html' title='BREW Extensions Demystified - Part IV'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-4931179387069939174</id><published>2008-04-24T04:24:00.000-07:00</published><updated>2008-04-25T06:14:12.968-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>BREW Extensions Demystified - Part III</title><content type='html'>Please read this &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-ii.html&quot;&gt;post&lt;/a&gt; for context before moving on.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Creation of IMcbXML.c&lt;/strong&gt;&lt;br /&gt;The IMcbXML.c is the main source file for our extension, it is equivalent to AEEAppGen.c and AEEModGen.c in case of BREW Applets. This file implements instantiation of the extension, setting up of VTBL and reference counting.&lt;br /&gt;We need to create a class structure to hold our instance specific information such as our reference count, shell and module pointer.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;typedef struct McbXML{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;DECLARE_VTBL(IMcbXML)&lt;br /&gt;&amp;nbsp;&amp;nbsp;uint32 m_nRefs;&lt;br /&gt;&amp;nbsp;&amp;nbsp;IShell *m_pIShell; &lt;br /&gt;&amp;nbsp;&amp;nbsp;IModule *m_pIModule;&lt;br /&gt;};&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;Lets create the entry point for our extension, the all important AEEClsCreateInstance function.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po, void ** ppObj)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;*ppObj = NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if( ClsId == AEECLSID_MCBXML )&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( McbXML_New(sizeof(McbXML_t), pIShell, po, (IModule **)ppObj) == SUCCESS )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return AEE_SUCCESS;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;return EFAILED;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;The AEEClsCreateInstance is the entry point for the extension.&lt;br /&gt;The McbXML_New is the constructor function for our extension. It allocates the memory for the class structure and VTBL, sets up the VTBL with the function pointers and stores the IShell and IModule pointers.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;int McbXML_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;McbXML_t *pMe = NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;VTBL(IMcbXML) * modFuncs;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if( !ppMod !pIShell !pIModule )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return EFAILED;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;*ppMod = NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Allocate memory for the IMcbXML object &lt;br /&gt;&amp;nbsp;&amp;nbsp;if( nSize &lt; sizeof(McbXML_t) )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nSize += sizeof(McbXML_t);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if( (pMe = (McbXML_t*)MALLOC(nSize + sizeof(IMcbXMLVtbl))) == NULL )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return ENOMEMORY;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Allocate the vtbl and assign each function pointer to the correct&lt;br /&gt;&amp;nbsp;&amp;nbsp;// function address &lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs = (IMcbXMLVtbl *)((byte *)pMe + nSize); &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs-&gt;AddRef = McbXML_AddRef; &lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs-&gt;Release = McbXML_Release;&lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs-&gt;ParseXML = McbXML_ParseXML;&lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs-&gt;FindElement= McbXML_FindElement;&lt;br /&gt;&amp;nbsp;&amp;nbsp;modFuncs-&gt;DeleteRoot = McbXML_DeleteRoot;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//initialize the vtable &lt;br /&gt;&amp;nbsp;&amp;nbsp;INIT_VTBL(pMe, IModule, *modFuncs);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//We&#39;ve got one reference since this class is allocated &lt;br /&gt;&amp;nbsp;&amp;nbsp;pMe-&gt;m_nRefs = 1;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// initialize our internal member variables&lt;br /&gt;&amp;nbsp;&amp;nbsp;pMe-&gt;m_pIShell = pIShell;&lt;br /&gt;&amp;nbsp;&amp;nbsp;pMe-&gt;m_pIModule = pIModule;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//Add References to the interfaces we&#39;re using &lt;br /&gt;&amp;nbsp;&amp;nbsp;ISHELL_AddRef(pIShell);&lt;br /&gt;&amp;nbsp;&amp;nbsp;IMODULE_AddRef(pIModule);&lt;br /&gt;&amp;nbsp;&amp;nbsp;*ppMod = (IModule*)pMe;&lt;br /&gt;&amp;nbsp;&amp;nbsp;return AEE_SUCCESS;&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;Now, to manage our references we need to create the AddRef and Release functions.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;static uint32 McbXML_AddRef(IMcbXML * po)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return (++((McbXML_t *)po)-&gt;m_nRefs);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static uint32 McbXML_Release(IMcbXML * po)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;McbXML_t *pMe = (McbXML_t *)po;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//Decrease the number of references. If we still &lt;br /&gt;&amp;nbsp;&amp;nbsp;//have some references to this object, return &lt;br /&gt;&amp;nbsp;&amp;nbsp;//and do not free resources &lt;br /&gt;&amp;nbsp;&amp;nbsp;if(-pMe-&gt;m_nRefs != 0) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return pMe-&gt;m_nRefs;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Release interfaces&lt;br /&gt;&amp;nbsp;&amp;nbsp;ISHELL_Release(pMe-&gt;m_pIShell);&lt;br /&gt;&amp;nbsp;&amp;nbsp;IMODULE_Release(pMe-&gt;m_pIModule);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;//Free the object &lt;br /&gt;&amp;nbsp;&amp;nbsp;FREE_VTBL(pMe, IModule);&lt;br /&gt;&amp;nbsp;&amp;nbsp;FREE(pMe);&lt;br /&gt;&amp;nbsp;&amp;nbsp;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;As you can see the AddRef function increments the m_nRefs variable, the release function will Free up the memory when the reference count reaches zero. This reference counting mechanism prevents the release of an extension when it is still used by someone.&lt;br /&gt;&lt;br /&gt;Now, we need to create the wrapper function to call the actuan McbXML API&#39;s.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;static McbXMLElement* McbXML_ParseXML(IMcbXML *po, LPCTSTR lpszXML, McbXMLResults *pResults)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return McbParseXML(lpszXML, pResults);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static McbXMLElement* McbXML_FindElement(IMcbXML *po, McbXMLElement *pHead, LPCTSTR lpszName)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return McbFindElement(pHead, lpszName);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static void McbXML_DeleteRoot(IMcbXML *po, McbXMLElement * pElement)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;McbDeleteRoot(pElement);&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;In the next &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-iv.html&quot;&gt;post&lt;/a&gt; we will create the supporting BID and MIF file and see how to use our extension.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/4931179387069939174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/4931179387069939174' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4931179387069939174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4931179387069939174'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-iii.html' title='BREW Extensions Demystified - Part III'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-328759412183689392</id><published>2008-04-24T04:08:00.000-07:00</published><updated>2008-04-25T06:15:05.796-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>BREW Extensions Demystified - Part II</title><content type='html'>Please see &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-i.html&quot;&gt;this&lt;/a&gt; post for the context before moving on.&lt;br /&gt;&lt;br /&gt;The following files IMcbXML.c and IMcbXML.h needs to be created to convert the McbXML into a BREW Interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Creation of IMcbXML.h&lt;/strong&gt;&lt;br /&gt;The IMcbXML.h is the interface file for our extension, it is equivalent to AEEMenu.h or AEEText.h. To use the McbXML in a applet this header file must be included in the applet&#39;s source file.&lt;br /&gt;The most important component of an extenstion is the VTBL (vector table or virtual table). The VTBL is a structure that stores a set of function pointers.&lt;br /&gt;Lets create the VTBL structure for our extension.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;typedef struct _IMcbXML IMcbXML;&lt;br /&gt;QINTERFACE(IMcbXML)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;INHERIT_IBase(IMcbXML);&lt;br /&gt;};&lt;/span&gt;&lt;/blockquote&gt;If you expand the macros, it will become&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;br /&gt;typedef struct _IMcbXML IMcbXML;&lt;br /&gt;struct _IMcbXML {&lt;br /&gt;&amp;nbsp;&amp;nbsp;struct IMcbXMLVtbl *pvt;&lt;br /&gt;};&lt;br /&gt;typedef struct IMcbXMLVtbl IMcbXMLVtbl;&lt;br /&gt;struct IMcbXMLVtbl&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;uint32 (*AddRef) (IMcbXML*);&lt;br /&gt;&amp;nbsp;&amp;nbsp;uint32 (*Release) (IMcbXML*);&lt;br /&gt;};&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;The structure IMcbXMLVtbl is our VTVL structure, the _IMcbXML is our interface class structure. The AddRef and Release function pointers are a must to any interface, they are used for reference counting and to decide when to unload the extension from the memory. Let&#39;s add the XML Parsing functionality to the extension, for now we will add 2 API which are supported by McbXML.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;br /&gt;typedef struct _IMcbXML IMcbXML;&lt;br /&gt;QINTERFACE(IMcbXML)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;INHERIT_IBase(IMcbXML);&lt;br /&gt;&amp;nbsp;&amp;nbsp;McbXMLElement* (*ParseXML)(IMcbXML *po, LPCTSTR lpszXML, McbXMLResults *pResults);&lt;br /&gt;&amp;nbsp;&amp;nbsp;McbXMLElement* (*FindElement)(IMcbXML *po, McbXMLElement *pHead, LPCTSTR lpszName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;void (*DeleteRoot)(IMcbXML *po, McbXMLElement * pElement);&lt;br /&gt;};&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;Finally, now we need to create macros to the function pointers of the interface VTBL.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;br /&gt;#define IMCBXML_AddRef(p) GET_PVTBL(p,IMcbXML)-&gt;AddRef(p)&lt;br /&gt;#define IMCBXML_Release(p) GET_PVTBL(p,IMcbXML)-&gt;Release(p)&lt;br /&gt;#define IMCBXML_ParseXML(p, px, pr) GET_PVTBL(p,IMcbXML)-&gt;ParseXML(p, px, pr)&lt;br /&gt;#define IMCBXML_FindElement(p, ph, pp) GET_PVTBL(p,IMcbXML)-&gt;FindElement(p, ph, pp)&lt;br /&gt;#define IMCBXML_DeleteRoot(p, pe) GET_PVTBL(p,IMcbXML)-&gt;DeleteRoot(p, pe)&lt;/span&gt;&lt;/blockquote&gt;In the next &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-iii.html&quot;&gt;post&lt;/a&gt; will we will continue creating the IMcbXML.c file.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/328759412183689392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/328759412183689392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/328759412183689392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/328759412183689392'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-ii.html' title='BREW Extensions Demystified - Part II'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-4759914412982577232</id><published>2008-04-24T04:05:00.001-07:00</published><updated>2008-04-25T06:17:24.720-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>BREW Extensions Demystified - Part I</title><content type='html'>The BREW extensions are nothing but custom BREW interfaces developed for a specific purpose. Every BREW extension will have its own folder in the brew directory with its mod, mif, sig and bar files.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Difference between Applets and Extensions&lt;/strong&gt;&lt;br /&gt;The basic difference BREW applets and extensions are&lt;br /&gt;&lt;br /&gt;1. Applets are stand-alone BREW applications, whereas extensions are used by one or more applets for a specific functionality.&lt;br /&gt;2. Applets must provide the IApplet interface to the BREW for reference counting and handling of events. Extensions can have its own interface.&lt;br /&gt;3. Applets can be launched from BREW App Manager or ISHELL_StartApplet() or equivalent API&#39;s. Extensions are instantiated with ISHELL_CreateInstance().&lt;br /&gt;&lt;br /&gt;Note: An extensions privileges are same as the privileges of the applet in which the extension in instantiated. For example if you are using IFile API&#39;s in your extenstion, the applet which will be using your extension should have the File Persmisson.&lt;br /&gt;&lt;br /&gt;Now that you have the basic understanding of what are applets and extensions, In the following &lt;a href=&quot;http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-ii.html&quot;&gt;posts&lt;/a&gt; we will convert the McbXML by &lt;a href=&quot;http://www.codeguru.com/cpp/data/data-misc/xml/article.php/c4549/&quot;&gt;Martyn Brown &lt;/a&gt;as a IMCBXML BREW interface.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/4759914412982577232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/4759914412982577232' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4759914412982577232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4759914412982577232'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/brew-extensions-demystified-part-i.html' title='BREW Extensions Demystified - Part I'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-4249229920075488579</id><published>2008-04-23T02:29:00.000-07:00</published><updated>2008-04-23T03:01:13.450-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="J2ME"/><title type='text'>Getting started with J2ME Application Development</title><content type='html'>Of late I have started developing J2ME Applications in my spare time. I initially tried to learn Symbian / C++, but I am not quite comfortable with C++ and the Nokia emulators are a pile of crap. Since I own a Sony Ericsson W710i mobile phone, I can test the application on my phone itself :-). This is my first tryst with a interpreted programming language after BASIC in my good old high school days.&lt;br /&gt;&lt;br /&gt;To get the ball rolling, you`ll have to download and install the &lt;a href=&quot;http://java.sun.com/products/sjwtoolkit/download.html&quot;&gt;Sun Java Wireless Toolkit 2.5.2 for CLDC&lt;/a&gt;. The required JDK/JRE is also listed in the download page itself. There are loads of sample applications to test the water before jumping into development.&lt;br /&gt;&lt;br /&gt;The most basic radical differnce for me in J2ME compared against BREW is the memory management. There is no need to manage memory in J2ME, ofcourse there are best practices and guidelines to keep you memory utilization low but it wont crash the phone as BREW apps can do. You have the system garbage collector running whenever the phone is low on memory to reclaim the unused memory.&lt;br /&gt;&lt;br /&gt;I follow up with more posts on my experience with J2ME Apps.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/4249229920075488579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/4249229920075488579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4249229920075488579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/4249229920075488579'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/getting-started-with-j2me-application.html' title='Getting started with J2ME Application Development'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-8146179471855593078</id><published>2008-04-22T01:54:00.000-07:00</published><updated>2008-04-25T06:47:34.477-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>Using Webservices ( SOAP ) in BREW</title><content type='html'>This post deals with making the SOAP based Webservices API to work in the BREW environment. It is not intended to be a tutorial on SOAP or webservices.&lt;br /&gt;There has been a lot of confusion regarding whether the webservices API are supported in BREW or not. The correct answer is No, because BREW does not have a XML parser or a SOAP abstraction layer on its own, which is a critcal component for SOAP based webservices. However, if you are ready roll up your sleeves and get your hands dirty with low level stuff you can make SOAP based webservices work in BREW environment.&lt;br /&gt;The SOAP based webservices at it core are nothing but the exchange of XML messages in accordance with the WSDL document of the webservice being used. The sample webservice we will be using now is GetAtomicNumber Operation of Periodictable API provided by &lt;a href=&quot;http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=37&quot;&gt;Webservicex.net&lt;/a&gt;. The XML Parser used is a basic compact ANSI C XML parser written by &lt;a href=&quot;http://www.codeguru.com/cpp/data/data-misc/xml/article.php/c4549/&quot;&gt;Martyn Brown&lt;/a&gt; and modified to work in BREW environment.&lt;br /&gt;As mentioned above, to use the Periodic table webservice API, all we need to do is to POST a valid HTTP request using IWEB API with appropriate headers and the XML request as the body. The response we get will contain the result in XML format.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Request and Response XML&lt;/strong&gt;&lt;br /&gt;The structure of the XML messages to retrive the AtomicNumber of a given element is as below. In the SOAP Request the &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;query&lt;/span&gt; &lt;/span&gt;has to be a valid element name. In the SOAP Response the &lt;span style=&quot;color:#3366ff;&quot;&gt;value&lt;/span&gt; contains the result.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SOAP Request&lt;br /&gt;&lt;/strong&gt;&lt;blockquote&gt;&lt;strong&gt;Header Information&lt;br /&gt;&lt;/strong&gt;POST /periodictable.asmx &lt;br /&gt;HTTP/1.1&lt;br /&gt;Host: http://www.webservicex.net/&lt;br /&gt;Content-Type: text/xml; charset=utf-8&lt;br /&gt;Content-Length: length&lt;br /&gt;SOAPAction: &quot;&lt;a href=&quot;http://www.webservicex.net/GetAtomicNumber&quot;&gt;http://www.webserviceX.NET/GetAtomicNumber&lt;/a&gt;&quot;&lt;br /&gt;&lt;strong&gt;XML Request&lt;br /&gt;&lt;/strong&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;soap:Envelope xmlns:xsi=&quot;&lt;a href=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&quot;&lt;br /&gt;xmlns:xsd=&quot;&lt;a href=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;http://www.w3.org/2001/XMLSchema&lt;/a&gt;&quot;&lt;br /&gt;xmlns:soap=&lt;a href=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;lt;soap:Body&amp;gt;&lt;br /&gt;&amp;lt;GetAtomicNumber xmlns=&lt;a href=&quot;http://www.webservicex.net/&quot;&gt;&quot;http://www.webservicex.net&lt;/a&gt;/&quot;&amp;gt;&lt;br /&gt;&amp;lt;ElementName&amp;gt;&lt;span class=&quot;value&quot;  style=&quot;color:#3366ff;&quot;&gt;query&lt;/span&gt;&amp;lt;/ElementName&amp;gt;&lt;br /&gt;&amp;lt;/GetAtomicNumber&amp;gt;&lt;br /&gt;&amp;lt;/soap:Body&amp;gt;&lt;br /&gt;&amp;lt;/soap:Envelope&amp;gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;strong&gt;SOAP Response&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Header Information&lt;br /&gt;&lt;/strong&gt;HTTP/1.1 200 OK&lt;br /&gt;Content-Type:&lt;br /&gt;text/xml; charset=utf-8&lt;br /&gt;Content-Length: length&lt;br /&gt;&lt;strong&gt;XML Response&lt;br /&gt;&lt;/strong&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;soap:Envelope xmlns:xsi=&quot;&lt;a href=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&quot;&lt;br /&gt;xmlns:xsd=&quot;&lt;a href=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;http://www.w3.org/2001/XMLSchema&lt;/a&gt;&quot;&lt;br /&gt;xmlns:soap=&lt;a href=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;lt;soap:Body&amp;gt;&lt;br /&gt;&amp;lt;GetAtomicNumberResponse xmlns=&quot;&lt;a href=&quot;http://www.webservicex.net/&quot;&gt;&quot;http://www.webservicex.net/&quot;&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;lt;GetAtomicNumberResult&amp;gt;&lt;span class=&quot;value&quot;  style=&quot;color:#3366ff;&quot;&gt;value&lt;/span&gt;&amp;lt;/GetAtomicNumberResult&amp;gt;&lt;br /&gt;&amp;lt;/GetAtomicNumberResponse&amp;gt;&lt;br /&gt;&amp;lt;/soap:Body&amp;gt;&lt;br /&gt;&amp;lt;/soap:Envelope&amp;gt;&lt;/blockquote&gt;&lt;strong&gt;Making a SOAP Web Request in BREW.&lt;/strong&gt;You have to create the XML request and hold it in the buffer.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;char request[1024] = &quot;&amp;lt;soap:Envelope&lt;br /&gt;xmlns:xsi=\&quot;http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=\&quot;http://www.w3.org/2001/XMLSchema\&quot; xmlns:soap=\&quot;http://schemas.xmlsoap.org/soap/envelope/\&quot;&amp;gt; &amp;lt;soap:Body&amp;gt; &amp;lt;GetAtomicNumber xmlns=\&quot;http://www.webservicex.net/\&quot;&amp;gt;&lt;br /&gt;&amp;lt;ElementName&amp;gt;%s&amp;lt;/ElementName&amp;gt;&lt;br /&gt;&amp;lt;/GetAtomicNumber&amp;gt; &amp;lt;/soap:Body&amp;gt;&lt;br /&gt;&amp;lt;/soap:Envelope&amp;gt;&quot;;&lt;/span&gt;&lt;/blockquote&gt;The &lt;span style=&quot;color:#3333ff;&quot;&gt;%s&lt;/span&gt; in the element name tag has to be replaced by the name of the element for which the AtomicNumber is requested. The variable pszElement contains the name of the element. Now, prepare the ISource pointer for the request.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;ISHELL_CreateInstance(pMe-&gt;a.m_pIShell, AEECLSID_SOURCEUTIL, (void **)&amp;amp;(pMe-&gt;sourceUtil));&lt;br /&gt;nLen = SNPRINTF(NULL, 0, request, pszElement);&lt;br /&gt;pMe-&gt;postData = (char*)MALLOC(sizeof(char)*(nLen+1));&lt;br /&gt;SNPRINTF(pMe-&gt;postData, nLen, request, pszElement);&lt;br /&gt;ISOURCEUTIL_SourceFromMemory(pMe-&gt;sourceUtil, pMe-&gt;postData, nLen, NULL, NULL, &amp;amp;(pMe-&gt;source));&lt;/span&gt;&lt;/blockquote&gt;Now, initialize the callback and make the HTTP request using IWEB API.&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;CALLBACK_Init(&amp;amp;pMe-&gt;callback, webservices_GotResponse, pMe);&lt;br /&gt;IWEB_GetResponse(pMe-&gt;web, (pMe-&gt;web, &amp;amp;pMe-&gt;webresp, &amp;amp;pMe-&gt;callback, &quot;http://www.webservicex.net/periodictable.asmx&quot;,&lt;br /&gt;WEBOPT_HANDLERDATA, pMe, &lt;br /&gt;WEBOPT_METHOD,&quot;POST&quot;, &lt;br /&gt;WEBOPT_HEADER, &quot;Content-Type:text/xml\r\n SOAPAction:http://www.webserviceX.NET/GetAtomicNumber\r\n&quot;, &lt;br /&gt;WEBOPT_CONTENTLENGTH, pMe-&gt;postLen-1, &lt;br /&gt;WEBOPT_BODY, pMe-&gt;source, &lt;br /&gt;WEBOPT_HEADERHANDLER, webservices_PrintHeader,&lt;br /&gt;WEBOPT_STATUSHANDLER, webservices_PrintStatus,&lt;br /&gt;WEBOPT_END));&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;Once you have got the successfull response, you need to retrive the XML response sent by the server and parse it to get the result.&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;McbXMLResults pResults;&lt;br /&gt;McbXMLElement *pRoot = NULL;&lt;br /&gt;McbXMLElement *pResult = NULL;&lt;br /&gt;pRoot = McbParseXML(pMe-&gt;response, &amp;amp;pResults);&lt;br /&gt;pResult = McbFindElement(pRoot,&lt;br /&gt;&quot;xml/soap:Envelope/soap:Body/GetAtomicNumberResponse/GetAtomicNumberResult&quot;);&lt;/span&gt;&lt;/blockquote&gt;Now, the variable pResult-&gt;pEntries-&gt;node.pText-&gt;lpszValue will have the result. The complete sample application can be downloaded &lt;a href=&quot;http://xgportfolio.com/brew/webservice.zip&quot;&gt;here&lt;/a&gt;. The application was developed using BREW SDK 3.1.5.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/8146179471855593078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/8146179471855593078' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/8146179471855593078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/8146179471855593078'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/using-webservices-soap-in-brew.html' title='Using Webservices ( SOAP ) in BREW'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-3308686672930397777</id><published>2008-04-17T21:53:00.000-07:00</published><updated>2008-04-17T22:54:03.657-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>Compiling BREW Application for Phone (GNUARM)</title><content type='html'>&lt;p&gt;The officially supported ARM compiler for the BREW Applications is &lt;a href=&quot;http://www.arm.com/products/DevTools/RealViewForBREW.html&quot;&gt;ARM&#39;S Real View Suite&lt;/a&gt;. It will cost you $1500 per seat for a node locked license. It is strongly recommended that you compile your application with the RVCT before sending it for TBT. However, you can use the free ARM Compliers for development and testing.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Compiling with GNUARM&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In this section we`ll see the steps needed to compile your BREW Applciation with GNUARM Compiler. You`ll have to download and install the following tools&lt;/p&gt;&lt;p&gt;1. &lt;a href=&quot;https://brewx.qualcomm.com/brew/sdk/download.jsp&quot;&gt;BREW SDK&lt;/a&gt;. The version used is 3.1.2.&lt;/p&gt;&lt;p&gt;2. &lt;a href=&quot;http://www.gnuarm.org/bu-2.17_gcc-4.2.0-c-c++_nl-1.15.0_gi-6.6.exe&quot;&gt;GNUARM Compiler&lt;/a&gt;. The version used is 4.2.0.&lt;/p&gt;&lt;p&gt;3. &lt;a href=&quot;https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/elf2mod&quot;&gt;BREW ElftoMod Tool&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;4. If you do not have Microsoft Visual Studio installed in your PC. You have to download the &lt;a href=&quot;http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084&quot;&gt;NMAKE&lt;/a&gt; Make Utility from Microsoft.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Preparing your environment&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;1. When you install elf2mod, you&#39;ll get the elf2mod.x and GCCResolver.c files in the gnu folder. Copy these files to your project directory.&lt;/p&gt;&lt;p&gt;2. If you do not have Microsoft Visual Studio installed in your PC. You`ll have to Copy the NMAKE.EXE and NMAKE.ERR to your project directory. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Modifying the Make file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You can download the sample make file from &lt;a href=&quot;http://www.xgportfolio.com/brew/whiteboard.mak&quot;&gt;here&lt;/a&gt;. This sample make file compiles the whiteboard example in the BREW SDK. If you cannot download this file leave a comment with your email. I`ll send you the file.&lt;/p&gt;&lt;p&gt;Make sure you have set the GCCHOMEPATH to your GNUARM installation folder and BREW_PATH to your BREW SDK Installation foler.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Executing the make file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Open the windows command prompt. Change the directory to your project directory in this case whiteboard folder in the examples folder of BREW SDK. Execute &lt;strong&gt;nmake whiteboard.mak.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Downloading the Mod file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You are all set to execute your BREW Application on the phone. Download the generated whiteboard.mod, whiteboard.bar, whiteboard.mif along with the whiteboard.sig file to your phone into the appropriate directories using BREW AppLoader. Launch your application by selecting the whiteboard icon from the BREW AppManager Menu.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Compiling with other Toolchains&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;1. Compiling with &lt;a href=&quot;http://brewforums.qualcomm.com/showthread.php?t=1601&quot;&gt;GNUDE&lt;/a&gt; from BREW Forums.&lt;/p&gt;&lt;p&gt;2. Compiling with &lt;a href=&quot;http://brew.wardco.com/index.html&quot;&gt;WINARM&lt;/a&gt; from Ward Willat.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/3308686672930397777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/3308686672930397777' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3308686672930397777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/3308686672930397777'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/compiling-brew-application-for-phone.html' title='Compiling BREW Application for Phone (GNUARM)'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-1851308531975070336</id><published>2008-04-17T01:34:00.000-07:00</published><updated>2008-04-17T01:41:45.461-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><category scheme="http://www.blogger.com/atom/ns#" term="Debugging"/><title type='text'>Common reasons for Application Crash in BREW</title><content type='html'>&lt;p&gt;The most common and fatal issue in BREW Applicaion is crashes. When you get a Application crash you are almost certain that you are accessing a invalid pointer. It means you are either using a NULL pointer are a pointer which is already free&#39;d. In both these cases it will cause the application to crash. You can easily check the statement causing the crash using the Visual Studio IDE and check the call stack if needed. These are the most common reasons for such crashes.&lt;/p&gt;&lt;p&gt;1. Calling a BREW API with a invalid interface pointer. &lt;/p&gt;&lt;p&gt;E.g. ITAPI_MakeVoiceCall(pITAPI, pApp-&gt;szPhoneNumber, 0); &lt;/p&gt;&lt;p&gt;The above API will crash if the pITAPI is not created previously or a invalid pointer.&lt;/p&gt;&lt;p&gt;2. Double Free problem. &lt;/p&gt;&lt;p&gt;Sometimes your application will crash when you call FREE(), even when the pointer you are passing to FREE() shows a address in the watch window. In this case the pointer has been free&#39;d earlier, check your code for instances of freeing that particular pointer. The easiest possible solution for this problem is replace all your FREE() to FREEIF() calls.&lt;/p&gt;&lt;p&gt;3. Double Release problem. &lt;/p&gt;&lt;p&gt;In this case, your application will crash when you release a interface, the reason is same as the double free problem above. You are trying to release a interface that is already released. To fix this problem replace all your IXXX_Release() calls to RELEASEIF() macro. &lt;/p&gt;&lt;p&gt;Add the below definition to your source file. &lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;font-family:courier new;color:#3366ff;&quot;&gt;#define RELEASEIF(p) if( (p) != NULL){ \ &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;font-family:courier new;color:#3366ff;&quot;&gt;IBASE_Release((IBase*)p);\ &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;font-family:courier new;color:#3366ff;&quot;&gt;(p) = NULL; \ &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;font-family:courier new;color:#3366ff;&quot;&gt;}&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Unlike a JAVA Application which will throw an exception, the invalid memory access could crash the entire phone causing it to restart.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/1851308531975070336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/1851308531975070336' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1851308531975070336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/1851308531975070336'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/common-reasons-for-application-crash-in.html' title='Common reasons for Application Crash in BREW'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-2804748898761697825</id><published>2008-04-15T01:58:00.000-07:00</published><updated>2008-04-15T02:07:44.925-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>Components of a BREW Application</title><content type='html'>&lt;p&gt;&lt;strong&gt;Executable file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Windows executable (&lt;app&gt;.dll)&lt;/p&gt;&lt;p&gt;The BREW Application executable file is a native win 32 dll file, when you compile the application using a Microsoft C/C++ compiler to run in the BREW Simulator. &lt;/p&gt;&lt;p&gt;ARM executable (&lt;app&gt;.mod)&lt;/p&gt;&lt;p&gt;The BREW Application executable file is a native ARM Module file, when you compile the application using a ARM compiler to run in the Phone &lt;/p&gt;&lt;p&gt;&lt;strong&gt;MIF file (&lt;app&gt;.mif)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;MIF is the Module Information File of your application. As the name suggests it holds the information about your application like Applet name, Class ID, Icon, Privileges, Notification flags, dependencies etc. The MIF file is generated using the BREW MIF Editor in BREW SDK Tools folder. In later versions of MIF Editor, the file generated will have a .mfx extension, you have to compile it to get the .mif file.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;BID file (&lt;app&gt;.BID)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Every BREW Application will have a BID file in the name &lt;app&gt;.BID, in which the applications unique Class ID is defined. The Class ID can be generated locally for development and testing from the BREW MIF Editor, but when you commercialize your application you need to generate your Class ID from Qualcomm&#39;s Website. The BID file must be included in you application &lt;app&gt;.c file.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Resource file (.bar)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Resource file contains the resources needed by your application like Strings, Images, Binary files, Objects etc. The Resource file is generated using the BREW Resource Editor in BREW SDK Tools folder. The Resource Editor will generate a .brx file, which is a XML file containing the definitions of the resources, this file is compiled to generate the .bar file.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Signature file (&lt;app&gt;.sig)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The signature file is needed if you want to run your application in the phone. You can generate a signature file for your phone for from the Qualcomm&#39;s Website by entering your phones ESN. You need to be a authenticated BREW developer to generate a test signature file.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/2804748898761697825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/2804748898761697825' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2804748898761697825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/2804748898761697825'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/components-of-brew-application.html' title='Components of a BREW Application'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-5338156699711596200</id><published>2008-04-14T23:45:00.000-07:00</published><updated>2008-04-14T23:57:02.956-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BREW"/><title type='text'>What is BREW?</title><content type='html'>&lt;p&gt;&lt;strong&gt;BREW&lt;/strong&gt; stands for Binary &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;Runtime&lt;/span&gt; Environment for Wireless debuted in 2001 by &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;Qualcomm&lt;/span&gt;. It is a platform providing rich set of &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;API&#39;s&lt;/span&gt; to develop applications targeting wireless environment. &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;Qualcomm&#39;s&lt;/span&gt; BREW is NOT a hobbyist platform. There are costs involved if you want to distribute your application or just want to run it in your mobile for personal use. Presently, the BREW platform is available only in &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;CDMA&lt;/span&gt; Phones, which is a &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;Qualcomm&#39;s&lt;/span&gt; forte. However, you can freely download the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;SDK&lt;/span&gt; from &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;Qualcomm&lt;/span&gt; and develop &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;application&lt;/span&gt; that will run in BREW Simulator.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The programming language for BREW is C and C++. BREW is written in C and so its all of the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;API&#39;s&lt;/span&gt;. You can start your BREW App&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;lication&lt;/span&gt; development with your PC and port it to your phone late&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Getting Started with PC&lt;/strong&gt;&lt;br /&gt;When you are developing BREW in a simulator environment the applicaton will be compiled as native Win32 dll file using the Microsoft C/C++ Compiler.&lt;br /&gt;You need to download and install the following tools&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Microsoft Visual Studio 6 or above to compile the BREW for Simulator envionment.  &lt;/li&gt;&lt;li&gt;BREW SDK from &lt;a href=&quot;http://brew.qualcomm.com/brew/en/&quot;&gt; Qualcomm&#39;s website &lt;/a&gt;.  &lt;/li&gt;&lt;li&gt;BREW SDK TOOLS from &lt;a href=&quot;http://brew.qualcomm.com/brew/en/&quot;&gt; Qualcomm&#39;s website &lt;/a&gt;. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Note:  You can also use the free express edition of the Microsoft Visual C++, but then you have to do the project settings yourself. In case on Microsoft Visual Studio you get a BREW AppWizard in your Project Dialog box, which will create a barebone BREW App for you.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Now, that you have successfully setup your environment, you can start developing you BREW application. There are some nice sample application that comes along with the SDK, try to understand them. The BREW API Reference document is the most important document you need when you develop any BREW Application. It is a comprehensive documentation of all the BREW API&#39;s.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/5338156699711596200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/5338156699711596200' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5338156699711596200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/5338156699711596200'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/what-is-brew.html' title='What is BREW?'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8574775355704977298.post-9216100065525985473</id><published>2008-04-14T06:26:00.000-07:00</published><updated>2008-04-14T06:27:19.957-07:00</updated><title type='text'>Introduction</title><content type='html'>I have been thinking of starting a technology blog on mobiles for quite some time and now I have enough time to spare to create this blog and start sharing what I have learnt. The mobile platforms I will be concentrating for the time being are Qualcomm&#39;s BREW and Sun&#39;s J2ME. I intend this blog to become a repository of knowledge, which will solve most of the &quot;newbie&quot; problems and be a comprehensive diving pad for these technologies. I am open to critiques on anything that is wrong or mis-intrepereted on this blog.</content><link rel='replies' type='application/atom+xml' href='http://brew-j2me.blogspot.com/feeds/9216100065525985473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8574775355704977298/9216100065525985473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/9216100065525985473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574775355704977298/posts/default/9216100065525985473'/><link rel='alternate' type='text/html' href='http://brew-j2me.blogspot.com/2008/04/introduction.html' title='Introduction'/><author><name>Karthik</name><uri>http://www.blogger.com/profile/11621384245869214461</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>