What happens when we need to synchronize data and the Internet connection is not available?
In this scenario an alternative channel needs to be used to send and receive changes. SMS via a mobile phone is one possible alternative channel.
The idea is to share data between two PCs with the mobile phone plugged in. The application uses the phone as a modem.
Mesh4x's SMS Adapter allows 2-way synchronization over SMS messages, optimizing the number of messages sent both ways.
The following picture shows this idea in detail. The data in this example are KML file elements:
Packaging and Configuration
The application is distributed by a zip file.
After unzipping the file some configuration changes need to be made.
To configure the application we will edit the mesh4j_sms.properties file. The default configuration looks like this:
Here, the default KML file and the default SMS phone number can be changed.
The default.base.directory property defines the directory where the application stores the SMS Adapter information. If a '#' is added before the property, the value is replaced with the current directory (where the application was installed):
As the application is using the mobile as a modem, the modem port must be configured. Although the automatic discovery of modem is possible, it is a pending issue in the TODO list :)
Don't forget to enter the properties default.sms.port and default.sms.baud.rate !
Obtaining the Modem Port
There are several ways to obtain the modem port. In Windows Vista, the DeviceManager application can be used:
Running the Demo
To run the demo, double-click over the mesh4j-SMS-DemoApp.jar file. To use it, you must have java JDK installed in your PC. The following window will be shown:
To synchronize a KML with other KML files or with a Sync Server via HTTP you can use the "KML synchronization Group".
You should enter the endpoint1 and endpoint2 using a KML file or a sync server URL.
The button named "Synchronize" starts the synchronization process. Partial information is shown in the console view.
When the KML file is newer the file needs to be prepared for the process of synchronization. The KML Adapter adds the sync information to the KML file.
For this process you should press the "Prepare file to sync" button. If you do not prepare the file but you run the synchronization process, the KML adapter always prepares the file before the synchronization process is run.
The KML file with and without Sync Information are very similar.
KML File without Sync Information:
KML File with Sync Information:
The "Purge" button removes all the sync history with exception of the latest one.
The button "clean" removes all the sync information (clean up everything).
When the application starts up, it verifies if the modem has been plugged in (using the value in the property default.sms.port). If the modem has been plugged in the modem's name is shown in the field named "Phone". Otherwise, the word "Demo" is shown.
To synchronize a KML file with another PC via SMS, the next step is to enter the KML file to synchronize (the file must be located in the mobile phone directory, this will be discussed more in detail later in this post) and the phone number of the counterpart.
The button "Synchronization" start the synchronization process. This process could take time, but it works as an asynchronous process.
The console view shows all messages traffic, and you can see high level notifications too.
You could simulate the process with the button "Simulate" which lets you see in the console view the complete traffic of the protocol messages (no SMS messages are sent).
For test purposes you can send a message manually. First you enter the phone number and the message to send, and then press the button "send".
The console view shows notification messages of all processes running in the application (file to file synchronization, file to URL synchronization or file to file SMS synchronization).
The protocol is based on a SyncSession concept. A sync session is a session that maintain the information of the synchronization process.
A new directory for the mobile phone plugged in the PC is created on the default.base.directory. In this directory the SmsAdapter stores the sync session information. (*1)
Snapshot Session Feed Example:
Each protocol message to be sent is divided in a batch of compressed messages. For assurance of the reliability of the protocol two queues are used to store in/out messages. Each queue is persisted as a Feed.
In Queue Feed Example (smsChannel_incomming.xml):
Out Queue Feed Example (smsChannel_outcomming.xml) :
The smslib java library is used to send and receive SMS messages.
The application requires the "Java Communications Library" installed in your PC. smsLib uses the serial port cable to communicate with the mobile phone to send and receive messages. Please check the following installation instructions (only Java Communications Library section).
Please check if your mobile phone is in the Compatible GSM Modems/Phones list.
I hope that it can help you !!!