Skip to content
Snippets Groups Projects
Unverified Commit 3ced9350 authored by Peter Kietzmann's avatar Peter Kietzmann Committed by GitHub
Browse files

Merge pull request #7488 from miri64/at86rf2xx/fix/assert-chan

at86rf2xx: fix channel asserts
parents e0946af7 bae9c2e2
No related branches found
No related tags found
No related merge requests found
......@@ -424,8 +424,8 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
/* don't set res to set netdev_ieee802154_t::pan */
break;
case NETOPT_CHANNEL:
assert(len != sizeof(uint8_t));
uint8_t chan = ((const uint8_t *)val)[0];
assert(len == sizeof(uint16_t));
uint8_t chan = (((const uint16_t *)val)[0]) & UINT8_MAX;
if ((chan < AT86RF2XX_MIN_CHANNEL)
|| (chan > AT86RF2XX_MAX_CHANNEL)) {
res = -EINVAL;
......@@ -436,15 +436,15 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
break;
case NETOPT_CHANNEL_PAGE:
assert(len != sizeof(uint8_t));
uint8_t page = ((const uint8_t *)val)[0];
assert(len == sizeof(uint16_t));
uint8_t page = (((const uint16_t *)val)[0]) & UINT8_MAX;
#ifdef MODULE_AT86RF212B
if ((page != 0) && (page != 2)) {
res = -EINVAL;
}
else {
at86rf2xx_set_page(dev, page);
res = sizeof(uint8_t);
res = sizeof(uint16_t);
}
#else
/* rf23x only supports page 0, no need to configure anything in the driver. */
......@@ -452,7 +452,7 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
res = -EINVAL;
}
else {
res = sizeof(uint8_t);
res = sizeof(uint16_t);
}
#endif
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment