首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> Network >> 正文
Sending a message from Symbian C++ to a J2ME MIDlet.
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:17:17

Introduction

A MIDP 2.0 J2ME Midlet registers itself with the push registry to a particular port for receiving incoming SMSes on that port. I have seen many people struggling with trying to send a message from native Symbian application to a J2ME application running on target phone listening. Here is my contribution on how this can be done.

The GSM 3.40 Version 6.0 gives a detailed specification of Short Message Service (SMS) and GSM/UMTS networks. A particular SMS-Deliver type PDU (Protocol Data Unit) has the following elements.

Abbr.ReferenceDescription
TP MTITP Message Type IndicatorParameter describing the message type.(2bits)
TP MMSTP More Messages to SendParameter indicating whether or not there are more messages to send (1 bit).
TP RPTP Reply PathParameter indicating that Reply Path exists. (1 bit)
TP UDHITP User Data Header IndicatorParameter indicating that the TP UD field contains a Header. (1 bit)
TP SRITP Status Report IndicationParameter indicating if the SME has requested a status report. (1 bit)
TP OATP Originating AddressAddress of the originating SME.(2-12 octets)
TP PIDTP Protocol IdentifierParameter identifying the above layer protocol, if any (1 octet).
TP DCSTP Data Coding SchemeParameter identifying the coding scheme within the TP User Data. (1 octet)
TP SCTSTP Service Centre Time StampParameter identifying time when the SC received the message. (7 octets)
TP UDLTP User Data LengthParameter indicating the length of the TP User Data field to follow. (Integer)
TP UDTP User DataVariable length user data.

Section 9.2.3.24 describes the TP-User Data (TP-UD) field in the SMS PDU. The TP-UD may just contain a message or a User Header along with the message. This is specified by setting the TP-User Data Header Indicator (TP-UDHI) field to appropriate value.

  1. If the TP UDHI field is 0’ the TP-UD field contains only data.
  2. If the TP UDHI field is 1’ the TP-UD field contains a header along with data.

The User data header contains information in the following format.
Information Element Identifier1 octet
Length of Information Element1 octet
Information Element Data0 to "n" octets

The Information Element is used to convey information such as an indicator of a special SMS, concatenated SMS or the application port addressing scheme. The full list of the various Information Elements can be found in section 9.2.3.24 of the GSM 3.40 specification.

Note: Adding an Information Element eats up the space available for SMS message. Therefore less space is available for your message.

For specifying the destination port number the Information Element to be added is,
Information Element Identifier0x05
Length of Information Element0x04
Information Element Data0x40, 0x74, 0x00, 0x00 For destination port number 16500

Note: Remember if a port number is not specified, then by default the SMS is directed to port zero.

In Symbian, an Information Element can be added to the SMS PDU using;

void CSmsUserData::AddInformationElementL (
                   CSmsInformationElement::TSmsInformationElementIdentifier aIdentifier,
                    const TDesC8& aData);

Ex:


CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(iMtm);
CSmsHeader&   header          = smsMtm->SmsHeader();
CSmsSettings& serviceSettings = smsMtm->ServiceSettings();

CSmsPDU& smsPDU = header.Message().SmsPDU();
smsPDU.SetAlphabet(iMsgEncoding);

CSmsUserData& userData = smsPDU.UserData();

TBuf8<4> smsPort;
smsPort.SetLength(4);
smsPort[0] = 0x40; //setting destination port to 16500(0x4074)
smsPort[1] = 0x74;
smsPort[2] = 0x00;
smsPort[3] = 0x00;
userData.AddInformationElementL( CSmsInformationElement::ESmsIEIApplicationPortAddressing16Bit, smsPort );

Note: Adding destination port multiple times will result AddInformationElementL () to throw KErrAlreadyExists. This information element needs to be added only once.

The port numbers ranges from 0 to 65535 and are allocated for various purposes as follows;

VALUEALLOCATED
0-15999As allocated by IANA (http://www.IANA.com/)
16000-16999Available for allocation by applications
17000-65535Reserved

I have attached a sample J2ME MIDlet for testing. This Midlet registers itself with the Push registry on port 16500 and should be invoked when you send an SMS from your Symbian application.

Enjoy!

Vinay

SE NSS http://xms.za.net/web.html

相关文章:
Programatically sending an SMS Message
How to detect if an application is launched by user or the startup list
Using SIP with Nokia Series60 and Asterisk
Getting the Current Cell Id using Symbian S60
My experiences making a Task Manager
Symbian OS Exec Calls
An application for Series 60 - a step-by-step example
Detecting user inactivity
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号