This is an example based on mbed-os cellular APIs that demonstrates a TCP or UDP echo transaction with a public echo server. Included TPB23 NB-IoT module which is can use LGU+ in Korea.

This example is showing how to use the NB-IoT(SECOM TPB23 module) of LGU plus network in Korea. The NB-IoT module' seller provided a document on how to start based on Mbed OS 5.11. (Created by CodeZoo) This guide has been supported to the latest os version which included 5.12 ~ 5.15.

  • if you need specific version of Mbed OS, please revision of TPB23_Driver and check it out.
  • Pelion ready example code is here!

Requirement

462 320 320

320

Tested with

1. Import the application into your desktop

mbed import http://os.mbed.com/users/Daniel_Lee/code/mbed-os-example-cellular-TPB23/

cd mbed-os-example-cellular-TPB23

2. Compile and program

mbed compile -t <toolchain> -m <TARGET_BOARD>

(supported toolchains : GCC_ARM / ARM / IAR)

3. Download binary to a target board

4. Result

mbed-os-example-cellular


Built: Aug  7 2019, 06:10:47


[MAIN], plmn: NULL
Establishing connection
[00000001ms][INFO][CELL]: New CellularContext  (20000a08)
[00000002ms][INFO][CELL]: CellularContext plmn NULL
[00000003ms][INFO][CELL]: CellularContext connect
[00000036ms][INFO][CELL]: RSSI -69 dBm
[00000036ms][INFO][CELL]: Start connecting (timeout 1 s)
[00000087ms][INFO][CELL]: RSSI -69 dBm
[00000116ms][INFO][CELL]: Modem ready
[00000146ms][INFO][CELL]: RSSI -69 dBm
[00000146ms][INFO][CELL]: Setup SIM (timeout 1 s)
[00001233ms][INFO][CELL]: Looked up APN internet
[00001362ms][ERR ][CELL]: AT error code 50
[00001362ms][WARN][CELL]: Packet domain event reporting set failed!
[00001393ms][INFO][CELL]: RSSI -65 dBm
[00001393ms][INFO][CELL]: Network registration (timeout 180 s)
[00001443ms][INFO][CELL]: Registering network => Attaching network
[00001473ms][INFO][CELL]: RSSI -65 dBm
[00001473ms][INFO][CELL]: Attaching network (timeout 60 s)
[00001601ms][INFO][CELL]: Found PDP context 1
[00001649ms][INFO][CELL]: Activate PDP context 1


Connection Established.
[00001671ms][INFO][CELL]: Socket 0 open
[00001707ms][INFO][CELL]: Socket 1 open
[00001748ms][INFO][CELL]: Socket create id: 1
[00001883ms][INFO][CELL]: Socket 1 sent 43 bytes to 8.8.8.8 port 53
[00004311ms][INFO][CELL]: Socket 1 recv 59 bytes from 8.8.8.8 port 53
[00004331ms][INFO][CELL]: Close socket: 1 error: 0
[00004331ms][INFO][CELL]: Socket 1 closed
[00004373ms][INFO][CELL]: Socket create id: 1
TCP: connected with echo.mbedcloudtesting.com server
[00004448ms][INFO][CELL]: Socket 0 sent 4 bytes to 52.215.34.155 port 7
TCP: Sent 4 Bytes to echo.mbedcloudtesting.com
[00007560ms][INFO][CELL]: Socket 0 recv 4 bytes
[00007580ms][INFO][CELL]: Close socket: 1 error: 0
[00007580ms][INFO][CELL]: Socket 0 closed
Received from echo server 4 Bytes
[00007581ms][INFO][CELL]: CellularContext disconnect()
[00007630ms][INFO][CELL]: cb: CellularContext disconnected


Success. Exiting
Committer:
mbed_official
Date:
Mon May 06 09:02:01 2019 +0100
Revision:
40:c46ee5b71843
Parent:
36:6294a71c9e9e
Child:
42:cab443dff75e
Merge pull request #135 from mirelachirica/nonip_socket_support

Added NonIP socket example
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-cellular

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:4611f6cf2413 1 /*
mbed_official 0:4611f6cf2413 2 * Copyright (c) 2017 ARM Limited. All rights reserved.
mbed_official 0:4611f6cf2413 3 * SPDX-License-Identifier: Apache-2.0
mbed_official 0:4611f6cf2413 4 * Licensed under the Apache License, Version 2.0 (the License); you may
mbed_official 0:4611f6cf2413 5 * not use this file except in compliance with the License.
mbed_official 0:4611f6cf2413 6 * You may obtain a copy of the License at
mbed_official 0:4611f6cf2413 7 *
mbed_official 0:4611f6cf2413 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 0:4611f6cf2413 9 *
mbed_official 0:4611f6cf2413 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 0:4611f6cf2413 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
mbed_official 0:4611f6cf2413 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 0:4611f6cf2413 13 * See the License for the specific language governing permissions and
mbed_official 0:4611f6cf2413 14 * limitations under the License.
mbed_official 0:4611f6cf2413 15 */
mbed_official 0:4611f6cf2413 16
mbed_official 0:4611f6cf2413 17 #include "mbed.h"
mbed_official 0:4611f6cf2413 18 #include "common_functions.h"
mbed_official 40:c46ee5b71843 19 #include "CellularNonIPSocket.h"
mbed_official 40:c46ee5b71843 20 #include "CellularDevice.h"
mbed_official 0:4611f6cf2413 21 #include "UDPSocket.h"
mbed_official 6:5678c0b6f74e 22 #include "CellularLog.h"
mbed_official 0:4611f6cf2413 23
mbed_official 0:4611f6cf2413 24 #define UDP 0
mbed_official 0:4611f6cf2413 25 #define TCP 1
mbed_official 40:c46ee5b71843 26 #define NONIP 2
mbed_official 0:4611f6cf2413 27
mbed_official 0:4611f6cf2413 28 // Number of retries /
mbed_official 0:4611f6cf2413 29 #define RETRY_COUNT 3
mbed_official 0:4611f6cf2413 30
mbed_official 28:232da3ce8a88 31 NetworkInterface *iface;
mbed_official 0:4611f6cf2413 32
mbed_official 0:4611f6cf2413 33 // Echo server hostname
mbed_official 11:23ea0907186e 34 const char *host_name = MBED_CONF_APP_ECHO_SERVER_HOSTNAME;
mbed_official 0:4611f6cf2413 35
mbed_official 0:4611f6cf2413 36 // Echo server port (same for TCP and UDP)
mbed_official 11:23ea0907186e 37 const int port = MBED_CONF_APP_ECHO_SERVER_PORT;
mbed_official 0:4611f6cf2413 38
mbed_official 6:5678c0b6f74e 39 static rtos::Mutex trace_mutex;
mbed_official 6:5678c0b6f74e 40
mbed_official 6:5678c0b6f74e 41 #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 6:5678c0b6f74e 42 static void trace_wait()
mbed_official 6:5678c0b6f74e 43 {
mbed_official 6:5678c0b6f74e 44 trace_mutex.lock();
mbed_official 6:5678c0b6f74e 45 }
mbed_official 6:5678c0b6f74e 46
mbed_official 6:5678c0b6f74e 47 static void trace_release()
mbed_official 6:5678c0b6f74e 48 {
mbed_official 6:5678c0b6f74e 49 trace_mutex.unlock();
mbed_official 6:5678c0b6f74e 50 }
mbed_official 6:5678c0b6f74e 51
mbed_official 6:5678c0b6f74e 52 static char time_st[50];
mbed_official 6:5678c0b6f74e 53
mbed_official 6:5678c0b6f74e 54 static char* trace_time(size_t ss)
mbed_official 6:5678c0b6f74e 55 {
mbed_official 6:5678c0b6f74e 56 snprintf(time_st, 49, "[%08llums]", Kernel::get_ms_count());
mbed_official 6:5678c0b6f74e 57 return time_st;
mbed_official 6:5678c0b6f74e 58 }
mbed_official 6:5678c0b6f74e 59
mbed_official 6:5678c0b6f74e 60 static void trace_open()
mbed_official 6:5678c0b6f74e 61 {
mbed_official 6:5678c0b6f74e 62 mbed_trace_init();
mbed_official 6:5678c0b6f74e 63 mbed_trace_prefix_function_set( &trace_time );
mbed_official 6:5678c0b6f74e 64
mbed_official 6:5678c0b6f74e 65 mbed_trace_mutex_wait_function_set(trace_wait);
mbed_official 6:5678c0b6f74e 66 mbed_trace_mutex_release_function_set(trace_release);
mbed_official 11:23ea0907186e 67
mbed_official 11:23ea0907186e 68 mbed_cellular_trace::mutex_wait_function_set(trace_wait);
mbed_official 11:23ea0907186e 69 mbed_cellular_trace::mutex_release_function_set(trace_release);
mbed_official 6:5678c0b6f74e 70 }
mbed_official 6:5678c0b6f74e 71
mbed_official 6:5678c0b6f74e 72 static void trace_close()
mbed_official 6:5678c0b6f74e 73 {
mbed_official 11:23ea0907186e 74 mbed_cellular_trace::mutex_wait_function_set(NULL);
mbed_official 11:23ea0907186e 75 mbed_cellular_trace::mutex_release_function_set(NULL);
mbed_official 11:23ea0907186e 76
mbed_official 6:5678c0b6f74e 77 mbed_trace_free();
mbed_official 6:5678c0b6f74e 78 }
mbed_official 6:5678c0b6f74e 79 #endif // #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 6:5678c0b6f74e 80
mbed_official 2:0f644d6045cf 81 Thread dot_thread(osPriorityNormal, 512);
mbed_official 0:4611f6cf2413 82
mbed_official 6:5678c0b6f74e 83 void print_function(const char *format, ...)
mbed_official 0:4611f6cf2413 84 {
mbed_official 6:5678c0b6f74e 85 trace_mutex.lock();
mbed_official 6:5678c0b6f74e 86 va_list arglist;
mbed_official 6:5678c0b6f74e 87 va_start( arglist, format );
mbed_official 6:5678c0b6f74e 88 vprintf(format, arglist);
mbed_official 6:5678c0b6f74e 89 va_end( arglist );
mbed_official 6:5678c0b6f74e 90 trace_mutex.unlock();
mbed_official 0:4611f6cf2413 91 }
mbed_official 0:4611f6cf2413 92
mbed_official 0:4611f6cf2413 93 void dot_event()
mbed_official 0:4611f6cf2413 94 {
mbed_official 0:4611f6cf2413 95 while (true) {
mbed_official 26:348eec457e58 96 ThisThread::sleep_for(4000);
mbed_official 28:232da3ce8a88 97 if (iface && iface->get_connection_status() == NSAPI_STATUS_GLOBAL_UP) {
mbed_official 13:4bea5334b419 98 break;
mbed_official 13:4bea5334b419 99 } else {
mbed_official 6:5678c0b6f74e 100 trace_mutex.lock();
mbed_official 6:5678c0b6f74e 101 printf(".");
mbed_official 6:5678c0b6f74e 102 fflush(stdout);
mbed_official 6:5678c0b6f74e 103 trace_mutex.unlock();
mbed_official 0:4611f6cf2413 104 }
mbed_official 0:4611f6cf2413 105 }
mbed_official 0:4611f6cf2413 106 }
mbed_official 0:4611f6cf2413 107
mbed_official 0:4611f6cf2413 108 /**
mbed_official 0:4611f6cf2413 109 * Connects to the Cellular Network
mbed_official 0:4611f6cf2413 110 */
mbed_official 0:4611f6cf2413 111 nsapi_error_t do_connect()
mbed_official 0:4611f6cf2413 112 {
mbed_official 6:5678c0b6f74e 113 nsapi_error_t retcode = NSAPI_ERROR_OK;
mbed_official 0:4611f6cf2413 114 uint8_t retry_counter = 0;
mbed_official 0:4611f6cf2413 115
mbed_official 28:232da3ce8a88 116 while (iface->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
mbed_official 11:23ea0907186e 117 retcode = iface->connect();
mbed_official 0:4611f6cf2413 118 if (retcode == NSAPI_ERROR_AUTH_FAILURE) {
mbed_official 0:4611f6cf2413 119 print_function("\n\nAuthentication Failure. Exiting application\n");
mbed_official 6:5678c0b6f74e 120 } else if (retcode == NSAPI_ERROR_OK) {
mbed_official 6:5678c0b6f74e 121 print_function("\n\nConnection Established.\n");
mbed_official 6:5678c0b6f74e 122 } else if (retry_counter > RETRY_COUNT) {
mbed_official 6:5678c0b6f74e 123 print_function("\n\nFatal connection failure: %d\n", retcode);
mbed_official 6:5678c0b6f74e 124 } else {
mbed_official 6:5678c0b6f74e 125 print_function("\n\nCouldn't connect: %d, will retry\n", retcode);
mbed_official 0:4611f6cf2413 126 retry_counter++;
mbed_official 0:4611f6cf2413 127 continue;
mbed_official 0:4611f6cf2413 128 }
mbed_official 0:4611f6cf2413 129 break;
mbed_official 0:4611f6cf2413 130 }
mbed_official 6:5678c0b6f74e 131 return retcode;
mbed_official 0:4611f6cf2413 132 }
mbed_official 0:4611f6cf2413 133
mbed_official 0:4611f6cf2413 134 /**
mbed_official 40:c46ee5b71843 135 * Opens:
mbed_official 40:c46ee5b71843 136 * - UDP or TCP socket with the given echo server and performs an echo
mbed_official 40:c46ee5b71843 137 * transaction retrieving current.
mbed_official 40:c46ee5b71843 138 * - Cellular Non-IP socket for which the data delivery path is decided
mbed_official 40:c46ee5b71843 139 * by network's control plane CIoT optimisation setup, for the given APN.
mbed_official 0:4611f6cf2413 140 */
mbed_official 0:4611f6cf2413 141 nsapi_error_t test_send_recv()
mbed_official 0:4611f6cf2413 142 {
mbed_official 0:4611f6cf2413 143 nsapi_size_or_error_t retcode;
mbed_official 0:4611f6cf2413 144 #if MBED_CONF_APP_SOCK_TYPE == TCP
mbed_official 0:4611f6cf2413 145 TCPSocket sock;
mbed_official 40:c46ee5b71843 146 #elif MBED_CONF_APP_SOCK_TYPE == UDP
mbed_official 0:4611f6cf2413 147 UDPSocket sock;
mbed_official 40:c46ee5b71843 148 #elif MBED_CONF_APP_SOCK_TYPE == NONIP
mbed_official 40:c46ee5b71843 149 CellularNonIPSocket sock;
mbed_official 0:4611f6cf2413 150 #endif
mbed_official 0:4611f6cf2413 151
mbed_official 40:c46ee5b71843 152 #if MBED_CONF_APP_SOCK_TYPE == NONIP
mbed_official 40:c46ee5b71843 153 retcode = sock.open((CellularContext*)iface);
mbed_official 40:c46ee5b71843 154 #else
mbed_official 11:23ea0907186e 155 retcode = sock.open(iface);
mbed_official 40:c46ee5b71843 156 #endif
mbed_official 40:c46ee5b71843 157
mbed_official 0:4611f6cf2413 158 if (retcode != NSAPI_ERROR_OK) {
mbed_official 21:e356e039f917 159 #if MBED_CONF_APP_SOCK_TYPE == TCP
mbed_official 21:e356e039f917 160 print_function("TCPSocket.open() fails, code: %d\n", retcode);
mbed_official 40:c46ee5b71843 161 #elif MBED_CONF_APP_SOCK_TYPE == UDP
mbed_official 6:5678c0b6f74e 162 print_function("UDPSocket.open() fails, code: %d\n", retcode);
mbed_official 40:c46ee5b71843 163 #elif MBED_CONF_APP_SOCK_TYPE == NONIP
mbed_official 40:c46ee5b71843 164 print_function("CellularNonIPSocket.open() fails, code: %d\n", retcode);
mbed_official 21:e356e039f917 165 #endif
mbed_official 0:4611f6cf2413 166 return -1;
mbed_official 0:4611f6cf2413 167 }
mbed_official 0:4611f6cf2413 168
mbed_official 40:c46ee5b71843 169 int n = 0;
mbed_official 40:c46ee5b71843 170 const char *echo_string = "TEST";
mbed_official 40:c46ee5b71843 171 char recv_buf[4];
mbed_official 40:c46ee5b71843 172
mbed_official 40:c46ee5b71843 173 sock.set_timeout(15000);
mbed_official 40:c46ee5b71843 174
mbed_official 40:c46ee5b71843 175 #if MBED_CONF_APP_SOCK_TYPE == NONIP
mbed_official 40:c46ee5b71843 176 retcode = sock.send((void*) echo_string, sizeof(echo_string));
mbed_official 40:c46ee5b71843 177 if (retcode < 0) {
mbed_official 40:c46ee5b71843 178 print_function("CellularNonIPSocket.send() fails, code: %d\n", retcode);
mbed_official 40:c46ee5b71843 179 return -1;
mbed_official 40:c46ee5b71843 180 } else {
mbed_official 40:c46ee5b71843 181 print_function("CellularNonIPSocket: Sent %d Bytes\n", retcode);
mbed_official 40:c46ee5b71843 182 }
mbed_official 40:c46ee5b71843 183
mbed_official 40:c46ee5b71843 184 n = sock.recv((void*) recv_buf, sizeof(recv_buf));
mbed_official 40:c46ee5b71843 185
mbed_official 40:c46ee5b71843 186 #else
mbed_official 40:c46ee5b71843 187
mbed_official 0:4611f6cf2413 188 SocketAddress sock_addr;
mbed_official 11:23ea0907186e 189 retcode = iface->gethostbyname(host_name, &sock_addr);
mbed_official 0:4611f6cf2413 190 if (retcode != NSAPI_ERROR_OK) {
mbed_official 6:5678c0b6f74e 191 print_function("Couldn't resolve remote host: %s, code: %d\n", host_name, retcode);
mbed_official 0:4611f6cf2413 192 return -1;
mbed_official 0:4611f6cf2413 193 }
mbed_official 0:4611f6cf2413 194
mbed_official 0:4611f6cf2413 195 sock_addr.set_port(port);
mbed_official 0:4611f6cf2413 196
mbed_official 0:4611f6cf2413 197 #if MBED_CONF_APP_SOCK_TYPE == TCP
mbed_official 0:4611f6cf2413 198 retcode = sock.connect(sock_addr);
mbed_official 0:4611f6cf2413 199 if (retcode < 0) {
mbed_official 6:5678c0b6f74e 200 print_function("TCPSocket.connect() fails, code: %d\n", retcode);
mbed_official 0:4611f6cf2413 201 return -1;
mbed_official 0:4611f6cf2413 202 } else {
mbed_official 6:5678c0b6f74e 203 print_function("TCP: connected with %s server\n", host_name);
mbed_official 0:4611f6cf2413 204 }
mbed_official 0:4611f6cf2413 205 retcode = sock.send((void*) echo_string, sizeof(echo_string));
mbed_official 0:4611f6cf2413 206 if (retcode < 0) {
mbed_official 6:5678c0b6f74e 207 print_function("TCPSocket.send() fails, code: %d\n", retcode);
mbed_official 0:4611f6cf2413 208 return -1;
mbed_official 0:4611f6cf2413 209 } else {
mbed_official 6:5678c0b6f74e 210 print_function("TCP: Sent %d Bytes to %s\n", retcode, host_name);
mbed_official 0:4611f6cf2413 211 }
mbed_official 0:4611f6cf2413 212
mbed_official 0:4611f6cf2413 213 n = sock.recv((void*) recv_buf, sizeof(recv_buf));
mbed_official 0:4611f6cf2413 214 #else
mbed_official 0:4611f6cf2413 215
mbed_official 0:4611f6cf2413 216 retcode = sock.sendto(sock_addr, (void*) echo_string, sizeof(echo_string));
mbed_official 0:4611f6cf2413 217 if (retcode < 0) {
mbed_official 6:5678c0b6f74e 218 print_function("UDPSocket.sendto() fails, code: %d\n", retcode);
mbed_official 0:4611f6cf2413 219 return -1;
mbed_official 0:4611f6cf2413 220 } else {
mbed_official 6:5678c0b6f74e 221 print_function("UDP: Sent %d Bytes to %s\n", retcode, host_name);
mbed_official 0:4611f6cf2413 222 }
mbed_official 0:4611f6cf2413 223
mbed_official 0:4611f6cf2413 224 n = sock.recvfrom(&sock_addr, (void*) recv_buf, sizeof(recv_buf));
mbed_official 0:4611f6cf2413 225 #endif
mbed_official 40:c46ee5b71843 226 #endif
mbed_official 0:4611f6cf2413 227
mbed_official 0:4611f6cf2413 228 sock.close();
mbed_official 0:4611f6cf2413 229
mbed_official 0:4611f6cf2413 230 if (n > 0) {
mbed_official 6:5678c0b6f74e 231 print_function("Received from echo server %d Bytes\n", n);
mbed_official 0:4611f6cf2413 232 return 0;
mbed_official 0:4611f6cf2413 233 }
mbed_official 0:4611f6cf2413 234
mbed_official 0:4611f6cf2413 235 return -1;
mbed_official 0:4611f6cf2413 236 }
mbed_official 0:4611f6cf2413 237
mbed_official 0:4611f6cf2413 238 int main()
mbed_official 0:4611f6cf2413 239 {
mbed_official 6:5678c0b6f74e 240 print_function("\n\nmbed-os-example-cellular\n");
mbed_official 34:6f85d44597ac 241 print_function("\n\nBuilt: %s, %s\n", __DATE__, __TIME__);
mbed_official 34:6f85d44597ac 242 #ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN
mbed_official 36:6294a71c9e9e 243 print_function("\n\n[MAIN], plmn: %s\n", (MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN ? MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN : "NULL"));
mbed_official 34:6f85d44597ac 244 #endif
mbed_official 34:6f85d44597ac 245
mbed_official 6:5678c0b6f74e 246 print_function("Establishing connection\n");
mbed_official 6:5678c0b6f74e 247 #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 6:5678c0b6f74e 248 trace_open();
mbed_official 6:5678c0b6f74e 249 #else
mbed_official 6:5678c0b6f74e 250 dot_thread.start(dot_event);
mbed_official 6:5678c0b6f74e 251 #endif // #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 27:97054be1a741 252
mbed_official 40:c46ee5b71843 253 #if MBED_CONF_APP_SOCK_TYPE == NONIP
mbed_official 40:c46ee5b71843 254 iface = CellularContext::get_default_nonip_instance();
mbed_official 40:c46ee5b71843 255 #else
mbed_official 40:c46ee5b71843 256 iface = CellularContext::get_default_instance();
mbed_official 40:c46ee5b71843 257 #endif
mbed_official 40:c46ee5b71843 258
mbed_official 11:23ea0907186e 259 MBED_ASSERT(iface);
mbed_official 11:23ea0907186e 260
mbed_official 40:c46ee5b71843 261 // sim pin, apn, credentials and possible plmn are taken automatically from json when using NetworkInterface::set_default_parameters()
mbed_official 40:c46ee5b71843 262 iface->set_default_parameters();
mbed_official 40:c46ee5b71843 263
mbed_official 6:5678c0b6f74e 264 nsapi_error_t retcode = NSAPI_ERROR_NO_CONNECTION;
mbed_official 0:4611f6cf2413 265
mbed_official 0:4611f6cf2413 266 /* Attempt to connect to a cellular network */
mbed_official 0:4611f6cf2413 267 if (do_connect() == NSAPI_ERROR_OK) {
mbed_official 6:5678c0b6f74e 268 retcode = test_send_recv();
mbed_official 0:4611f6cf2413 269 }
mbed_official 0:4611f6cf2413 270
mbed_official 26:348eec457e58 271 if (iface->disconnect() != NSAPI_ERROR_OK) {
mbed_official 26:348eec457e58 272 print_function("\n\n disconnect failed.\n\n");
mbed_official 26:348eec457e58 273 }
mbed_official 26:348eec457e58 274
mbed_official 6:5678c0b6f74e 275 if (retcode == NSAPI_ERROR_OK) {
mbed_official 6:5678c0b6f74e 276 print_function("\n\nSuccess. Exiting \n\n");
mbed_official 6:5678c0b6f74e 277 } else {
mbed_official 6:5678c0b6f74e 278 print_function("\n\nFailure. Exiting \n\n");
mbed_official 6:5678c0b6f74e 279 }
mbed_official 26:348eec457e58 280
mbed_official 6:5678c0b6f74e 281 #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 6:5678c0b6f74e 282 trace_close();
mbed_official 26:348eec457e58 283 #else
mbed_official 26:348eec457e58 284 dot_thread.terminate();
mbed_official 6:5678c0b6f74e 285 #endif // #if MBED_CONF_MBED_TRACE_ENABLE
mbed_official 6:5678c0b6f74e 286
mbed_official 6:5678c0b6f74e 287 return 0;
mbed_official 0:4611f6cf2413 288 }
mbed_official 0:4611f6cf2413 289 // EOF