From 420db06b37e58a47fa171b9dec2e291896f2848a Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Wed, 12 Jul 2017 00:53:04 -0400 Subject: [PATCH] ieee802154: Notify radio layer of changes in devmode --- wireless/ieee802154/mac802154_assoc.c | 10 ++++++++-- wireless/ieee802154/mac802154_internal.h | 15 ++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/wireless/ieee802154/mac802154_assoc.c b/wireless/ieee802154/mac802154_assoc.c index c5448ca1fb..b72ba08556 100644 --- a/wireless/ieee802154/mac802154_assoc.c +++ b/wireless/ieee802154/mac802154_assoc.c @@ -133,8 +133,14 @@ int mac802154_req_associate(MACHANDLE mac, /* Copy in the capabilities information bitfield */ - priv->devmode = (req->capabilities.devtype) ? - IEEE802154_DEVMODE_COORD : IEEE802154_DEVMODE_ENDPOINT; + if (req->capabilities.devtype) + { + mac802154_setdevmode(priv, IEEE802154_DEVMODE_COORD); + } + else + { + mac802154_setdevmode(priv, IEEE802154_DEVMODE_ENDPOINT); + } mac802154_setrxonidle(priv, req->capabilities.rxonidle); diff --git a/wireless/ieee802154/mac802154_internal.h b/wireless/ieee802154/mac802154_internal.h index fd1fd77568..8051763598 100644 --- a/wireless/ieee802154/mac802154_internal.h +++ b/wireless/ieee802154/mac802154_internal.h @@ -816,15 +816,16 @@ static inline void mac802154_setrxonidle(FAR struct ieee802154_privmac_s *priv, mac802154_rxdisable(priv); } - /* Unlike other attributes, we can't simply cast this one since it is a bit - * in a bitfield. Casting it will give us unpredicatble results. Instead - * of creating a ieee802154_attr_u, we use a local bool. Allocating the - * ieee802154_attr_u value would take up more room on the stack since it is - * as large as the largest attribute type. - */ - priv->radio->setattr(priv->radio, IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE, (FAR const union ieee802154_attr_u *)&rxonidle); } +static inline void mac802154_setdevmode(FAR struct ieee802154_privmac_s *priv, + enum ieee802154_devmode_e mode) +{ + priv->devmode = mode; + priv->radio->setattr(priv->radio, IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE, + (FAR const union ieee802154_attr_u *)&mode); +} + #endif /* __WIRELESS_IEEE802154__MAC802154_INTERNAL_H */