i8sak: Adds option to assoc command -t to specify how long to wait for a response from the Coordinator

This commit is contained in:
Anthony Merlino 2017-07-01 17:14:17 -04:00
parent 8494017164
commit 509ac5d510

View File

@ -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 ieee802154_assoc_req_s assocreq;
struct wpanlistener_eventfilter_s filter; struct wpanlistener_eventfilter_s filter;
FAR struct ieee802154_pandesc_s *pandesc; FAR struct ieee802154_pandesc_s *pandesc;
struct ieee802154_set_req_s setreq;
bool retry = false; bool retry = false;
int maxretries = 0; int maxretries = 0;
int retrycnt; int retrycnt;
@ -92,6 +93,9 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
int ret; int ret;
uint8_t resindex; 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 /* 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 * 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 * 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; optcnt = 0;
while ((option = getopt(argc, argv, ":hr:s:e:w:")) != ERROR) while ((option = getopt(argc, argv, ":hr:s:e:w:t:")) != ERROR)
{ {
optcnt++; optcnt++;
switch (option) 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" " -h = this help menu\n"
" -w = wait and retry on failure\n" " -w = wait and retry on failure\n"
" -r = use scan result index\n" " -r = use scan result index\n"
" -s = coordinator short address"
" -e = coordinator ext address"
" -t = response wait time"
, argv[0]); , argv[0]);
/* Must manually reset optind if we are going to exit early */ /* 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; break;
case 's': 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_str2saddr(optarg, i8sak->ep.saddr);
i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT; i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT;
@ -156,6 +163,12 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED; i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED;
break; break;
case 't':
/* Parse wait time and set the paremeter in the request */
setreq.attrval.mac.resp_waittime = i8sak_str2luint8(optarg);
break;
case 'w': case 'w':
/* Wait and retry if we fail to associate */ /* 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); i8sak_cmd_error(i8sak);
} }
ieee802154_set_req(fd, &setreq);
/* Register new callback for receiving the association notifications. */ /* Register new callback for receiving the association notifications. */
memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s)); memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));