System setup (administration level)

Contents

Driver setup

Working with MODEMS

Java comm configuration, by use with SMS modems

When you work with SMS modem, you need to download and install Java communication API extension (http://java.sun.com/products/javacomm/, anxious people can find basic files on resources/javacomm) . Some important tips:

-\# Paths to server-side serial port devices

serpath0 = /dev/ttyS0

serpath1 = /dev/ttyS1

serpath2 = /dev/ttyACM0

serpath3 = /dev/ttyACM1

serpath4 = /dev/ttyUSB0

serpath5 = /dev/ttyUSB1


Please be warned that while working with Eclipse and Tomcat, the javax.comm.properties shouldn't be placed in your home directory.

Serial ports on Linux (udev command)

Some problems would arise, if you are use the GSM modem under linux. The main problem would be about the current user not having permissions on the device file. Another problem is that the device could appear connected in a different file under the /dev folder every time you plug the device. udev can help solve this by mapping the device to a unique file.

  1. - Connect the device to the computer.
  2. - udevadm info -q all -n {path to the device mounting point} -a
  3. - create a file name for the udev rules in /etc/udev/rules.d/ name it wathever you want ending with .rules
  4. - write down in a single line comma separated, ENV or ATTRS ({the subsystem you see in step 2}), with values that identify the device you want,

add SYMLINK+="newdevicename" were newdevicename is the name of the file you want the device to be pluged-in, MODE="0777" so you give permissions to everybody or wathever permission is right for your installation (the running user should have read and write permissions over the file)

  1. - unplug the device
  2. - sudo restart udev and wait a few seconds after it finishes
  3. - plug-in the device and wait a few seconds
  4. - udevadm info -q all -n /dev/{symlink name you added} (this should show you the device information)
  5. - setup your application configuration files to point to the symbolic link instead of the real device

Log 4J

Asynchronic message system use Log4J as logger function. If you prefer change the log4j characteristic you would need to change the log4j.xml or log4j.properties files (they are placed on root directory of sources for both applications, driver and controller). To know how to configure log4j by an XML file please refer to log4j web site.

Driver (properties) configuration file

The DriverConfig.properties file is placed on folder WEB-INF, this allow to configure some characteristic and behaviors. The items that allow to configure are:

  1. driverId - All driver applications need a label Id. This label Id will be used by controller to identify the driver instantances and route the messages between it and Cyclos instances.
  2. wsClients - it's a while IP address list. Specify from which IP addresses allow to connect to served web service interfaces
  3. controllerUrl - specify the base url to contact the web services served by controller
  4. fromControllerQSize - Size for queue where to store message arrived from controller
  5. toControllerQSize - Size for queue where to store message arrived from external (going to go to Controller)
  6. engineClass - path and class name of engineClass, its an special implementation of driver (you have three implementation in Driver proyect:
    1. Http - nl.strohalm.cyclos.driver.sms.engine.HttpGatewayEngine - Allow send and receive messages using Http post (or get) from a Gateway provider
    2. Sms with Modem - nl.strohalm.cyclos.driver.sms.engine.SMSDriverEngine - Allow to send and receive SMS message through a GSM modem.
    3. Dummy - nl.strohalm.cyclos.driver.dummy.engine.DummyDriverEngine - Only log information, allow to test the asincrhonic message module

Driver configuration sample file

#the ID for this driver in controller
driverId=SmsDriver

#While list access for WS 
wsClients=127.0.0.1 192.168.3.192

#URL for consume controller web service
controllerUrl=http://127.0.0.1:8080/cyclos3_sms_controller/services/controller

# Incoming queue size for message (from controller)
fromControllerQSize=10 

# Outgoing queue size for message (to controller)
toControllerQSize=10

# The class path and name for extended engine class
#engineClass=nl.strohalm.cyclos.driver.sms.engine.SMSDriverEngine
#engineClass=nl.strohalm.cyclos.driver.sms.engine.HttpGatewayEngine
engineClass=nl.strohalm.cyclos.driver.dummy.engine.DummyDriverEngine

Controller setup

The controller configuration is based in two files config.xml and cyclosInstance.properties. The config.xml file (placed in the root folder of source) allow to set some aspects and behaviors. Here we will find the rules to route messages betwen cyclosInstances and driverInstances. Elements:

Cyclos instance

The Cyclos instance configuration has information about a cyclos which operate with this controller. Items:

Drivers instance

The Driver instance configuration has information for routing messages from the Driver to Cyclos. It is composed of a list of entry tags which contains the following tags:

Controller configuration sample file

<cycloscontroller  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="/opt/develop/workspace.galileo.cyclos3_sms/cyclos3_sms_controller/src/config.xsd">
         
         <cyclosInstances>
         	<entry>
         		<key>compras</key>
         		<value>
	         		<accountsAliases>
	         			<entry><key>UN</key><value>1</value></entry>
	         			<entry><key>UNITS</key><value>1</value></entry>
	         			<entry><key>PE</key><value>2</value></entry>
	         			<entry><key>PESOS</key><value>2</value></entry>
	         		</accountsAliases>
	         		<driverChannels>
	         			<entry><key>TtyDriver</key><value>sms</value></entry>
					<entry><key>SmsDriver</key><value>sms</value></entry>
	         		</driverChannels>
	         		<commandActions>
	         			<entry>
	         				<key>BALANCE_REQUEST</key>
	         				<value>nl.strohalm.cyclos.controller.command.BalanceCommand</value>
	         			</entry>
	         			<entry>
	         				<key>BALANCE_RESPONSE</key>
	         				<value>nl.strohalm.cyclos.controller.command.BalanceResponseCommand</value>
	         			</entry>

	         			<entry>
	         				<key>CONFIRM_PAYMENT</key>
	         				<value>nl.strohalm.cyclos.controller.command.ConfirmCommand</value>
	         			</entry>
	         			<entry>
	         				<key>REQUEST_PAYMENT</key>
	         				<value>nl.strohalm.cyclos.controller.command.RequestPayCommand</value>
	         			</entry>
	         			<entry>
	         				<key>ACCOUNT_DETAILS</key>
	         				<value>nl.strohalm.cyclos.controller.command.DetailCommand</value>
	         			</entry>
	         			<entry>
	         				<key>PERFORM_PAYMENT</key>
	         				<value>nl.strohalm.cyclos.controller.command.PayCommand</value>
	         			</entry>
	         		</commandActions>
	         		<driverDefault>
	         			<driverId>TtyDriver</driverId>
	         			<messageSource>1234</messageSource>
	         		</driverDefault>
	         		<driverMap>
	         			<entry>
	         				<key>Ancel</key>
	         				<value>
	         					<driverId>TtyDriver</driverId>
	         					<messageSource>1234</messageSource>
	         				</value>
	         			</entry>
	         			<entry>
	         				<key>Movistar</key>
	         				<value>
	         					<driverId>SmsDriver</driverId>
	         					<messageSource>4321</messageSource>
	         				</value>
	         			</entry>
	         		</driverMap>
	         		<id></id>
	         		<languageProperties>cyclosInstance.properties</languageProperties>
	         		<memberDiscriminatorField>phone</memberDiscriminatorField>
	         		<provider>cell_provider</provider>
	         		<rootUrl>http://127.0.0.1:8280/cyclos</rootUrl>
         		</value>         	
         	</entry>
         </cyclosInstances>
          <digitsSessionId>12</digitsSessionId>
          <driverInstances>
          	<entry>
          		<key>SmsDriver</key>
          		<value>
         			<cyclosDefault>compras</cyclosDefault>
          			<rootUrl>http://localhost:8080/cyclos3_sms_driver/services/driver</rootUrl>
         			<routeToCyclos>
         				<entry>
          					<key>1234</key>
         					<value>compras</value>
         				</entry>
        				<entry>
         					<key>4321</key>
         					<value>compras</value>
         				</entry>
         			</routeToCyclos>
         		</value>
        	</entry>
         	<entry>
         		<key>TtyDriver</key>
         		<value>
         			<cyclosDefault>compras</cyclosDefault>
         			<rootUrl>http://localhost:8080/cyclos3_sms_driver/services/driver</rootUrl>
         			<routeToCyclos>
         				<entry>
         					<key>1234</key>
         					<value>compras</value>
         				</entry>
         				<entry>
         					<key>4321</key>
         					<value>compras</value>
         				</entry>
         			</routeToCyclos>
         		</value>
         	</entry>
          </driverInstances> 		 
	   <ipWhiteList>127.0.0.1</ipWhiteList>
          <maxSessionHandler>10</maxSessionHandler>
          <sessionTimeout>20</sessionTimeout>
</cycloscontroller>

Cyclos setup

Common mitakes

Once you have setup the environment it is important to run some test to check the setup was successfull.

Regular expressions

Language setup

Controller setup

How to test the system

To simulate sending or recieving an SMS to the driver at URL:
http://<IpTomcat>:<PortTomcat>/cyclos3_sms_driver/driverTtyServlet

You can also use the Dummy driver (only create log, but don't take real action) by setting the parameter engineClass=nl.strohalm.cyclos.driver.dummy.engine.DummyDriverEngine into the properties file driver configuration.

Driver simulation servlet


Test sample

Simulate: Rx
From cellular: 59898399813
To cellular: 1234 Message: Py 5678 745812 110

The sample will simulate areceived message (by driver) which would make a payment: from memeber with cellular 59898399813, to member with login name 745812, an by 110 unit in the default currency (1234 is the short number for Cyclos, and 5678 is the payer PIN).