Skip to content
Permalink
Browse files

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>
  • Loading branch information...
Loic Poulain authored and jukkar committed Feb 13, 2019
1 parent 38129ce commit 50fa6bdd5e60addca8cd0da226a7125107c7730a
Showing with 29 additions and 4 deletions.
  1. +1 −0 drivers/wifi/eswifi/eswifi.h
  2. +23 −4 drivers/wifi/eswifi/eswifi_bus_spi.c
  3. +5 −0 drivers/wifi/eswifi/eswifi_core.c
@@ -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
@@ -182,15 +182,34 @@ static int eswifi_spi_request(struct eswifi_dev *eswifi, char *cmd, size_t clen,

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);
@@ -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)

0 comments on commit 50fa6bd

Please sign in to comment.
You can’t perform that action at this time.