diff --git a/ports/arduino_uno/apdu.c b/ports/arduino_uno/apdu.c index ec767c89..c56e4c34 100644 --- a/ports/arduino_uno/apdu.c +++ b/ports/arduino_uno/apdu.c @@ -70,10 +70,10 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t * apdu, /* APDU data */ { uint16_t len = 0; /* counts where we are in PDU */ - service_data->segmented_message = (apdu[0] & BIT3) ? true : false; - service_data->more_follows = (apdu[0] & BIT2) ? true : false; + service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false; + service_data->more_follows = (apdu[0] & BIT(2)) ? true : false; service_data->segmented_response_accepted = - (apdu[0] & BIT1) ? true : false; + (apdu[0] & BIT(1)) ? true : false; service_data->max_segs = decode_max_segs(apdu[1]); service_data->max_resp = decode_max_apdu(apdu[1]); service_data->invoke_id = apdu[2]; diff --git a/ports/at91sam7s/dlmstp.c b/ports/at91sam7s/dlmstp.c index 1644bf4f..9f08785c 100644 --- a/ports/at91sam7s/dlmstp.c +++ b/ports/at91sam7s/dlmstp.c @@ -274,7 +274,7 @@ static bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -297,7 +297,7 @@ static bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/atmega168/apdu.c b/ports/atmega168/apdu.c index 986d31d0..20df3a77 100644 --- a/ports/atmega168/apdu.c +++ b/ports/atmega168/apdu.c @@ -71,10 +71,10 @@ uint16_t apdu_decode_confirmed_service_request( { uint16_t len = 0; /* counts where we are in PDU */ - service_data->segmented_message = (apdu[0] & BIT3) ? true : false; - service_data->more_follows = (apdu[0] & BIT2) ? true : false; + service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false; + service_data->more_follows = (apdu[0] & BIT(2)) ? true : false; service_data->segmented_response_accepted = - (apdu[0] & BIT1) ? true : false; + (apdu[0] & BIT(1)) ? true : false; service_data->max_segs = decode_max_segs(apdu[1]); service_data->max_resp = decode_max_apdu(apdu[1]); service_data->invoke_id = apdu[2]; diff --git a/ports/bdk-atxx4-mstp/dlmstp.c b/ports/bdk-atxx4-mstp/dlmstp.c index 091b72f1..e58da09f 100644 --- a/ports/bdk-atxx4-mstp/dlmstp.c +++ b/ports/bdk-atxx4-mstp/dlmstp.c @@ -273,7 +273,7 @@ static bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -296,7 +296,7 @@ static bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/bdk-atxx4-mstp/test.c b/ports/bdk-atxx4-mstp/test.c index b7b2cc00..fa7e4dd6 100644 --- a/ports/bdk-atxx4-mstp/test.c +++ b/ports/bdk-atxx4-mstp/test.c @@ -165,13 +165,13 @@ void test_task( mstimer_reset(&Test_Timer); sprintf(Send_Buffer, "BACnet: 0000000\r\n"); MSTP_MAC_Address = input_address(); - Send_Buffer[8] = (MSTP_MAC_Address & BIT0) ? '1' : '0'; - Send_Buffer[9] = (MSTP_MAC_Address & BIT1) ? '1' : '0'; - Send_Buffer[10] = (MSTP_MAC_Address & BIT2) ? '1' : '0'; - Send_Buffer[11] = (MSTP_MAC_Address & BIT3) ? '1' : '0'; - Send_Buffer[12] = (MSTP_MAC_Address & BIT4) ? '1' : '0'; - Send_Buffer[13] = (MSTP_MAC_Address & BIT5) ? '1' : '0'; - Send_Buffer[14] = (MSTP_MAC_Address & BIT6) ? '1' : '0'; + Send_Buffer[8] = (MSTP_MAC_Address & BIT(0)) ? '1' : '0'; + Send_Buffer[9] = (MSTP_MAC_Address & BIT(1)) ? '1' : '0'; + Send_Buffer[10] = (MSTP_MAC_Address & BIT(2)) ? '1' : '0'; + Send_Buffer[11] = (MSTP_MAC_Address & BIT(3)) ? '1' : '0'; + Send_Buffer[12] = (MSTP_MAC_Address & BIT(4)) ? '1' : '0'; + Send_Buffer[13] = (MSTP_MAC_Address & BIT(5)) ? '1' : '0'; + Send_Buffer[14] = (MSTP_MAC_Address & BIT(6)) ? '1' : '0'; serial_bytes_send((uint8_t *) Send_Buffer, 17); } if (serial_byte_get(&data_register)) { diff --git a/ports/linux/dlmstp.c b/ports/linux/dlmstp.c index 0cc87eb0..cea55170 100644 --- a/ports/linux/dlmstp.c +++ b/ports/linux/dlmstp.c @@ -447,7 +447,7 @@ static bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) { + if (request_pdu[offset] & BIT(3)) { request.service_choice = request_pdu[offset + 5]; } else { request.service_choice = request_pdu[offset + 3]; @@ -475,7 +475,7 @@ static bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) { + if (reply_pdu[offset] & BIT(3)) { reply.service_choice = reply_pdu[offset + 4]; } else { reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/linux/dlmstp_linux.c b/ports/linux/dlmstp_linux.c index bbdad1ab..f97b5c67 100644 --- a/ports/linux/dlmstp_linux.c +++ b/ports/linux/dlmstp_linux.c @@ -444,7 +444,7 @@ bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) { + if (request_pdu[offset] & BIT(3)) { request.service_choice = request_pdu[offset + 5]; } else { request.service_choice = request_pdu[offset + 3]; @@ -472,7 +472,7 @@ bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) { + if (reply_pdu[offset] & BIT(3)) { reply.service_choice = reply_pdu[offset + 4]; } else { reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/pic18f6720/apdu.c b/ports/pic18f6720/apdu.c index 004ca63a..85005fe8 100644 --- a/ports/pic18f6720/apdu.c +++ b/ports/pic18f6720/apdu.c @@ -85,10 +85,10 @@ uint16_t apdu_decode_confirmed_service_request( { uint16_t len = 0; /* counts where we are in PDU */ - service_data->segmented_message = (apdu[0] & BIT3) ? true : false; - service_data->more_follows = (apdu[0] & BIT2) ? true : false; + service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false; + service_data->more_follows = (apdu[0] & BIT(2)) ? true : false; service_data->segmented_response_accepted = - (apdu[0] & BIT1) ? true : false; + (apdu[0] & BIT(1)) ? true : false; service_data->max_segs = decode_max_segs(apdu[1]); service_data->max_resp = decode_max_apdu(apdu[1]); service_data->invoke_id = apdu[2]; diff --git a/ports/pic18f6720/mstp.c b/ports/pic18f6720/mstp.c index 13d41792..02e53493 100644 --- a/ports/pic18f6720/mstp.c +++ b/ports/pic18f6720/mstp.c @@ -590,7 +590,7 @@ static bool mstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -613,7 +613,7 @@ static bool mstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/pic18f97j60/apdu.c b/ports/pic18f97j60/apdu.c index 004ca63a..85005fe8 100644 --- a/ports/pic18f97j60/apdu.c +++ b/ports/pic18f97j60/apdu.c @@ -85,10 +85,10 @@ uint16_t apdu_decode_confirmed_service_request( { uint16_t len = 0; /* counts where we are in PDU */ - service_data->segmented_message = (apdu[0] & BIT3) ? true : false; - service_data->more_follows = (apdu[0] & BIT2) ? true : false; + service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false; + service_data->more_follows = (apdu[0] & BIT(2)) ? true : false; service_data->segmented_response_accepted = - (apdu[0] & BIT1) ? true : false; + (apdu[0] & BIT(1)) ? true : false; service_data->max_segs = decode_max_segs(apdu[1]); service_data->max_resp = decode_max_apdu(apdu[1]); service_data->invoke_id = apdu[2]; diff --git a/ports/pic18f97j60/mstp.c b/ports/pic18f97j60/mstp.c index 87f14752..83fa3e4e 100644 --- a/ports/pic18f97j60/mstp.c +++ b/ports/pic18f97j60/mstp.c @@ -590,7 +590,7 @@ static bool mstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -609,7 +609,7 @@ static bool mstp_compare_data_expecting_reply( case PDU_TYPE_CONFIRMED_SERVICE_REQUEST: reply.invoke_id = reply_pdu[offset + 2]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 5]; else reply.service_choice = reply_pdu[offset + 3]; @@ -621,7 +621,7 @@ static bool mstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/stm32f10x/dlmstp.c b/ports/stm32f10x/dlmstp.c index 9aed5e69..58830d60 100644 --- a/ports/stm32f10x/dlmstp.c +++ b/ports/stm32f10x/dlmstp.c @@ -277,7 +277,7 @@ static bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -300,7 +300,7 @@ static bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/win32/dlmstp-mm.c b/ports/win32/dlmstp-mm.c index 1cfd5543..95009b09 100644 --- a/ports/win32/dlmstp-mm.c +++ b/ports/win32/dlmstp-mm.c @@ -350,7 +350,7 @@ bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -372,7 +372,7 @@ bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/win32/dlmstp.c b/ports/win32/dlmstp.c index bf81a64e..3dabef1e 100644 --- a/ports/win32/dlmstp.c +++ b/ports/win32/dlmstp.c @@ -334,7 +334,7 @@ static bool dlmstp_compare_data_expecting_reply( } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; @@ -357,7 +357,7 @@ static bool dlmstp_compare_data_expecting_reply( case PDU_TYPE_COMPLEX_ACK: reply.invoke_id = reply_pdu[offset + 1]; /* segmented message? */ - if (reply_pdu[offset] & BIT3) + if (reply_pdu[offset] & BIT(3)) reply.service_choice = reply_pdu[offset + 4]; else reply.service_choice = reply_pdu[offset + 2]; diff --git a/ports/xplained/dlmstp.c b/ports/xplained/dlmstp.c index 5938c4fc..6a1cd0ee 100644 --- a/ports/xplained/dlmstp.c +++ b/ports/xplained/dlmstp.c @@ -253,7 +253,7 @@ static bool dlmstp_compare_data_expecting_reply(uint8_t * request_pdu, } request.invoke_id = request_pdu[offset + 2]; /* segmented message? */ - if (request_pdu[offset] & BIT3) + if (request_pdu[offset] & BIT(3)) request.service_choice = request_pdu[offset + 5]; else request.service_choice = request_pdu[offset + 3]; diff --git a/src/bacnet/bacdcode.c b/src/bacnet/bacdcode.c index 7f05ff61..cbc3c44e 100644 --- a/src/bacnet/bacdcode.c +++ b/src/bacnet/bacdcode.c @@ -216,7 +216,7 @@ int encode_tag(uint8_t *apdu, apdu[0] = 0; if (context_specific) { - apdu[0] = BIT3; + apdu[0] = BIT(3); } /* additional tag byte after this byte */ @@ -256,7 +256,7 @@ int encode_opening_tag(uint8_t *apdu, uint8_t tag_number) int len = 1; /* set class field to context specific */ - apdu[0] = BIT3; + apdu[0] = BIT(3); /* additional tag byte after this byte for extended tag byte */ if (tag_number <= 14) { apdu[0] |= (tag_number << 4); @@ -278,7 +278,7 @@ int encode_closing_tag(uint8_t *apdu, uint8_t tag_number) int len = 1; /* set class field to context specific */ - apdu[0] = BIT3; + apdu[0] = BIT(3); /* additional tag byte after this byte for extended tag byte */ if (tag_number <= 14) { apdu[0] |= (tag_number << 4); @@ -595,29 +595,29 @@ static uint8_t byte_reverse_bits(uint8_t in_byte) { uint8_t out_byte = 0; - if (in_byte & BIT0) { - out_byte |= BIT7; + if (in_byte & BIT(0)) { + out_byte |= BIT(7); } - if (in_byte & BIT1) { - out_byte |= BIT6; + if (in_byte & BIT(1)) { + out_byte |= BIT(6); } - if (in_byte & BIT2) { - out_byte |= BIT5; + if (in_byte & BIT(2)) { + out_byte |= BIT(5); } - if (in_byte & BIT3) { - out_byte |= BIT4; + if (in_byte & BIT(3)) { + out_byte |= BIT(4); } - if (in_byte & BIT4) { - out_byte |= BIT3; + if (in_byte & BIT(4)) { + out_byte |= BIT(3); } - if (in_byte & BIT5) { - out_byte |= BIT2; + if (in_byte & BIT(5)) { + out_byte |= BIT(2); } - if (in_byte & BIT6) { - out_byte |= BIT1; + if (in_byte & BIT(6)) { + out_byte |= BIT(1); } - if (in_byte & BIT7) { - out_byte |= BIT0; + if (in_byte & BIT(7)) { + out_byte |= BIT(0); } return out_byte; @@ -2522,7 +2522,7 @@ static void testBACDCodeTags(Test *pTest) test_len = get_apdu_len(IS_EXTENDED_TAG_NUMBER(apdu[0]), value); ct_test(pTest, len == test_len); /* stop at the the last value */ - if (value & BIT31) { + if (value & BIT(31L)) { break; } } diff --git a/src/bacnet/bacdcode.h b/src/bacnet/bacdcode.h index f528f602..374cbd73 100644 --- a/src/bacnet/bacdcode.h +++ b/src/bacnet/bacdcode.h @@ -508,7 +508,7 @@ extern "C" { /* from clause 20.2.1.1 Class */ /* true if the tag is context specific */ -#define IS_CONTEXT_SPECIFIC(x) ((x & BIT3) == BIT3) +#define IS_CONTEXT_SPECIFIC(x) ((x & BIT(3)) == BIT(3)) /* from clause 20.2.1.3.2 Constructed Data */ /* true if the tag is an opening tag */ diff --git a/src/bacnet/bits.h b/src/bacnet/bits.h index cf10533f..e4b1253b 100644 --- a/src/bacnet/bits.h +++ b/src/bacnet/bits.h @@ -27,54 +27,39 @@ /******************************************************************** * Bit Masks *********************************************************************/ -#define BIT(x) (1<<(x)) -#define BIT0 (0x01) -#define BIT1 (0x02) -#define BIT2 (0x04) -#define BIT3 (0x08) -#define BIT4 (0x10) -#define BIT5 (0x20) -#define BIT6 (0x40) -#define BIT7 (0x80) -#define BIT8 (0x0100) -#define BIT9 (0x0200) -#define BIT10 (0x0400) -#define BIT11 (0x0800) -#define BIT12 (0x1000) -#define BIT13 (0x2000) -#define BIT14 (0x4000) -#define BIT15 (0x8000) -#define BIT16 (0x010000UL) -#define BIT17 (0x020000UL) -#define BIT18 (0x040000UL) -#define BIT19 (0x080000UL) -#define BIT20 (0x100000UL) -#define BIT21 (0x200000UL) -#define BIT22 (0x400000UL) -#define BIT23 (0x800000UL) -#define BIT24 (0x01000000UL) -#define BIT25 (0x02000000UL) -#define BIT26 (0x04000000UL) -#define BIT27 (0x08000000UL) -#define BIT28 (0x10000000UL) -#define BIT29 (0x20000000UL) -#define BIT30 (0x40000000UL) -#define BIT31 (0x80000000UL) +#ifndef BIT +#define BIT(x) (1<<(x)) +#endif +#ifndef _BV +#define _BV(x) (1<<(x)) +#endif /* a=register, b=bit number to act upon 0-n */ +#ifndef BIT_SET #define BIT_SET(a,b) ((a) |= (1<<(b))) +#endif +#ifndef BIT_CLEAR #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b))) +#endif +#ifndef BIT_FLIP #define BIT_FLIP(a,b) ((a) ^= (1<<(b))) +#endif +#ifndef BIT_CHECK #define BIT_CHECK(a,b) ((a) & (1<<(b))) +#endif /* x=target variable, y=mask */ +#ifndef BITMASK_SET #define BITMASK_SET(x,y) ((x) |= (y)) +#endif +#ifndef BITMASK_CLEAR #define BITMASK_CLEAR(x,y) ((x) &= (~(y))) +#endif +#ifndef BITMASK_FLIP #define BITMASK_FLIP(x,y) ((x) ^= (y)) +#endif +#ifndef BITMASK_CHECK #define BITMASK_CHECK(x,y) (((x) & (y)) == (y)) - -#ifndef _BV -#define _BV(x) (1<<(x)) #endif #endif diff --git a/src/bacnet/npdu.c b/src/bacnet/npdu.c index fb3cc6e1..848c279b 100644 --- a/src/bacnet/npdu.c +++ b/src/bacnet/npdu.c @@ -144,7 +144,7 @@ int npdu_encode_pdu(uint8_t *npdu, /* 0 indicates that the NSDU contains a BACnet APDU. */ /* Message Type field is absent. */ if (npdu_data->network_layer_message) { - npdu[1] |= BIT7; + npdu[1] |= BIT(7); } /*Bit 6: Reserved. Shall be zero. */ /*Bit 5: Destination specifier where: */ @@ -153,7 +153,7 @@ int npdu_encode_pdu(uint8_t *npdu, /* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent */ /* DLEN > 0 specifies length of DADR field */ if (dest && dest->net) { - npdu[1] |= BIT5; + npdu[1] |= BIT(5); } /* Bit 4: Reserved. Shall be zero. */ /* Bit 3: Source specifier where: */ @@ -162,7 +162,7 @@ int npdu_encode_pdu(uint8_t *npdu, /* SLEN = 0 Invalid */ /* SLEN > 0 specifies length of SADR field */ if (src && src->net && src->len) { - npdu[1] |= BIT3; + npdu[1] |= BIT(3); } /* Bit 2: The value of this bit corresponds to the */ /* data_expecting_reply parameter in the N-UNITDATA primitives. */ @@ -173,7 +173,7 @@ int npdu_encode_pdu(uint8_t *npdu, /* a segment of a BACnet-ComplexACK-PDU, */ /* or a network layer message expecting a reply is present. */ if (npdu_data->data_expecting_reply) { - npdu[1] |= BIT2; + npdu[1] |= BIT(2); } /* Bits 1,0: Network priority where: */ /* B'11' = Life Safety message */ @@ -330,7 +330,7 @@ int npdu_decode(uint8_t *npdu, /* Message Type field is present. */ /* 0 indicates that the NSDU contains a BACnet APDU. */ /* Message Type field is absent. */ - npdu_data->network_layer_message = (npdu[1] & BIT7) ? true : false; + npdu_data->network_layer_message = (npdu[1] & BIT(7)) ? true : false; /*Bit 6: Reserved. Shall be zero. */ /* Bit 4: Reserved. Shall be zero. */ /* Bit 2: The value of this bit corresponds to data expecting reply */ @@ -341,7 +341,7 @@ int npdu_decode(uint8_t *npdu, /* 0 indicates that other than a BACnet-Confirmed-Request-PDU, */ /* a segment of a BACnet-ComplexACK-PDU, */ /* or a network layer message expecting a reply is present. */ - npdu_data->data_expecting_reply = (npdu[1] & BIT2) ? true : false; + npdu_data->data_expecting_reply = (npdu[1] & BIT(2)) ? true : false; /* Bits 1,0: Network priority where: */ /* B'11' = Life Safety message */ /* B'10' = Critical Equipment message */ @@ -355,7 +355,7 @@ int npdu_decode(uint8_t *npdu, /* 1 = DNET, DLEN, and Hop Count present */ /* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent */ /* DLEN > 0 specifies length of DADR field */ - if (npdu[1] & BIT5) { + if (npdu[1] & BIT(5)) { len += decode_unsigned16(&npdu[len], &dest_net); /* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent */ /* DLEN > 0 specifies length of DADR field */ @@ -389,7 +389,7 @@ int npdu_decode(uint8_t *npdu, /* Bit 3: Source specifier where: */ /* 0 = SNET, SLEN, and SADR absent */ /* 1 = SNET, SLEN, and SADR present */ - if (npdu[1] & BIT3) { + if (npdu[1] & BIT(3)) { len += decode_unsigned16(&npdu[len], &src_net); /* SLEN = 0 denotes broadcast MAC SADR and SADR field is absent */ /* SLEN > 0 specifies length of SADR field */