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
97102static 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,
245249void 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 }
0 commit comments