wifi: eswifi: Parse async messages

The eswifi controller can generate events via asynchronous messages
which can be polled via the 'MR\r' command. The messages will have a
Start Of Message Asynchronous [SOMA] and End Of Message Asynchronous
[EOMA] delimiters.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
This commit is contained in:
Loic Poulain 2019-02-13 10:54:50 +01:00 committed by Jukka Rissanen
commit 50fa6bdd5e
3 changed files with 29 additions and 4 deletions

View file

@ -102,5 +102,6 @@ int eswifi_offload_init(struct eswifi_dev *eswifi);
struct eswifi_dev *eswifi_by_iface_idx(u8_t iface);
int eswifi_at_cmd_rsp(struct eswifi_dev *eswifi, char *cmd, char **rsp);
int eswifi_at_cmd(struct eswifi_dev *eswifi, char *cmd);
void eswifi_async_msg(struct eswifi_dev *eswifi, char *msg, size_t len);
#endif

View file

@ -182,15 +182,34 @@ data:
static void eswifi_spi_read_msg(struct eswifi_dev *eswifi)
{
const char startstr[] = "[SOMA]";
const char endstr[] = "[EOMA]";
char cmd[] = "MR\r";
size_t msg_len;
char *rsp;
int err;
int ret;
LOG_DBG("");
eswifi_lock(eswifi);
err = eswifi_at_cmd_rsp(eswifi, cmd, &rsp);
if (err < 0) {
LOG_ERR("Unable to read msg %d", err);
ret = eswifi_at_cmd_rsp(eswifi, cmd, &rsp);
if (ret < 0) {
LOG_ERR("Unable to read msg %d", ret);
eswifi_unlock(eswifi);
return;
}
if (strncmp(rsp, startstr, sizeof(endstr) - 1)) {
LOG_ERR("Malformed async msg");
eswifi_unlock(eswifi);
return;
}
/* \r\n[SOMA]...[EOMA]\r\nOK\r\n> */
msg_len = ret - (sizeof(startstr) - 1) - (sizeof(endstr) - 1);
if (msg_len > 0) {
eswifi_async_msg(eswifi, rsp + sizeof(endstr) - 1, msg_len);
}
eswifi_unlock(eswifi);

View file

@ -487,6 +487,11 @@ static int eswifi_mgmt_connect(struct device *dev,
return err;
}
void eswifi_async_msg(struct eswifi_dev *eswifi, char *msg, size_t len)
{
LOG_DBG("len %u", len);
}
#if defined(CONFIG_NET_IPV4)
static int eswifi_mgmt_ap_enable(struct device *dev,
struct wifi_connect_req_params *params)