tsch-packet: define constant for frame pending bit offset

This commit is contained in:
Simon Duquennoy 2018-05-13 06:47:37 -07:00
parent 9569519bbe
commit 359ae59499
1 changed files with 5 additions and 2 deletions

View File

@ -70,6 +70,9 @@
*/ */
static struct packetbuf_attr eackbuf_attrs[PACKETBUF_NUM_ATTRS]; static struct packetbuf_attr eackbuf_attrs[PACKETBUF_NUM_ATTRS];
/* The offset of the frame pending bit flag within the first byte of FCF */
#define IEEE802154_FRAME_PENDING_BIT_OFFSET 4
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
tsch_packet_eackbuf_set_attr(uint8_t type, const packetbuf_attr_t val) tsch_packet_eackbuf_set_attr(uint8_t type, const packetbuf_attr_t val)
@ -463,14 +466,14 @@ tsch_packet_parse_eb(const uint8_t *buf, int buf_size,
void void
tsch_packet_set_frame_pending(uint8_t *buf, int buf_size) tsch_packet_set_frame_pending(uint8_t *buf, int buf_size)
{ {
buf[0] |= (1 << 4); buf[0] |= (1 << IEEE802154_FRAME_PENDING_BIT_OFFSET);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Get frame pending bit from a packet */ /* Get frame pending bit from a packet */
int int
tsch_packet_get_frame_pending(uint8_t *buf, int buf_size) tsch_packet_get_frame_pending(uint8_t *buf, int buf_size)
{ {
return (buf[0] >> 4) & 1; return (buf[0] >> IEEE802154_FRAME_PENDING_BIT_OFFSET) & 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** @} */ /** @} */