Merge pull request #7488 from miri64/at86rf2xx/fix/assert-chan
at86rf2xx: fix channel asserts
This commit is contained in:
commit
3ced935057
@ -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 */
|
/* don't set res to set netdev_ieee802154_t::pan */
|
||||||
break;
|
break;
|
||||||
case NETOPT_CHANNEL:
|
case NETOPT_CHANNEL:
|
||||||
assert(len != sizeof(uint8_t));
|
assert(len == sizeof(uint16_t));
|
||||||
uint8_t chan = ((const uint8_t *)val)[0];
|
uint8_t chan = (((const uint16_t *)val)[0]) & UINT8_MAX;
|
||||||
if ((chan < AT86RF2XX_MIN_CHANNEL)
|
if ((chan < AT86RF2XX_MIN_CHANNEL)
|
||||||
|| (chan > AT86RF2XX_MAX_CHANNEL)) {
|
|| (chan > AT86RF2XX_MAX_CHANNEL)) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
@ -436,15 +436,15 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NETOPT_CHANNEL_PAGE:
|
case NETOPT_CHANNEL_PAGE:
|
||||||
assert(len != sizeof(uint8_t));
|
assert(len == sizeof(uint16_t));
|
||||||
uint8_t page = ((const uint8_t *)val)[0];
|
uint8_t page = (((const uint16_t *)val)[0]) & UINT8_MAX;
|
||||||
#ifdef MODULE_AT86RF212B
|
#ifdef MODULE_AT86RF212B
|
||||||
if ((page != 0) && (page != 2)) {
|
if ((page != 0) && (page != 2)) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
at86rf2xx_set_page(dev, page);
|
at86rf2xx_set_page(dev, page);
|
||||||
res = sizeof(uint8_t);
|
res = sizeof(uint16_t);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* rf23x only supports page 0, no need to configure anything in the driver. */
|
/* 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;
|
res = -EINVAL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = sizeof(uint8_t);
|
res = sizeof(uint16_t);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user