From 7ac185c13259443bcc422e8c1abb20c8df58690f Mon Sep 17 00:00:00 2001 From: Naruto TAKAHASHI Date: Fri, 27 Jul 2018 00:42:25 +0900 Subject: [PATCH] apply review feedback --- mynewt/README.md | 46 +++++++++++++++++++++++++++++++++++++++ mynewt/client-tls-mn.c | 2 +- mynewt/setup.sh | 2 +- mynewt/test_client-tls.sh | 22 +++++++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 mynewt/test_client-tls.sh diff --git a/mynewt/README.md b/mynewt/README.md index 518f82a1..6b963fff 100644 --- a/mynewt/README.md +++ b/mynewt/README.md @@ -8,6 +8,12 @@ It provides follows mynewt packages. - apps/wolfsslclienttlsmn - client-tls simple example ssl/tls client application for mn_socket. +## Prepare + +install `newt` command by referencing below document. + +http://mynewt.apache.org/latest/get_started/native_install/index.html + ## How to setup ### delopy wolfssl source to mynewt project @@ -46,3 +52,43 @@ newt clean wolfsslclienttlsmn_sim newt build wolfsslclienttlsmn_sim ./bin/targets/wolfsslclienttlsmn_sim/app/apps/wolfsslclienttlsmn/wolfsslclienttlsmn.elf ``` + +## Usage +### connect `wolfsslclienttlsmn` + +`wolfssl clienttlsmn.elf` displays tty file path. +be able to connect `wolfsslclienttlsmn.elf` by using terminal softwre such as `screen` or `kermit`. + +### command list + +`wolfsslclienttlsmn` has below commands. + + +| command | argument | describe | example | +|---------|----------------------------------|----------------------------|---------------------------------------| +| time | "unix timestamp" | To set the time | "time 1532616682" | +| net | udp | create udp socket | "net udp" | +| net | tcp | create tcp socket | "net tcp" | +| net | connect "ipaddress" port | connect "ipaddress" | "net connect 93.184.216.34" 443 | +| net | close | close socket | "net close" | +| net | send "string" "ipaddress" "port" | send string | "net send "GET \r\n" 93.184.216.34 80 | +| net | recv "ipaddress" | recv from ipaddress | "net recv 93.184.216.34 80 | +| wolfssl | init | initialize wolfssl library | "wolfssl init" | +| wolfssl | connect | connect via ssl | "wolfssl connect" | +| wolfssl | write "string" | send string via ssl | "wolfssl write "GET /"" | +| wolfssl | read | recv via ssl | "wolfssl recv" | +| wolfssl | clear | finish wolfssl library | "wolfssl clear" | + +### command examples +get `index.html` from `www.example.com:443` + +``` +net tcp +net connect +wolfssl init +wolfssl connect +wolfssl write +wolfssl read +wolfssl clear +net close +``` diff --git a/mynewt/client-tls-mn.c b/mynewt/client-tls-mn.c index b256546b..e379e333 100644 --- a/mynewt/client-tls-mn.c +++ b/mynewt/client-tls-mn.c @@ -87,7 +87,7 @@ time_cli(int argc, char **argv) } time = strtoul(argv[1], &eptr, 0); if (*eptr != '\0') { - console_printf("Invalid port %s\n", argv[3]); + console_printf("Invalid time %s\n", argv[3]); return 0; } diff --git a/mynewt/setup.sh b/mynewt/setup.sh index 717a8f09..731e03d2 100755 --- a/mynewt/setup.sh +++ b/mynewt/setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e # this scrypt deploy wolfssl and wolfcrypto source code to mynewt project # run as bash "mynewt project root directory path" diff --git a/mynewt/test_client-tls.sh b/mynewt/test_client-tls.sh new file mode 100644 index 00000000..4b5cac65 --- /dev/null +++ b/mynewt/test_client-tls.sh @@ -0,0 +1,22 @@ +#!/bin/sh -e + +if [ $# -ne 1 ]; then + echo "$0 program_path" + exit 1 +fi +PROGRAM=$1 + +TIMEOUT=10 + +expect -c " + set timeout ${TIMEOUT} + spawn \"${PROGRAM}\" + expect -re {uart0 at (.*)} { + send $expect_out(1,string) + send $expect_out(0,string) + send $expect_out(2,string) + } + expect \"$\" + exit 0 +" +exit 0 \ No newline at end of file