Skip to content

Commit bc94f7c

Browse files
author
Andrew Boie
committed
Revert "misc: Remove generic PRINT macros from net samples"
This reverts commit 4dc93fe. Change-Id: I35f7e355f1b9cfcfdf933a26cc30e0f92680079d Signed-off-by: Andrew Boie <[email protected]>
1 parent 701f059 commit bc94f7c

35 files changed

+197
-189
lines changed

samples/net/coap_observe_client/prj_802154.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_TEST_RANDOM_GENERATOR=y
32
CONFIG_NETWORKING=y
43
CONFIG_NETWORKING_WITH_LOGGING=y

samples/net/coap_observe_client/prj_bt.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_NETWORKING=y
32
CONFIG_NETWORKING_WITH_LOGGING=y
43
CONFIG_NETWORKING_WITH_BT=y

samples/net/coap_observe_client/prj_slip.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_TEST_RANDOM_GENERATOR=y
32
CONFIG_NETWORKING=y
43
CONFIG_NETWORKING_WITH_LOGGING=y

samples/net/coap_observe_client/src/coap-observe-client.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
* limitations under the License.
1717
*/
1818

19-
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
20-
#include <misc/sys_log.h>
19+
#if defined(CONFIG_STDOUT_CONSOLE)
20+
#include <stdio.h>
21+
#define PRINT printf
22+
#else
23+
#include <misc/printk.h>
24+
#define PRINT printk
25+
#endif
2126

2227
#if defined(CONFIG_TINYDTLS_DEBUG)
2328
#define DEBUG DEBUG_FULL
2429
#else
25-
#define DEBUG DEBUG_SYS_LOG_INF
30+
#define DEBUG DEBUG_PRINT
2631
#endif
2732
#include "contiki/ip/uip-debug.h"
2833

@@ -96,7 +101,7 @@ static struct in_addr in4addr_my = MY_IPADDR;
96101

97102
static inline void init_app(void)
98103
{
99-
SYS_LOG_INF("%s: run coap observe client", __func__);
104+
PRINT("%s: run coap observe client\n", __func__);
100105

101106
#if defined(CONFIG_NET_TESTING)
102107
net_testing_setup();
@@ -209,30 +214,29 @@ static void notification_callback(coap_observee_t *obs, void *notification,
209214
int len = 0;
210215
const uint8_t *payload = NULL;
211216

212-
SYS_LOG_INF("Notification handler");
213-
SYS_LOG_INF("Observee URI: %s", obs->url);
217+
PRINT("Notification handler\n");
218+
PRINT("Observee URI: %s\n", obs->url);
214219
if(notification) {
215220
len = coap_get_payload(notification, &payload);
216221
}
217222
switch(flag) {
218223
case NOTIFICATION_OK:
219-
SYS_LOG_INF("NOTIFICATION OK: %*s", len, (char *)payload);
224+
PRINT("NOTIFICATION OK: %*s\n", len, (char *)payload);
220225
break;
221226
case OBSERVE_OK: /* server accepeted observation request */
222-
SYS_LOG_INF("OBSERVE_OK: %*s", len, (char *)payload);
227+
PRINT("OBSERVE_OK: %*s\n", len, (char *)payload);
223228
break;
224229
case OBSERVE_NOT_SUPPORTED:
225-
SYS_LOG_INF("OBSERVE_NOT_SUPPORTED: %*s", len,
226-
(char *)payload);
230+
PRINT("OBSERVE_NOT_SUPPORTED: %*s\n", len, (char *)payload);
227231
obs = NULL;
228232
break;
229233
case ERROR_RESPONSE_CODE:
230-
SYS_LOG_INF("ERROR_RESPONSE_CODE: %*s", len, (char *)payload);
234+
PRINT("ERROR_RESPONSE_CODE: %*s\n", len, (char *)payload);
231235
obs = NULL;
232236
break;
233237
case NO_REPLY_FROM_SERVER:
234-
SYS_LOG_INF("NO_REPLY_FROM_SERVER: "
235-
"removing observe registration with token %x%x",
238+
PRINT("NO_REPLY_FROM_SERVER: "
239+
"removing observe registration with token %x%x\n",
236240
obs->token[0], obs->token[1]);
237241
obs = NULL;
238242
break;
@@ -245,11 +249,11 @@ static void notification_callback(coap_observee_t *obs, void *notification,
245249
void toggle_observation(coap_context_t *coap_ctx)
246250
{
247251
if(obs) {
248-
SYS_LOG_INF("Stopping observation");
252+
PRINT("Stopping observation\n");
249253
coap_obs_remove_observee(obs);
250254
obs = NULL;
251255
} else {
252-
SYS_LOG_INF("Starting observation");
256+
PRINT("Starting observation\n");
253257
obs = coap_obs_request_registration(coap_ctx,
254258
(uip_ipaddr_t *)&in6addr_peer,
255259
PEER_PORT,
@@ -295,7 +299,7 @@ void startup(void)
295299

296300
#if defined(CONFIG_NETWORKING_WITH_BT)
297301
if (bt_enable(NULL)) {
298-
SYS_LOG_INF("Bluetooth init failed");
302+
PRINT("Bluetooth init failed\n");
299303
return;
300304
}
301305
ipss_init();
@@ -304,7 +308,7 @@ void startup(void)
304308

305309
coap_ctx = coap_context_new((uip_ipaddr_t *)&in6addr_my, MY_PORT);
306310
if (!coap_ctx) {
307-
SYS_LOG_INF("Cannot get CoAP context.");
311+
PRINT("Cannot get CoAP context.\n");
308312
return;
309313
}
310314

@@ -316,7 +320,7 @@ void startup(void)
316320
if (!coap_context_connect(coap_ctx,
317321
(uip_ipaddr_t *)&in6addr_peer,
318322
PEER_PORT)) {
319-
SYS_LOG_INF("Cannot connect to peer.");
323+
PRINT("Cannot connect to peer.\n");
320324
return;
321325
}
322326

@@ -325,16 +329,16 @@ void startup(void)
325329

326330
while (1) {
327331
while (!coap_context_is_connected(coap_ctx)) {
328-
SYS_LOG_INF("Trying to connect to peer...");
332+
PRINT("Trying to connect to peer...\n");
329333
if (!coap_context_wait_data(coap_ctx, WAIT_TICKS)) {
330334
continue;
331335
}
332336
}
333337

334338
if(first_round || etimer_expired(&et)) {
335-
SYS_LOG_INF("--Toggle timer--");
339+
PRINT("--Toggle timer--\n");
336340
toggle_observation(coap_ctx);
337-
SYS_LOG_INF("--Done--");
341+
PRINT("--Done--\n");
338342
etimer_restart(&et);
339343
first_round = false;
340344
}

samples/net/coap_server/prj_802154.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_NETWORKING=y
32
CONFIG_NETWORKING_WITH_LOGGING=y
43
CONFIG_IP_BUF_RX_SIZE=3

samples/net/coap_server/prj_bt.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_NETWORKING=y
32
CONFIG_NETWORKING_WITH_LOGGING=y
43
CONFIG_NETWORKING_WITH_BT=y

samples/net/coap_server/prj_slip.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
CONFIG_TEST_RANDOM_GENERATOR=y
32
CONFIG_NETWORKING=y
43
CONFIG_NETWORKING_WITH_LOGGING=y

samples/net/coap_server/src/coap-server.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
* limitations under the License.
1717
*/
1818

19-
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
20-
#include <misc/sys_log.h>
19+
#if defined(CONFIG_STDOUT_CONSOLE)
20+
#include <stdio.h>
21+
#define PRINT printf
22+
#else
23+
#include <misc/printk.h>
24+
#define PRINT printk
25+
#endif
2126

2227
#if defined(CONFIG_TINYDTLS_DEBUG)
2328
#define DEBUG DEBUG_FULL
2429
#else
25-
#define DEBUG DEBUG_SYS_LOG_INF
30+
#define DEBUG DEBUG_PRINT
2631
#endif
2732
#include "contiki/ip/uip-debug.h"
2833

@@ -71,7 +76,7 @@ char fiberStack[STACKSIZE];
7176

7277
static inline void init_app(void)
7378
{
74-
SYS_LOG_INF("%s: run coap server", __func__);
79+
PRINT("%s: run coap server\n", __func__);
7580

7681
#if defined(CONFIG_NET_TESTING)
7782
net_testing_setup();
@@ -225,12 +230,12 @@ void startup(void)
225230
my_addr.family = AF_INET;
226231
#endif
227232

228-
SYS_LOG_INF("Starting ETSI IoT Plugtests Server");
233+
PRINT("Starting ETSI IoT Plugtests Server\n");
229234

230-
SYS_LOG_INF("uIP buffer: %u", UIP_BUFSIZE);
231-
SYS_LOG_INF("LL header: %u", UIP_LLH_LEN);
232-
SYS_LOG_INF("IP+UDP header: %u", UIP_IPUDPH_LEN);
233-
SYS_LOG_INF("REST max chunk: %u", REST_MAX_CHUNK_SIZE);
235+
PRINT("uIP buffer: %u\n", UIP_BUFSIZE);
236+
PRINT("LL header: %u\n", UIP_LLH_LEN);
237+
PRINT("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
238+
PRINT("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);
234239

235240
net_init();
236241

@@ -244,7 +249,7 @@ void startup(void)
244249

245250
#if defined(CONFIG_NETWORKING_WITH_BT)
246251
if (bt_enable(NULL)) {
247-
SYS_LOG_INF("Bluetooth init failed");
252+
PRINT("Bluetooth init failed\n");
248253
return;
249254
}
250255
ipss_init();

samples/net/dhcp_client/prj_galileo.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_SYS_LOG=y
21
#
32
#console
43
#

samples/net/dhcp_client/src/dhcp-client.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
* limitations under the License.
1717
*/
1818

19-
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
20-
#include <misc/sys_log.h>
19+
#if defined(CONFIG_STDOUT_CONSOLE)
20+
#include <stdio.h>
21+
#define PRINT printf
22+
#else
23+
#include <misc/printk.h>
24+
#define PRINT printk
25+
#endif
2126

2227
#include <zephyr.h>
2328
#include <sections.h>
@@ -30,19 +35,18 @@
3035

3136
static void dhcpc_configured_cb(void)
3237
{
33-
SYS_LOG_INF("%s", __func__);
34-
SYS_LOG_INF("Got IP address %d.%d.%d.%d",
35-
uip_ipaddr_to_quad(&uip_hostaddr));
38+
PRINT("%s\n", __func__);
39+
PRINT("Got IP address %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr));
3640
}
3741

3842
static void dhcpc_unconfigured_cb(void)
3943
{
40-
SYS_LOG_INF("%s", __func__);
44+
PRINT("%s\n", __func__);
4145
}
4246

4347
void main(void)
4448
{
45-
SYS_LOG_INF("run dhcp client");
49+
PRINT("run dhcp client\n");
4650
dhcpc_set_callbacks(dhcpc_configured_cb, dhcpc_unconfigured_cb);
4751
net_init();
4852
}

0 commit comments

Comments
 (0)