Anil Dhiman

Dear All,

I am developing an application using GSM modem I have around 50 messages limitonto my SIM card of Modem. Time when I am receiving the SMS I have to delete it using AT commands through C#.NET, Similarily I did when I had very less traffic , But Now I am getting numerous messages and the time when I am deleting the messages I am getting more messages still to come and it goes on increasing and my process of reading data gets slow...

I want to get the messages directly to my PC hard disk instead of getting it on SIM card .As soon as new message comes in to GSM modem I would be able to redorect message to my hard disk

So that , I would be able to handle large amount of Messages on my Machine

Regards,

Anil Dhiman




Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

hi anil,

are you manually deleting from the sim card if yes, i have a similar project. what i did was do some code where everytime my sim received a message, it automatically saved them in a database (db4o) and afterwards deleted the message from the sim. i have another function where i can refer to the saved messages in the database for later use. the project is an sms portal for chatting purposes on a discussion board for a tv show, and it receives a lot of messages at a time too. by the way, i'm not using AT commands. i used GSMComm library for c#.net to connect to my gsm modem and it works well too. i'd be happy to share more info with you if you want to. i hope this helps.

im not sure if there's a way where you can directly get messages to your hd because it's the sim that receives the sent messages to your gsm modem.






Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Anil Dhiman

Hi

That's a great idea , but still it seems somewhat heuristic. Storing the sms in database and deleting them do take time and in that interval there are numerous sms on the sim.

Can you tell me how many sms you have (at max) handled in 1 min

Is it possible to save and delete sms from SIM using GSMCOMM library

P lz help me

Regards

Anil Dhiman






Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

good to hear from you anil. what database are you currently using i'm using db4o 5.0 and it takes my system only a few seconds to retrieve sms from the sim, save it in the database and then delete it. i did some code where when the sms arrives, the program automatically does the retrieve-store-delete function so it saves time. i really don't have an accurate measurement of the time it takes but i'll check again to give you the exact figures. i'll also run a test later for your sms handled per minute rate. our old sim here is only allowed 30 sms in it so it's even lower that your sim limit.

yes you can delete sms from sim using the gsmcomm library. in storing sms in the db4o database, i'll share with you some code later on. when you get the gsmcomm library, there is a bundled sample app so you can get ideas from it using to code with vb or c#

regards,
dave patricio




Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Anil Dhiman

Hi Dave,

Nice to hear from you again dave, I am using SQL Server for my project . I have downLoaded the GSMCOmm library , I think that library is free to be used.

Again , my SIM capacity is 25 , I have gone through the coding part of library for C# . Can u share your sample code for store-delete

Regards,

Anil






Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

hi anil, here's some of the code for store and delete, btw since i used a different database, i'll leave it to you in storing in sql server(i'm not quite familiar with this).

define your gsm connection as:

GsmCommunication.GsmComm GSM = new GsmCommunication.GsmComm(port number);

make sure you're connected with you modem so use this code:


private void connectToolStripMenuItem_Click(object sender, EventArgs e)
{

GSM.Open();
if (GSM.IsConnected())
{
this.txtStatus.Text = "Modem is connected" + '\n';
Enable_Menu();

}
else
{
this.txtStatus.Text = "Modem is not connected" + '\n';

}
}

make sure that you added the gsmcomm library in the references (using PduConverter; Using GsmCommunication;) i used gsmcomm version 1.6

to receive messages as they arrive in your sim, make sure first that you have enabled message notification (you can get the code from the sample application of gsmcomm)

private void ShowNewMessage( string msgStorageLocation, int msgStoreIndex )
{
// This shows the new message in a textbox txtStatus, you can change this of course
DecodedShortMessage message = GSM.ReadMessage(msgStoreIndex, msgStorageLocation);
PduConverter.SmsDeliverPdu SMSPDU;
SMSPDU = (PduConverter.SmsDeliverPdu)message.Data;
this.txtStatus.Text += SMSPDU.OriginatingAddress.ToString() + '\n';
this.txtStatus.Text += (SMSPDU.GetTimestamp().ToDateTime().ToString()) + '\n';
this.txtStatus.Text += (message.Data.UserDataText.ToString()) + '\n';

// Add code here to store in SQL server
message.Data.UserDataText //this is your sms, store the value in your sql server

// Delete message from sim
GSM.DeleteMessage(msgStoreIndex, msgStorageLocation);
}

by the way, i'm using a listview tool to show different parts of the message because i'm using keywords and specific message formatting. let me know if you want code on that too. good luck

dave




Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Anil Dhiman

Hi Dave,

Thanks for that piece of code . I really liked the way u present the things . I will now try with this piece of code and will definitely revert back to you at the earliest

Regards,

Anil Dhiman






Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

hey Anil,

you're welcome and good luck with your project. i'll be standing by for further info on your development.

dave patricio





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Luis69

Hello dave,

I've been using gsmcomm for months now. I use it with my simple .Net application to communicate to my customers.

I've been successful in interfacing my code to send sms with the library, but I've never been able to export (in) messages to my PC.

I can run the Demo application delivered with the bundle, and I can create the c:\messages.xml file, but the "data" field contains some sort of (seemingly) hexadecimal code (I use the "Manage SMS">"Export all messages" button in the demo).

Am I missing something simple

Thanks in advance for your time.





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

hey Luis69,

first of all, what language are you using second, what type of message do you want to export to your pc in my case i have identified two types: messages already in your sim inbox and new messages that are being received by your application during runtime. i used gsmcomm v 1.6 so some of the code might not be identical, just to play safe.

by the way i did not use the export message function in the demo because i retieved the messages as they arrived and stored them in a database (db4o). the code in the export all function only exports messages stored in the sim. just let me know if you want help in retrieving in runtime.

thanks to zamba for developing gsmcomm!


dave patricio





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Luis69

Hello dave,

thank you for your feedback and sorry for the delay in my reply, I've been playing with the library to learn more about it, before posting back.

I've written my scritp to download messages from my phone storages (thank you Zamba for GSMComm!).

I still have a problem I would like to share: if a message is a multiple (i.e. long) message, then it is split out into shorter messages.

I use

DecodedShortMessage[] messages =

this.gsmCommMain.ReadMessages(PhoneMessageStatus.All, storage);

to read the messages and then

SmsDeliverPdu messaggio = (SmsDeliverPdu)decodedShortMessage.Data;

dataRow[ MessaggiEsportati.Testo ] = messaggio.UserDataText;

to store the text in a DataRow cell.

The problem is that, when I have a message longer than 160 characters (in my cell phone I see a special icon for such "long" messages) that message is split out into multiple short messages (and the UserDataText field contains, at the begin of such message "parts" some "strange" characters).

It would be great if I had the chance to treat such long messages as a single message.

If this is not possible, I would appreciate a way to cut out the strange characters I see at the begin of such message parts.

Thanks in advance for your help.

Luis





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

welcome luis,

is there like anyway to determine whether the message you receive is longer than 160 chars you see it depends on your unit. old ones make like "[1/2]" for the first message and "[2/2]" for the second. new ones that support 160+ chars just automatically connects the messages. if there is some way or some kind of constant mean of determining if the message your system received is 160+ then it is possible to "connect" the messages. for example, just place a condition IF 1st characters = [1/2] and [2/2], then determine if the senderID is the same and also if the date and time when the message is sent is the same. if the results are all true then you can combine the two strings to show as one. Concatenate!

as for the cutting out the strange characters at the beginning of your message, you can do some code where it takes the first group of characters: you can do this by splitting your string by spaces

string[] Word = message.Data.UserDataText.TrimStart().Split(' ');

and taking out the first member example: Word[0].) after retrieving the first group or word, you can trim out those nasty weird characters.

ps: i had a lot of explaining to do when we got to this issue in part of our thesis defense lol. whew

dave





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Mohan1

Hi Dave,

Could you please tell me which dll or namespace or component to use for GsmCommunication class which you have mensioned on your code

Mohan





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Dave Patricio

Hi Mohan,

you'll have to reference the gsmcomm library for that. just google it up and download it. feel free to send me a message if you have any questions. good luck!

Dave





Re: Smart Devices VB and C# Projects Traffic on GSM Modem

Raman-astix

hey dave

i am getting this error when i run ur coding.

NO PHONE CONNECTED.

i dont know what yo do .