SMS App (Extension from Web-based CRM Module-Telephony)

All Case Experiences in Topic format. Easy reading mode for contextual understanding. Quickie snapshot and howtos Files are linked into http://compiere.red1.org/

SMS App (Extension from Web-based CRM Module-Telephony)

Postby zam » Mon Aug 14, 2006 6:53 pm

Note: Explanation below are based on a sports facilities booking system and the concept could be applied in Web-based CRM Module-Telephony (in SMS area).

Objective: Enable sports facilities booking thru SMS
Device/ Item Required: Pocket SMSC™ as the SMS gateway, SIM card from a GSM/PCN Mobile Telco Provider
Programming Language: Visual Basic 6.0
ActiveX Control Used: PocketSMSCControlBasic.ocx
Database: MySQL, Access

Pocket SMSC™ Features :

Image
http://www.ebos.com.my/m_smsxtra.asp

- Instant messaging to mobile phone (GSM/PCN) users
- A single SIM card (from a GSM/PCN Mobile Telco Provider) allows LAN users to send and receive SMS
- Supports multiple simultaneous access
- Sends to multiple destinations
- Messages able to reach mobile users worldwide
- Target messaging (one-to-one a/o one-to-many)
- Configurable with web interface from anywhere on the LAN
- Sends and receives SMS using web browser
- Equipped with users' SMS quota setting and tracking facilities

Technical Specifications:

- Embedded Web Server with Dual Band GSM Engine (900/1800 MHz) and antenna
- Standard RJ45 10 Base T connection to Local Area Network (LAN)
- TCP / IP
- Input: 5V DC via power adaptor
- Dimension: 30mm x 110mm x 180mm

Pocket SMSC™ Work Flow:
Image
Pocket SMSC™ (PSMSC) is used to enable the process of sending and receiving SMS. The Short Message Service is a store and forward service, in other words, short messages are not sent directly from sender to recipient, but always via an SMS Center (SMSC) instead.

A card phone together with a SIM card provided by the GSM Network Service Provider is needed to activate the PSMSC. Inactivated PSMSC is not able to send or receive messages. The outgoing messages will be stored in its database. Pending messages will only be sent when the device is on. Same goes for all incoming SMS which will only be retrieved from the network once the device is on and correctly configured.

PSMSC will be connected to LAN and hold a specific IP. Device comes with a basic web application that is accessible by typing the IP of PSMSC (http://<PSMSC ip>). User can easily login to the application to send SMS, view incoming and outgoing SMS.

SMS Application Development:
An activeX control, PocketSMSCControlBasic.ocx , is used with VB to enable the process of sending and receiving SMS.

1) Initialization of PSMSC in VB
Code: Select all
    PocketSMSCBasicControl1.ip = <ip of PSMSC>
    PocketSMSCBasicControl1.UserID = <one PSMSC’s registered user >
    PocketSMSCBasicControl1.Password = <registered user’s password>

2) Code to send SMS
The single line code can be manipulated to enable the process of broadcasting a message to a group of users.
Code: Select all
Call PocketSMSCBasicControl1.SendSMS (phone_number, message, 1)

3) Code to read incoming SMS
The function below will read all incoming messages in the user mailbox. In order to display a new message, program will check with database. New incoming SMS will not have its Msgref stored inside database.

Code: Select all
Private Sub PocketSMSCBasicControl1_NewSMS(ByVal Msgref As Long, ByVal timeRcv As Date)
    Dim found As String
    On Error Resume Next
    Dim db As Connection
    Set db = New Connection
    db.CursorLocation = adUseClient
    db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\smsdb.mdb;"

    Set rs = New Recordset
    SqlString = "Select * from sms_receive"
    rs.Open SqlString, db, adOpenStatic, adLockOptimistic
    Dim msisdn As String
    Dim MsgBody As String
    Dim msgtype As Integer
    Call PocketSMSCBasicControl1.ReadSMS(Msgref, timeRcv, msisdn, MsgBody, msgtype)

    rs.MoveFirst
    While Not rs.EOF
        If Msgref = rs("Msgref") Then
            found = 1   // Msgref exists in database thus, SMS is not new.
            Exit Sub
        Else
            found = 2 // Could not find Msgref  in database thus, SMS is a new.

        End If
        rs.MoveNext
    Wend

    //New SMS is stored inside database
    If found = 2 Then
        rs.AddNew
        rs("Msgref") = Msgref
        rs("TimeReceive") = timeRcv
        rs("UserNo") = msisdn
        rs("Body") = MsgBody
        rs.Update
        num = num + 1
        sent = sent + 1
        lblx.Caption = num & " new messages"
    End If
    rs.Close
    Call jam
End Sub


4) Logic of booking process or process alike (voting) is done by extracting/splitting incoming SMS. Incoming SMS will be grouped based on the first part of the whole SMS (Eg: BOOK for booking process, CREDIT to check for credit balance etc)
<user_id><password><service_code><game code><date><slot_code>

Example of incoming MsgBody is : zam zam BOOK tennis 2/9/2006 2.00pm. So it is understood by the system that zam is sending a request to book for tennis slot on 2/9/2006 at 2.00 pm

Code: Select all
Call PocketSMSCBasicControl1.ReadSMS(Msgref, timeRcv, msisdn, MsgBody, msgtype)

5) Application is able to recognize first part of the incoming SMS. Messages received will be routed to the specific account based on the username specified in the incoming SMS (eg:zam-hello). User can only view the messages sent to him/her only.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby red1 » Wed Aug 16, 2006 4:05 pm

This Short Messaging System option will add to the present 2 notification methods in Compiere Request Module:
1) Notice
2) EMail
3) SMS

As SMS needs shortened messages, we add an SMS Control to the system to morph certain fields such as summary, assignee (if the recepient is the assignee, then 'you') and Requester (just name).

Another module comes into play to handle the interative follow-up by the recepient to such request via sms, and such responses has to update the CRM or operate it further. For example, the service person may reply 'k' to mean 'yes'; 'n' to mean 'no' ; 'w' - yes but pending; 'd' - give to someone else this task, 'a' - give me its address; '20m' - arriving in 20 mins. If multiple requests it can prefix '*1' to mean the first request.

All these interactivity can be stored in a Rules Box for parsing the SMS returns. Such rules can update the CRM upon each action, i.e. 'Agent asked for Address'; 'Agent agreed to attend to customer'.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Tue Aug 22, 2006 2:21 am

It seems that this model has become obselete and we are now looking at other devices such as Nokia 30. Info on programming it is at http://discussion.forum.nokia.com/forum ... /f-15.html
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Wed Aug 23, 2006 10:34 am

We have succesfully downloaded Nokia 12 IMP_1_0 Concept Simulator Beta 1_0 free from http://forum.nokia.com together with its Application Development Kit.

We run the emulator.bat (where we set the first two properties to our context):
Code: Select all
set EMULATOR_HOME=F:\NokiaSim
set DESCRIPTOR_FILE=concept_config.xml
java -classpath %EMULATOR_HOME%\bin\emulator.jar;%EMULATOR_HOME%\externalapp\classes;%EMULATOR_HOME%\bin -Demulator.home=%EMULATOR_HOME% com.nokia.phone.sdk.Emulator -Xdescriptor %DESCRIPTOR_FILE%
The emulator pops up in all its glory but died after 30 secs:
Code: Select all
java.io.UTFDataFormatException: invalid first byte 10101110
        at com.sun.cldc.i18n.j2me.UTF_8_Reader.read(+201)
        at java.io.Reader.read(+11)
        at java.io.InputStreamReader.read(+11)
        at com.sun.midp.midletsuite.JadProperties.readLine(+18)
        at com.sun.midp.midletsuite.JadProperties.partialLoad(+60)
        at com.sun.midp.midletsuite.JadProperties.load(+8)
        at com.sun.midp.midletsuite.JadProperties.load(+6)
        at com.nokia.phone.sdk.concept.midletsuite.MIDletSuite.initialize(+53)
        at com.nokia.phone.sdk.concept.midletsuite.MIDletSuite.<init>(+37)
        at com.nokia.phone.sdk.concept.main.MIDPMain.runLocalClass(+31)
        at com.sun.midp.Main.main(+93)
[EventDispatcher] run() evt.getHandlerSlot() == -1
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Fri Sep 01, 2006 10:06 pm

the above is solved by
Code: Select all
set DESCRIPTOR_FILE=concept_config.jad
We begun using it to run the SMSTester.class which has a SMSSend but not sure if this sends OUT or sends IN to the SMS gateway device.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Tue Sep 05, 2006 3:48 pm

When we run the SMSTester.class from the Emulator it has a preset phone number 012-3456789. Where it comes from? It comes from SMSTester.java:
Code: Select all
public void run()
     {
          smsStateMachine   = SimulatorControlFactory.getSMSStateMachine();
getSMSStateMachine has got it set:
Code: Select all
private static final java.lang.String CONST_EXTERNAL_APP_PHONENMBER =  "012-3456789";
And other sets. This class has no source and its in the emulator.jar given by Nokia.

The IMLET Programming Guide throws enuf clues on how to get into it. It describes the use of packages which are present in the classes.zip where emulator merely extends from.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Wed Sep 06, 2006 3:38 pm

Suresh advised not to do it this complicated and use the standard Java Comm API - http://www.javaworld.com/javaworld/jw-0 ... vadev.html

It has samples that shows how to wrap AT calls to the phone device, which are pretty simple and open I/Os.

The samples that are there is BlackBox which is a HyperTerminal that can dialog your AT commands to the port.

One sample small enough to learn from is SimpleRead and SimpleWrite javas.

When debuging in Eclipse place this in the VM Arguments
Code: Select all
-Djava.library.path=D:\red1org\projects\Ntegrator\comport\commapi
It shuld point to a comm.jar which u must classpath to also.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Wed Sep 06, 2006 5:49 pm

Back to the Nokia story. It seems that it uses Information Modules or IMlets, which there is a sample called aplicom12sdk which u can download from the web. Just search for the name and u can see inside is an ExampleImlets (D:\red1org\projects\Ntegrator\aplicom12sdk\Java\Examples\ExampleIMlets). Put the jad and jar from there into the Nokia/bin folder and exec the emulator again using the jad as argument.

U can create a new Eclipse project on the src and i m not sureyet of how u can debug and run the emulator.
Note that u need the classes.zip in the classpath.

Now that we know how to run the IMlet, the Nokia 12 Concept Simulator User Guide now makes sense and excitement - see in it pages 26 and 27.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Thu Sep 07, 2006 5:50 pm

Tested the SimpleRead. It worked .. can tell me what com port i have and listen to it.. waiting.

But when deployed into Tomcat package of main app, it returns null. Suresh helped by refering to http://www.jguru.com/faq/view.jsp?EID=1048895 where we place the comm.jar and win32com.dll (download) in the java_home/jre/lib/ext ...

Now it worked as proven concept. Next is to put the SimpleWrite at convenient place within the Compiere processor that handles issuing of request notice and receipt of notice has to be another place where we place a notifier to check for incoming sms from device and spawn a check as to the contents of message. This follows hereby a protocol:

1. Check CLI of incoming sms.
2. If in request_updates<>user_id.phone,
3. Submit reply to request with message+wrap.
4. Message is translated from SMS Dictionary
i.e. 1 = "Will attend to it rite away"
2 = "Will attend after present task"
3 = "Cannot attend. Pls route"
Wrapper shall prefix the user name, and type of reply i.e. "Engineer A sent sms:Will attend..."

Carrying the SMS dream abit further, we can have ERP on Demand! or SMS-ERP!

For example, u send "SO-Joe" and system returns "Joe Block has 3 open Sales Orders. Key in which one u like - 1/2/3"
U then send, "2";
System: "2nd Orders 3 Hoes. Do u want to ship? Y-1/N-2)"
U say, "1";
System: "3 Hoes to ship to Joe. Warehouse notified" and system sends an sms to the Warehouse Manager's handphone :D
Last edited by red1 on Sat Sep 09, 2006 10:01 pm, edited 1 time in total.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby zam » Thu Sep 07, 2006 6:39 pm

Sending SMS Messages from Terminal Devices
by Al Pritchard


Sending an SMS text message to a cellular phone from a terminal device is a simple affair, as the following code fragments demonstrate. The phone used in this example is a Nokia 7100 series, and the ME (mobile equipment) is linked to the computer via communications port #1.

Also note that the Ctrl-Z necessary for terminating the text entry sent to the mobile device is copied from the terminal session and then added to the code.

+ To send an SMS text message with Visual Basic
Code: Select all
' Set up the communications port
MSComm1.CommPort = 1 ' Com Port 1

' Set for 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"

' Tell the control to read entire buffer when Input is used
MSComm1.InputLen = 0

' Open the port
MSComm1.PortOpen = True

' Send an 'AT' command to the phone
MSComm1.Output = "AT" & Chr$(13) & Chr(10)
' The phone will respond with an 'OK'

' Set up the phone for a text message
MSComm1.Output = "AT+CMGF=1" & Chr$(13) & Chr(10)
' The phone will respond with an 'OK'

' Prep for SMS, give destination type and destination address.
' Enter the destination type and destination address to prep for SMS
' e.g. AT+CMGS="+2145551212",129
MSComm1.Output = "AT+CMGS= " & Chr(34) & _
   "+2145551212" & Chr(34) & ",129" & Chr$(13) & Chr(10)
' The phone will return a'>' prompt, and await entry of the SMS message text.

' Now send the text to the phone and terminate with (Ctrl-Z)
MSComm1.Output = "This is a test. WOW! "
' The phone will respond with a conformation containing
' the 'message reference number' eg. +CMGS:

' Close the port
MSComm1.PortOpen = False


+ From a terminal, it would look like this:
Code: Select all
AT
OK
AT+CMGF=1
OK
AT+CMGS="+15127752607",129
>This is a test. WOW!
+CMGS: 49

OK
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Fri Sep 08, 2006 5:22 pm

I tried to send ATDT + number thru the hyperterminal but it keeps on giving "NO CARRIER" reply.

Below is a code by Niversphere on how he sends sms. He is using PDU format.
_____________________________________________________________
Java Coding Problems with AT commands by Niversphere.
http://discussion.forum.nokia.com/forum/showthread.php?t=83998

Code: Select all
protected void converse() throws IOException {
String resp;// the modem response.
// Send the reset command
send("ATZ");
expect("OK");
send("ATDT" + number);
expect("OK");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// nothing to do
}
is.close();
os.close();
}
}


Cant seem to get it right to send sms through. ATD + number works but there is no ring tone on my phone and the receiver cannot hear.

Further to that, I was wondering how AT+CMGS works for this code segment. I tried but then the response is always wrong. It works on Hyperterminal. My guess is that there are some hidden characters in it.

Whats the character for Ctrl-Z when i need to send it as a String to the Serial Port?

Solution
Code: Select all
..........

send("AT+CMGS=17\n");
expect(">");
send("0011000A915612345680000FF04D4F29C0E\n");
expect("0011000A915612345680000FF04D4F29C0E\n");
expect("+CMGS: 0\n");
expect("OK");

....

00 11 00 0A 91 5612345678 00 00 FF 04 D4F29C0E

00 : use of the service center number stored in the phone
11 : user data header
00 : message reference number, phone decides
0A: length of the phone number in this case , 5612345678 = 0A( 10 in decimal)
5612345678: Phone number represented in semi-octet format.actually phonenum is 6521436587
00: protocol identifier
00: data coding scheme
..And there is no timestamp for my phone. In its place was the FF.
04:The length of the PDU
* note : When using the 7-bit data coding scheme, the user data length is the amount of characters(septets) and not the amount of octets.
(That part got me confused for a while.)

The character represented ctrl-z is . Had a hard time trying ^z and such.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Mon Sep 11, 2006 2:46 pm

Got from http://www.velocityreviews.com/forums/t302787-sms-with-at-commands.html
_______________________________________________________________

Here is a code that can be used to send SMS's from your GPRS device.
This code was modified from 'SimpleWrite.java' example taken from
Samples of API Documentation. Beware that this code has'nt been tested.
So use it at your own risk.

Code: Select all
import java.io.*;
import java.util.*;
import javax.comm.*;

public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String commands[] =
{"AT+CMGS=1","AT+CMGS=\"9292912345\","Hello there"};
static byte[] newline[]={(byte)13,(byte)10}
static SerialPort serialPort;
static OutputStream outputStream;

public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)

{
if (portId.getName().equals("COM1")) //your comm port
{
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {}

try {
//get the output stream
outputStream = serialPort.getOutputStream();
//write the commands string to the output stream
for(int i=0;i<commands.length;i++)
{ outputstream.write(commands[i]); // write command
outputstream.write(newline); //write new line
}
outputStream.write(messageString.getBytes());
} catch (IOException e) {}
}
}
}
}
}
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Mon Sep 11, 2006 6:29 pm

I used the code below for my sms testing :

Code: Select all
import java.io.*;
import java.util.*;
import javax.comm.*;

public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static SerialPort serialPort;
static OutputStream outputStream;
static InputStream inputStream;

static String messageString1 = "Please contact me!"; //overwritten later
static String destinationAddress = "+60176377916";
static String commandString1 = "AT+CMGS=\"" + destinationAddress + "\",145\r" + messageString1 + "\u001A\u005A";
public static void main(String[] args)
{
            portList = CommPortIdentifier.getPortIdentifiers();

            // slide the found ports.
            while (portList.hasMoreElements())
            {
            {
               portId = (CommPortIdentifier) portList.nextElement();
               //System.out.println(portId.getName()); //writes all available ports to screen
               if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
               {
                  if (portId.getName().equals("COM1"))
                  { //selects the port
                     try {
                           serialPort = (SerialPort)
                           portId.open("", 2000); //opens the port
            
                        }
                         catch (PortInUseException e)
                         {
                            System.out.println("port in use:");
                            System.out.println(e.toString());
                         }
            
                        try {
                                 outputStream = serialPort.getOutputStream();
                            }
                            catch (IOException e) {}
            
                        try {
                                serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
                            }
                            catch (UnsupportedCommOperationException e) {}
                       
                        try {
                                 //byte[] myCommand=commandString1.getBytes();
                                  // outputStream.flush();
                                  outputStream.write(commandString1.getBytes());
                                 //outputStream.write(myCommand, 0, myCommand.length);
                              System.out.println(commandString1);
                              serialPort.close();
                              System.out.println("ok");
                        }
                        catch (IOException e)
                        {
                           System.out.println("could not write to outputstream:");
                           System.out.println(e.toString());
                        }
                     }
               }
            }
                }
}


}


First debug : I managed to display the 'AT+CMGS="+60176377916",145 ' but sms was not sent. I was not sure on how to make the program responded by displaying 'OK' like in hyperterminal.

Second debug: 'AT+CMGS="+60176377916",145 ' failed to be displayed. Instead i got "could not write to outputstream:java.io.IOException: write error" error.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby red1 » Tue Sep 12, 2006 4:32 pm

I have already CVSed my work into NTSB project of the above, where u can use UI to interact with the Simple javas.

Use the x.html and click on the Test Phone link which calls up the Pojo.java which calls the simple javas.

Seems u re bit stuck with Write here. Why not use the SimpleRead and see if it can read from the device? :D
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby red1 » Tue Sep 12, 2006 5:43 pm

Zam,
What did u do different between the first and second debug? Your string looks the same.

Also, what is the full error stack that is thrown? After the not write to outputstream:java.io.IOException: write error. When u put a break just before the outputStream.write can u see the contents of serialPort? Use the watch feature in Eclipse. Maybe inside that, can tell u sumtin that wasnt present to proceed.
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby zam » Wed Sep 13, 2006 11:20 am

Code: Select all
First debug : I managed to display the 'AT+CMGS="+60176377916",145 ' but sms was not sent. I was not sure on how to make the program responded by displaying 'OK' like in hyperterminal.

Second debug: 'AT+CMGS="+60176377916",145 ' failed to be displayed. Instead i got "could not write to outputstream:java.io.IOException: write error" error.


Refering to the output I got when running simplewrite, I presume that i will get "could not write to outputstream:java.io.IOException: write error" when

- the COM port I initialized is being used by other program or the port is not properly closed
- the string I used is not correctly coded ( CR =\r , CTRL+Z = 0x1A;)

In hyperterminal, every time the AT+CMGS..... is entered, modem will respond by giving "OK".

As for now, to make sure my program is interacting with Nokia modem, I have to program a read process that will be executed once the ATCommand string is sent out. Read process should return "OK" if program does communicate with the modem.

I'm refering to the link below for my write and read sms process.

http://lists.freebsd.org/pipermail/freebsd-java/2004-August/002771.html
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Wed Sep 13, 2006 12:34 pm

As suggested by Encik Rahman, I try to send "AT" first before moving on to sending SMS. If program returns "OK", it confirms that there is connection between program and modem.

Previously I was not sure whether
- I failed to communicate with the COM port or
- I can communicate with COM port but AT+CMGS string is coded wrongly

Based on the read coding from the link http://lists.freebsd.org/pipermail/freebsd-java/2004-August/002771.html, I managed to get a respond from modem when AT is sent out. So from here, I'll test on the AT+CMGS string. If sms is successfully being sent out, that means the string is correctly coded or else I'll have to search on how they encode those characters of CTRL+ Z or CR in java. I found various styles of how they encode the characters but not sure which one is correct.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Wed Sep 13, 2006 4:42 pm

Able to send out sms by executing
Code: Select all
static String commandString3 = "AT"+"+"+"CMGS=\"+60176377916\",145\rtest\032";

When the above string is sent, SMS being received by receipient is
Code: Select all
AT+CMGS="+60176377916",145 test

The actual SMS to be received by receipient is "test" only, instead of the whole AT Command.

Still not sure on how to encode CTRL-Z. As for now I'm using 032 for CTRL-Z. After few times of trying, SMS-es were successfully sent out . Later, the same exact line didnt seem to work. Still figuring out causes of the inconsistent process.
Last edited by zam on Mon Sep 18, 2006 2:46 pm, edited 2 times in total.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Fri Sep 15, 2006 10:48 am

Below is the output when I send-->static String commandString4 = "AT"+"+"+"CMGR=2\r";

Code: Select all
Reading ...
Available: 238
.
.
.

Available: 5
Available: 4
Available: 3
Available: 2
Available: 1
AT+CMGR=2

AT+CMGR=2

+CMGR: "REC READ","+60192824722",,"06/09/03,23:52:26+32"
?@ @  @ZAM, where r u? nizam here! i need some help! now, i'm in india! my hp doesnt hv roaming, dnt call it will reverse chrge! can u buy me some prepaid? i'll

OK


the whole string from +CMGR..till i'll is the same with the output displayed in hyperterminal when the same string is sent out
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby zam » Fri Sep 15, 2006 11:55 am

AT+CMGL="REC READ" should list out all SMS-es that have been read by user. The outcome of hyperterminal is as follows:

Code: Select all
at+cmgl="REC READ"
+CMGL: 1,"REC READ","+60125663211",,"06/09/15,10:18:06+32"
Zam, lunch hour g mana? Igt nk g cyber nk kasi cd miri.
+CMGL: 2,"REC READ","+60192824722",,"06/09/03,23:52:26+32"
‚@ @  @ZAM, where r u? nizam here! i need some help! now, i'm in india! my hp do
esnt hv roaming, dnt call it will reverse chrge! can u buy me some prepaid? i'll

+CMGL: 3,"REC READ","+60125663211",,"06/09/15,11:01:52+32"
Aku nk paskan cd kt ko je. Igt kalo g sana pn, jmp kt fudcourt blkg 2 je la
+CMGL: 6,"REC READ","+60192824722",,"06/09/03,23:52:29+32"
‚@ @ ­@ payback. here, this is my number. i'm using prepaid.
+CMGL: 10,"REC READ","+60192824722",,"06/09/04,00:00:24+32"
its ok if u can't help me! anything, just sms, do not call. it will expensive!
+CMGL: 18,"REC READ","+60122216547",,"06/09/08,08:09:10+32"
bley.B-19-20 vista pinggiran,jln pp 1 sksyen 2,tmn pgran putra,43300 bdr ptra pe
rmai.sel.dia btntngan jusco tmn equine.apart yg plg tg...
+CMGL: 22,"REC READ","+60126229144",,"06/09/08,22:48:01+32"
2-8-7,Tgkat 8,blok anggerik,umah no 7.boleh jek.. Xpela,awk miskol bla nk dtg,sy
kol balik..

OK



but i failed to get the same output in simplewrite. the program only display
Code: Select all
Reading ...
Available: 16
.
.
.
Available: 4
Available: 3
Available: 2
Available: 1
AT+CMGL="REC READ"

i need some hel


I think modification on how big the buffer for storing inputstream need to be done, so that remaining text can be retrieved as well.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby red1 » Fri Sep 15, 2006 7:42 pm

I tried searching for "Java Ctrl Z" in Yahoo! and got answers like:

1) myOutputStream.write( (byte)26 );

2) .. \032

But i think... \032 must be literal... so it has to be "\\032", get it?
red1
Site Admin
 
Posts: 2705
Joined: Tue Jul 06, 2004 3:01 pm
Location: Kuala Lumpur, Malaysia

Postby zam » Mon Sep 18, 2006 11:02 am

red1 wrote:I tried searching for "Java Ctrl Z" in Yahoo! and got answers like:

1) myOutputStream.write( (byte)26 );

2) .. \032

But i think... \032 must be literal... so it has to be "\\032", get it?

if i use the code below
Code: Select all
static String commandString1 = "AT+CMGS="" + destinationAddress + "",145\r" + messageString1 + "\\032";

the AT Command being sent would be
Code: Select all
AT+CMGS="+60176377916",145
monday\032

so "\\032" does not represent CTRL-Z..it represents a string
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby sureshquest » Mon Sep 18, 2006 2:55 pm

zam wrote:Able to send out sms by executing
Code: Select all
static String commandString3 = "AT"+"+"+"CMGS="+60176377916",145\rtest\032";

When the above string is sent, SMS being received by receipient is
Code: Select all
AT+CMGS="+60176377916",145 test

The actual SMS to be received by receipient is "test" only, instead of the whole AT Command.

Still not sure on how to encode CTRL-Z. As for now I'm using 032 for CTRL-Z. After few times of trying, SMS-es were successfully sent out . Later, the same exact line didnt seem to work. Still figuring out causes of the inconsistent process.



If u guys have problem like receiving the AT command also along with the SMS message in the phone u could try any of the following solutions,

1. Try to prefix the message with a null character or \0 , becoz some devices use tht to identify as the msg prefix.

2. Or the another way is to try send the msg in PDU format instead of string, The following link explains how to send in PDU format.

http://www.dreamfabric.com/sms/
sureshquest
Regular
 
Posts: 69
Joined: Wed Sep 15, 2004 11:09 pm
Location: India

Postby zam » Mon Sep 18, 2006 3:53 pm

sureshquest wrote:If u guys have problem like receiving the AT command also along with the SMS message in the phone u could try any of the following solutions,

1. Try to prefix the message with a null character or \0 , becoz some devices use tht to identify as the msg prefix.

2. Or the another way is to try send the msg in PDU format instead of string, The following link explains how to send in PDU format.

http://www.dreamfabric.com/sms/

Have tested method 1. It didnt work. Msg received by recipient still
Code: Select all
AT+CMGS="+60176377916",145 test

\0 added a space before 'test'. Will surf to see if there is other character that can actually extract out the message only.
Last edited by zam on Mon Sep 18, 2006 5:24 pm, edited 1 time in total.
zam
 
Posts: 49
Joined: Mon Jul 17, 2006 9:30 am

Postby sureshquest » Mon Sep 18, 2006 4:04 pm

Try prefix the message with new line character ( \r\n )
sureshquest
Regular
 
Posts: 69
Joined: Wed Sep 15, 2004 11:09 pm
Location: India

Next

Return to Compiere Case Workshop

Who is online

Users browsing this forum: No registered users and 1 guest

cron