drivers: wireless: Add retry sequence in gs2200m_send_cmd()

Summary:
- This commit is a workaround to avoid errors in gs2200m_send_cmd()
- See the actual sequence in Testing for details

Impact:
- gs2200m driver

Testing:
- Test with spresense:wifi
- 1-1 Run tcpclient on NuttX and run nc on Linux
- 1-2 Stop nc on Linux then tcpclient also stops
- 1-3 Run tcpclient then the first AT+NCTCP will fail
- 1-4 But the second AT+NCTCP will succeed
- 2-1 Run tcpclient on NuttX and run nc on Linux
- 2-2 Stop nc on Linux then tcpclient also stops
- 2-3 Run tcpserver then the first AT+NSTCP will fail
- 2-4 But the second AT+NSTCP will succeed

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa
2020-08-11 09:39:43 +09:00
committed by Xiang Xiao
parent a10e9615ca
commit a104490b00
+19
View File
@@ -1450,6 +1450,7 @@ static enum pkt_type_e gs2200m_send_cmd(FAR struct gs2200m_dev_s *dev,
{
enum spi_status_e s;
enum pkt_type_e r = TYPE_SPI_ERROR;
int n = 1;
/* Disable gs2200m irq to poll dready */
@@ -1457,6 +1458,8 @@ static enum pkt_type_e gs2200m_send_cmd(FAR struct gs2200m_dev_s *dev,
wlinfo("+++ cmd=%s", cmd);
retry:
s = gs2200m_hal_write(dev, cmd, strlen(cmd));
r = _spi_err_to_pkt_type(s);
@@ -1467,6 +1470,22 @@ static enum pkt_type_e gs2200m_send_cmd(FAR struct gs2200m_dev_s *dev,
r = gs2200m_recv_pkt(dev, pkt_dat);
/* NOTE: retry in case of errors */
if ((TYPE_OK != r) && (0 <= --n))
{
if (pkt_dat)
{
/* release & initialize pkt_dat before retry */
_release_pkt_dat(dev, pkt_dat);
memset(pkt_dat, 0, sizeof(pkt_dat));
}
wlwarn("*** retry cmd=%s (n=%d) \n", cmd, n);
goto retry;
}
errout:
/* Enable gs2200m irq again */