Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Latest commit

 

History

History
108 lines (74 loc) · 3.24 KB

README.rst

File metadata and controls

108 lines (74 loc) · 3.24 KB

Golioth Hello sample

Overview

This sample application demonstrates how to connect with Golioth and publish simple Hello messages.

Requirements

  • Golioth credentials and server information
  • Network connectivity

Building and Running

Configure the following Kconfig options based on your Golioth credentials and server in your own overlay config file:

  • GOLIOTH_SERVER_IP_ADDR - Server IPv4 address.
  • GOLIOTH_SERVER_PORT - Server port number.
  • GOLIOTH_SERVER_DTLS_PSK_ID - PSK ID of registered device
  • GOLIOTH_SERVER_DTLS_PSK - PSK of registered device

Platform specific configuration

QEMU

This application has been built and tested with QEMU x86 (qemu_x86) and QEMU ARM Cortex-M3 (qemu_cortex_m3).

On your Linux host computer, open a terminal window, locate the source code of this sample application (i.e., samples/hello) and type:

$ west build -b qemu_x86 samples/hello
$ west build -t run

See Networking with QEMU on how to setup networking on host and configure NAT/masquerading to access Internet.

ESP32

Configure the following Kconfig options based on your WiFi AP credentials:

  • ESP32_WIFI_SSID - WiFi SSID
  • ESP32_WIFI_PASSWORD - WiFi PSK

On your host computer open a terminal window, locate the source code of this sample application (i.e., samples/hello) and type:

$ west build -b esp32 samples/hello
$ west flash

This is the overlay template for WiFi credentials:

CONFIG_ESP32_WIFI_SSID="my-wifi"
CONFIG_ESP32_WIFI_PASSWORD="my-psk"

See ESP32 for details on how to use ESP32 board.

Sample overlay file

This is the overlay template for Golioth credentials and server:

CONFIG_GOLIOTH_SERVER_DTLS_PSK_ID="my-psk-id"
CONFIG_GOLIOTH_SERVER_DTLS_PSK="my-psk"
CONFIG_GOLIOTH_SERVER_IP_ADDR="192.168.1.10"
CONFIG_GOLIOTH_SERVER_PORT=5684

Sample output

This is the output from the serial console:

[00:00:00.000,000] <inf> golioth_hello: Initializing golioth client
[00:00:00.000,000] <inf> golioth_hello: Golioth client initialized
[00:00:00.000,000] <inf> golioth_hello: Sending hello! 0
[00:00:00.000,000] <wrn> golioth_hello: Failed to send hello!
[00:00:00.000,000] <inf> golioth_hello: Starting connect
[00:00:00.000,000] <inf> golioth_hello: Client connected!
[00:00:05.010,000] <inf> golioth_hello: Sending hello! 1
[00:00:05.020,000] <dbg> golioth_hello: Payload
                                        48 65 6c 6c 6f 20 6d 61  72 6b                   |Hello ma rk
[00:00:10.030,000] <inf> golioth_hello: Sending hello! 2
[00:00:10.030,000] <dbg> golioth_hello: Payload
                                        48 65 6c 6c 6f 20 6d 61  72 6b                   |Hello ma rk

Responses to Hello messages are printed above as a hexdump of "Hello mark". This means that communication with Golioth is working.