Skip to content

Commit e4bf7f6

Browse files
committed
samples: net: websocket: App for doing Websocket client requests
This is BSD sockets based application for connecting to Websocket server. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent b3bea64 commit e4bf7f6

File tree

6 files changed

+450
-0
lines changed

6 files changed

+450
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.13.1)
4+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
project(http_client)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})
9+
10+
set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/)
11+
12+
generate_inc_file_for_target(
13+
app
14+
src/echo-apps-cert.der
15+
${gen_dir}/echo-apps-cert.der.inc
16+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Networking config
2+
CONFIG_NETWORKING=y
3+
CONFIG_NET_IPV4=y
4+
CONFIG_NET_IPV6=y
5+
CONFIG_NET_TCP=y
6+
CONFIG_NET_SHELL=y
7+
CONFIG_NET_STATISTICS=y
8+
9+
# Sockets
10+
CONFIG_NET_SOCKETS=y
11+
CONFIG_NET_SOCKETS_POSIX_NAMES=y
12+
CONFIG_NET_SOCKETS_POLL_MAX=4
13+
14+
# Network driver config
15+
CONFIG_TEST_RANDOM_GENERATOR=y
16+
17+
# Network address config
18+
CONFIG_NET_CONFIG_SETTINGS=y
19+
CONFIG_NET_CONFIG_NEED_IPV4=y
20+
CONFIG_NET_CONFIG_NEED_IPV6=y
21+
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
22+
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
23+
# Address of HTTP IPv4 server
24+
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
25+
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
26+
# Address of HTTP IPv6 server
27+
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
28+
29+
# HTTP & Websocket
30+
CONFIG_HTTP_CLIENT=y
31+
CONFIG_WEBSOCKET_CLIENT=y
32+
33+
# Network debug config
34+
CONFIG_LOG=y
35+
CONFIG_LOG_IMMEDIATE=y
36+
CONFIG_NET_LOG=y
37+
#CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y
38+
#CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
39+
#CONFIG_NET_WEBSOCKET_LOG_LEVEL_DBG=y
40+
#CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=y
41+
#CONFIG_NET_TCP_LOG_LEVEL_DBG=y
42+
43+
CONFIG_MAIN_STACK_SIZE=2048
44+
CONFIG_HEAP_MEM_POOL_SIZE=1500
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
common:
2+
tags: net http http_client websocket_client
3+
sample:
4+
description: Websocket client sample
5+
name: websocket_client
6+
tests:
7+
sample.net.sockets.websocket_client:
8+
harness: net
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define CA_CERTIFICATE_TAG 1
8+
9+
#define TLS_PEER_HOSTNAME "localhost"
10+
11+
/* This is the same cert as what is found in net-tools/echo-apps-cert.pem file
12+
*/
13+
static const unsigned char ca_certificate[] = {
14+
#include "echo-apps-cert.der.inc"
15+
};
767 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)