Multimode Messaging

The Multimode telephony API provides a number of specialised messaging classes that are derived from RTelSubSessionBase. One of the classes is responsible for SMS, another for Broadcast and another for USSD messaging.

The following table describes the three messaging types.

Type Required GSM WCDMA CDMA

SMS messaging

No

Yes

Yes

Yes

Broadcast messaging

No

Yes

Yes

Yes

USSD messaging

No

Yes

Yes

No

SMS messaging

RMobileSmsMessaging provides access to the Short Message Service provided by GSM, WCDMA and CDMA networks.

In CDMA mode, SMS has three protocol layers: Relay lowest level, Transport and Teleservice. Relay is the lowest level while Transport and Teleservice are application level. RMobileSmsMessaging provides an interface to the Transport layer. Usually, the Teleservice layer is implemented in a sockets protocol module. The Teleservice layer, rather than RMobileSmsMessaging, would be the interface used by applications to send SMS messages. SMS messages are passed across the API as Packet Data Units (PDUs).

Segmentation and reassembly of long SMS messages over 255 bytes is not provided by the API, and must be provided by a higher-level module such as the smsprot.prt protocol module.

RMobileSmsMessaging allows clients to:

Example

The following code sends the message aPdu to the destination aDest over GSM.

The code assumes iMobilePhone is an RMobilePhone object.

void CClientApp::SendSMSL(
        const RMobileSmsMessaging::TMobileSmsGsmTpdu& aPdu, 
        const TDesC& aDest)
    {
    // Open SMS session
    RMobileSmsMessaging smsSession;
    User::LeaveIfError(smsSession.Open(iMobilePhone));
    CleanupClosePushL(smsSession);

    // Get SMS capabilities
    RMobileSmsMessaging::TMobileSmsCapsV1 smsCaps;
    RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(smsCaps);
    User::LeaveIfError(smsSession.GetCaps(smsCapsPckg));

    // Test if SMS can be sent over GSM
    if ( smsCaps.iSmsMode & RMobileSmsMessaging::KCapsGsmSms
        & ( (smsCaps.iSmsControl & RMobileSmsMessaging::KCapsSendWithAck ) || 
            (smsCaps.iSmsControl & RMobileSmsMessaging::KCapsSendNoAck )))
        {
        // Set the required bearer
        TRequestStatus status;
        smsSession.SetMoSmsBearer(status, RMobileSmsMessaging::ESmsBearerCircuitPreferred);
        User::WaitForRequest(status);
        User::LeaveIfError(status.Int());

        // Set destination address and data format attributes
        RMobileSmsMessaging::TMobileSmsSendAttributesV1 sendAtts;
        sendAtts.iDestination.iTelNumber = aDest;
        sendAtts.iDataFormat = RMobileSmsMessaging::EFormatGsmTpdu;
        RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg sendAttsPckg(sendAtts);

        // Send the message
        smsSession.SendMessage(status, aPdu, sendAttsPckg);
        User::WaitForRequest(status);
        User::LeaveIfError(status.Int());
        }
     
    // Clean up
    CleanupStack::PopAndDestroy(); // calls smsSession.Close()
    }

Broadcast messaging

RMobileBroadcastMessaging provides access to the broadcast messaging services provided by GSM, WCDMA and CDMA networks.

Clients open an RMobileBroadcastMessaging sub-session and then wait for incoming broadcast messages. The broadcast messages received can depend on a message filter that defines the languages and identifiers of acceptable and unacceptable messages.

RMobileBroadcastMessaging allows clients to:

Example

The following code gets the contents of the next GSM broadcast message received in aMessageData.

void CClientApp::ReceiveBroadcastMessageL(RMobileBroadcastMessaging::TGsmBroadcastMessageData& aMessageData)
    {
    // Open session
    RMobileBroadcastMessaging bmSession;
    User::LeaveIfError(bmSession.Open(iMobilePhone));
    CleanupClosePushL(bmSession);

    // Get BM capabilities
    RMobileBroadcastMessaging::TMobileBroadcastCapsV1 bmCaps;
    RMobileBroadcastMessaging::TMobileBroadcastCapsV1Pckg bmCapsPckg(bmCaps);
    User::LeaveIfError(bmSession.GetCaps(bmCapsPckg));

    // Test if GSM 03.41 cell broadcast messages are supported
    if (bmCaps.iModeCaps & RMobileBroadcastMessaging::KCapsGsmTpduFormat)
        {
        // Get the next received broadcast message
        RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 bmAtts;
        RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg bmAttsPckg(bmAtts);
        TRequestStatus status;
        bmSession.ReceiveMessage(status, aMessageData, bmAttsPckg);
        User::WaitForRequest(status);
        User::LeaveIfError(status.Int());
        }
     
    // Clean up
    CleanupStack::PopAndDestroy(); // calls bmSession.Close()
    }

USSD messaging

The Unstructured Supplementary Service Data (USSD) service provided by GSM/ WCDMA networks transmits information over the network signalling channels.

USSD is incorporated in the messaging functionality because of its potential use as a bearer for WAP or other overlying protocol. The USSD protocol is therefore suitable for implementation within a Sockets protocol (.PRT) module.

RMobileUssdMessaging allows clients to:

Example

The following code gets in aMessageData the contents, and in aUssdAtts the attributes, of the next USSD message received.

void CClientApp::ReceiveUssdMessageL(
    RMobileUssdMessaging::TGsmUssdMessageData& aMessageData,
    RMobileUssdMessaging::TMobileUssdAttributesV1& aUssdAtts)
    {
    // Open session
    RMobileUssdMessaging ussdSession;
    User::LeaveIfError(ussdSession.Open(iMobilePhone));
    CleanupClosePushL(ussdSession);

    // Get ussd capabilities
    RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps;
    RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps);
    User::LeaveIfError(ussdSession.GetCaps(ussdCapsPckg));

    // Test if USSD messages can be received
    if (ussdCaps.iUssdTypes & RMobileUssdMessaging::KCapsMTUssd)
        {
        // Get the next received Ussd message
        RMobileUssdMessaging::TMobileUssdAttributesV1Pckg ussdAttsPckg(aUssdAtts);
        TRequestStatus status;
        ussdSession.ReceiveMessage(status, aMessageData, ussdAttsPckg);
        User::WaitForRequest(status);
        User::LeaveIfError(status.Int());
        }
     
    // Clean up
    CleanupStack::PopAndDestroy(); // calls ussdSession.Close()
    }
Related information
SMS message store