Thursday, October 9, 2008

Testing S60 Phone's Light, Vibra and Battery

I found an application, which tests the phones(S60 3.x phones) light, vibrator and battery.

sis file (unsigned) is here. Since the application requires "ReadDeviceData" capability, it needs to "Symbian Signed" with "ReadDeviceData", before installing on to the device. If you don't know about symbian signed, go to the end of the post for more details.

Source code of the test application can be found is s60 3.x SDK's @ \Symbian\9.x\S60_3rd_FPx\S60Ex\HWRMTestApp (I have changed the name of the app from HWRMTestApp to LightVibraBattery.).


Application Details:

Although most of the functions are obvious looking at the Menu of the app, i discovered few things with my N73 device (I think, it applies to all s60 3.x phones)

1) Vibration is not allowed, if the device is charging. Why ?
Please leave a comment if u have more information on this.
This can be verified even if u don't have the application installed.
Make a phone call to S60 device (vibrator setting should be on in the profile).
When the device is vibrating (and ringing), connect the charger. Vibration stops.
2) You can selectively switch on/off, blink the device Light targets. Light target can be "Primary Display", "Primary Keyboard", "Secondary Display", ....

Here are some screen shots of the application (Thanks to ScreenShot application)
(After installation on the device, Launch app from Menu->Applications -> LightVibraBattery)


After launching the app, it shows
1) Status of various light targets (0x1- Primary Display, 0x2 - Primary Keyboard, 0x3-Primary Display And Keyboard, ....)
2) Supported Light targets.
3) Whether Vibra Settings is ON/OFF in the current active profile (Menu->Tools->Profiles)
4) Current status of Vibra (ON/OFF)
5) Battery charging status, Battery level/status.


Now lets play with lights. (Go to Options, i.e press LSK)

Here Keyboard light blinks for 10 seconds, with 0.5 sec on period and 0.5 second off period, with intensity 50. (note that all time information should be entered in milliseconds)


Vibrate the phone now.
Note the intensity values here. 100 denotes rotation at full speed in one direction(clockwise) and -100 denotes rotation at full speed in other direction(anticlockwise).



When charger is connected, vibra status is changed to "Vibration not allowed".

This app has other functionality(Reserve/Release of resources, getting current status/settings).
Some of the functions (especially Reserving,switching off lights) might not work based on the device/settings.
Refer to S60 SDK for more information.

If you have access to sdn++, u can read more on HWRM(HardWare Resource Manager) here.

Hope you find many interesting things from this application.

Signing application:

I feel using "Open signed Online" is the easy way to sign the application.
1) Click on this link.

2) U need to fill the form with following details
- Enter IMEI of ur phone (Enter *#06# in idle screen. Enter the Serial number displayed here.)
- Enter valid email. You get download link for the signed application @ this mail id.
- Choose the path where u downloaded the sis file.
- Select checkbox containing "ReadDeviceData"
- Enter valid security code
- Accept the legal agreement and click on send.

3) After this u will get 2 mails. First one for verification of email-id and after verification, second mail containing download link for the signed application.

Disclaimer: I have tested most of the functionality on my N73 device.
By installing/using the application, you assume all risks associated.

Sunday, September 28, 2008

How TDesC and TLitC (generated using _LIT macro) class are related ?



When i started working on Symbian-C++ (i was also new to C++) , i was wondering how the below code is compiling.

This was not trivial as i looked at class hierarchy of TDesC.

Reproduced from this book.

TLitC is not present in TDesC class hierarchy.
(If TLitC was there in the hierarchy, then derived class object(TLitC) can be passed where Base Class object(TDesC) is expected.)

How TLitC class object is converted to TDesC ?

Then i started looking into Symbian books and one of the book came close to the answer, but could not convince fully. Here is an excerpt from the book (I missed the code snippet in the book which was present above this excerpt.)

"TLitC16 (and TLitC8) do not derive from TDesC8 or TDesC16 but they have the same binary layouts as TBufC8 or TBufC16. This allows objects of these types to be used wherever TDesC is used."

This seems to be logically correct.
But how will the compiler know, the two class have same binary layout ?
Does the compiler have that intelligence ?
So i tried the below program


Both 'X' and 'Y' class have same binary layout, but the compiler gives following error

"error C2664: 'PrintObj' : cannot convert parameter 1 from 'class X' to 'class Y &' "

At that time, I was parallely reading Stroustrup's book "Design and Evolution of C++".
In chapter 3 of the book, "conversion operator" is introduced, which is the concept behind TLitC to TDesC conversion.

I will briefly describe the "conversion operator" here.
Going back to "class X" and "class Y" example, we need to add "class X " to "class Y" conversion operator, so that "class X" objects can be passed to PrintObj function(which expects class Y objects).Adding "operator const Y& () const" to "class X", objects of type "class X" can be converted to converted to "class Y".

Similarly in case of TLitC, following conversion operator converts TLitC to TDesC.


In summary, "Conversion Operator" does the trick of converting TLitC to TDesC.

Sunday, September 21, 2008

Kickoff

Welcome to my webblog.

My aim is to share information(hopefully useful !!) on mobile phone software development, mostly on Symbian-C++(native language used in Symbian OS) .

Also, i plan to highlight some of the mobile phone features, which are common to all platforms.

U can subscribe to my posts, through RSS (Find it on top right corner)

No idea about RSS?
See this video (Lee LeFever of commoncraft show, explains in plain English)