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

This app requires a ZentriOS 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 ZentriOS terminal.

Usage Instructions

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

This app assumes your ZentriOS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the ZentriOS 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

zn_app_init:

wlan_network_event_handler:

udp_receive_handler:

udp_transmit_handler:

zn_app_deinit:

Source

See: