From 509ac5d5101b34bd0b7dfbc3bc6aff4065bf01a3 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Sat, 1 Jul 2017 17:14:17 -0400 Subject: [PATCH] i8sak: Adds option to assoc command -t to specify how long to wait for a response from the Coordinator --- wireless/ieee802154/i8sak/i8sak_assoc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/wireless/ieee802154/i8sak/i8sak_assoc.c b/wireless/ieee802154/i8sak/i8sak_assoc.c index d06ff0bf4..5f1c3ac1c 100644 --- a/wireless/ieee802154/i8sak/i8sak_assoc.c +++ b/wireless/ieee802154/i8sak/i8sak_assoc.c @@ -83,6 +83,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) struct ieee802154_assoc_req_s assocreq; struct wpanlistener_eventfilter_s filter; FAR struct ieee802154_pandesc_s *pandesc; + struct ieee802154_set_req_s setreq; bool retry = false; int maxretries = 0; int retrycnt; @@ -92,6 +93,9 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) int ret; uint8_t resindex; + setreq.attr = IEEE802154_ATTR_MAC_RESPONSE_WAIT_TIME; + setreq.attrval.mac.resp_waittime = 32; + /* If the addresses has never been automatically or manually set before, set * it assuming that we are the default device address and the endpoint is the * default PAN Coordinator address. This is actually the way the i8sak settings @@ -104,7 +108,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) } optcnt = 0; - while ((option = getopt(argc, argv, ":hr:s:e:w:")) != ERROR) + while ((option = getopt(argc, argv, ":hr:s:e:w:t:")) != ERROR) { optcnt++; switch (option) @@ -115,6 +119,9 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) " -h = this help menu\n" " -w = wait and retry on failure\n" " -r = use scan result index\n" + " -s = coordinator short address" + " -e = coordinator ext address" + " -t = response wait time" , argv[0]); /* Must manually reset optind if we are going to exit early */ @@ -143,7 +150,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) break; case 's': - /* Parse extended address and put it into the i8sak instance */ + /* Parse short address and put it into the i8sak instance */ i8sak_str2saddr(optarg, i8sak->ep.saddr); i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT; @@ -155,6 +162,12 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) i8sak_str2eaddr(optarg, i8sak->ep.eaddr); i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED; break; + + case 't': + /* Parse wait time and set the paremeter in the request */ + + setreq.attrval.mac.resp_waittime = i8sak_str2luint8(optarg); + break; case 'w': /* Wait and retry if we fail to associate */ @@ -197,6 +210,8 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) i8sak_cmd_error(i8sak); } + ieee802154_set_req(fd, &setreq); + /* Register new callback for receiving the association notifications. */ memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));