mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
Merge pull request #207 from authmillenon/refactor_ieee802154
Refactor ieee802154
This commit is contained in:
commit
d46ac9db0c
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net -I$(RIOTBASE)/core/include -Iinclude/ -I$(RIOTBASE)/sys/net/ieee802154/
|
||||
INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net -I$(RIOTBASE)/core/include -Iinclude/ -I$(RIOTBASE)/sys/net/ieee802154/include
|
||||
MODULE =at86rf231
|
||||
|
||||
DIRS =
|
||||
|
||||
@ -42,12 +42,12 @@ void at86rf231_rx_handler(void)
|
||||
return;
|
||||
}
|
||||
|
||||
read_802154_frame(&buf[1], &at86rf231_rx_buffer[rx_buffer_next].frame,
|
||||
at86rf231_rx_buffer[rx_buffer_next].length - 2);
|
||||
ieee802154_frame_read(&buf[1], &at86rf231_rx_buffer[rx_buffer_next].frame,
|
||||
at86rf231_rx_buffer[rx_buffer_next].length - 2);
|
||||
|
||||
if (at86rf231_rx_buffer[rx_buffer_next].frame.fcf.frame_type != 2) {
|
||||
#ifdef ENABLE_DEBUG
|
||||
print_802154_fcf_frame(&at86rf231_rx_buffer[rx_buffer_next].frame);
|
||||
ieee802154_frame_print_fcf_frame(&at86rf231_rx_buffer[rx_buffer_next].frame);
|
||||
#endif
|
||||
|
||||
/* notify transceiver thread if any */
|
||||
@ -61,7 +61,7 @@ void at86rf231_rx_handler(void)
|
||||
else {
|
||||
#ifdef ENABLE_DEBUG
|
||||
DEBUG("GOT ACK for SEQ %u\n", at86rf231_rx_buffer[rx_buffer_next].frame.seq_nr);
|
||||
print_802154_fcf_frame(&at86rf231_rx_buffer[rx_buffer_next].frame);
|
||||
ieee802154_frame_print_fcf_frame(&at86rf231_rx_buffer[rx_buffer_next].frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,8 @@ int16_t at86rf231_send(at86rf231_packet_t *packet)
|
||||
sequenz_nr += 1;
|
||||
|
||||
// calculate size of the frame (payload + FCS) */
|
||||
packet->length = get_802154_hdr_len(&packet->frame) + packet->frame.payload_len + 1;
|
||||
packet->length = ieee802154_frame_get_hdr_len(&packet->frame) +
|
||||
packet->frame.payload_len + 1;
|
||||
|
||||
if (packet->length > AT86RF231_MAX_PKT_LENGTH) {
|
||||
return -1;
|
||||
@ -90,7 +91,7 @@ static void at86rf231_xmit(uint8_t *data, uint8_t length)
|
||||
static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet)
|
||||
{
|
||||
uint8_t index, offset;
|
||||
index = init_802154_frame(&packet->frame, &buf[1]);
|
||||
index = ieee802154_frame_init(&packet->frame, &buf[1]);
|
||||
|
||||
// add length for at86rf231
|
||||
buf[0] = packet->length + 1;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <ieee802154/ieee802154_frame.h>
|
||||
#include "ieee802154_frame.h"
|
||||
|
||||
#include <at86rf231_settings.h>
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net -I$(RIOTBASE)/core/include -Iinclude/ -I$(RIOTBASE)/sys/net/ieee802154/
|
||||
INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net -I$(RIOTBASE)/core/include -Iinclude/ -I$(RIOTBASE)/sys/net/ieee802154/include
|
||||
MODULE =cc2420
|
||||
|
||||
DIRS =
|
||||
|
||||
@ -45,12 +45,12 @@ void cc2420_rx_handler(void)
|
||||
DEBUG("Got packet with invalid crc.\n");
|
||||
return;
|
||||
}
|
||||
read_802154_frame(buf,
|
||||
&cc2420_rx_buffer[rx_buffer_next].frame,
|
||||
cc2420_rx_buffer[rx_buffer_next].length-2);
|
||||
ieee802154_frame_read(buf,
|
||||
&cc2420_rx_buffer[rx_buffer_next].frame,
|
||||
cc2420_rx_buffer[rx_buffer_next].length-2);
|
||||
if(cc2420_rx_buffer[rx_buffer_next].frame.fcf.frame_type != 2) {
|
||||
#ifdef DEBUG
|
||||
print_802154_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame);
|
||||
ieee802154_frame_print_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame);
|
||||
#endif
|
||||
/* notify transceiver thread if any */
|
||||
if (transceiver_pid) {
|
||||
@ -62,7 +62,7 @@ void cc2420_rx_handler(void)
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
DEBUG("GOT ACK for SEQ %u\n", cc2420_rx_buffer[rx_buffer_next].frame.seq_nr);
|
||||
print_802154_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame);
|
||||
ieee802154_frame_print_fcf_frame(&cc2420_rx_buffer[rx_buffer_next].frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,8 @@ int16_t cc2420_send(cc2420_packet_t *packet)
|
||||
sequenz_nr += 1;
|
||||
|
||||
/* calculate size of the package (header + payload + fcs) */
|
||||
packet->length = get_802154_hdr_len(&packet->frame) + packet->frame.payload_len + 2;
|
||||
packet->length = ieee802154_frame_get_hdr_len(&packet->frame) +
|
||||
packet->frame.payload_len + 2;
|
||||
|
||||
if(packet->length > CC2420_MAX_PKT_LENGTH) {
|
||||
return -1;
|
||||
@ -106,7 +107,7 @@ int16_t cc2420_send(cc2420_packet_t *packet)
|
||||
static void cc2420_gen_pkt(uint8_t *buf, cc2420_packet_t *packet)
|
||||
{
|
||||
uint8_t index, offset;
|
||||
index = init_802154_frame(&packet->frame, buf);
|
||||
index = ieee802154_frame_init(&packet->frame, buf);
|
||||
offset = index;
|
||||
while(index < packet->length-2) {
|
||||
buf[index] = packet->frame.payload[index-offset];
|
||||
|
||||
@ -76,7 +76,7 @@ Frame type value:
|
||||
#ifndef CC2420_H
|
||||
#define CC2420_H
|
||||
|
||||
#include <ieee802154/ieee802154_frame.h>
|
||||
#include <ieee802154_frame.h>
|
||||
#include <cc2420_settings.h>
|
||||
|
||||
#define CC2420_MAX_PKT_LENGTH 127
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
MODULE:=$(shell basename $(CURDIR))
|
||||
INCLUDES = -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/net
|
||||
INCLUDES = -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/net -I$(RIOTBASE)/sys/net/ieee802154/include
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
||||
@ -23,7 +23,7 @@ uint8_t ieee802154_hdr_ptr;
|
||||
uint8_t ieee802154_payload_ptr;
|
||||
uint16_t ieee802154_payload_len;
|
||||
|
||||
uint8_t init_802154_frame(ieee802154_frame_t *frame, uint8_t *buf)
|
||||
uint8_t ieee802154_frame_init(ieee802154_frame_t *frame, uint8_t *buf)
|
||||
{
|
||||
/* Frame Control Field - 802.15.4 - 2006 - 7.2.1.1 */
|
||||
uint8_t index = 0;
|
||||
@ -105,7 +105,7 @@ uint8_t init_802154_frame(ieee802154_frame_t *frame, uint8_t *buf)
|
||||
* | FCF | DSN | DPID | DAD | SPID | SAD |
|
||||
* -------------------------------------------
|
||||
*/
|
||||
uint8_t get_802154_hdr_len(ieee802154_frame_t *frame)
|
||||
uint8_t ieee802154_frame_get_hdr_len(ieee802154_frame_t *frame)
|
||||
{
|
||||
uint8_t len = 0;
|
||||
|
||||
@ -141,7 +141,8 @@ uint8_t get_802154_hdr_len(ieee802154_frame_t *frame)
|
||||
return (len + 3);
|
||||
}
|
||||
|
||||
uint8_t read_802154_frame(uint8_t *buf, ieee802154_frame_t *frame, uint8_t len)
|
||||
uint8_t ieee802154_frame_read(uint8_t *buf, ieee802154_frame_t *frame,
|
||||
uint8_t len)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
uint8_t hdrlen;
|
||||
@ -158,8 +159,6 @@ uint8_t read_802154_frame(uint8_t *buf, ieee802154_frame_t *frame, uint8_t len)
|
||||
frame->fcf.ack_req = (buf[index] >> 5) & 0x01;
|
||||
frame->fcf.panid_comp = (buf[index] >> 6) & 0x01;
|
||||
|
||||
//print_802154_fcf_frame(frame);
|
||||
|
||||
index++;
|
||||
|
||||
frame->seq_nr = buf[index];
|
||||
@ -236,7 +235,7 @@ uint8_t read_802154_frame(uint8_t *buf, ieee802154_frame_t *frame, uint8_t len)
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
void print_802154_fcf_frame(ieee802154_frame_t *frame)
|
||||
void ieee802154_frame_print_fcf_frame(ieee802154_frame_t *frame)
|
||||
{
|
||||
printf("frame type: %02x\n"
|
||||
"security enabled: %02x\n"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Data struct and prototypes for the IEEE 802.15.4 frame format
|
||||
* Data struct and prototypes for the IEEE 802.15.4 frame format
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
@ -7,17 +7,17 @@
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup sixlowpan
|
||||
* @ingroup net
|
||||
* @{
|
||||
* @file ieee802154_frame.h
|
||||
* @file ieee802154/ieee802154_frame.h
|
||||
* @brief IEEE 802.14.4 framing data structs and prototypes
|
||||
* @author Stephan Zeisberg <zeisberg@mi.fu-berlin.de>
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef IEEE802154_FRAME
|
||||
#define IEEE802154_FRAME
|
||||
#ifndef IEEE802154_IEEE802154_FRAME
|
||||
#define IEEE802154_IEEE802154_FRAME
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@ -46,10 +46,10 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t dest_addr_m;
|
||||
uint8_t frame_ver;
|
||||
uint8_t src_addr_m;
|
||||
} ieee802154_fcf_frame_t;
|
||||
} ieee802154_frame_fcf_frame_t;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
ieee802154_fcf_frame_t fcf;
|
||||
ieee802154_frame_fcf_frame_t fcf;
|
||||
uint8_t seq_nr;
|
||||
uint16_t dest_pan_id;
|
||||
uint8_t dest_addr[8];
|
||||
@ -59,10 +59,10 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t payload_len;
|
||||
} ieee802154_frame_t;
|
||||
|
||||
uint8_t init_802154_frame(ieee802154_frame_t *frame, uint8_t *buf);
|
||||
uint8_t get_802154_hdr_len(ieee802154_frame_t *frame);
|
||||
uint8_t get_802154_pkt_len(void);
|
||||
uint8_t read_802154_frame(uint8_t *buf, ieee802154_frame_t *frame, uint8_t len);
|
||||
void print_802154_fcf_frame(ieee802154_frame_t *frame);
|
||||
uint8_t ieee802154_frame_init(ieee802154_frame_t *frame, uint8_t *buf);
|
||||
uint8_t ieee802154_frame_get_hdr_len(ieee802154_frame_t *frame);
|
||||
uint8_t ieee802154_frame_read(uint8_t *buf, ieee802154_frame_t *frame,
|
||||
uint8_t len);
|
||||
void ieee802154_frame_print_fcf_frame(ieee802154_frame_t *frame);
|
||||
|
||||
#endif /* IEEE802154_FRAME */
|
||||
#endif /* IEEE802154_IEEE802154_FRAME */
|
||||
@ -16,7 +16,7 @@
|
||||
#include <transceiver.h>
|
||||
|
||||
#include "sixlowpan.h"
|
||||
#include "ieee802154/ieee802154_frame.h"
|
||||
#include "ieee802154_frame.h"
|
||||
|
||||
//prototytpes
|
||||
static uint8_t etx_count_packet_tx(etx_neighbor_t *candidate);
|
||||
@ -391,7 +391,7 @@ void etx_radio(void)
|
||||
if (m.type == PKT_PENDING) {
|
||||
p = (radio_packet_t *) m.content.ptr;
|
||||
|
||||
read_802154_frame(p->data, &frame, p->length);
|
||||
ieee802154_frame_read(p->data, &frame, p->length);
|
||||
|
||||
if (frame.payload[0] == ETX_PKT_OPTVAL) {
|
||||
//copy to receive buffer
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "posix_io.h"
|
||||
#include "board_uart0.h"
|
||||
|
||||
#include "ieee802154_frame.h"
|
||||
#include "sixlowpan/error.h"
|
||||
#include "bordermultiplex.h"
|
||||
#include "flowcontrol.h"
|
||||
@ -34,7 +35,6 @@
|
||||
#include "icmp.h"
|
||||
#include "serialnumber.h"
|
||||
|
||||
#include "sys/net/ieee802154/ieee802154_frame.h"
|
||||
#include "sys/net/net_help/net_help.h"
|
||||
|
||||
#define READER_STACK_SIZE (KERNEL_CONF_STACKSIZE_DEFAULT)
|
||||
|
||||
@ -142,7 +142,7 @@ void recv_ieee802154_frame(void)
|
||||
if (m.type == PKT_PENDING) {
|
||||
|
||||
p = (radio_packet_t *) m.content.ptr;
|
||||
hdrlen = read_802154_frame(p->data, &frame, p->length);
|
||||
hdrlen = ieee802154_frame_read(p->data, &frame, p->length);
|
||||
length = p->length - hdrlen;
|
||||
|
||||
/* deliver packet to network(6lowpan)-layer */
|
||||
@ -172,7 +172,7 @@ void set_ieee802154_fcf_values(ieee802154_frame_t *frame, uint8_t dest_mode,
|
||||
frame->fcf.src_addr_m = src_mode;
|
||||
frame->fcf.dest_addr_m = dest_mode;
|
||||
#if ENABLE_DEBUG
|
||||
print_802154_fcf_frame(frame);
|
||||
ieee802154_frame_print_fcf_frame(frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -212,10 +212,10 @@ void sixlowpan_mac_send_ieee802154_frame(const ieee_802154_long_t *addr,
|
||||
daddr = HTONS(addr->uint16[3]);
|
||||
frame.payload = (uint8_t *)payload; // payload won't be changed so cast is legal.
|
||||
frame.payload_len = length;
|
||||
uint8_t hdrlen = get_802154_hdr_len(&frame);
|
||||
uint8_t hdrlen = ieee802154_frame_get_hdr_len(&frame);
|
||||
|
||||
memset(&buf, 0, PAYLOAD_SIZE);
|
||||
init_802154_frame(&frame, (uint8_t *)&buf);
|
||||
ieee802154_frame_init(&frame, (uint8_t *)&buf);
|
||||
memcpy(&buf[hdrlen], frame.payload, frame.payload_len);
|
||||
/* set FCS */
|
||||
/* RSSI = 0 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user