TCP Client and UDP Client Auto-Connect

Description

This example shows how to use the TCP and UDP auto connection feature. With this feature the module will automatically connect to a remote server. The following features are demonstrated:

Setup

First let's configure some basic module settings needed for the rest of the examples. Issue the following command to connect the module to a local network:

nup -s

Once this command completes, the module should be connected to the local network.

By default the module is in Command Mode . Issue the following command to but the module in Stream Mode .

set bus.mode stream

Next configure the module to automatically connect to the network. Then save and reboot:

set wlan.auto_join.enabled 1
save
reboot

After the module reboots, it's in Stream Mode . To issue more commands to the module, a break-in sequence is needed. The default break-in sequence is '$$$'. Issue '$$$' to break out of stream mode and into Command Mode:

$$$
Command Mode Start
>

Note: if an invalid break-in sequence is issued, wait 3 seconds before sending the break-in sequence again.

TCP Auto Connect

Now that we've issue the break sequence and can issue more commands, let's configure the module to automatically connect to a remote TCP server. Issue the following commands:

set tcp.client.remote_host test.zentri.com
set tcp.client.remote_port 50007
set tcp.client.auto_start 1
save
reboot

That's it. The module has been configured to automatically connect to the remote TCP server: test.zentri.com:50007. When the module reboots, it will connect to the network then connect to the TCP server. Once connected, anything that's typed into terminal will be echoed.

Notes:

UDP Auto Connect

The UDP Auto Connect feature is very similar to the TCP Auto Connect. To configure the module for UDP Auto Connect, first issue the break-in sequence as described above. Once the module is able to receive more commands. Issue the following:

set tcp.client.auto_start 0

This will disable the TCP Auto connect feature from the previous example. Note that in Stream Mode , only one stream may be opened at a time. Next issue the following commands to enable UDP Auto Connect:

set udp.client.remote_host test.zentri.com
set udp.client.remote_port 50007
set udp.client.auto_start 1
save
reboot

That's it. The module has been configured to automatically connect to the remote UDP server: test.zentri.com:50007. When the module reboots, it will connect to the network then connect to the UDP server. Once connected, anything that's typed into terminal will be echoed.


Supporting Gecko OS Editions and Versions

Change Log

Modified Changes
2015-02-03 Created