drivers/wireless/ieee802154/xbee: Cancel query timeout upon receiving the expected response. Add protection for race condition that can cause association timeout to continue firing repeatedly

This commit is contained in:
Anthony Merlino 2019-01-11 01:31:57 +04:00
parent bc60397e48
commit 3529be7d9b
3 changed files with 10 additions and 2 deletions

View File

@ -637,6 +637,7 @@ static void xbee_process_apiframes(FAR struct xbee_priv_s *priv,
frame->io_data[frame->io_offset] != 0x13)
{
wd_cancel(priv->assocwd);
priv->associating = false;
primitive = ieee802154_primitive_allocate();
primitive->type = IEEE802154_PRIMITIVE_CONF_ASSOC;
@ -724,6 +725,7 @@ static void xbee_process_apiframes(FAR struct xbee_priv_s *priv,
if ((priv->querycmd[0] == *command) &&
(priv->querycmd[1] == *(command + 1)))
{
wd_cancel(priv->atquery_wd);
priv->querydone = true;
nxsem_post(&priv->atresp_sem);
}

View File

@ -167,6 +167,7 @@ struct xbee_priv_s
* callback to registered receivers */
WDOG_ID assocwd; /* Association watchdog */
struct work_s assocwork; /* For polling for association status */
bool associating; /* Are we currently associating */
sem_t atquery_sem; /* Only allow one AT query at a time */
sem_t atresp_sem; /* For signaling pending AT response received */
char querycmd[2]; /* Stores the pending AT Query command */

View File

@ -146,9 +146,12 @@ static void xbee_assocworker(FAR void *arg)
{
FAR struct xbee_priv_s *priv = (FAR struct xbee_priv_s *)arg;
if (priv->associating)
{
xbee_send_atquery(priv, "AI");
(void)wd_start(priv->assocwd, XBEE_ASSOC_POLLDELAY, xbee_assoctimer, 1, (wdparm_t)arg);
}
}
/****************************************************************************
@ -660,6 +663,8 @@ int xbee_req_associate(XBEEHANDLE xbee, FAR struct ieee802154_assoc_req_s *req)
xbee_set_epassocflags(priv, XBEE_EPASSOCFLAGS_AUTOASSOC);
priv->associating = true;
/* In order to track the association status, we must poll the device for
* an update.
*/