Use the logging module
This commit is contained in:
parent
2388aa9302
commit
ab68be8672
@ -32,15 +32,17 @@
|
||||
#include "net/ipv6/uip.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "dev/slip.h"
|
||||
#include "os/sys/log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define LOG_MODULE "slip-net"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define SLIP_END 0300
|
||||
#define SLIP_ESC 0333
|
||||
#define SLIP_ESC_END 0334
|
||||
#define SLIP_ESC_ESC 0335
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
slipnet_init(void)
|
||||
@ -79,29 +81,28 @@ slipnet_input(void)
|
||||
uip_len = packetbuf_datalen();
|
||||
i = packetbuf_copyto(uip_buf);
|
||||
|
||||
if(DEBUG) {
|
||||
printf("Slipnet got input of len: %d, copied: %d\n",
|
||||
packetbuf_datalen(), i);
|
||||
LOG_DBG("Slipnet got input of len: %d, copied: %d\n",
|
||||
packetbuf_datalen(), i);
|
||||
|
||||
for(i = 0; i < uip_len; i++) {
|
||||
printf("%02x", (unsigned char) uip_buf[i]);
|
||||
if((i & 15) == 15) printf("\n");
|
||||
else if((i & 7) == 7) printf(" ");
|
||||
for(i = 0; i < uip_len; i++) {
|
||||
LOG_DBG("%02x", (unsigned char)uip_buf[i]);
|
||||
if((i & 15) == 15) {
|
||||
LOG_DBG_("\n");
|
||||
} else if((i & 7) == 7) {
|
||||
LOG_DBG_(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
LOG_DBG_("\n");
|
||||
|
||||
/* printf("SUT: %u\n", uip_len); */
|
||||
slip_send_packet(uip_buf, uip_len);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t
|
||||
slipnet_output(const linkaddr_t *localdest)
|
||||
{
|
||||
/* do nothing... */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct network_driver slipnet_driver = {
|
||||
"slipnet",
|
||||
|
@ -42,12 +42,16 @@
|
||||
#include "net/netstack.h"
|
||||
#include "net/packetbuf.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
#include "cmd.h"
|
||||
#include "slip-radio.h"
|
||||
#include "packetutils.h"
|
||||
#include "os/sys/log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define LOG_MODULE "slip-radio"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef SLIP_RADIO_CONF_SENSORS
|
||||
extern const struct slip_radio_sensors SLIP_RADIO_CONF_SENSORS;
|
||||
#endif
|
||||
@ -114,8 +118,8 @@ packet_sent(void *ptr, int status, int transmissions)
|
||||
uint8_t sid;
|
||||
int pos;
|
||||
sid = *((uint8_t *)ptr);
|
||||
PRINTF("Slip-radio: packet sent! sid: %d, status: %d, tx: %d\n",
|
||||
sid, status, transmissions);
|
||||
LOG_DBG("Slip-radio: packet sent! sid: %d, status: %d, tx: %d\n",
|
||||
sid, status, transmissions);
|
||||
/* packet callback from lower layers */
|
||||
/* neighbor_info_packet_sent(status, transmissions); */
|
||||
pos = 0;
|
||||
@ -141,7 +145,7 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
|
||||
packetbuf_clear();
|
||||
pos = packetutils_deserialize_atts(&data[3], len - 3);
|
||||
if(pos < 0) {
|
||||
PRINTF("slip-radio: illegal packet attributes\n");
|
||||
LOG_ERR("slip-radio: illegal packet attributes\n");
|
||||
return 1;
|
||||
}
|
||||
pos += 3;
|
||||
@ -152,8 +156,8 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
|
||||
memcpy(packetbuf_dataptr(), &data[pos], len);
|
||||
packetbuf_set_datalen(len);
|
||||
|
||||
PRINTF("slip-radio: sending %u (%d bytes)\n",
|
||||
data[2], packetbuf_datalen());
|
||||
LOG_DBG("slip-radio: sending %u (%d bytes)\n",
|
||||
data[2], packetbuf_datalen());
|
||||
|
||||
/* parse frame before sending to get addresses, etc. */
|
||||
parse_frame();
|
||||
@ -167,7 +171,7 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
|
||||
return 1;
|
||||
}
|
||||
} else if(uip_buf[0] == '?') {
|
||||
PRINTF("Got request message of type %c\n", uip_buf[1]);
|
||||
LOG_DBG("Got request message of type %c\n", uip_buf[1]);
|
||||
if(data[1] == 'M') {
|
||||
/* this is just a test so far... just to see if it works */
|
||||
uip_buf[0] = '!';
|
||||
@ -192,7 +196,7 @@ slip_radio_cmd_output(const uint8_t *data, int data_len)
|
||||
static void
|
||||
slip_input_callback(void)
|
||||
{
|
||||
PRINTF("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]);
|
||||
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]);
|
||||
cmd_input(uip_buf, uip_len);
|
||||
uip_clear_buf();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user