A very simple TAPI dialer for Windows Mobile

by Krishnaraj Varma on September 20, 2009

in Windows Mobile

Download TAPI Dialer Code (358)

Here is a very simple TAPI dialer for Windows Mobile as requested by one of my friend. I hope this will help beginners to start with TAPI on Windows Mobile. Following are the steps to dial a number using TAPI:

  • Initialize TAPI
  • Negotiate the TAPI version
  • Open the cellular line
  • Dial the number using lineMakeCall
  • To drop the initiated call use lineDrop
  • { 0 comments }

    Getting Signal Strength using TAPI and RIL

    by Krishnaraj Varma on September 6, 2009

    in Windows Mobile

    Download RIL Sample (358)
    Download TAPI Sample (302)

    In Windows Mobile, we can retrieve signal strength in two ways, one using TAPI and other using RIL. The TAPI function lineGetLineDevStatus is used to retrieve the signal strength of the current line. This function returns the details in LINEDEVSTATUS variable length structure. The dwSignalLevel member contains the signal strength in the range 0×00000000 to 0x0000FFFF.

    The other method is to use the RIL function RIL_GetSignalQuality. This functon returns the signal strength in RILSIGNALQUALITY structure. The member nSignalStrength contains the signal strength. This link explains how to calculate the signal strength from the RILSIGNALQUALITY structure members.

    { 0 comments }

    Download the source code (256)

    Here is a sample application to get the messaging configuration using Radio Interface Layer (RIL). The RIL function RIL_GetMsgConfig is used to get the messaging configuration. This function returns the configuration in RILMSGCONFIG structure.

    { 0 comments }

    Programmatically start touch screen calibration

    by Krishnaraj Varma on August 23, 2009

    in Windows Mobile

    The following link explains the Touch Screen Driver functions. Since we cannot directly call these function using Windows Mobile SDK, we have to load the CoreDll.dll file and call these function dynamically. The following code snippet start the Touch Screen calibration programmatically.

    typedef BOOL (WINAPI* pfnTouchCalibrate)(void)
    int _tmain(int argc, _TCHAR* argv[])
    {
    	HMODULE hCoreDLL = LoadLibrary(_T("coredll.dll"));
    	pfnTouchCalibrate pTouchCalibrate = (pfnTouchCalibrate)GetProcAddress(hCoreDLL, _T("TouchCalibrate"));
    	if (pTouchCalibrate)
    		pTouchCalibrate();
    	FreeLibrary(hCoreDLL);
    }

    { 0 comments }

    Download the source code

    While searching I found this useful link explaining how to retrieve ICC-ID using Sim Manager APIs. I extended this sample to read IMSI, TMSI, MNC, MCC and LAC. The SimReadRecord API is used to read the records stored in the SIM. The second parameter specifies the address to read and the sixth parameter specifies the size of the data to read. To get more details of the SIM records refer to the GSM 11.11 specification. Below are some of the record address and its length:

    ICCID address 0x2FE2, length 10 bytes
    IMSI address 0x6F07, length 10 bytes
    TMSI, MCC, MNC, LAC address 0x6F7E, length 11 bytes

    { 7 comments }

    Download the source code

    This is a sample to retrieve the APN and IP address using Radio Interface Layer. The API RIL_GetGPRSContextList is used to retrieve the GPRS context information. The API will return the data in RILGPRSCONTEXT. The sample retrieves the APN and IP address and displays in an edit box.

    { 0 comments }

    RIL Sample: Getting Device Capabilites

    by Krishnaraj Varma on July 5, 2009

    in Windows Mobile

    Download Source Code

    Here is a sample RIL (Radio Interface Layer) application to check the capabilities of the device. This sample uses RIL_GetDevCaps function to retrieve capabilities of the device. There are many device capability types, only few is used in this sample. Refer to MSDN documentation for a complete list of capability types.

    { 0 comments }

    Camera Live Preview using DirectShow

    by Krishnaraj Varma on June 28, 2009

    in Windows Mobile

    Download source code

    I was trying to create an application that Geotag the picture taken from camera. This application uses DirectShow to show the live camera preview. I think it is better to share the piece of code that show the live preview with you. I not able to successfully geotag the image taken from camera, I will post the code here once I complete the geotaging application.

    { 0 comments }

    Programatically forwarding calls using TAPI

    by Krishnaraj Varma on February 9, 2009

    in Windows Mobile

    Download the source code

    Recently one of my friend asked me how to forward calls using the USSD commands. This link describes how to forward calls using USSD codes. I tried a lot using my previous article code but ended up with no success. The USSD command are sending successfully but always the result is “UNKNOWN APPLICATION”. Then I decided to work on a sample using the TAPI API lineForward.

    The lineForward API is used to programatically forward calls. The syntax of the API is defined as:

    LONG WINAPI lineForward(HLINE hLine,DWORD bAllAddresses,
            DWORD dwAddressID,LPLINEFORWARDLIST const lpForwardList,
            DWORD dwNumRingsNoAnswer,LPHCALL lphConsultCall,LPLINECALLPARAMS const lpCallParams);

    The first parameter is the handle to the line (Cellular Line), second a boolean value indicating all originating addresses of the line or a single address of the line. Third is the address id of the line. Fourth is a pointer to variably sized structure that describes the forwarding instructions. Fifth is number of rings that has to be considered as no answer. Sixth is a pointer to handle to a call which will be filled with handle to a consultation call (only used in some telephony environments). Seventh is pointer to LINECALLPARAMS, if NULL specified default call parameter will be used.

    Following steps are needed to forward calls:

    1. Initialize TAPI
    2. Open the Cellular Line
    3. Allocate and initialize the LINEFORWARDLIST variable sized structure
    4. Call lineForward API

    Allocating and initializing the LINEFORWARDLIST structure is little bit complex. This is a pointer to a variable sized structure and is defined as:

    typedef struct lineforwardlist_tag {
      DWORD dwTotalSize;
      DWORD dwNumEntries;
      LINEFORWARD ForwardList[1];
    } LINEFORWARDLIST, FAR* LPLINEFORWARDLIST;

    The dwTotalSize member is the total size of the structure, dwNumEntries member is the number of ForwardList array. The LINEFORWARD structure is defined as:

    typedef struct lineforward_tag {
    DWORD dwForwardMode;
    DWORD dwCallerAddressSize;
    DWORD dwCallerAddressOffset;
    DWORD dwDestCountryCode;
    DWORD dwDestAddressSize;
    DWORD dwDestAddressOffset;
    DWORD dwCallerAddressType;
    DWORD dwDestAddressType;
    } LINEFORWARD,  *LPLINEFORWARD;

    The dwDestAddressOffset specifies the offset of the destination address from the starting of the structure. The dwDestAddressSize specifies the size of the destination address in bytes. Same in the case of dwCallerAddressOffset and dwCallerAddressSize and specifies the caller address and size. To allocate memory for the forward list, first we have to find out the total number of bytes needed. This will be:

    sizeof(LINEFORWARDLIST) + (sizeof(LINEFORWARD) * number of entries - 1) + size of all phone numbers

    After allocating the memory we need to initialize the members of the structure and append the phone numbers. The API lineForward returns a positive integer if successful otherwise a negative value indicating the error. To get the current status of the call forward, lineGetAddressStatus API is used. This returns the result in a variable sized array. The sample application presented here retrieves the call forward status and display it is dialog. Users can change the settings and upon exit the application sets new call forward information. Hope this gives you an introduction on how to programatically forward calls.

    { 2 comments }

    Sending USSD message using TAPI

    by Krishnaraj Varma on January 26, 2009

    in Windows Mobile

    Download the source code

    Unstructured Supplementary Service Data (USSD) is GSM technology used to send short message from mobile device to GSM network. It uses the signaling channel of GSM connection and can have up to 182 bytes in length. The messages received on the device are not saved. It has different set of applications and most common use of USSD message is balance enquiry. For example “*123#” used for balance enquiry in India. For a more detailed explanation of USSD messages refer to the Wikipedia.

    The TAPI API lineSendUSSD is used to send the USSD command. The syntax is defined as:

    LONG WINAPI lineSendUSSD(HLINE hLine,const BYTE * const lpbUSSD,DWORD dwUSSDSize,DWORD dwFlags);

    The hLine parameter is the handle to the line and lpbUSSD is a pointer to USSD command. The dwUSSDSize parameter is the length of th USSD command and dwFlags flags to the USSD command which will be 0 in most cases.

    The function returns a positive request identifier and is completed asynchronously. A negative integer will returned if an error occurs. The sample application presented here uses a database to store USSD commands. The application lists all the commands in the database in a list control. You can add, edit or delete the entries. Upon double clicking an entry the application sends corresponding USSD command using the Cellular Line.

    { 2 comments }

    Disclaimer: This is a personal weblog. The information in this weblog is provided “AS IS” with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.