SMSLib for .NET is a port of the Java SMSLib library for the Microsoft .NET Framework platform. Its an attempt to create a binary distribution for the same java sources that the normal SMSLib is build from. The binary conversion is possible with the help of IKVM tools.
Please note that SMSLib for .NET is experimental! Please read carefully the following document in order to understand the port and know what to expect.
Looking a couple of years back, there was a seperate SMSLib for .NET codebase. So, I had to maintain and enhance two seperate versions, a C# version and a Java version. Supporting and synchronizing two platforms was found to be a tremendous load for me. Sadly, I've decided to drop one of the two. I like Java very much - I also like C# a lot, but I decided to go with Java since it was the most established version. Needless to say that I've received numerous complaints since then...
Some time ago I got to know a bit more about some conversion tools, mainly IKVM. My problem was that SMSLib is not an 100% pure Java library - there are binary dependencies, namely the JavaComm / RxTx serial communications' libraries. My first attempts to port SMSLib to the .NET platform failed misserably, as I couldn't make the comm library work. At the end, I decided to take a different approach. The result of this work is that now I can create .NET projects, use SMSLib as a DLL and having the full SMSLib functionality available on the .NET Framework platform, by keeping the same sources for Java as well as for .NET.
I decided to go with IKVM. IKVM is licensed with a business friendly license, like SMSLib is. It also appeared to me as a more mature product. I won't bother you with the exact conversion details - if you are reading this you are probably a .NET developer, so I assume that you don't give a damn about how this is done. What you should really remember is that SMSLib is packaged as a .NET Framework DLL, ready to be downloaded and used in your project.
Enough with the theory! Below you will find the installation instructions for SMSLib for .NET. Its a pretty simple process.
The following installation instructions are valid for IKVM version 0.44.0.5. Different IKVM versions may implement different packaging of .NET/Java classes, so the installation may differ a bit. |
In order to use SMSLib, you should download:
Unpack the SMSLib for .NET package in a directory of its own. The package contains the ready-to-use .NET SMSLib library (smslib-x.y.z.dll
) plus two sample projects to get you started.
Unpack the IKVM package at a temporary location. Grap all the files named bin/IKVM.*.dll
and copy them in the Libraries
subdirectory of the SMSLib for .NET directory.
That's it!
There are two sample projects for your initial tests. The ReadMessages
project which reads messages from a serial modem or phone and the SendMessage
project which sends a message via a serial modem or phone.
ReadMessages
project with Visual Studio.Libraries
subdirectory) are added in the "References" section of the project.IKVM.*.dll
filesSince the java comm libraries (JavaComm and/or RxTx) could not be converted and used by the .NET application, I decided to solve the problem differently.
The Comm2IP
is a .NET native application which acts as an interface between a COM port and a socket. Traffic received from the one is pushed to the other and vice versa. Why I did this? Because, by doing this, I would be able to connect to a serial modem in the same way as I connect to an IP modem: I don't use a COM port, I use a network connection. Bye bye javacomm libraries!
The Comm2IP
is build as a .DLL in order to be easy for you to include it in your SMSLib projects.
The Comm2IP
is a vital component and I am sure it will be the subject of most support questions. If you don't set it up correctly, you will not be able to communicate with your modem. Examine the relevant code in the ReadMessages.cs
source file:
Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new byte[] { 127, 0, 0, 1 }, 12000, "com1", 19200); new Thread(new ThreadStart(com1.Run)).Start();
This code:
Comm2IP
component to bind to the local host (127.0.0.1) under port 12000 and to the com1 serial port, with a baud rate of 19200bps.From now on, all traffic from com1 will be forwarded to the listener which binds on 127.0.0.1:12000 and vice versa.
Later on in the code, you create your IP modem gateway:
IPModemGateway gateway = new IPModemGateway("modem.com1", "127.0.0.1", 12000, "Nokia", "");
which binds to the same host:port that the Comm2IP
component is initialized.
Remember: One Comm2IP
thread is for one modem. For multiple modems you should create a matching number of Comm2IP
threads!
In the "/Misc" subdirectory of the SMSLib distribution file you will find the file names log4j.properties
. If you wish to enable the debug output, just copy the file together with your applications (i.e. your .EXE files).
If you would like to build the .dll file from the latest SMSLib distribution, follow these simple steps:
bin
directory. Copy the following files in the bin
directory: smslib-x.y.z.jar
, the log4j-x.y.z.jar
and the commons-net-2.0.jar
.ikvmc -target:library smslib-x.y.z.jar log4j-1.2.15.jar commons-net-2.0.jar
You will get some warnings about non-existent referenced classes, but for most cases the .dll build after this command is OK for use.
Once more, SMSLib for .NET should be considered experimental until further feedback is given. As a result, the .NET specific documentation is a bit short, but I am working on it.
Remember that the SMSLib is actually the same for Java and for .NET. The entire SMSLib functionality is available to you. The Support page will guide you in case you need support.