Establish connection with Beckhoff LTE stick

This chapter shows you how to establish a network connection with the LTE stick (CU8210-D004-0200) and how to use the serial interface of the LTE stick.

Requirements:

Proceed as follows:

1. Connect the LTE stick to the industrial PC.
2. A new network interface (by default ue0) is recognized. The available interfaces are displayed with ifconfig.
Administrator@CX-3D6912:~ $ ifconfig
---snipped---
ue0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
       options=80000<LINKSTATE>
       ether 76:ae:02:ec:c9:45
       inet 192.168.225.40 netmask 0xffffff00 broadcast 192.168.225.255
       inet6 fe80::8f92:e7ea:ed:1a66%ue0 prefixlen 64 scopeid 0x4
       inet6 2a01:599:640:6862:c05:263b:b3a4:385f prefixlen 64 autoconf
       media: Ethernet autoselect
       status: active
       nd6 options=1<PERFORMNUD>
---snipped---
3. If the dhclient is used, an entry must be made in the configuration file rc.conf so that the LTE stick receives an IP address. Open the configuration file with doas ee /etc/rc.conf and add the line ifconfig_ue0="SYNCDHCP".

This entry ensures that the LTE stick either receives an IP address from an existing DHCP server or assigns one itself. Here, the LTE stick receives an IP address from the provider.
4. If dhcpcd (default as of version 13.2.0.6 / 89449) is used instead, this configuration is not required and is carried out using the default settings.
5. Use ls /dev to check which virtual COM interface has been recognized by TwinCAT/BSD. Normally the following has been added: ttyU0
6. With the command doas cu -l /dev/ttyU0 we establish a serial connection to the LTE stick in order to enter the SIM pin and the access data of the network provider (APN, Access Point Name). After a successful connection, Connected is displayed in the console.
Administrator@CX-505918:~ $ doas cu -l /dev/ttyU0
Password:
Connected
7. In the next step, AT commands can be exchanged with the LTE stick in order to enter the SIM PIN or to inform the LTE stick of its APN. The APN must be entered the first time the stick is set up and is stored on the stick.
8. Enter the SIM PIN if the SIM card has a PIN. The SIM PIN must of course be re-entered each time the device is rebooted.
AT+CPIN=<your pin> 
9. If your policies allow it, you can disable the SIM PIN by using the following command:
AT+CLCK="SC",0,"<your pin>"
10. Use the following command to enter the APN:
AT+CGDCONT=APN#,"IPV4V6","your_new_apn"
11. For example, the command AT+CGDCONT=1,"IPV4V6","internet.t-mobile" results in using "internet.t-mobile" as the first prioritized access point (APN1).
12. The created APNs can be displayed with AT+CGDCONT?.
AT+CGDCONT?
+CGDCONT: 1,"IPV4V6","internet.t-mobile","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0
13. Incorrect or unused APNs can be deleted with AT+CGDCONT=<select Index>.
14. To apply the above changes (when using the dhclient) to the rc.conf, TwinCAT/BSD must be restarted once.
After the restart, the interface ue0 receives an IP address and also has a connection to the Internet if the data plan is active. The LED on the LTE stick flashes "blue" when the SIM card is unlocked and the mobile communication network is accessible with an active data plan. If the SIM card is not unlocked or there are problems reaching the mobile communication network, the LED flashes "red".

External communication is possible by default so that, for example, a ping can be sent to Google (ping: 8.8.8.8) for testing. If you have more restrictive firewall rules, you may need to adjust your firewall settings to allow ue0 to communicate with the outside world.

Side note: Sending SMS via the LTE stick

If you want to use the SMS function block (SendSMS) from TwinCAT, you can use the serial interface ttyU0 mentioned above. The TF6340's ADS server (Serial Communication) allows USB devices to be addressed via a virtual serial interface.

Requirements:

In this case, the virtual serial interface can be connected via the TwinCAT 3 function TF6340 (Serial Communication). The TwinCAT 3 function TF6340 must also be installed on the TwinCAT/BSD system. The TwinCAT 3 function TF6350 (SMS/SMTP) then enables SMS to be sent to a recipient using function blocks. A detailed sample of how an SMS can be sent via the LTE stick can be found here: https://infosys.beckhoff.com/content/1033/tf6350_tc3_sms_smtp/373331083.html?id=3466585722444011586

If, for example, the TwinCAT SMS function block is to be used, port "0" must be entered for the interface ttyU0 in the function block.

Establish connection with Beckhoff LTE stick 1:
Example of the use of the SMS function block in TwinCAT 3.