Code Repo    |     RSS
MD's Technical Sharing



Wednesday, April 28, 2010

Native SIP on Windows Mobile 6.1 and 6.5

Although Windows Mobile 6.1 and above supports SIP natively, the user does not always have the ability to configure SIP settings. In particular, SIP (a.k.a Internet Call) needs to be enabled in the device firmware, and SIP server configuration needs to be set via registry. This post summarizes the step needed to enable SIP and make Internet Calls from the phone's native dialer.

First, you must check if your firmware enables Internet Call. There should be an Internet Call item on your Today Screen:



If you are not using the standard Today screen plugin, check your Phone settings, there should be a tab for Internet Call:


Your operator may have bundled the SIP configuration settings with the phone. If so, you're good to go, just select either "Whenever Available" or "Only if cellular is not available" from the drop down. The phone will attempt SIP registration whenever a connection is available and you'll see "Internet Call: Available" on the Today screen when SIP is registered. If SIP is not registered, you'll see "Internet Call: No Service".

If your phone does not have bundled SIP configuration settings, you will need to configure it yourself. You can do this manually, but I'd recommend using a tool called Sip Config Tool:


Input your SIP server configuration and choose to save. This will overwrite any existing configuration. By default, SIP over a cellular connection is disabled, but you can enable it via the menu if you want to.

You may need some configuration to make sure that the number you dial from the dialpad gets translated into a proper SIP address. Check \windows\ipdialplan.xml and you'll see something like this:
   
   
<!-- International -->
   
<rule pattern='(\d+)'
        dial='sip:\1@$host$'
        display='\1'
        transfer='sip:\1@$host$'
        />


pattern: the number you dial in the dialpad
dial: the actual SIP address where INVITE request is sent to
display: the number to be displayed during the call

The default configuration is only suitable for US number so you may need to change them as appropriate according to your country's telephone nunbering plan. In my case, I remove everything except one entry in the International section. To dial a number, I simple enter the full format, country code + area code + telephone number.

If your device does not support playing audio on the earpiece via RIL_SetAudioDevices, don't expect Internet calls to work with your earpiece. In my case (Acer F900), audio is played via loudspeaker unless a headset is connected, with a lower volume to simulate the earpiece. At the beginning of every call, a beep tone will be played to indicate an Internet call.
Read More »

Friday, April 16, 2010

"csc.exe - Application Error" when shutting Windows with a .running NET application

Recently a friend reported to me that my application written in .NET prevents his computer from shutting down. If the application is running when Windows tries to shut down, the following error message appears and Windows cannot shut down:

csc.exe - Application Error
The application failted to initialize properly (0xc0000142). Click on OK to terminate the application.

Some investigation reveals that the issue has to do with the .NET class XmlSerializer. My application stores user data into an XML file, which gets saved when the application is closed. In particular, the following code seems to cause the problem:
Dim serializer As New XmlSerializer(ConfigObj.GetType())
Dim writer As New StreamWriter(datafile)
serializer.Serialize(writer, ConfigObj)
writer.Close()

The error occurs as soon as XmlSerializer.Serialize() is called. A file system monitor tool such as Process Monitor shows me that csc.exe is creating temporary files in C:\Windows\Temp, which is perhaps interrupted by the shutdown process, causing the above problem. I am not even sure why csc.exe (the microsoft C# compiler) gets called even though I am using VB.NET!

Not sure how to fix the problem, I have to avoid calling XmlSerializer when Windows is shutting down by using:

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
...
If e.CloseReason <> CloseReason.WindowsShutDown
    Dim serializer As New XmlSerializer(ConfigObj.GetType())
   Dim writer As New StreamWriter(datafile)
   serializer.Serialize(writer, ConfigObj)
   writer.Close()
End If
...
End Sub

This way, user data may be lost, but at least my application does not prevent the system from shutting down. I have to find another way to save user data more frequently...

Reference:
Read More »