diff --git a/include/wireless/ieee802154.h b/include/wireless/ieee802154.h index 71730f762..3e6b5a131 100644 --- a/include/wireless/ieee802154.h +++ b/include/wireless/ieee802154.h @@ -112,6 +112,9 @@ int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr); int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca); int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca); +int ieee802154_setmaxretries(int fd, uint8_t retries); +int ieee802154_getmaxretries(int fd, FAR uint8_t *retries); + int ieee802154_getdevmode(int fd, FAR enum ieee802154_devmode_e *devmode); int ieee802154_setassocpermit(int fd, bool assocpermit); @@ -193,6 +196,10 @@ int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr); int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr); +int sixlowpan_setmaxretries(int sock, FAR const char *ifname, uint8_t retries); +int sixlowpan_getmaxretries(int sock, FAR const char *ifname, + FAR uint8_t *retries); + int sixlowpan_getdevmode(int fd, FAR const char *ifname, FAR enum ieee802154_devmode_e *devmode); diff --git a/wireless/ieee802154/i8sak/i8sak_get.c b/wireless/ieee802154/i8sak/i8sak_get.c index b4ed2816f..1442f4a1a 100644 --- a/wireless/ieee802154/i8sak/i8sak_get.c +++ b/wireless/ieee802154/i8sak/i8sak_get.c @@ -83,9 +83,9 @@ void i8sak_get_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) argind = 1; while ((option = getopt(argc, argv, ":h")) != ERROR) { + argind++; switch (option) { - argind++; case 'h': fprintf(stderr, "Gets various parameters and attributes\n" "Usage: %s [-h] parameter\n" @@ -104,6 +104,8 @@ void i8sak_get_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) " ep_addrmode = destination address mode" " rxonidle = Receiver on when idle\n" " txpwr = Transmit power\n" + " maxretries = macMaxFrameRetries\n" + " promisc = Promiscuous Mode\n" , argv[0]); /* Must manually reset optind if we are going to exit early */ @@ -125,6 +127,14 @@ void i8sak_get_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) } } + /* Make sure that there is another argument */ + + if (argc <= argind) + { + fprintf(stderr, "ERROR: Must include an attribute to get\n"); + i8sak_cmd_error(i8sak); /* This exits for us */ + } + /* Check for i8sak level options. Not dependent on opening file/socket */ if (strcmp(argv[argind], "addrmode") == 0) @@ -251,6 +261,23 @@ void i8sak_get_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) ieee802154_gettxpwr(fd, &u.attr.phy.txpwr); printf("i8sak: Transmit Power: %d\n", (int)u.attr.phy.txpwr); } + else if (strcmp(argv[argind], "maxretries") == 0) + { + ieee802154_getmaxretries(fd, &u.attr.mac.max_retries); + printf("i8sak: Max Frame Retries: %d\n", (int)u.attr.mac.max_retries); + } + else if (strcmp(argv[argind], "promisc") == 0) + { + ieee802154_getpromisc(fd, &u.attr.mac.promisc_mode); + if (u.attr.mac.promisc_mode) + { + printf("i8sak: Promiscuous Mode: true\n"); + } + else + { + printf("i8sak: Promiscuous Mode: false\n"); + } + } else { fprintf(stderr, "ERROR: unsupported parameter: %s\n", argv[argind]); @@ -319,6 +346,23 @@ void i8sak_get_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) sixlowpan_gettxpwr(fd, i8sak->ifname, &u.attr.phy.txpwr); printf("i8sak: Transmit Power: %d\n", (int)u.attr.phy.txpwr); } + else if (strcmp(argv[argind], "maxretries") == 0) + { + sixlowpan_getmaxretries(fd, i8sak->ifname, &u.attr.mac.max_retries); + printf("i8sak: Transmit Power: %d\n", (int)u.attr.mac.max_retries); + } + else if (strcmp(argv[argind], "promisc") == 0) + { + sixlowpan_getpromisc(fd, i8sak->ifname, &u.attr.mac.promisc_mode); + if (u.attr.mac.promisc_mode) + { + printf("i8sak: Promiscuous Mode: true\n"); + } + else + { + printf("i8sak: Promiscuous Mode: false\n"); + } + } else { fprintf(stderr, "ERROR: unsupported parameter: %s\n", argv[argind]); diff --git a/wireless/ieee802154/i8sak/i8sak_main.c b/wireless/ieee802154/i8sak/i8sak_main.c index ed5d4a93e..ccbd72129 100644 --- a/wireless/ieee802154/i8sak/i8sak_main.c +++ b/wireless/ieee802154/i8sak/i8sak_main.c @@ -897,6 +897,14 @@ int i8sak_main(int argc, char *argv[]) i8sak_showusage(argv[0], EXIT_FAILURE); } + /* Check to make sure the user supplied a command */ + + if (argc <= argind) + { + fprintf(stderr, "ERROR: Must include a command\n"); + i8sak_showusage(argv[0], EXIT_FAILURE); + } + /* Find the command in the g_i8sak_command[] list */ i8sakcmd = NULL; diff --git a/wireless/ieee802154/i8sak/i8sak_set.c b/wireless/ieee802154/i8sak/i8sak_set.c index ab7b909f6..7b9d601fc 100644 --- a/wireless/ieee802154/i8sak/i8sak_set.c +++ b/wireless/ieee802154/i8sak/i8sak_set.c @@ -83,11 +83,11 @@ void i8sak_set_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) argind = 1; while ((option = getopt(argc, argv, ":h")) != ERROR) { + argind++; switch (option) { - argind++; case 'h': - fprintf(stderr, "Gets various parameters and attributes\n" + fprintf(stderr, "Sets various parameters and attributes\n" "Usage: %s [-h] parameter\n" " -h = this help menu\n" " \n" @@ -103,6 +103,8 @@ void i8sak_set_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) " ep_port 1-65535 = port to send to\n" " rxonidle = Receiver on when idle\n" " txpwr = Transmit Power\n" + " maxretries = macMaxFrameRetries\n" + " promisc = Promiscuous Mode\n" , argv[0]); /* Must manually reset optind if we are going to exit early */ @@ -240,6 +242,14 @@ void i8sak_set_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { ieee802154_settxpwr(fd, i8sak_str2long(argv[argind + 1])); } + else if (strcmp(argv[argind], "maxretries") == 0) + { + ieee802154_setmaxretries(fd, i8sak_str2luint8(argv[argind + 1])); + } + else if (strcmp(argv[argind], "promisc") == 0) + { + ieee802154_setpromisc(fd, i8sak_str2bool(argv[argind + 1])); + } else { fprintf(stderr, "ERROR: unsupported parameter: %s\n", argv[argind]); @@ -284,6 +294,14 @@ void i8sak_set_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { sixlowpan_settxpwr(fd, i8sak->ifname, i8sak_str2long(argv[argind + 1])); } + else if (strcmp(argv[argind], "maxretries") == 0) + { + sixlowpan_setmaxretries(fd, i8sak->ifname, i8sak_str2luint8(argv[argind + 1])); + } + else if (strcmp(argv[argind], "promisc") == 0) + { + sixlowpan_setpromisc(fd, i8sak->ifname, i8sak_str2bool(argv[argind + 1])); + } else { fprintf(stderr, "ERROR: unsupported parameter: %s\n", argv[argind]); diff --git a/wireless/ieee802154/libmac/ieee802154_getreq.c b/wireless/ieee802154/libmac/ieee802154_getreq.c index e8a4854fe..11beeb17a 100644 --- a/wireless/ieee802154/libmac/ieee802154_getreq.c +++ b/wireless/ieee802154/libmac/ieee802154_getreq.c @@ -195,3 +195,17 @@ int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr) return ret; } + +int ieee802154_getmaxretries(int fd, FAR uint8_t *retries) +{ + struct ieee802154_get_req_s req; + int ret; + + req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES; + ret = ieee802154_get_req(fd, &req); + + *retries = req.attrval.mac.max_retries; + + return ret; +} + diff --git a/wireless/ieee802154/libmac/ieee802154_setreq.c b/wireless/ieee802154/libmac/ieee802154_setreq.c index 31af10651..1b0b57e08 100644 --- a/wireless/ieee802154/libmac/ieee802154_setreq.c +++ b/wireless/ieee802154/libmac/ieee802154_setreq.c @@ -148,3 +148,13 @@ int ieee802154_settxpwr(int fd, int32_t txpwr) return ieee802154_set_req(fd, &req); } + +int ieee802154_setmaxretries(int fd, uint8_t retries) +{ + struct ieee802154_set_req_s req; + + req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES; + req.attrval.mac.max_retries = retries; + + return ieee802154_set_req(fd, &req); +} \ No newline at end of file diff --git a/wireless/ieee802154/libmac/sixlowpan_getreq.c b/wireless/ieee802154/libmac/sixlowpan_getreq.c index fb3864d6b..31cce6600 100644 --- a/wireless/ieee802154/libmac/sixlowpan_getreq.c +++ b/wireless/ieee802154/libmac/sixlowpan_getreq.c @@ -188,6 +188,19 @@ int sixlowpan_getdevmode(int sock, FAR const char *ifname, return ret; } +int sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc) +{ + struct ieee802154_get_req_s req; + int ret; + + req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE; + ret = sixlowpan_get_req(sock, ifname, &req); + + *promisc = req.attrval.mac.promisc_mode; + + return ret; +} + int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr) { struct ieee802154_get_req_s req; @@ -200,3 +213,18 @@ int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr) return ret; } + +int sixlowpan_getmaxretries(int sock, FAR const char *ifname, FAR uint8_t *retries) +{ + struct ieee802154_get_req_s req; + int ret; + + req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES; + ret = sixlowpan_get_req(sock, ifname, &req); + + *retries = req.attrval.mac.max_retries; + + return ret; +} + + diff --git a/wireless/ieee802154/libmac/sixlowpan_setreq.c b/wireless/ieee802154/libmac/sixlowpan_setreq.c index 3252793ba..5942c0267 100644 --- a/wireless/ieee802154/libmac/sixlowpan_setreq.c +++ b/wireless/ieee802154/libmac/sixlowpan_setreq.c @@ -155,3 +155,13 @@ int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr) return sixlowpan_set_req(sock, ifname, &req); } + +int sixlowpan_setmaxretries(int sock, FAR const char *ifname, uint8_t retries) +{ + struct ieee802154_set_req_s req; + + req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES; + req.attrval.mac.max_retries = retries; + + return sixlowpan_set_req(sock, ifname, &req); +}