Tunnel – Using API to send data coming from a 3rd party webpage form and output serial port MTX-Tunnel

¿Buscas alguna otra cosa?

Scenario details:

  • We have a special display/LCD with a serial RS232 input. The data present in the RS232 port is shown in the display
  • We need to remotely control the LCD using the MTX-Tunnel GPRS-Serial tunnel
  • We can control the LCD in several ways.
  • We could develop a code for the server PC and use the TCP/IP port socket to connect to MTXTunnel
  • This example shows how to do this in any third-party web page using a form. The form will have a user defined entry box, so the text data captured will be resent to the LCD using the RS232 port. The LCD will answer with a code which will be displayed in the Web page form

Solution: MTX-Tunnel firmware + MTX-Java-IoT/MTX-Java-T/MTX-Java-T2

Config.txt configuration file:

Configuration Observations
COMM_baudrate: 115200
COMM_bitsperchar: 8
COMM_autocts: off
COMM_autorts: off
COMM_stopbits: 1
COMM_parity: none
COMM2_baudrate: 115200
COMM2_bitsperchar: 8
COMM2_autocts: off
COMM2_autorts: off
COMM2_stopbits: 1
COMM2_parity: none
GPRS_apn: movistar.es
GPRS_login: MOVISTAR
GPRS_password: MOVISTAR
GPRS_timeout: 0
MTX_model: MTX-4G-JAVA-T2
MTX_mode: none
MTX_ping: 30
MTX_pingIP: 8.8.8.8
WEBSERVER_firewall: off
WEBSERVER_enabled: on
WEBSERVER_login:user
WEBSERVER_password: 1234
WEBSERVER_skin: http://www.mtxtunnel.com/webserverimg/
WEBSERVER_gsmScript: http://www.blogelectronica.com/gps/gsm.php
Serial port baud rate
8 bit data
CTS hardware control disabled
RTS hardware control disabled
1 stop bit
No parity
Serial port baud rate
8 bit data
CTS hardware control disabled
RTS hardware control disabled
1 stop bit
No parity
GPRS APN from your network operator
GPRS Login
GPRS Password
Modem is permanently connected to GPRS
MTX-Terminal modem model used
No gateway is activated
Minutes for connectivity supervision ping
Connectivity supervision IP address
Firewall disabled
Internal webserver enabled
Webserver login
Webserver password
Webserver skin
Script GSM positioning

Third-party Web page form example:

This example has a very simple HTML code web page. It has a form with a text field and a button. HTML code also has a small script –JavaScript code- calling MTX-Tunnel.

This is the Web Page aspect:

HTML code for this webpage is as follows. Please ask iotsupport@mtxm2m.com for the full code.

This example “LED DISPLAY” text has been written in Webpage form and it is sent to the remote MTXTunnel and GPRS-serial tunnel. After this the data is now in the R232 port which will be shown in the LCD display.

The LCD screen responds with “Set TEXT OK” code which is collected by MTX-Tunnel and resent as a response to the form. Obviously, the given response is very simple since we are looking at an example.

In real applications, the response would lead to a more complex page being shown to the end user.

This is very simple example; in real application complex codes should be implemented.

We can control two LCD screens with just one MTXTerminal modem with MTX-Tunnel installed.

The key is the AT^MTXTUNNEL command.

In the example, we used AT^MTXTUNNEL=RS232,1But this command can send data to COM2 changing the “value” parameter (shown in red) to 2.

So we can control 2 LCD screens as follows:

Details:

  • Remember if you want to configure COM2 port as RS232 you need to turn off the microswitch 2 next to the SIM card slot (if not it is configured as RS485)