misc: Remove generic PRINT macros from net samples

Remove generic PRINT macros from net samples and replace
with SYS_LOG  module.

Jira: ZEP-240

Change-Id: I4bec179c99056cce41e1f3495c162f25c3cd2364
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
This commit is contained in:
Juan Manuel Cruz Alcaraz 2016-08-02 22:00:29 -05:00 committed by Inaky Perez-Gonzalez
commit 4dc93fed2f
35 changed files with 189 additions and 197 deletions

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_BT=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y

View file

@ -16,18 +16,13 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#if defined(CONFIG_TINYDTLS_DEBUG)
#define DEBUG DEBUG_FULL
#else
#define DEBUG DEBUG_PRINT
#define DEBUG DEBUG_SYS_LOG_INF
#endif
#include "contiki/ip/uip-debug.h"
@ -101,7 +96,7 @@ static struct in_addr in4addr_my = MY_IPADDR;
static inline void init_app(void)
{
PRINT("%s: run coap observe client\n", __func__);
SYS_LOG_INF("%s: run coap observe client", __func__);
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
@ -214,29 +209,30 @@ static void notification_callback(coap_observee_t *obs, void *notification,
int len = 0;
const uint8_t *payload = NULL;
PRINT("Notification handler\n");
PRINT("Observee URI: %s\n", obs->url);
SYS_LOG_INF("Notification handler");
SYS_LOG_INF("Observee URI: %s", obs->url);
if(notification) {
len = coap_get_payload(notification, &payload);
}
switch(flag) {
case NOTIFICATION_OK:
PRINT("NOTIFICATION OK: %*s\n", len, (char *)payload);
SYS_LOG_INF("NOTIFICATION OK: %*s", len, (char *)payload);
break;
case OBSERVE_OK: /* server accepeted observation request */
PRINT("OBSERVE_OK: %*s\n", len, (char *)payload);
SYS_LOG_INF("OBSERVE_OK: %*s", len, (char *)payload);
break;
case OBSERVE_NOT_SUPPORTED:
PRINT("OBSERVE_NOT_SUPPORTED: %*s\n", len, (char *)payload);
SYS_LOG_INF("OBSERVE_NOT_SUPPORTED: %*s", len,
(char *)payload);
obs = NULL;
break;
case ERROR_RESPONSE_CODE:
PRINT("ERROR_RESPONSE_CODE: %*s\n", len, (char *)payload);
SYS_LOG_INF("ERROR_RESPONSE_CODE: %*s", len, (char *)payload);
obs = NULL;
break;
case NO_REPLY_FROM_SERVER:
PRINT("NO_REPLY_FROM_SERVER: "
"removing observe registration with token %x%x\n",
SYS_LOG_INF("NO_REPLY_FROM_SERVER: "
"removing observe registration with token %x%x",
obs->token[0], obs->token[1]);
obs = NULL;
break;
@ -249,11 +245,11 @@ static void notification_callback(coap_observee_t *obs, void *notification,
void toggle_observation(coap_context_t *coap_ctx)
{
if(obs) {
PRINT("Stopping observation\n");
SYS_LOG_INF("Stopping observation");
coap_obs_remove_observee(obs);
obs = NULL;
} else {
PRINT("Starting observation\n");
SYS_LOG_INF("Starting observation");
obs = coap_obs_request_registration(coap_ctx,
(uip_ipaddr_t *)&in6addr_peer,
PEER_PORT,
@ -299,7 +295,7 @@ void startup(void)
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
SYS_LOG_INF("Bluetooth init failed");
return;
}
ipss_init();
@ -308,7 +304,7 @@ void startup(void)
coap_ctx = coap_context_new((uip_ipaddr_t *)&in6addr_my, MY_PORT);
if (!coap_ctx) {
PRINT("Cannot get CoAP context.\n");
SYS_LOG_INF("Cannot get CoAP context.");
return;
}
@ -320,7 +316,7 @@ void startup(void)
if (!coap_context_connect(coap_ctx,
(uip_ipaddr_t *)&in6addr_peer,
PEER_PORT)) {
PRINT("Cannot connect to peer.\n");
SYS_LOG_INF("Cannot connect to peer.");
return;
}
@ -329,16 +325,16 @@ void startup(void)
while (1) {
while (!coap_context_is_connected(coap_ctx)) {
PRINT("Trying to connect to peer...\n");
SYS_LOG_INF("Trying to connect to peer...");
if (!coap_context_wait_data(coap_ctx, WAIT_TICKS)) {
continue;
}
}
if(first_round || etimer_expired(&et)) {
PRINT("--Toggle timer--\n");
SYS_LOG_INF("--Toggle timer--");
toggle_observation(coap_ctx);
PRINT("--Done--\n");
SYS_LOG_INF("--Done--");
etimer_restart(&et);
first_round = false;
}

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_IP_BUF_RX_SIZE=3

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_BT=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y

View file

@ -16,18 +16,13 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#if defined(CONFIG_TINYDTLS_DEBUG)
#define DEBUG DEBUG_FULL
#else
#define DEBUG DEBUG_PRINT
#define DEBUG DEBUG_SYS_LOG_INF
#endif
#include "contiki/ip/uip-debug.h"
@ -76,7 +71,7 @@ char fiberStack[STACKSIZE];
static inline void init_app(void)
{
PRINT("%s: run coap server\n", __func__);
SYS_LOG_INF("%s: run coap server", __func__);
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
@ -230,12 +225,12 @@ void startup(void)
my_addr.family = AF_INET;
#endif
PRINT("Starting ETSI IoT Plugtests Server\n");
SYS_LOG_INF("Starting ETSI IoT Plugtests Server");
PRINT("uIP buffer: %u\n", UIP_BUFSIZE);
PRINT("LL header: %u\n", UIP_LLH_LEN);
PRINT("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
PRINT("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);
SYS_LOG_INF("uIP buffer: %u", UIP_BUFSIZE);
SYS_LOG_INF("LL header: %u", UIP_LLH_LEN);
SYS_LOG_INF("IP+UDP header: %u", UIP_IPUDPH_LEN);
SYS_LOG_INF("REST max chunk: %u", REST_MAX_CHUNK_SIZE);
net_init();
@ -249,7 +244,7 @@ void startup(void)
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
SYS_LOG_INF("Bluetooth init failed");
return;
}
ipss_init();

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
#
#console
#

View file

@ -16,13 +16,8 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#include <zephyr.h>
#include <sections.h>
@ -35,18 +30,19 @@
static void dhcpc_configured_cb(void)
{
PRINT("%s\n", __func__);
PRINT("Got IP address %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr));
SYS_LOG_INF("%s", __func__);
SYS_LOG_INF("Got IP address %d.%d.%d.%d",
uip_ipaddr_to_quad(&uip_hostaddr));
}
static void dhcpc_unconfigured_cb(void)
{
PRINT("%s\n", __func__);
SYS_LOG_INF("%s", __func__);
}
void main(void)
{
PRINT("run dhcp client\n");
SYS_LOG_INF("run dhcp client");
dhcpc_set_callbacks(dhcpc_configured_cb, dhcpc_unconfigured_cb);
net_init();
}

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -16,18 +16,13 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#if defined(CONFIG_TINYDTLS_DEBUG)
#define DEBUG DEBUG_FULL
#else
#define DEBUG DEBUG_PRINT
#define DEBUG DEBUG_SYS_LOG_INF
#endif
#include "contiki/ip/uip-debug.h"
@ -101,7 +96,7 @@ static const unsigned char ecdsa_pub_key_y[] = {
static inline void init_app(void)
{
PRINT("%s: run dtls client\n", __func__);
SYS_LOG_INF("%s: run dtls client", __func__);
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
@ -162,7 +157,7 @@ static inline bool wait_reply(const char *name,
/* Wait for the answer */
buf = net_receive(user_data->ctx, WAIT_TICKS);
if (buf) {
PRINT("Received data %p datalen %d\n",
SYS_LOG_INF("Received data %p datalen %d",
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
dtls_handle_message(dtls, session, ip_buf_appdata(buf),
@ -209,7 +204,7 @@ static inline struct net_context *get_context(void)
&peer_addr, PEER_PORT,
&my_addr, MY_PORT);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return NULL;
}
@ -223,10 +218,10 @@ static int read_from_peer(struct dtls_context_t *ctx,
struct data *user_data = (struct data *)dtls_get_app_data(ctx);
int pos;
PRINT("%s: read from peer %p len %d\n", __func__, data, len);
SYS_LOG_INF("%s: read from peer %p len %d", __func__, data, len);
if (user_data->expecting != len) {
PRINT("%s: received %d bytes, expected %d\n",
SYS_LOG_INF("%s: received %d bytes, expected %d",
__func__, len, user_data->expecting);
user_data->fail = true;
return 0;
@ -242,7 +237,7 @@ static int read_from_peer(struct dtls_context_t *ctx,
pos = user_data->ipsum_len - user_data->expecting;
if (memcmp(lorem_ipsum + pos, data, user_data->expecting)) {
PRINT("%s: received data mismatch.\n", __func__);
SYS_LOG_INF("%s: received data mismatch.", __func__);
user_data->fail = true;
}
@ -266,10 +261,11 @@ static int send_to_peer(struct dtls_context_t *ctx,
max_data_len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN;
PRINT("%s: send to peer data %p len %d\n", __func__, data, len);
SYS_LOG_INF("%s: send to peer data %p len %d", __func__, data, len);
if (len > max_data_len) {
PRINT("%s: too much (%d bytes) data to send (max %d bytes)\n",
SYS_LOG_INF("%s: too much (%d bytes) data "
"to send (max %d bytes)",
__func__, len, max_data_len);
ip_buf_unref(buf);
len = -EINVAL;
@ -376,7 +372,7 @@ static int handle_event(struct dtls_context_t *ctx, session_t *session,
struct data *user_data =
(struct data *)dtls_get_app_data(ctx);
PRINT("*** Connected ***\n");
SYS_LOG_INF("*** Connected ***");
/* We can send data now */
user_data->connected = true;
@ -401,7 +397,7 @@ static void init_dtls(struct data *user_data, dtls_context_t **dtls)
#endif /* DTLS_ECC */
};
PRINT("DTLS client started\n");
SYS_LOG_INF("DTLS client started");
#ifdef CONFIG_TINYDTLS_DEBUG
dtls_set_log_level(DTLS_LOG_DEBUG);
@ -429,13 +425,13 @@ void startup(void)
user_data.ctx = get_context();
if (!user_data.ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
init_dtls(&user_data, &dtls);
if (!dtls) {
PRINT("%s: Cannot get DTLS context\n", __func__);
SYS_LOG_INF("%s: Cannot get DTLS context", __func__);
return;
}
@ -444,9 +440,9 @@ void startup(void)
uip_ipaddr_copy(&session.addr.ipaddr, (uip_ipaddr_t *)&in6addr_peer);
session.addr.port = uip_htons(PEER_PORT);
PRINT("Trying to connect to ");
PRINT6ADDR(&session.addr.ipaddr);
PRINTF(":%d\n", uip_ntohs(session.addr.port));
SYS_LOG_INF("Trying to connect to :%d",
uip_ntohs(session.addr.port));
dtls_connect(dtls, &session);
@ -461,7 +457,7 @@ void startup(void)
}
}
PRINT("ERROR: Did not receive reply, closing.\n");
SYS_LOG_INF("ERROR: Did not receive reply, closing.");
dtls_close(dtls, &session);
}

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_IP_BUF_RX_SIZE=3

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_BT=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_NETWORKING=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_NETWORKING=y

View file

@ -16,13 +16,8 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#include <zephyr.h>
@ -63,7 +58,7 @@ static const unsigned char ecdsa_pub_key_y[] = {
static inline void init_app(void)
{
PRINT("%s: run dtls server\n", __func__);
SYS_LOG_INF("%s: run dtls server", __func__);
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
@ -105,7 +100,7 @@ static inline void receive_message(const char *name,
&NET_BUF_IP(buf)->srcipaddr);
session.addr.port = NET_BUF_UDP(buf)->srcport;
PRINT("Received data %p datalen %d\n",
SYS_LOG_INF("Received data %p datalen %d",
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
dtls_handle_message(dtls, &session, ip_buf_appdata(buf),
@ -153,7 +148,7 @@ static inline struct net_context *get_context(void)
&any_addr, 0,
&my_addr, MY_PORT);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return NULL;
}
@ -164,7 +159,7 @@ static int read_from_peer(struct dtls_context_t *ctx,
session_t *session,
uint8 *data, size_t len)
{
PRINT("%s: read from peer %p len %d\n", __func__, data, len);
SYS_LOG_INF("%s: read from peer %p len %d", __func__, data, len);
/* In this test we reverse the received bytes.
* We could also just pass the data back as is.
@ -194,10 +189,11 @@ static int send_to_peer(struct dtls_context_t *ctx,
max_data_len = IP_BUF_MAX_DATA - sizeof(struct uip_udp_hdr) -
sizeof(struct uip_ip_hdr);
PRINT("%s: reply to peer data %p len %d\n", __func__, data, len);
SYS_LOG_INF("%s: reply to peer data %p len %d", __func__, data, len);
if (len > max_data_len) {
PRINT("%s: too much (%d bytes) data to send (max %d bytes)\n",
SYS_LOG_INF("%s: too much (%d bytes) data to "
"send (max %d bytes)",
__func__, len, max_data_len);
ip_buf_unref(buf);
len = -EINVAL;
@ -321,7 +317,7 @@ static int handle_event(struct dtls_context_t *ctx, session_t *session,
} else if (level == 0) {
/* internal event */
if (code == DTLS_EVENT_CONNECTED) {
PRINT("*** Connected ***\n");
SYS_LOG_INF("*** Connected ***");
}
}
@ -343,7 +339,7 @@ static void init_dtls(struct net_context *recv, dtls_context_t **dtls)
#endif /* DTLS_ECC */
};
PRINT("DTLS server started\n");
SYS_LOG_INF("DTLS server started");
#if defined(CONFIG_TINYDTLS_DEBUG)
dtls_set_log_level(DTLS_LOG_DEBUG);
@ -368,7 +364,7 @@ void startup(void)
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
SYS_LOG_INF("Bluetooth init failed");
return;
}
ipss_init();
@ -377,13 +373,13 @@ void startup(void)
recv = get_context();
if (!recv) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
init_dtls(recv, &dtls);
if (!dtls) {
PRINT("%s: Cannot get DTLS context\n", __func__);
SYS_LOG_INF("%s: Cannot get DTLS context", __func__);
return;
}

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_IP_BUF_RX_SIZE=2

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_LE=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -23,13 +23,8 @@
* back to the originator.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#include <zephyr.h>
#include <sections.h>
@ -121,7 +116,7 @@ static struct net_context *unicast, *multicast;
static inline void init_app(void)
{
PRINT("%s: run mcast tester\n", __func__);
SYS_LOG_INF("%s: run mcast tester", __func__);
sys_rand32_init();
@ -166,21 +161,23 @@ static inline int send_packet(const char *name,
/* We have a pending packet that needs to be sent
* first.
*/
PRINT("%s: Trying to re-send %p len %d\n", __func__, buf,
SYS_LOG_INF("%s: Trying to re-send %p len %d", __func__, buf,
buf->len);
ret = net_send(buf);
if (ret == -EAGAIN || ret == -EINPROGRESS) {
PRINT("%s: packet %p needs to be re-sent (%d)\n",
SYS_LOG_INF("%s: packet %p needs to be re-sent (%d)",
name, buf, ret);
return ret;
} else if (ret < 0) {
PRINT("%s: returned %d pending buffer discarded %p\n",
SYS_LOG_INF("%s: returned %d pending buffer "
"discarded %p",
name, ret, buf);
ip_buf_unref(buf);
buf = NULL;
return ret;
} else {
PRINT("%s: returned %d pending buffer cleared %p\n",
SYS_LOG_INF("%s: returned %d pending buffer "
"cleared %p",
name, ret, buf);
buf = NULL;
return 0;
@ -197,24 +194,26 @@ static inline int send_packet(const char *name,
ip_buf_appdatalen(buf) = sending_len;
PRINT("%s: Trying to send %p buflen %d datalen %d\n",
SYS_LOG_INF("%s: Trying to send %p buflen %d datalen %d",
__func__, buf, buf->len, ip_buf_appdatalen(buf));
ret = net_send(buf);
if (ret < 0) {
if (ret == -EINPROGRESS) {
PRINT("%s: no connection yet, try again\n",
SYS_LOG_INF("%s: no connection yet,"
" try again",
__func__);
} else if (ret == -EAGAIN || ret == -ECONNRESET) {
PRINT("%s: no connection, try again later\n",
SYS_LOG_INF("%s: no connection, "
"try again later",
__func__);
} else {
PRINT("%s: sending %d bytes failed\n",
SYS_LOG_INF("%s: sending %d bytes failed",
__func__, sending_len);
ip_buf_unref(buf);
buf = NULL;
}
} else {
PRINT("%s: sent %d bytes\n", __func__,
SYS_LOG_INF("%s: sent %d bytes", __func__,
sending_len);
buf = NULL;
}
@ -242,8 +241,8 @@ again:
if (ip_buf_appdatalen(buf) < expected_len) {
if (memcmp(lorem_ipsum + pos, ip_buf_appdata(buf),
ip_buf_appdatalen(buf))) {
PRINT("%s: received %d bytes (total %d), "
"partial data mismatch\n",
SYS_LOG_INF("%s: received %d bytes (total %d), "
"partial data mismatch",
name, ip_buf_appdatalen(buf),
expected_len);
fail = true;
@ -265,17 +264,18 @@ again:
if (memcmp(lorem_ipsum + pos, ip_buf_appdata(buf),
expected_len)) {
PRINT("%s: received data mismatch in "
"last packet.\n", name);
SYS_LOG_INF("%s: received data mismatch in "
"last packet.", name);
fail = true;
goto free_buf;
}
if (total_len != sum) {
PRINT("Received %d bytes, expected %d\n",
SYS_LOG_INF("Received %d bytes, expected %d",
sum, total_len);
} else {
PRINT("Received %d bytes (in %d messages)\n",
SYS_LOG_INF("Received %d bytes"
" (in %d messages)",
total_len, count + 1);
}
}
@ -283,7 +283,7 @@ again:
buf = net_receive(ctx, WAIT_TICKS);
if (buf) {
if (ip_buf_appdatalen(buf) != expected_len) {
PRINT("%s: received %d bytes, expected %d\n",
SYS_LOG_INF("%s: received %d bytes, expected %d",
name, ip_buf_appdatalen(buf), expected_len);
fail = true;
goto free_buf;
@ -300,19 +300,19 @@ again:
*/
if (memcmp(lorem_ipsum + pos, ip_buf_appdata(buf),
expected_len)) {
PRINT("%s: received data mismatch.\n", name);
SYS_LOG_INF("%s: received data mismatch.", name);
fail = true;
goto free_buf;
}
PRINT("%s: received %d bytes\n", __func__,
SYS_LOG_INF("%s: received %d bytes", __func__,
expected_len);
#endif
free_buf:
ip_buf_unref(buf);
} else {
PRINT("%s: expected data, got none\n", name);
SYS_LOG_INF("%s: expected data, got none", name);
fail = true;
}
@ -370,7 +370,7 @@ static inline bool get_context(struct net_context **unicast,
&peer_addr, PEER_PORT,
&my_addr, MY_PORT);
if (!*unicast) {
PRINT("%s: Cannot get sending network context\n",
SYS_LOG_INF("%s: Cannot get sending network context",
__func__);
return false;
}
@ -380,7 +380,7 @@ static inline bool get_context(struct net_context **unicast,
&mcast_addr, PEER_PORT,
&my_addr, MY_PORT);
if (!*multicast) {
PRINT("%s: Cannot get mcast sending network context\n",
SYS_LOG_INF("%s: Cannot get mcast sending network context",
__func__);
return false;
}
@ -405,7 +405,7 @@ static bool sending(int resend)
static const char *type = "Unicast";
#endif
PRINT("%s: Sending packet\n", __func__);
SYS_LOG_INF("%s: Sending packet", __func__);
if (resend) {
expecting = resend;
@ -419,23 +419,23 @@ static bool sending(int resend)
expecting);
if (ret == -EAGAIN || ret == -EINPROGRESS) {
fiber_sleep(10);
PRINT("retrying...\n");
SYS_LOG_INF("retrying...");
goto again;
} else if (ret == -ETIMEDOUT) {
PRINT("Connection timed out\n");
SYS_LOG_INF("Connection timed out");
return false;
} else if (ret < 0) {
PRINT("%s sending %d bytes FAIL\n", type,
SYS_LOG_INF("%s sending %d bytes FAIL", type,
ipsum_len - expecting);
} else {
PRINT("%s sent %d bytes\n", type,
SYS_LOG_INF("%s sent %d bytes", type,
ipsum_len - expecting);
}
#if !defined(CONFIG_NETWORKING_WITH_TCP)
} else {
if (send_packet(__func__, multicast, ipsum_len,
expecting)) {
PRINT("Multicast sending %d bytes FAIL\n",
SYS_LOG_INF("Multicast sending %d bytes FAIL",
ipsum_len - expecting);
}
#endif
@ -449,16 +449,16 @@ void receiving(void)
int expecting_len = 0;
while (sending(expecting_len)) {
PRINT("Waiting packet\n");
SYS_LOG_INF("Waiting packet");
if (wait_reply(__func__, unicast,
ipsum_len, expecting)) {
if (expecting_len > 0) {
PRINT("Resend %d bytes -> FAIL\n",
SYS_LOG_INF("Resend %d bytes -> FAIL",
ipsum_len - expecting);
expecting_len = 0;
} else {
PRINT("Waiting %d bytes -> resending\n",
SYS_LOG_INF("Waiting %d bytes -> resending",
ipsum_len - expecting);
expecting_len = expecting;
}
@ -477,7 +477,7 @@ void main(void)
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
SYS_LOG_INF("Bluetooth init failed");
return;
}
ipss_init();
@ -485,7 +485,7 @@ void main(void)
#endif
if (!get_context(&unicast, &multicast)) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_IP_BUF_RX_SIZE=3

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_LE=y
CONFIG_BLUETOOTH_DEBUG_LOG=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_INIT_STACKS=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_NETWORKING=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_NETWORKING=y

View file

@ -16,13 +16,8 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#include <zephyr.h>
#include <sections.h>
@ -93,7 +88,7 @@ uip_ipaddr_t uip_netmask = { { 255, 255, 255, 0 } };
static inline void init_app(void)
{
PRINT("%s: run echo server\n", __func__);
SYS_LOG_INF("%s: run echo server", __func__);
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
@ -120,7 +115,7 @@ static inline struct net_buf *prepare_reply(const char *name,
struct net_buf *buf,
int proto)
{
PRINT("%s: %sreceived %d bytes data\n", name, type,
SYS_LOG_INF("%s: %sreceived %d bytes data", name, type,
ip_buf_appdatalen(buf));
if (proto != IPPROTO_TCP) {
@ -189,12 +184,13 @@ static inline void receive_and_reply(const char *name,
} else if (!ret) {
tcpbuf = NULL;
} else {
PRINT("Retrying to send packet %p\n", tcpbuf);
SYS_LOG_INF("Retrying to send packet %p",
tcpbuf);
}
} else {
tcpbuf = net_receive(tcp_recv, WAIT_TICKS);
if (tcpbuf) {
PRINT("Received packet %p len %d\n",
SYS_LOG_INF("Received packet %p len %d",
tcpbuf, ip_buf_appdatalen(tcpbuf));
prepare_reply(name, "tcp ", tcpbuf, IPPROTO_TCP);
goto reply;
@ -245,7 +241,7 @@ static inline bool get_context(struct net_context **udp_recv,
&any_addr, 0,
&my_addr, MY_PORT);
if (!*udp_recv) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return NULL;
}
@ -255,7 +251,8 @@ static inline bool get_context(struct net_context **udp_recv,
&any_addr, 0,
&my_addr, MY_PORT);
if (!*tcp_recv) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context",
__func__);
return NULL;
}
}
@ -265,7 +262,7 @@ static inline bool get_context(struct net_context **udp_recv,
&any_addr, 0,
&mcast_addr, MY_PORT);
if (!*mcast_recv) {
PRINT("%s: Cannot get receiving mcast network context\n",
SYS_LOG_INF("%s: Cannot get receiving mcast network context",
__func__);
}
@ -283,7 +280,7 @@ void receive(void)
static struct net_context *mcast_recv;
if (!get_context(&udp_recv, &tcp_recv, &mcast_recv)) {
PRINT("%s: Cannot get network contexts\n", __func__);
SYS_LOG_INF("%s: Cannot get network contexts", __func__);
return;
}
@ -300,7 +297,7 @@ void main(void)
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
SYS_LOG_INF("Bluetooth init failed");
return;
}
ipss_init();

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_IPV6_NO_ND=y

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_IPV6_NO_ND=y

View file

@ -18,13 +18,8 @@
#include <zephyr.h>
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#include <net/ip_buf.h>
#include <net/net_core.h>
@ -98,15 +93,15 @@ int eval_rcvd_data(char *rcvd_buf, int rcvd_len)
if (data_len != rcvd_len) {
rc = -1;
PRINT("Received %d bytes but was sent %d bytes\n",
SYS_LOG_INF("Received %d bytes but was sent %d bytes",
rcvd_len, data_len);
} else {
/* Data integrity */
rc = memcmp(text, rcvd_buf, data_len-1);
if (rc != 0) {
PRINT("Sent and received data does not match.\n");
PRINT("Sent: %.*s\n", data_len, text);
PRINT("Received: %.*s\n",
SYS_LOG_INF("Sent and received data does not match.");
SYS_LOG_INF("Sent: %.*s", data_len, text);
SYS_LOG_INF("Received: %.*s",
data_len, rcvd_buf);
}
}
@ -124,7 +119,7 @@ void fiber_receiver(void)
&any_addr, 0,
&loopback_addr, 4242);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
@ -136,11 +131,11 @@ void fiber_receiver(void)
rcvd_buf = ip_buf_appdata(buf);
rcvd_len = ip_buf_appdatalen(buf);
PRINT("[%d] %s: Received: %d bytes\n",
SYS_LOG_INF("[%d] %s: Received: %d bytes",
received, __func__, rcvd_len);
if (eval_rcvd_data(rcvd_buf, rcvd_len) != 0) {
PRINT("[%d] %s: net_receive failed!\n",
SYS_LOG_INF("[%d] %s: net_receive failed!",
received, __func__);
failure = 1;
}
@ -192,7 +187,7 @@ void fiber_sender(void)
&loopback_addr, 4242,
&any_addr, 0);
if (!ctx) {
PRINT("Cannot get network context\n");
SYS_LOG_INF("Cannot get network context");
return;
}
@ -205,12 +200,12 @@ void fiber_sender(void)
data_len = sent_len - header_size;
ip_buf_appdatalen(buf) = data_len;
PRINT("[%d] %s: App data: %d bytes, IPv6+UDP: %d bytes, "
"Total packet size: %d bytes\n",
SYS_LOG_INF("[%d] %s: App data: %d bytes, IPv6+UDP:"
" %d bytes, Total packet size: %d bytes",
sent, __func__, len, header_size, sent_len);
if (net_send(buf) < 0) {
PRINT("[%d] %s: net_send failed!\n",
SYS_LOG_INF("[%d] %s: net_send failed!",
sent, __func__);
failure = 1;
}
@ -229,9 +224,9 @@ void fiber_sender(void)
}
if (failure) {
PRINT("TEST FAILED\n");
SYS_LOG_INF("TEST FAILED");
} else {
PRINT("TEST PASSED\n");
SYS_LOG_INF("TEST PASSED");
}
}
@ -240,7 +235,7 @@ void main(void)
struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; /* :: */
struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; /* ::1 */
PRINT("%s: running network loopback test\n", __func__);
SYS_LOG_INF("%s: running network loopback test", __func__);
sys_rand32_init();

View file

@ -1,3 +1,4 @@
CONFIG_SYS_LOG=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_6LOWPAN=y

View file

@ -18,13 +18,8 @@
#include <zephyr.h>
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
#include <misc/sys_log.h>
#ifdef CONFIG_NET_SANITY_TEST
#include <tc_util.h>
@ -99,7 +94,7 @@ static const char *lorem_ipsum =
static inline void init_test()
{
PRINT("%s: run 802.15.4 loopback tester\n", __func__);
SYS_LOG_INF("%s: run 802.15.4 loopback tester", __func__);
net_set_mac(src_mac, sizeof(src_mac));
@ -117,11 +112,11 @@ static void set_routes()
*/
if (!uip_ds6_nbr_add((uip_ipaddr_t *)&in6addr_dest,
&dest_mac, 0, NBR_REACHABLE))
PRINT("Cannot add neighbor cache\n");
SYS_LOG_INF("Cannot add neighbor cache");
if (!uip_ds6_route_add((uip_ipaddr_t *)&in6addr_dest, 128,
(uip_ipaddr_t *)&in6addr_dest))
PRINT("Cannot add localhost route\n");
SYS_LOG_INF("Cannot add localhost route");
}
static void send_data(const char *taskname, struct net_context *ctx)
@ -142,11 +137,11 @@ static void send_data(const char *taskname, struct net_context *ctx)
sent_len = buf->len;
if (net_send(buf) < 0) {
PRINT("%s: %s(): sending %d bytes failed\n",
SYS_LOG_INF("%s: %s(): sending %d bytes failed",
taskname, __func__, len);
ip_buf_unref(buf);
} else {
PRINT("%s: %s(): sent %d bytes\n", taskname,
SYS_LOG_INF("%s: %s(): sent %d bytes", taskname,
__func__, sent_len);
}
}
@ -161,11 +156,11 @@ static void receive_data(const char *taskname, struct net_context *ctx)
buf = net_receive(ctx, TICKS_NONE);
if (buf) {
PRINT("%s: %s(): received %d bytes\n", taskname,
SYS_LOG_INF("%s: %s(): received %d bytes", taskname,
__func__, ip_buf_appdatalen(buf));
if (memcmp(ip_buf_appdata(buf),
lorem_ipsum, sizeof(lorem_ipsum))) {
PRINT("ERROR: data does not match\n");
SYS_LOG_INF("ERROR: data does not match");
#ifdef CONFIG_NET_SANITY_TEST
rp = TC_FAIL;
@ -200,7 +195,7 @@ static struct net_context *get_context(const struct net_addr *remote,
remote, remote_port,
local, local_port);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return NULL;
}
@ -264,7 +259,7 @@ void taskA(void)
ctx = get_context(&any_addr, SRC_PORT, &loopback_addr, DEST_PORT);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
@ -303,7 +298,7 @@ void taskB(void)
ctx = get_context(&loopback_addr, DEST_PORT, &any_addr, SRC_PORT);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
@ -344,7 +339,7 @@ void fiber_receiving(void)
ctx = get_context(&any_addr, SRC_PORT, &loopback_addr, DEST_PORT);
if (!ctx) {
PRINT("%s: Cannot get network context\n", __func__);
SYS_LOG_INF("%s: Cannot get network context", __func__);
return;
}
@ -374,7 +369,7 @@ void fiber_sending(void)
ctx = get_context(&loopback_addr, DEST_PORT, &any_addr, SRC_PORT);
if (!ctx) {
PRINT("Cannot get network context\n");
SYS_LOG_INF("Cannot get network context");
return;
}
@ -397,7 +392,7 @@ void fiber_sending(void)
void main(void)
{
PRINT("%s: run test_15_4\n", __func__);
SYS_LOG_INF("%s: run test_15_4", __func__);
net_init();
init_test();