Revert "misc: Remove generic PRINT macros from net samples"

This reverts commit 4dc93fed2f.

Change-Id: I35f7e355f1b9cfcfdf933a26cc30e0f92680079d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-08-23 13:13:06 -07:00
commit bc94f7c723
35 changed files with 197 additions and 189 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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