• <GetStart>
  • CSPro User's Guide
    • The CSPro System
      • What is CSPro?
      • CSPro Capabilities
      • Release History
      • What's New in CSPro?
      • CSPro Applications
      • CSPro General Concepts
      • CSPro General Functionality
        • Data Sources
        • Data Requirements
        • Connection String
        • Encrypted Data
        • Text Attributes
        • Unicode Primer
        • Synchronization Overview
        • Paradata
        • Multiple Language Applications
        • Mapping
        • Questionnaire View
      • How To ...
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • Synchronization
    • CSPro Statements and Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Synchronization Overview

Synchronization Strategies
When using mobile devices for a survey or census, it is important to be able to transfer data collected in the field back to the head office. This allows for faster processing and analysis as well as better monitoring of field operations.
In CSPro, transferring data between devices in the field and the head office is referred to as synchronization. CSPro supports data synchronization over the Internet between interviewers' devices in the field and a central server. Interviewers use CSEntry to collect data on tablets, phones, or laptops and then use the Internet to synchronize the data on their devices with a server at the head office or in the cloud. In CSPro, the data collection itself may be done entirely offline, with no Internet connection. When an interviewer is able to connect to the Internet they may synchronize with the server and transfer any data collected since the last synchronization. Synchronization may be done using Wi-Fi or a mobile data connection.
synchronization internet flow
Direct synchronization between interviewers and central server over the Internet.
In situations where an interviewer rarely or never has access to the Internet, CSPro supports peer-to-peer synchronization between devices using Bluetooth. Bluetooth synchronization does not require an Internet connection. It is a direct connection between two devices that are in close proximity. Using Bluetooth, an interviewer may synchronize their device with a supervisor's device, transferring their data to the supervisor. Later, the supervisor travels to a location where they are able to connect their device to the Internet in order to synchronize with the central server. In this scenario, a supervisor might visit multiple interviewers in order to synchronize with them and later upload their data to the server at the head office.
synchronization bluetooth flow
Synchronization with supervisor over Bluetooth when interviewers do not have Internet access.
CSPro supports both one-way and two-way data synchronization. This means that it is possible to send data from the interviewer's device to the server as well as to download data from the server to the interviewer's device. You can configure your synchronization to only send data to the server, to only receive data from the server, or to both send and receive data.
It is possible to synchronize both CSPro data sources and files such as applications, images, and text files. It is possible to update data entry applications in the field by downloading the latest .pen and .pff files from the server. This way, modifications to the application at the head office can easily be distributed to interviewers in the field. It is, however, simpler to deploy and update application files on mobile devices using the Deploy Application tool. This tool packages application files for deployment, uploads them to a server, and allows interviewers in the field to install and update them on a tablet by choosing Add Application from the menu on their mobile device.
Synchronization Service
For synchronization over the Internet, a central server is required. CSPro supports several synchronization services, including CSWeb, Dropbox, and FTP.
When synchronizing CSPro data sources, synchronization is done at the case (questionnaire) level. CSPro keeps track of which cases have been added or updated and only sends cases that are new or have been modified since the last synchronization. This significantly reduces the amount of data transferred and therefore reduces bandwidth and the cost of air time. It also reduces the chance that two interviewers overwrite each other's work by both syncing to the same data file on the server. As long as two interviewers do not modify the same case at the same time, they may both synchronize to the same server without overwriting each other's data.
Once interviewers in the field have used data synchronization to upload data to the server, you can use the Data Manager tool to download the data. When using CSWeb for data file synchronization, data is stored in a MySQL database on the server. When using either Dropbox or FTP, data will be stored on the server in a set of files in the directory /CSPro/DataSync. In both cases, the data on the server cannot be opened directly by CSPro. In order to retrieve the data that has been uploaded to the server, use Data Manager's download function. This will download all the data on the server into a single CSPro data file that can be used by other CSPro applications and tools.
Simple Synchronizations
Basic synchronizations can be set up by defining a Simple Synchronization routine.
Advanced Synchronizations
For more advanced synchronization scenarios, CSPro has logic functions, and Action Invoker actions, that can be used to implement data and file synchronizations. It is possible to synchronize data sources, including those associated with external dictionaries, and non-data files over either the Internet or Bluetooth.
The following functions and actions are available:
FunctionActionDescription
syncconnectSync.connectConnects to a synchronization service, initiating a synchronization session.
syncdisconnectSync.disconnectEnds a synchronization session, disconnecting from the service.
syncdataSynchronizes cases in CSPro data sources.
syncfileUploads or downloads non-data files.
syncparadataSync.syncParadataSynchronizes paradata.
syncappUpdates an application on the device from a new version on the service.
syncmessageSync.sendMessageSends a message and returns the service's response.
synctimeReturns the time of the last synchronization of a data source or a specific case.
While it is possible to use syncfile to synchronize CSPro data sources, it is more efficient to use syncdata since it will only send/receive cases that have been modified whereas syncfile always sends the entire file.
You will generally call syncconnect once to start the session followed by multiple calls to syncdata, syncapp, and syncfile, followed by a call to syncdisconnect. In the example below, we connect to the server and upload cases from the data source associated with the dictionary SURVEY_DICT.
// connect to the CSWeb server
if syncconnect("https://example.org/csweb/api") then

   
// send the latest cases to the CSWeb server
    syncdata(PUT, SURVEY_DICT);

   
syncdisconnect();

endif;
Bluetooth Synchronization from Logic
Bluetooth synchronization is done between two devices. One device, called the client, has logic similar to what is used for server-based services like CSWeb. The second device plays the role of a server. With Bluetooth synchronization, the server is passive. The device acting as the server runs only a single logic function, syncserver, which waits and processes commands from the client device. Only the client device runs synchronization functions like syncconnect and syncdata.
The client and server devices must be in close physical proximity in order to connect to each other. The server device must first execute the syncserver function which causes it to wait for connections from nearby devices. Then the client device executes syncconnect which initiates the connection between the two devices. The client then executes one or more calls to syncdata and/or other synchronization functions, followed by a call to syncdisconnect, which ends the session. This requires that the two operators using the devices coordinate to start the synchronization routines on the two devices at roughly the same time.
synchronization bluetooth server flow
The following example shows the logic that would be written for the client and for the server:
Client Logic:
// connect to supervisor via Bluetooth
if syncconnect("Bluetooth") then

   
// send the latest cases to the supervisor
    syncdata(PUT, SURVEY_DICT);

   
syncdisconnect();

endif;
Server Logic:
// start peer-to-peer Bluetooth server
syncserver(Bluetooth);
Application Deployment over the Internet
The synchronization functions all assume that your CSPro application is already installed on interviewers' devices. This means that it is not possible to use the above methods to download a new application for initial installation. While it is possible to simply copy the application to an interviewer's device by connecting it to a PC via USB, in some cases it is preferable for the interviewer to download applications over the Internet. To download an application onto a device, use Add Application from CSEntry's Entry Applications menu. To package and upload an application to a synchronization service from where it can be downloaded, use the Deploy Application tool. Once an application has been installed on a mobile device, it can easily be updated by redeploying the application to the server and then using Update Installed Applications from the menu on the mobile device or by using syncapp in application logic.
Troubleshooting
Many errors that you may encounter during synchronization are caused by a lack of network connectivity rather than a problem within your CSPro application. An easy way to identify the source of the problem is to attempt to connect to the synchronization service within your web browser. For example, if you are trying to synchronize data on a tablet using Dropbox, go to https://dropbox.com within its web browser. If you are unable to connect, then there is a problem with your connection to the Internet which needs to be resolved.
To get additional details on synchronization errors you can look at the sync.log file. This file lists all synchronization operations along with any errors encountered. This includes errors in uploading/downloading applications in Application Deployment and accessing data in Data Manager.
On Android devices you can find the sync.log file in the csentry directory. Starting with CSPro version 7.5, the csentry directory is located at <external storage>/Android/data/gov.census.cspro.csentry/files/csentry. In earlier versions it was located at <external storage>/csentry. If you previously had an older version of CSPro on your Android device, the csentry will not be moved when you upgrade.
On Windows you can find the file in the directory %AppData%\CSPro. On Windows you can also locate the sync.log file from the Help menu in CSPro Designer under Troubleshooting. When asking for technical support with synchronization issues, please attach the sync.log file from your device to your email or forum post.
See also: Simple Synchronizations, Synchronization Services, Sync Action Invoker Namespace