U s e r a p p l i c a t i o n e x a m p l e s
User Application Examples
on Geneko Cellular Routers
Document version: 1.2
Date: September 2016
1
User application examples
Abstract
This document describes user application examples delivered on Geneko Cellular Routers.
Document Control
Version 1.2
Document:
File
Status Valid
GWR User Application Examples 2016 Sep Rev C.pdf
Role Name
Author Tanja Savic Creation:
Review C
Role Name
Approval:
Team Leader Darko Kojic
Trademark
Geneko ® is the registered trademark of Geneko Company.
© 2016 Geneko Company. All rights reserved. Copying of this document or parts of it is prohibited.
3
User application examples
Content
ABSTRACT .................................................................................................................................................... 3
OCUMENT C ONTROL ............................................................................................................................... 3
D
RADEMARK ................................................................................................................................................ 3
T
IST OF FIGURES ........................................................................................................................................... 5
L
I NTRODUCTION ........................................................................................................................................ 6
1.
1.1 Purpose ............................................................................................................................................. 6
U SER APPLICATION ENVIRONMENT........................................................................................................ 7
2.
E XAMPLES................................................................................................................................................. 8
3.
3.1 Connection and access of FTP server............................................................................................ 8
3.2 Get modem info ............................................................................................................................... 8
3.3 Read data from serial port............................................................................................................ 10
3.4 Read received SMS messages....................................................................................................... 11
3.5 Remove SIM card PIN................................................................................................................... 12
3.6 Report ppp_0 status ...................................................................................................................... 13
3.7 Router Network configuration ....................................................................................................14
3.8 Connect and access of TCP server............................................................................................... 16
3.9 SMS Send ........................................................................................................................................17
3.10 E-mail send ................................................................................................................................... 18
3.11 General Purpose Input/Output (GPIO)................................................................................... 19
3.11.1 gpio_functionality................................................................................................................... 20
3.11.2 gpio_send_sms .......................................................................................................................21
4
User application examples
List of Figures
Figure 1 – GWG Gateway display of examples ......................................................................................... 7
Figure 2 – ftp_connect script.........................................................................................................................8
Figure 3 – FileZilla client ............................................................................................................................... 8
Figure 4 – Result after execution get_modem_info ................................................................................... 9
Figure 5 – Result after execution serial_read_example...........................................................................10
Figure 6 – Display serial_read_example ................................................................................................... 10
Figure 7 – Result after execution read_sms_perform_action................................................................. 11
Figure 8 – Display read_sms_perform #1.................................................................................................12
Figure 9 – Result after execution remove_sim_card_pin........................................................................ 12
Figure 10 – Display remove_sim_card_pin .............................................................................................. 13
Figure 11 – Result after execution report_ppp_status............................................................................. 14
Figure 12 – Display report_ppp_status..................................................................................................... 14
Figure 13 – Result after execution router_network_configuration_example ...................................... 15
Figure 14 – Display router_network_configuration_example #1.......................................................... 15
Figure 15 – Result after execution tcp_server_example.......................................................................... 16
Figure 16 – PuTTY configuration............................................................................................................... 16
Figure 17 – PuTTY display.......................................................................................................................... 17
Figure 18 – Display sms_send .................................................................................................................... 18
Figure 19 – Result after execution script send_e-mail............................................................................. 18
Figure 20 – Display send_e_mail ...............................................................................................................19
Figure 21 - Result after execution gpio_functionality.sh ........................................................................20
Figure 22 - gpio_functionality ...................................................................................................................21
Figure 23 - Result after execution gpio_send_sms.sh .............................................................................21
Figure 24 - gpio_send_sms.......................................................................................................................... 22
5
User application examples
1. Introduction
Geneko Cellular Routers (GWR-HS, GWR362, GWR462, GWRI-362, GWRI-462 and GWG
models) support use of user applications, thereby extending standard router functionality.
Supported languages for user applications are:
• Shell scripts (sh, bash, dash)
• LUA
• C/C++
• Perl
• Python (on GWR-HS, GWR362, GWR462, GWRI-362 and GWRI-462 models)
User applications are stored in a permanent location and can be started on system startup. They
are executing in a chroot environment. A chroot environment is an operating system call that will
change the root location temporarily to a new folder. Chroot runs a command or an interactive
shell from another directory and treats that directory as root directory.
1.1 Purpose
The purpose of this document is to show how to use existing user application examples on
Geneko Cellular Routers.
Intended audience is customer technical engineers and management interested in detailed
progress information.
6
User application examples
2. User application environment
Use Putty, Secure CRT, etc on Windows, or Putty, Minicom, GTKterm or your favorite
Linux terminal on Linux for connection over serial RS-232 port or SSH over LAN port.
After logging in as admin the user should call gwr_chroot command to activate user
application environment.
For example: Use SSH to enter in global configuration mode.
ssh 192.168.1.1 //ssh to br0 at TCP PORT 22
Login as: admin
admin@192.168.1.1's password:admin
admin@geneko>gwr_chroot
There is possibility to user write his/her own examples. In directory /home/admin user
can make new directories, write scripts, applications to extend router functionality. In
folder startup are stored scripts, that need to be started during the startup of the router.
geneko:~# cd /home/admin
geneko:~# ls
startup/
All exiting examples are stored in directory /home/examples.
geneko:~# cd /home/examples/
geneko:~#ls
Figure 1 – GWG Gateway display of examples
7
User application examples
3. Examples
3.1 Connection and access of FTP server
In this example is described configuration of FTP connection.
geneko:/home/examples# vi ftp_connect
Figure 2 – ftp_connect script
geneko:/home/examples# cp /home/examples/ftp_connect /home/admin/startup/
geneko:/home/examples# reboot
Use FileZilla client for connection and access of FTP server.
Figure 3 – FileZilla client
3.2 Get modem info
In this example is described basic modem information, network operator, supported AT
commands.
8
User application examples
geneko:/home/examples#./get_modem_info
Figure 4 – Result after execution get_modem_info
9
User application examples
3.3 Read data from serial port
In this example is described reading data from serial port and reply back to sender.
geneko:/home/examples#./serial_read_example
Figure 5 – Result after execution serial_read_example
geneko:/home/examples#vi serial_read_example
Figure 6 – Display serial_read_example
10
User application examples
3.4 Read received SMS messages
In this example is described the possibility of a modem GWG Gateway to receive SMS
messages.
geneko:/home/examples#./read_sms_perform_action
Figure 7 – Result after execution read_sms_perform_action
geneko:/home/examples#vi read_sms_perform
11
User application examples
3.5 Remove SIM card PIN
In this example is described information about SIM card PIN and PUK code and possibility
to unlock SIM card.
geneko:/home/examples#./remove_sim_card_pin
Figure 8 – Display read_sms_perform #1
Figure 9 – Result after execution remove_sim_card_pin
12
User application examples
geneko:/home/examples#vi remove_sim_card_pin
3.6 Report ppp_0 status
In this example is described basic information about ppp_0 status, mobile provider, APN,
username, password and etc..
geneko:/home/examples#./report_ppp_status
Figure 10 – Display remove_sim_card_pin
13
User application examples
Figure 11 – Result after execution report_ppp_status
geneko:/home/examples#vi report_ppp_status
Figure 12 – Display report_ppp_status
3.7 Router Network configuration
In this example is described making router network configuration. There is the possibility
of exporting the new configuration via web interface.
geneko:/home/examples#./router_network_configuration_example
14
User application examples
Figure 13 – Result after execution router_network_configuration_example
geneko:/home/examples#vi router_network_configuration_example
Figure 14 – Display router_network_configuration_example #1
15
User application examples
3.8 Connect and access of TCP server
In this example is described reading data from TCP socket and return reply.
geneko:/home/examples#./tcp_server_example
Figure 15 – Result after execution tcp_server_example
Use PuTTY for connection on port 7777, connection type is Telnet.
Figure 16 – PuTTY configuration
16
User application examples
Figure 17 – PuTTY display
3.9 SMS Send
In this example is described sending sms when the strength of a signal is lower than
recommended.
geneko:/home/examples#./sms_send
Enter the phone number in the form +31625670634:
+381640140555 <ENTER>
The signal strength is in the recommended range. Signal strength is 19.
If the signal is lower than recommended, message will be sent to the registered number.
17
User application examples
Figure 18 – Display sms_send
3.10 E-mail send
In this example is described sending e-mail.
geneko:/home/examples#$ ./smtp.netcat.test mx.example.com 25 from@example.com
to@example.com
Figure 19 – Result after execution script send_e-mail
geneko:/home/examples#vi send_e-mail
18
User application examples
Figure 20 – Display send_e_mail
3.11 General Purpose Input/Output (GPIO)
19
User application examples
This chapter describes the General Purpose Input/Output (GPIO) functionality on the
GWG Gateway.
On router’s board are 5 GPIO generic pins which represent:
1. +5VDC with 500mA resettable PTC fuse
2. IO1
3. IO2
4. IO3
5. GND
IO1, IO2, IO3 are 3 user selectable input or output.
Input value is readable (high=1, low=0).
Output value is writable (high=1, low=0).
3.11.1 gpio_functionality
In this example is described GPIO functionality supported by service gpio .
admin@geneko>service gpio
service gpio -i read value of an input GPIO
service gpio -o write value to an output GPIO (gpio_id must be specified)
service gpio -g <gpio_id> GPIO to read/write. If this option is not specified it
will return combined value of all GPIO inputs. If the ID
is wrong, the program will return EXIT_WRONG_ID value
service gpio -v <value> value to be written to an output GPIO.
Valid values are 0 and 1.
If the value is wrong, the program will return
EXIT_WRONG_VALUE value
-h this help
geneko:/home/examples#./gpio_functionality.sh
Figure 21 - Result after execution gpio_functionality.sh
geneko:/home/examples#vi gpio_functionality.sh
20
User application examples
Figure 22 - gpio_functionality
3.11.2 gpio_send_sms
In this example is described, when gpio pin change its state, GWG Gateway read combined
value of all GPIO inputs. If the state of GPIO pins is changed, GWG Gateway sends sms.
geneko:/home/examples#./gpio_send_sms.sh
Figure 23 - Result after execution gpio_send_sms.sh
21
User application examples
geneko:/home/examples# vi gpio_send_sms.sh
Figure 24 - gpio_send_sms
22
U s e r a p p l i c a t i o n e x a m p l e s
Bul. Despota Stefana 59a
11000 Belgrade • Serbia
Phone: +381 11 3340-591, 3340-178
Fax: +381 11 3224-437
e-mail: gwrsupport@geneko.rs
www.geneko.rs
GWR User App Examples Rev. C Sep 16