1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #8232 from aabadie/pr/drivers/sx127x_netdev

drivers/sx127x: improve netdev adaption
This commit is contained in:
Alexandre Abadie 2017-12-10 16:08:26 +01:00 committed by GitHub
commit 04c3acc4b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 19 deletions

View File

@ -292,10 +292,10 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
assert(max_len >= sizeof(netopt_state_t));
return _get_state(dev, val);
case NETOPT_DEVICE_MODE:
assert(max_len >= sizeof(uint8_t));
*((uint8_t*) val) = dev->settings.modem;
return sizeof(uint8_t);
case NETOPT_DEVICE_TYPE:
assert(max_len >= sizeof(uint16_t));
*((uint16_t*) val) = NETDEV_TYPE_LORA;
return sizeof(uint16_t);
case NETOPT_CHANNEL:
assert(max_len >= sizeof(uint32_t));
@ -325,12 +325,12 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
case NETOPT_INTEGRITY_CHECK:
assert(max_len >= sizeof(netopt_enable_t));
*((netopt_enable_t*) val) = sx127x_get_crc(dev) ? NETOPT_ENABLE : NETOPT_DISABLE;
break;
return sizeof(netopt_enable_t);
case NETOPT_CHANNEL_HOP:
assert(max_len >= sizeof(netopt_enable_t));
*((netopt_enable_t*) val) = (dev->settings.lora.flags & SX127X_CHANNEL_HOPPING_FLAG) ? NETOPT_ENABLE : NETOPT_DISABLE;
break;
return sizeof(netopt_enable_t);
case NETOPT_CHANNEL_HOP_PERIOD:
assert(max_len >= sizeof(uint8_t));
@ -340,7 +340,7 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
case NETOPT_SINGLE_RECEIVE:
assert(max_len >= sizeof(uint8_t));
*((netopt_enable_t*) val) = sx127x_get_rx_single(dev) ? NETOPT_ENABLE : NETOPT_DISABLE;
break;
return sizeof(netopt_enable_t);
case NETOPT_TX_POWER:
assert(max_len >= sizeof(int8_t));
@ -350,13 +350,13 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
case NETOPT_IQ_INVERT:
assert(max_len >= sizeof(uint8_t));
*((netopt_enable_t*) val) = sx127x_get_iq_invert(dev) ? NETOPT_ENABLE : NETOPT_DISABLE;
break;
return sizeof(netopt_enable_t);
default:
break;
}
return 0;
return -ENOTSUP;
}
static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
@ -375,10 +375,16 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
assert(len <= sizeof(netopt_state_t));
return _set_state(dev, *((const netopt_state_t*) val));
case NETOPT_DEVICE_MODE:
assert(len <= sizeof(uint8_t));
sx127x_set_modem(dev, *((const uint8_t*) val));
return sizeof(netopt_enable_t);
case NETOPT_DEVICE_TYPE:
assert(len <= sizeof(uint16_t));
/* Only LoRa modem is supported for the moment */
if (*(const uint16_t*) val == NETDEV_TYPE_LORA) {
sx127x_set_modem(dev, SX127X_MODEM_LORA);
return sizeof(uint16_t);
}
else {
return -EINVAL;
}
case NETOPT_CHANNEL:
assert(len <= sizeof(uint32_t));

View File

@ -406,11 +406,6 @@ typedef enum {
*/
NETOPT_TX_TIMEOUT,
/**
* @brief Get/Set the radio modem type as uint8_t.
*/
NETOPT_DEVICE_MODE,
/**
* @brief Get/Set the radio modulation bandwidth as uint8_t.
*/

View File

@ -72,7 +72,6 @@ static const char *_netopt_strmap[] = {
[NETOPT_L2FILTER] = "NETOPT_L2FILTER",
[NETOPT_L2FILTER_RM] = "NETOPT_L2FILTER_RM",
[NETOPT_LAST_ED_LEVEL] = "NETOPT_LAST_ED_LEVEL",
[NETOPT_DEVICE_MODE] = "NETOPT_DEVICE_MODE",
[NETOPT_BANDWIDTH] = "NETOPT_BANDWIDTH",
[NETOPT_SPREADING_FACTOR] = "NETOPT_SPREADING_FACTOR",
[NETOPT_CODING_RATE] = "NETOPT_CODING_RATE",