Basic UDP Client Example

Send GPIO data from the device to a UDP server, and receive echoed data from server.

API Features Demonstrated

Platforms

This app works on:

Requirements and Prerequisites

Requires a Gecko OS evaluation board, such as a WGM160P_eval.

Other Gecko OS hardware can also be used by changing the source of the logged data to suit your device.

Description

The app connects to the UDP echo server at test.zentri.com and periodically sends GPIO values. The remote server echoes the values back, and the app displays the values on the Gecko OS terminal.

Usage Instructions

Open a Gecko OS serial terminal to the device. See Getting Started, Opening a Gecko OS Terminal.

This app assumes your Gecko OS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the Gecko OS terminal, run the commands:

network_up -s
save

See the Wi-Fi Command API documentation for network_up and save.

The app displays output similar to the following:

> Connecting to remote UDP server test.zentri.com:50007
Connected!
Transmitting data every 5000ms
Rx data: gpios:1472610
Rx data: gpios:1433652
Rx data: gpios:1433610
...

Implementation

gos_app_init:

wlan_network_event_handler:

udp_receive_handler:

udp_transmit_handler:

gos_app_deinit:

Source

See: