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

ieee802154: add definitions & config options for MR-O-QPSK

Define options for IEEE 802.15.4g MR-O-QPSK as well as shell commands
to set them via ifconfig.
This commit is contained in:
Benjamin Valentin 2019-12-13 17:17:15 +01:00 committed by Benjamin Valentin
parent 795cd165fd
commit fac35644d0
5 changed files with 184 additions and 3 deletions

View File

@ -61,6 +61,7 @@ PSEUDOMODULES += mpu_stack_guard
PSEUDOMODULES += mpu_noexec_ram
PSEUDOMODULES += nanocoap_%
PSEUDOMODULES += netdev_default
PSEUDOMODULES += netdev_ieee802154_%
PSEUDOMODULES += netstats
PSEUDOMODULES += netstats_l2
PSEUDOMODULES += netstats_ipv6

View File

@ -97,6 +97,14 @@ extern "C" {
#define IEEE802154_FRAME_LEN_MAX (127U) /**< maximum 802.15.4 frame length */
#define IEEE802154G_FRAME_LEN_MAX (2047U) /**< maximum 802.15.4g-2012 frame length */
/**
* For the SUN PHYs, the value is 1 ms expressed in symbol periods, rounded
* up to the next integer number of symbol periods using the ceiling() function.
*
* 802.15.4g, Table 70 (p. 43)
*/
#define IEEE802154G_ATURNAROUNDTIME_US (1 * US_PER_MS)
/**
* @brief 802.15.4 PHY modes
*/
@ -110,6 +118,15 @@ enum {
IEEE802154_PHY_MR_FSK /**< Multi-Rate Frequency Shift Keying */
};
/**
* @brief 802.15.4 forward error correction schemes
*/
enum {
IEEE802154_FEC_NONE, /**< no forward error correction */
IEEE802154_FEC_NRNSC, /**< non-recursive and non-systematic code */
IEEE802154_FEC_RSC /**< recursive and systematic code */
};
/**
* @brief Special address definitions
* @{

View File

@ -656,6 +656,26 @@ typedef enum {
*/
NETOPT_IEEE802154_PHY,
/**
* @brief (uint8_t) legacy O-QPSK Rate Mode
*/
NETOPT_OQPSK_RATE,
/**
* @brief (uint8_t) MR-O-QPSK Chip Rate (kchip/s)
*/
NETOPT_MR_OQPSK_CHIPS,
/**
* @brief (uint8_t) MR-O-QPSK Rate Mode
*/
NETOPT_MR_OQPSK_RATE,
/**
* @brief (uint8_t) PHY Channel Spacing (kHz)
*/
NETOPT_CHANNEL_SPACING,
/**
* @brief (uint8_t*) phy layer syncword
*/

View File

@ -106,6 +106,11 @@ static const char *_netopt_strmap[] = {
[NETOPT_LORAWAN_RX2_FREQ] = "NETOPT_LORAWAN_RX2_FREQ",
[NETOPT_LORAWAN_MAX_RX_ERROR] = "NETOPT_LORAWAN_MAX_RX_ERROR",
[NETOPT_LORAWAN_MIN_RX_SYMBOL] = "NETOPT_LORAWAN_MIN_RX_SYMBOL",
[NETOPT_IEEE802154_PHY] = "NETOPT_IEEE802154_PHY",
[NETOPT_OQPSK_RATE] = "NETOPT_O-QPSK_RATE",
[NETOPT_MR_OQPSK_CHIPS] = "NETOPT_MR-O-QPSK_CHIPS",
[NETOPT_MR_OQPSK_RATE] = "NETOPT_MR-O-QPSK_RATE",
[NETOPT_CHANNEL_SPACING] = "NETOPT_CHANNEL_SPACING",
[NETOPT_SYNCWORD] = "NETOPT_SYNCWORD",
[NETOPT_RANDOM] = "NETOPT_RANDOM",
[NETOPT_RX_SYMBOL_TIMEOUT] = "NETOPT_RX_SYMBOL_TIMEOUT",

View File

@ -18,6 +18,7 @@
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@ -86,6 +87,15 @@ static void _print_iface_name(netif_t *iface)
printf("%s", name);
}
__attribute__ ((unused))
static void str_toupper(char *str)
{
while (*str) {
*str = toupper((unsigned) *str);
++str;
}
}
#ifdef MODULE_NETSTATS
static const char *_netstats_module_to_str(uint8_t module)
{
@ -173,6 +183,13 @@ static void _set_usage(char *cmd_name)
" * \"dr\" - sets datarate\n"
" * \"rx2_dr\" - sets datarate of RX2 (lorawan)\n"
" * \"nwkskey\" - sets Network Session Key\n"
#endif
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE
" * \"phy_mode\" - select PHY mode\n"
#endif
#ifdef MODULE_NETDEV_IEEE802154_MR_OQPSK
" * \"chip_rate\" - BPSK/QPSK chip rate in kChip/s\n"
" * \"rate_mode\" - BPSK/QPSK rate mode\n"
#endif
" * \"power\" - TX power in dBm\n"
" * \"retrans\" - max. number of retransmissions\n"
@ -303,7 +320,33 @@ static void _print_netopt(netopt_t opt)
case NETOPT_CODING_RATE:
printf("coding rate");
break;
#endif
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE
case NETOPT_IEEE802154_PHY:
printf("PHY mode");
break;
#endif /* MODULE_NETDEV_IEEE802154_MULTIMODE */
#ifdef MODULE_NETDEV_IEEE802154_OQPSK
case NETOPT_OQPSK_RATE:
printf("high rate");
break;
#endif /* MODULE_NETDEV_IEEE802154_OQPSK */
#ifdef MODULE_NETDEV_IEEE802154_MR_OQPSK
case NETOPT_MR_OQPSK_CHIPS:
printf("chip rate");
break;
case NETOPT_MR_OQPSK_RATE:
printf("rate mode");
break;
#endif /* MODULE_NETDEV_IEEE802154_MR_OQPSK */
case NETOPT_CHECKSUM:
printf("checksum");
break;
@ -359,6 +402,18 @@ static const char *_netopt_coding_rate_str[] = {
};
#endif
#ifdef MODULE_NETDEV_IEEE802154
static const char *_netopt_ieee802154_phy_str[] = {
[IEEE802154_PHY_DISABLED] = "DISABLED",
[IEEE802154_PHY_BPSK] = "BPSK",
[IEEE802154_PHY_ASK] = "ASK",
[IEEE802154_PHY_OQPSK] = "O-QPSK",
[IEEE802154_PHY_MR_OQPSK] = "MR-O-QPSK",
[IEEE802154_PHY_MR_OFDM] = "MR-OFDM",
[IEEE802154_PHY_MR_FSK] = "MR-FSK"
};
#endif
/* for some lines threshold might just be 0, so we can't use _LINE_THRESHOLD
* here */
static unsigned _newline(unsigned threshold, unsigned line_thresh)
@ -493,7 +548,42 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" CR: %s ", _netopt_coding_rate_str[u8]);
}
#endif
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#ifdef MODULE_NETDEV_IEEE802154
res = netif_get_opt(iface, NETOPT_IEEE802154_PHY, 0, &u8, sizeof(u8));
if (res >= 0) {
printf(" PHY: %s ", _netopt_ieee802154_phy_str[u8]);
switch (u8) {
#ifdef MODULE_NETDEV_IEEE802154_OQPSK
case IEEE802154_PHY_OQPSK:
printf("\n ");
res = netif_get_opt(iface, NETOPT_OQPSK_RATE, 0, &u8, sizeof(u8));
if (res >= 0 && u8) {
printf(" high data rate: %d ", u8);
}
break;
#endif /* MODULE_NETDEV_IEEE802154_OQPSK */
#ifdef MODULE_NETDEV_IEEE802154_MR_OQPSK
case IEEE802154_PHY_MR_OQPSK:
printf("\n ");
res = netif_get_opt(iface, NETOPT_MR_OQPSK_CHIPS, 0, &u16, sizeof(u16));
if (res >= 0) {
printf(" chip rate: %u ", u16);
}
res = netif_get_opt(iface, NETOPT_MR_OQPSK_RATE, 0, &u8, sizeof(u8));
if (res >= 0) {
printf(" rate mode: %d ", u8);
}
break;
#endif /* MODULE_NETDEV_IEEE802154_MR_OQPSK */
}
}
#endif /* MODULE_NETDEV_IEEE802154 */
netopt_enable_t link;
res = netif_get_opt(iface, NETOPT_LINK, 0, &link, sizeof(netopt_enable_t));
if (res >= 0) {
@ -781,6 +871,36 @@ static int _netif_set_coding_rate(netif_t *iface, char *value)
}
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE
static int _netif_set_ieee802154_phy_mode(netif_t *iface, char *value)
{
/* ignore case */
str_toupper(value);
for (uint8_t i = 0; i < ARRAY_SIZE(_netopt_ieee802154_phy_str); ++i) {
if (strcmp(_netopt_ieee802154_phy_str[i], value)) {
continue;
}
if (netif_set_opt(iface, NETOPT_IEEE802154_PHY, 0, &i, sizeof(uint8_t)) < 0) {
printf("error: unable to set PHY mode to %s\n", value);
return 1;
}
printf("success: set PHY mode %s\n", value);
return 0;
}
printf("usage: ifconfig <if_id> set phy ");
for (unsigned i = 0; i < ARRAY_SIZE(_netopt_ieee802154_phy_str); ++i) {
printf("%c%s", i ? '|' : '[', _netopt_ieee802154_phy_str[i]);
}
puts("]");
return 1;
}
#endif /* MODULE_NETDEV_IEEE802154_MULTIMODE */
static int _netif_set_u16(netif_t *iface, netopt_t opt, uint16_t context,
char *u16_str)
{
@ -1162,7 +1282,25 @@ static int _netif_set(char *cmd_name, netif_t *iface, char *key, char *value)
else if (strcmp("rx2_dr", key) == 0) {
return _netif_set_u8(iface, NETOPT_LORAWAN_RX2_DR, 0, value);
}
#endif
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE
else if ((strcmp("phy_mode", key) == 0) || (strcmp("phy", key) == 0)) {
return _netif_set_ieee802154_phy_mode(iface, value);
}
#endif /* MODULE_NETDEV_IEEE802154_MULTIMODE */
#ifdef MODULE_NETDEV_IEEE802154_OQPSK
else if (strcmp("high_rate", key) == 0) {
return _netif_set_u8(iface, NETOPT_OQPSK_RATE, 0, value);
}
#endif /* MODULE_NETDEV_IEEE802154_OQPSK */
#ifdef MODULE_NETDEV_IEEE802154_MR_OQPSK
else if ((strcmp("chip_rate", key) == 0) || (strcmp("chips", key) == 0)) {
return _netif_set_u16(iface, NETOPT_MR_OQPSK_CHIPS, 0, value);
}
else if (strcmp("rate_mode", key) == 0) {
return _netif_set_u8(iface, NETOPT_MR_OQPSK_RATE, 0, value);
}
#endif /* MODULE_NETDEV_IEEE802154_MR_OQPSK */
else if ((strcmp("channel", key) == 0) || (strcmp("chan", key) == 0)) {
return _netif_set_u16(iface, NETOPT_CHANNEL, 0, value);
}