Wednesday, October 15, 2008

Mesh4x SMS Adapter Desktop PC

Introduction

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:

 image

Packaging and Configuration

The application is distributed by a zip file.

After unzipping the file some configuration changes need to be made.

 image

To configure the application we will edit the mesh4j_sms.properties file. The default configuration looks like this:

default.kml.file=c:\\Clarius\\mesh4x\\test\\example.kml
default.feed.url=http://sync.instedd.org/Service.svc/feeds/Default
sync.identity.provider=org.mesh4j.sync.security.LoggedInIdentityProvider
default.base.directory=c:\\Clarius\\mesh4x\\test\\
default.sms.phone.number.destination=01136544867



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):




sync.identity.provider=org.mesh4j.sync.security.LoggedInIdentityProvider
#default.base.directory=c:\\Clarius\\mesh4x\\test\\
default.sms.phone.number.destination=01136544867



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 !




default.sms.port=COM23
default.sms.baud.rate=115200
default.sms.sender.delay=0
default.sms.receiver.delay=0
default.sms.read.delay=60000
default.sms.channel.delay=1000
default.sms.max.message.length=100
default.sms.compress.method=org.mesh4j.sync.message.encoding.CompressBase64MessageEncoding
default.sms.use.asynchronous.connection=true



Obtaining the Modem Port



There are several ways to obtain the modem port. In Windows Vista, the DeviceManager application can be used:



 image



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:



image



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.



 image



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.



 image



The KML file with and without Sync Information are very similar.



KML File without Sync Information:





   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <kml xmlns="http://earth.google.com/kml/2.2">  


   4:   <Document> 


   5:     <name>default.kml</name>  


   6:     <Style id="sn_ylw-pushpin"> 


   7:       <IconStyle> 


   8:         <scale>1.1</scale>  


   9:         <Icon> 


  10:           <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> 


  11:         </Icon>  


  12:         <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> 


  13:       </IconStyle> 


  14:     </Style>  


  15:     <Style id="sh_ylw-pushpin"> 


  16:       <IconStyle> 


  17:         <scale>1.3</scale>  


  18:         <Icon> 


  19:           <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> 


  20:         </Icon>  


  21:         <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> 


  22:       </IconStyle> 


  23:     </Style>  


  24:     <StyleMap id="msn_ylw-pushpin"> 


  25:       <Pair> 


  26:         <key>normal</key>  


  27:         <styleUrl>#sn_ylw-pushpin</styleUrl> 


  28:       </Pair>  


  29:       <Pair> 


  30:         <key>highlight</key>  


  31:         <styleUrl>#sh_ylw-pushpin</styleUrl> 


  32:       </Pair> 


  33:     </StyleMap>  


  34:     <Placemark> 


  35:       <name>My City - Brandsen</name>  


  36:       <description>My city...</description>  


  37:       <LookAt> 


  38:         <longitude>-58.23648800008881</longitude>  


  39:         <latitude>-35.17488100021453</latitude>  


  40:         <altitude>0</altitude>  


  41:         <range>1000.000703843458</range>  


  42:         <tilt>0</tilt>  


  43:         <heading>9.54166404439055e-015</heading> 


  44:       </LookAt>  


  45:       <styleUrl>#msn_ylw-pushpin</styleUrl>  


  46:       <Point> 


  47:         <coordinates>-58.23648800008881,-35.17488100021453,0</coordinates> 


  48:       </Point> 


  49:     </Placemark>  


  50:     <ExtendedData></ExtendedData> 


  51:   </Document> 


  52: </kml>




KML File with Sync Information:





   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <kml xmlns="http://earth.google.com/kml/2.2">  


   4:   <Document> 


   5:     <name>default.kml</name>  


   6:     <Style id="sn_ylw-pushpin_a981af11-d58e-413d-8f4e-3438c61a3c28" xml:id="a981af11-d58e-413d-8f4e-3438c61a3c28" xmlns:mesh4x="http://mesh4x.org/kml" mesh4x:originalId="sn_ylw-pushpin"> 


   7:       <IconStyle> 


   8:         <scale>1.1</scale>  


   9:         <Icon> 


  10:           <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> 


  11:         </Icon>  


  12:         <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> 


  13:       </IconStyle> 


  14:     </Style>  


  15:     <Style id="sh_ylw-pushpin_b21297e9-4efd-42fe-be7f-289f862b5fba" xml:id="b21297e9-4efd-42fe-be7f-289f862b5fba" xmlns:mesh4x="http://mesh4x.org/kml" mesh4x:originalId="sh_ylw-pushpin"> 


  16:       <IconStyle> 


  17:         <scale>1.3</scale>  


  18:         <Icon> 


  19:           <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> 


  20:         </Icon>  


  21:         <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> 


  22:       </IconStyle> 


  23:     </Style>  


  24:     <StyleMap id="msn_ylw-pushpin_f1c450c2-0b9c-4b1f-a6b8-559809f7e327" xml:id="f1c450c2-0b9c-4b1f-a6b8-559809f7e327" xmlns:mesh4x="http://mesh4x.org/kml" mesh4x:originalId="msn_ylw-pushpin"> 


  25:       <Pair> 


  26:         <key>normal</key>  


  27:         <styleUrl>#sn_ylw-pushpin_a981af11-d58e-413d-8f4e-3438c61a3c28</styleUrl> 


  28:       </Pair>  


  29:       <Pair> 


  30:         <key>highlight</key>  


  31:         <styleUrl>#sh_ylw-pushpin_b21297e9-4efd-42fe-be7f-289f862b5fba</styleUrl> 


  32:       </Pair> 


  33:     </StyleMap>  


  34:     <Placemark xml:id="5a4fe143-35d6-41c4-9907-fb39f11e0cba"> 


  35:       <name>My City - Brandsen</name>  


  36:       <description>My city...</description>  


  37:       <LookAt> 


  38:         <longitude>-58.23648800008881</longitude>  


  39:         <latitude>-35.17488100021453</latitude>  


  40:         <altitude>0</altitude>  


  41:         <range>1000.000703843458</range>  


  42:         <tilt>0</tilt>  


  43:         <heading>9.54166404439055e-015</heading> 


  44:       </LookAt>  


  45:       <styleUrl>#msn_ylw-pushpin_f1c450c2-0b9c-4b1f-a6b8-559809f7e327</styleUrl>  


  46:       <Point> 


  47:         <coordinates>-58.23648800008881,-35.17488100021453,0</coordinates> 


  48:       </Point> 


  49:     </Placemark>  


  50:     <ExtendedData xmlns:mesh4x="http://mesh4x.org/kml">


  51:       <mesh4x:hierarchy xml:id="45ec93d6-0690-40ad-890b-edde0e921fad" mesh4x:childId="a981af11-d58e-413d-8f4e-3438c61a3c28"/>


  52:       <mesh4x:sync version="2024263971">


  53:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="45ec93d6-0690-40ad-890b-edde0e921fad" updates="1" deleted="false" noconflicts="false">


  54:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  55:         </sx:sync>


  56:       </mesh4x:sync>


  57:       <mesh4x:sync version="542466287">


  58:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="a981af11-d58e-413d-8f4e-3438c61a3c28" updates="1" deleted="false" noconflicts="false">


  59:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  60:         </sx:sync>


  61:       </mesh4x:sync>


  62:       <mesh4x:hierarchy xml:id="81a9522c-6881-4d5f-a080-aba688f0e8b9" mesh4x:childId="b21297e9-4efd-42fe-be7f-289f862b5fba"/>


  63:       <mesh4x:sync version="-188474479">


  64:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="81a9522c-6881-4d5f-a080-aba688f0e8b9" updates="1" deleted="false" noconflicts="false">


  65:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  66:         </sx:sync>


  67:       </mesh4x:sync>


  68:       <mesh4x:sync version="-1089580191">


  69:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="b21297e9-4efd-42fe-be7f-289f862b5fba" updates="1" deleted="false" noconflicts="false">


  70:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  71:         </sx:sync>


  72:       </mesh4x:sync>


  73:       <mesh4x:hierarchy xml:id="040b2f2f-b7ee-45d2-b087-685764632dcd" mesh4x:childId="f1c450c2-0b9c-4b1f-a6b8-559809f7e327"/>


  74:       <mesh4x:sync version="-432306466">


  75:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="040b2f2f-b7ee-45d2-b087-685764632dcd" updates="1" deleted="false" noconflicts="false">


  76:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  77:         </sx:sync>


  78:       </mesh4x:sync>


  79:       <mesh4x:sync version="-541558727">


  80:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="f1c450c2-0b9c-4b1f-a6b8-559809f7e327" updates="1" deleted="false" noconflicts="false">


  81:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  82:         </sx:sync>


  83:       </mesh4x:sync>


  84:       <mesh4x:hierarchy xml:id="8daad571-5866-4baa-a62f-42bff6e12e8a" mesh4x:childId="5a4fe143-35d6-41c4-9907-fb39f11e0cba"/>


  85:       <mesh4x:sync version="2019814375">


  86:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="8daad571-5866-4baa-a62f-42bff6e12e8a" updates="1" deleted="false" noconflicts="false">


  87:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  88:         </sx:sync>


  89:       </mesh4x:sync>


  90:       <mesh4x:sync version="1141301425">


  91:         <sx:sync xmlns:sx="http://feedsync.org/2007/feedsync" id="5a4fe143-35d6-41c4-9907-fb39f11e0cba" updates="1" deleted="false" noconflicts="false">


  92:           <sx:history sequence="1" when="2008-10-14T21:02:50Z" by="vcc-PC_jtondato"/>


  93:         </sx:sync>


  94:       </mesh4x:sync>


  95:     </ExtendedData>


  96:   </Document> 


  97: </kml>




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.



image 



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".



image



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).



 image



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)



 image



For each session there are 2 RSS Feed files: the current session and the last session snapshot.


The file are named  [sessionId]_current.xml and [sessionId]_snapshot.xml.


Current Session Feed Example :




   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <rss xmlns:sx="http://feedsync.org/2007/feedsync" version="2.0">


   4:   <channel>


   5:     <session sessionId="8eee69f6-3421-459a-8ee9-35147f2c1ae4" sessionVersion="1" 


   6:             sourceId="abc.kml" endpointId="01136544867" lastSyncDate="" 


   7:             full="true" open="true" cancelled="false">


   8:       <ack>5b8b3589-6f07-4913-b058-eb6d840a90e0</ack>


   9:       <ack>390f3dfc-b18a-4ef9-9cb4-6b80c2663c88</ack>


  10:     </session>


  11:     <item>


  12:       <title>hierarchy</title>


  13:       <description>Id: 5b8b3589-6f07-4913-b058-eb6d840a90e0 


  14:         version: 47379581</description>


  15:       <mesh4x:hierarchy xmlns:mesh4x="http://mesh4x.org/kml" 


  16:         xml:id="5b8b3589-6f07-4913-b058-eb6d840a90e0" 


  17:         mesh4x:childId="89d714e8-b1e5-4d85-876f-fe3971cc6e68"/>


  18:       <author>


  19:         <name>52-0950011-91_Deloluis</name>


  20:       </author>


  21:       <sx:sync id="5b8b3589-6f07-4913-b058-eb6d840a90e0" updates="1" 


  22:             deleted="false" noconflicts="false">


  23:         <sx:history sequence="1" when="Wed, 27 Aug 2008 06:33:52 GMT" 


  24:             by="52-0950011-91_Deloluis"/>


  25:       </sx:sync>


  26:     </item>


  27:     </channel>


  28: </rss>



Snapshot Session Feed Example:



   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <rss xmlns:sx="http://feedsync.org/2007/feedsync" version="2.0">


   4:   <channel>


   5:     <session sessionId="6aa2c381-d716-487f-bc43-50828f7338da" sessionVersion="1" 


   6:         sourceId="a.kml" endpointId="01136544867" lastSyncDate="Sat, 11 Oct 2008 03:52:00 GMT" 


   7:         full="true" open="false" cancelled="false"/>


   8:     <item>


   9:       <title>hierarchy</title>


  10:       <description>Id: 8976b491-b5c8-43bb-8393-395be6853155 version: 419821444</description>


  11:       <mesh4x:hierarchy xmlns:mesh4x="http://mesh4x.org/kml" 


  12:         xml:id="8976b491-b5c8-43bb-8393-395be6853155" 


  13:         mesh4x:childId="6aff55c2-2c0a-4756-a2ec-c97fea8a35bc"/>


  14:       <author>


  15:         <name>vcc-PC_jtondato</name>


  16:       </author>


  17:       <sx:sync id="8976b491-b5c8-43bb-8393-395be6853155" updates="2" 


  18:             deleted="false" noconflicts="false">


  19:         <sx:history sequence="2" when="Wed, 30 Jul 2008 15:55:40 GMT" by="vcc-PC_jtondato"/>


  20:         <sx:history sequence="1" when="Wed, 30 Jul 2008 15:55:40 GMT" by="vcc-PC_jtondato"/>


  21:       </sx:sync>


  22:     </item>


  23:   </channel>


  24: </rss>




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):





   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <SmsChannel> 


   4:   <IncommingOngoing/>


   5:   <IncommingCompleted>


   6:     <Batch batchId="381d5" protocol="^" messages="1" sms="01136544867" 


   7:             sessionId="8eee69f6-3421-459a-8ee9-35147f2c1ae4">


   8:       <BatchMessage sequence="0" lastModDate="Sat, 11 Oct 2008 03:56:12 GMT">


   9:         ^381d510bf52e8eee69f6-3421-459a-8ee9-35147f2c1ae4n21


  10:         </BatchMessage>


  11:     </Batch>


  12:   </IncommingCompleted>


  13:   <IncommingDiscarded/>


  14: </SmsChannel>






Out Queue Feed Example (smsChannel_outcomming.xml) :





   1: <?xml version="1.0" encoding="UTF-8"?>


   2:  


   3: <SmsChannel> 


   4:   <Outcomming> 


   5:     <Batch batchId="60c17" protocol="^" messages="1" sms="01136544867" sessionId="8eee69f6-3421-459a-8ee9-35147f2c1ae4"> 


   6:       <BatchMessage sequence="0" lastModDate="Sat, 11 Oct 2008 03:56:45 GMT">^60c1710381d58eee69f6-3421-459a-8ee9-35147f2c1ae4n61&amp;Te08c0500-a42f-4d35-b595-d2eb94f9fc0bT1219818832000admin</BatchMessage> 


   7:     </Batch>  


   8:     <Batch batchId="78964" protocol="^" messages="1" sms="01136544867" sessionId="8eee69f6-3421-459a-8ee9-35147f2c1ae4"> 


   9:       <BatchMessage sequence="0" lastModDate="Sat, 11 Oct 2008 03:57:25 GMT">^7896410381d58eee69f6-3421-459a-8ee9-35147f2c1ae4n61&amp;T9c6a1bae-1ce8-4c19-a3e3-47bdcdab4c8bT1219818832000admin</BatchMessage> 


  10:     </Batch>  


  11:   </Outcomming>  


  12:   <OutcommingCompleted>


  13:     <Batch batchId="bf52e" protocol="^" messages="1" sms="01136544867" sessionId="8eee69f6-3421-459a-8ee9-35147f2c1ae4">


  14:       <BatchMessage sequence="0" lastModDate="Sat, 11 Oct 2008 03:56:11 GMT">^bf52e10000008eee69f6-3421-459a-8ee9-35147f2c1ae4n11&amp;abc.kml</BatchMessage>


  15:     </Batch>


  16:   </OutcommingCompleted>


  17: </SmsChannel>




Requirements



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.



Download desktop application



I hope that it can help you !!!



JMT

Wednesday, October 8, 2008

JavaRosa MIDP Demo

In collaboration with JavaRosa, an OpenRosa java implementation which supports XForms for J2ME, we have migrated Mesh4J to J2ME and an experimental version is available here: Mesh4j2me Demo.

The main idea is to provide mesh capabilities allowing mobile phones to share XForms definitions and data.

This demo requires a mobile phone MIDP 2.0 and CLDC 1.1 compatible. I've tested it in a Sony Ericcson 950i and a Sony Ericcson 750i.

First of all, please install the MIDP in your phone. Now, you are ready to start the application.

The following steps will show you how to use the application:

 

1. Launch application (MIDP)

 image

2.  According to the phone model – Java will ask for authorization to send SMS

image

3. JavaRosa initialization and login (user admin)

image image 

image

4. Now, we need to configure the Mesh4X properties with the "Settings" menu option

image

Enter the base url for sync, in this example the InSTEDD feed sync server url: http://sync.instedd.org/Service.svc/feeds/

 image

 

Enter the default mobile phone number to synchronize data with sms protocol.

image

Please press the Done button to save your changes.

5. Add new form data: First select the Xform and next click the "Select" menu option

image image

The default behavior of java rosa xform editing UI is to send the form to the default transport method defined in java rosa. Because we'll be synchronizing the data over mesh4x, we don't need to submit the data at this point, so you can simply select "Send Later".

image

6. Now, we can view and edit the data previously entered. First select the xform and next click the "View Saved" menu option

image

The XformList UI shows all saved forms

image

 

You can use the "Select" menu option to select a form instance data to edit or delete.

image image

7. SMS synchronization: First select the Xform and next select the "Sync Data - Sms" menu option

image 

Depending on the phone model – Java will ask for authorization to send SMS

image

A "Console" view will show up with all sync messages. We can view the messages by Protocol (high level) or sms (low level) perspectives. The console is persisted in the phone rms storage, if you select the option "Clean", all sync messages are deleted from the storage.

image

 

The "End Sync" message indicates that the synchronization has finished.

image

So far we can enjoy java rosa with mesh!

 

8. Other features

  • Sync – Console
    • shows console view
  • Sync data – HTTP
    • mesh via Http the selected form with the default sync URL (Mesh4xDefaultBaseURL, see settings, for this example the InSTEDD sync site url)
  • Sync data – SMS
    • mesh via SMS the selected form with the default sms number (Mesh4xDefaultSMSTarget property, see settings)
  • Sync – Delete sync
    • delete sync information
  • Sync – Delete def/data/sync
    • delete sync information and xfoms data and definitions
  • Sync – Cancel sync
    • cancel the current sync for the selected form
  • Sync – Force Retries – SMS
    • retries pending messages (messages with pending ack)
  • Sync - Import def - Http
    • import xform definition from the default sync discovery url (Mesh4xDefaultDiscoveryURL, see settings, for this example we added to the InSTEDD sync site a feed with 2 xform definitions named XFormDemo1 and XFormDemo2, http://sync.instedd.org/Service.svc/feeds/XForms)
  • Sync - Import def - SMS
    • feature under construction, import xform definition from other mobile form.

 

image image

 

That's all folks !!!

Future posts.... Coming soon...

Kml Demo - pc client

Kml/SMS Demo - pc client

SyncEngine under the hood

How to create a new SyncAdapter

Adapters: FeedSyncAdapter

Adapters: HttpSyncAdapter

Adapters: SplitAdapter

Adapters: KmlAdapter

Adapters: HibernateAdapter

Adapters: MSAccessAdapter

Adapters: JavaRosaAdapter

Asynchronous sync

MessageSync Protocol

Sms channel

Tuesday, October 7, 2008

Mesh4X J2ME version with JavaRosa XForms

Welcome to Mesh4X !!!

Mesh4X is an open source FeedSync implementation mentored by InSTEDD and developed by Clarius.

InSTEDD is an innovation lab for technologies designed to improve community resilience and save lives through early disease detection and rapid disaster response.

Currently Mesh4x has Java and .Net versions and the Python implementation is coming soon (see waj blog).

There are excellent blogs related to FeedSync and Mesh4X, we can see that the pioneers said:

Currently, sms usage is crucial for humanitarian tasks in the field (see Ed links). Due to this concern, we are working in a mesh4x adapter for sms that allows two-way synchronization of arbitrary data over basic cell phone SMS. Following this direction, in collaboration with JavaRosa, an OpenRosa java implementation which supports XForms for J2ME, we have migrated Mesh4J to J2ME and an experimental version is available here: Mesh4j2me Demo.

The main idea is to provide multi-node XForms editing and sharing on mobile phones (a.k.a. mesh ;)). Imagine the following scenario:

  1. The server is receiving data from multiple mobile clients.
  2. The user enters data on his phone (using JavaRosa XForms).
  3. Upon synchronization, the mobile client updates its local data by merging the the latest changes from the server via an HTTP data connection, and the new local data is pushed to the server the same way.

The server is a FeedSync-standard compliant server we've created with ASP.NET & WCF exposing a RESTFull API (see http://sync.instedd.org/Service.svc/feeds)

 image 

Cool! You could share your information with other people in the world. Your data is stored in a centralized server (but which can also be just a node in another mesh!), so you can also view your data from a PC if you want.

image

Important: You don't need to develop special code for sync, just use the provided Mesh4J2me library.

But, what happens when you do not have an Internet connection but still need to synchronize information in a peer-to-peer fashion? Isn't that the whole point of "mesh"?

Now, we can imagine the following scenario:

  1. Mobile1 - User enters data
  2. Send data from Mobile1 to Mobile2 using sms (with a different adapter this time)
  3. Mobile2 – The data is merged locally executing the sync algorithm
  4. The magic is done! Mobile2 - User has the information available locally in his device.

image

Cool,... sounds great,  but...., Sms is not a reliable channel, messages can be lost and arrive not necessarily in the same sequence they have been sent.  FeedSync is an XML-based format and it can be very long. How does Mesh4X manage those issues?

The adapter we mentioned above, called the SmsAdapter, defines an asynchronous protocol that provides a reliable connection; the main goal is to ensure that all the messages will arrive, each data is expressed as XML, it is compressed and split in a batch of messages with sequence ordering, and only when all the messages have arrived the XML is regenerated and the next protocol step is executed. Retries are used for re sending lost messages.

The protocol is based on Rsync ideas to send only the differences in data between the mobile phones.

The protocol is a state machine divided in 3 phases:

Phase 1:  Differences negotiation

Phase 2: Data merging

Phase 3: Apply changes to the model

 

Feel free to take a look at our ideas in:

J2SE: https://mesh4x.googlecode.com/svn/Mesh4j/trunk

J2SE Spikes: https://mesh4x.googlecode.com/svn/Mesh4j/spikes/

J2me: http://code.dimagi.com/svn/JavaRosa/branches/dev-instedd/

 

In future posts I will explore deeper the Mesh4X project in its both synchronous and asynchronous modes.

What do you think about it?

JMT (Juan Marcelo Tondato)