SMSJ
by
Jean-Marc
Autexier, October 2004
Index
Features
- tray icon application
- online update check/FAQ (not working)
- configuration dialog (com port, ..)
- mobile device info dialog
- works with any mobile attached to local/virtual com port (best is bluetooth)
Installation
- extract zip file
- click on “smsj.vbs”
This application use the folowing third party libs:
- swt
- java comm
- jsmsengine.jar: many thanks to Thanasis Delenikas for the great library. update: jsmsengine is now smslib
- inspired from transj
application
Versions
V0.0.2 (02.10.2004) – download- new configuration dialog: com port (com1...com8),
- status dialog: shows mobile information (type, battery, signal...)
- swt gui (my first swt application)
- tray icon (see small blue icon)
- online update/faq. Not yet tested, but implemented
- vb script for start
- preference dialog (not yet implemented)
- send sms
Screenshots
Main
frame
Configuration
dialog
Status dialog
Theory
I had to do some changes to
jsmsengine. Here is the description:
| Bit no | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Name | TP-RP | TP-UDHI | TP-SRR | TP-VPF | TP-VPF | TP-RD | TP-MTI | TP-MTI |
Anr interesing bit is TP-SRR (Status report request). When set, you will get a SMS back when it has been delivered). The answer-SMS will have the field TP-SRI set in the first octet. One can use the message number or a text in user data to correlate both SMS.
| Bit no | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Name | TP-RP | TP-UDHI | TP-SRI | (unused) | (unused) | TP-MMS | TP-MTI | TP-MTI |
Here is some sample code of jsmsengine changes.
public class CMessageCOutgoingMessage and CIncomingMessage have been changed similary to allow setting and extraction of forst octect bits.
{
// Some constants to allow setting of bits
public static final int MESSAGE_ENCODING_7BIT = 1;
public static final int MESSAGE_ENCODING_8BIT = 2;
public static final int MESSAGE_ENCODING_UNICODE = 3;
public static final int TYPE_INCOMING = 1;
public static final int TYPE_OUTGOING = 2;
// SC->MS direction
public static final String TYPE_SMS_DELIVER = "00";
public static final String TYPE_SMS_STATUS_REPORT = "10";
public static final String TYPE_SMS_SUBMIT_REPORT = "01";
public static final String TYPE_RESERVED = "11";
// MS->SC direction
public static final String TYPE_SMS_DELIVER_REPORT = "00";
public static final String TYPE_SMS_COMMAND = "10";
public static final String TYPE_SMS_SUBMIT = "01";
// VALIDITY
public static final String VPF_NO = "00";
public static final String VPF_RELATIVE = "10";
public static final String VPF_ENHANCED = "01";
public static final String VPF_ABSOLUT = "11";
protected String protocolType = "00";
// The first octect
protected BitSet tpOctet = new BitSet();
/**
* Get the defined protocol type.
*
*/
public String getProtocolType()
{
return protocolType;
}
/**
* Set protocol type for this message.
* for now this just set the String as protocol type as I don't know all protocol types.
* Later on, constants may be available
*
* @param protocolType The protocoltype, standard is "00".
*/
public void setProtocolType(String protocolType)
{
this.protocolType = protocolType;
}
/**
* Set replayPath (TP-RP) bit in first octet. TP-RP says if a reply is requested
* from the receiving mobile station.
*
* @param bool set or unset replay path bit
*/
public void setReplayPath(boolean bool)
{
if ( bool)
tpOctet.set(7);
else
tpOctet.clear(7);
}
/**
* Return replay path bit
**/
public boolean isReplayPath()
{
return tpOctet.get(7);
}
/**
* Set TP-UDHI bit. Describes what the User Data field will contain.
* - 1 the User Data field contain a User Data Header in addition to the short message
* - 0 UDHI contains just the short message.
* See user data field (not yet implemented)
*
* @param bool set or unset UDHI field
*/
public void setUserDataHeaderIndicator(boolean bool)
{
if ( bool)
tpOctet.set(6);
else
tpOctet.clear(6);
}
/**
* Return value of UDHI bit
**/
public boolean isUserDataHeaderIndicator()
{
return tpOctet.get(6);
}
/**
* Set the status report bit. Basically requests another type of SMS to be
* returned to the Mobile after the SMS-SUBMIT is sent to the Service Centre.
*
* @param bool set or unset status report field
*/
public void setStatusReport(boolean bool) {
if (bool)
tpOctet.set(5);
else
tpOctet.clear(5);
}
/**
* return value of status report bit
*
* @return
*/
public boolean isStatusReport()
{
return tpOctet.get(5);
}
}
One can download modified classes here: CMessage, COutgoingMessage, CIncomingMessage.
Some technical stuff
I will write here things I learned during development:- SWT: yeah, this is my first SWT project, so I'm learning a lot
- VB script for java applicatin start. I used to use cmd files, the disadvantages beeing that a cmd appears on the screen. Doesn't with vbs
- configuration file: store user configuration in his home directory with System.getProperty("user.home") + "/.smsj";
- system tray: Tray tray = display.getSystemTray(); trayItem = new TrayItem(tray, SWT.DEFAULT); ...
- org.eclipse.swt.widgets.Display has a nice function: asyncExec(Runnable). It does what it say
- new version check (transj idea): check a file with actual version number on a web server with HttpURLConnection. If it is not identical to used version, show dialog
- tbd ...
Lasr change June 2005