finally got zepif running

This commit is contained in:
goldsimon 2018-03-02 12:56:55 +01:00
parent ab0e457066
commit 282e1601ef
2 changed files with 23 additions and 1 deletions

View File

@ -409,7 +409,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
return ERR_MEM;
}
LWIP_ASSERT("this needs a pbuf in one piece", p->len == p->tot_len);
LWIP_ASSERT("this needs a pbuf in one piece", p_frag->len == p_frag->tot_len);
/* Write IEEE 802.15.4 header. */
buffer = (u8_t *)p_frag->payload;

View File

@ -55,6 +55,7 @@
#include "netif/lowpan6.h"
#include "lwip/udp.h"
#include "lwip/timeouts.h"
#include <string.h>
/** Define this to 1 to loop back TX packets for testing */
@ -92,6 +93,18 @@ struct zepif_state {
u32_t seqno;
};
static u8_t zep_lowpan_timer_running;
/* Helper function that calls the 6LoWPAN timer and reschedules itself */
static void
zep_lowpan_timer(void *arg)
{
lowpan6_tmr();
if (zep_lowpan_timer_running) {
sys_timeout(LOWPAN6_TMR_INTERVAL, zep_lowpan_timer, arg);
}
}
/* Pass received pbufs into 6LowPAN netif */
static void
zepif_udp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
@ -138,6 +151,9 @@ zepif_udp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
if (pbuf_remove_header(p, sizeof(struct zep_hdr))) {
goto err_return;
}
/* TODO Check CRC? */
/* remove CRC trailer */
pbuf_realloc(p, p->tot_len - 2);
/* Call tcpip_6lowpan_input here, not netif->input as we know the direct call
* stack won't work as we could enter udp_input twice. */
@ -259,6 +275,12 @@ zepif_init(struct netif *netif)
netif->hwaddr[0] &= 0xfc;
}
netif->linkoutput = zepif_linkoutput;
if (!zep_lowpan_timer_running) {
sys_timeout(LOWPAN6_TMR_INTERVAL, zep_lowpan_timer, NULL);
zep_lowpan_timer_running = 1;
}
return ERR_OK;
}