net: openthread: Unify IS_ENABLED macro usage

Older OT code used preprocessor #if conditionals, while newer code
used IS_ENABLED macro. Unify the approach by switching to the latter
option.

Additinally, fix inclusion issue that came out after switching to
IS_ENABLED.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-03-05 16:45:07 +01:00 committed by Johan Hedberg
commit 24b6afaec2
2 changed files with 24 additions and 29 deletions

View file

@ -23,6 +23,7 @@ LOG_MODULE_REGISTER(net_l2_openthread, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
#include <openthread/ip6.h> #include <openthread/ip6.h>
#include <openthread/link.h> #include <openthread/link.h>
#include <openthread/message.h> #include <openthread/message.h>
#include <openthread/platform/diag.h>
#include <openthread/tasklet.h> #include <openthread/tasklet.h>
#include <openthread/thread.h> #include <openthread/thread.h>
#include <openthread/dataset.h> #include <openthread/dataset.h>
@ -182,9 +183,9 @@ void ot_receive_handler(otMessage *aMessage, void *context)
NET_DBG("Injecting Ip6 packet to Zephyr net stack"); NET_DBG("Injecting Ip6 packet to Zephyr net stack");
#if defined(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6) if (IS_ENABLED(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6)) {
net_pkt_hexdump(pkt, "Received IPv6 packet"); net_pkt_hexdump(pkt, "Received IPv6 packet");
#endif }
if (!pkt_list_is_full(ot_context)) { if (!pkt_list_is_full(ot_context)) {
if (net_recv_data(ot_context->iface, pkt) < 0) { if (net_recv_data(ot_context->iface, pkt) < 0) {
@ -242,11 +243,12 @@ static enum net_verdict openthread_recv(struct net_if *iface,
if (pkt_list_peek(ot_context) == pkt) { if (pkt_list_peek(ot_context) == pkt) {
pkt_list_remove_last(ot_context); pkt_list_remove_last(ot_context);
NET_DBG("Got injected Ip6 packet, " NET_DBG("Got injected Ip6 packet, sending to upper layers");
"sending to upper layers");
#if defined(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6) if (IS_ENABLED(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6)) {
net_pkt_hexdump(pkt, "Injected IPv6 packet"); net_pkt_hexdump(pkt, "Injected IPv6 packet");
#endif }
return NET_CONTINUE; return NET_CONTINUE;
} }
@ -261,17 +263,15 @@ static enum net_verdict openthread_recv(struct net_if *iface,
recv_frame.mInfo.mRxInfo.mLqi = net_pkt_ieee802154_lqi(pkt); recv_frame.mInfo.mRxInfo.mLqi = net_pkt_ieee802154_lqi(pkt);
recv_frame.mInfo.mRxInfo.mRssi = net_pkt_ieee802154_rssi(pkt); recv_frame.mInfo.mRxInfo.mRssi = net_pkt_ieee802154_rssi(pkt);
#if defined(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_15_4)
net_pkt_hexdump(pkt, "Received 802.15.4 frame");
#endif
#if OPENTHREAD_ENABLE_DIAG if (IS_ENABLED(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6)) {
if (otPlatDiagModeGet()) { net_pkt_hexdump(pkt, "Received 802.15.4 frame");
}
if (IS_ENABLED(OPENTHREAD_ENABLE_DIAG) && otPlatDiagModeGet()) {
otPlatDiagRadioReceiveDone(ot_context->instance, otPlatDiagRadioReceiveDone(ot_context->instance,
&recv_frame, OT_ERROR_NONE); &recv_frame, OT_ERROR_NONE);
} else } else {
#endif
{
otPlatRadioReceiveDone(ot_context->instance, otPlatRadioReceiveDone(ot_context->instance,
&recv_frame, OT_ERROR_NONE); &recv_frame, OT_ERROR_NONE);
} }
@ -313,9 +313,9 @@ int openthread_send(struct net_if *iface, struct net_pkt *pkt)
goto exit; goto exit;
} }
#if defined(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6) if (IS_ENABLED(CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6)) {
net_pkt_hexdump(pkt, "Sent IPv6 packet"); net_pkt_hexdump(pkt, "Sent IPv6 packet");
#endif }
exit: exit:
net_pkt_unref(pkt); net_pkt_unref(pkt);
@ -397,10 +397,9 @@ static int openthread_init(struct net_if *iface)
__ASSERT(ot_context->instance, "OT instance is NULL"); __ASSERT(ot_context->instance, "OT instance is NULL");
#if defined(CONFIG_OPENTHREAD_SHELL) if (IS_ENABLED(CONFIG_OPENTHREAD_SHELL)) {
platformShellInit(ot_context->instance); platformShellInit(ot_context->instance);
#endif }
otIp6SetEnabled(ot_context->instance, true); otIp6SetEnabled(ot_context->instance, true);

View file

@ -153,14 +153,10 @@ void platformRadioProcess(otInstance *aInstance)
sState = OT_RADIO_STATE_RECEIVE; sState = OT_RADIO_STATE_RECEIVE;
#if OPENTHREAD_ENABLE_DIAG if (IS_ENABLED(OPENTHREAD_ENABLE_DIAG) && otPlatDiagModeGet()) {
if (otPlatDiagModeGet()) {
otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame,
result); result);
} else } else {
#endif
{
if (sTransmitFrame.mPsdu[0] & IEEE802154_AR_FLAG_SET) { if (sTransmitFrame.mPsdu[0] & IEEE802154_AR_FLAG_SET) {
if (ack_frame.mLength == 0) { if (ack_frame.mLength == 0) {
LOG_DBG("No ACK received."); LOG_DBG("No ACK received.");