Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
esp.h File Reference
#include <kernel.h>
#include <net/net_context.h>
#include <net/net_if.h>
#include <net/net_ip.h>
#include <net/net_pkt.h>
#include <net/wifi_mgmt.h>
#include "modem_context.h"
#include "modem_cmd_handler.h"
#include "modem_iface_uart.h"

Go to the source code of this file.

Data Structures

struct  esp_socket
 
struct  esp_data
 

Macros

#define ESP_PROTO_PASSIVE(proto)   0
 
#define ESP_BUS   DT_BUS(DT_DRV_INST(0))
 
#define CONN_CMD_MAX_LEN
 
#define ESP_MAX_DNS   0
 
#define ESP_MAX_SOCKETS   5
 
#define ESP_MTU   2048
 
#define CIPRECVDATA_MAX_LEN   ESP_MTU
 
#define INVALID_LINK_ID   255
 
#define MDM_RING_BUF_SIZE   CONFIG_WIFI_ESP_AT_MDM_RING_BUF_SIZE
 
#define MDM_RECV_MAX_BUF   CONFIG_WIFI_ESP_AT_MDM_RX_BUF_COUNT
 
#define MDM_RECV_BUF_SIZE   CONFIG_WIFI_ESP_AT_MDM_RX_BUF_SIZE
 
#define ESP_CMD_TIMEOUT   K_SECONDS(10)
 
#define ESP_SCAN_TIMEOUT   K_SECONDS(10)
 
#define ESP_CONNECT_TIMEOUT   K_SECONDS(20)
 
#define ESP_INIT_TIMEOUT   K_SECONDS(10)
 
#define ESP_MODE_NONE   0
 
#define ESP_MODE_STA   1
 
#define ESP_MODE_AP   2
 
#define ESP_MODE_STA_AP   3
 
#define ESP_CMD_CWMODE(mode)    "AT+"_CWMODE"="STRINGIFY(_CONCAT(ESP_MODE_, mode))
 
#define ESP_CWDHCP_MODE_STATION   "1"
 
#define ESP_CWDHCP_MODE_SOFTAP   "2"
 
#define ESP_CMD_DHCP_ENABLE(mode, enable)    _ESP_CMD_DHCP_ENABLE(_CONCAT(ESP_CWDHCP_MODE_, mode), enable)
 
#define ESP_CMD_SET_IP(ip, gateway, mask)
 

Enumerations

enum  esp_socket_flags {
  ESP_SOCK_IN_USE = BIT(1) , ESP_SOCK_CONNECTING = BIT(2) , ESP_SOCK_CONNECTED = BIT(3) , ESP_SOCK_CLOSE_PENDING = BIT(4) ,
  ESP_SOCK_WORKQ_STOPPED = BIT(5)
}
 
enum  esp_data_flag { EDF_STA_CONNECTING = BIT(1) , EDF_STA_CONNECTED = BIT(2) , EDF_STA_LOCK = BIT(3) , EDF_AP_ENABLED = BIT(4) }
 

Functions

int esp_offload_init (struct net_if *iface)
 
struct esp_socketesp_socket_get (struct esp_data *data, struct net_context *context)
 
int esp_socket_put (struct esp_socket *sock)
 
void esp_socket_init (struct esp_data *data)
 
void esp_socket_close (struct esp_socket *sock)
 
void esp_socket_rx (struct esp_socket *sock, struct net_buf *buf, size_t offset, size_t len)
 
void esp_socket_workq_stop_and_flush (struct esp_socket *sock)
 
struct esp_socketesp_socket_ref (struct esp_socket *sock)
 
void esp_socket_unref (struct esp_socket *sock)
 
static struct esp_socketesp_socket_ref_from_link_id (struct esp_data *data, uint8_t link_id)
 
static atomic_val_t esp_socket_flags_update (struct esp_socket *sock, atomic_val_t value, atomic_val_t mask)
 
static atomic_val_t esp_socket_flags_clear_and_set (struct esp_socket *sock, atomic_val_t clear_flags, atomic_val_t set_flags)
 
static atomic_val_t esp_socket_flags_set (struct esp_socket *sock, atomic_val_t flags)
 
static bool esp_socket_flags_test_and_clear (struct esp_socket *sock, atomic_val_t flags)
 
static bool esp_socket_flags_test_and_set (struct esp_socket *sock, atomic_val_t flags)
 
static atomic_val_t esp_socket_flags_clear (struct esp_socket *sock, atomic_val_t flags)
 
static atomic_val_t esp_socket_flags (struct esp_socket *sock)
 
static struct esp_dataesp_socket_to_dev (struct esp_socket *sock)
 
static int esp_socket_work_submit (struct esp_socket *sock, struct k_work *work)
 
static int esp_socket_queue_tx (struct esp_socket *sock, struct net_pkt *pkt)
 
static bool esp_socket_connected (struct esp_socket *sock)
 
static void esp_flags_set (struct esp_data *dev, uint8_t flags)
 
static void esp_flags_clear (struct esp_data *dev, uint8_t flags)
 
static bool esp_flags_are_set (struct esp_data *dev, uint8_t flags)
 
static enum net_sock_type esp_socket_type (struct esp_socket *sock)
 
static enum net_ip_protocol esp_socket_ip_proto (struct esp_socket *sock)
 
static int esp_cmd_send (struct esp_data *data, const struct modem_cmd *handlers, size_t handlers_len, const char *buf, k_timeout_t timeout)
 
void esp_connect_work (struct k_work *work)
 
void esp_recvdata_work (struct k_work *work)
 
void esp_close_work (struct k_work *work)
 
void esp_send_work (struct k_work *work)
 

Variables

struct esp_data esp_driver_data
 

Macro Definition Documentation

◆ CIPRECVDATA_MAX_LEN

#define CIPRECVDATA_MAX_LEN   ESP_MTU

◆ CONN_CMD_MAX_LEN

#define CONN_CMD_MAX_LEN
Value:
(sizeof("AT+"_CWJAP"=\"\",\"\"") + \
#define WIFI_SSID_MAX_LEN
Definition: wifi.h:20
#define WIFI_PSK_MAX_LEN
Definition: wifi.h:21

◆ ESP_BUS

#define ESP_BUS   DT_BUS(DT_DRV_INST(0))

◆ ESP_CMD_CWMODE

#define ESP_CMD_CWMODE (   mode)     "AT+"_CWMODE"="STRINGIFY(_CONCAT(ESP_MODE_, mode))

◆ ESP_CMD_DHCP_ENABLE

#define ESP_CMD_DHCP_ENABLE (   mode,
  enable 
)     _ESP_CMD_DHCP_ENABLE(_CONCAT(ESP_CWDHCP_MODE_, mode), enable)

◆ ESP_CMD_SET_IP

#define ESP_CMD_SET_IP (   ip,
  gateway,
  mask 
)
Value:
"AT+"_CIPSTA"=\"" \
ip "\",\"" gateway "\",\"" mask "\""

◆ ESP_CMD_TIMEOUT

#define ESP_CMD_TIMEOUT   K_SECONDS(10)

◆ ESP_CONNECT_TIMEOUT

#define ESP_CONNECT_TIMEOUT   K_SECONDS(20)

◆ ESP_CWDHCP_MODE_SOFTAP

#define ESP_CWDHCP_MODE_SOFTAP   "2"

◆ ESP_CWDHCP_MODE_STATION

#define ESP_CWDHCP_MODE_STATION   "1"

◆ ESP_INIT_TIMEOUT

#define ESP_INIT_TIMEOUT   K_SECONDS(10)

◆ ESP_MAX_DNS

#define ESP_MAX_DNS   0

◆ ESP_MAX_SOCKETS

#define ESP_MAX_SOCKETS   5

◆ ESP_MODE_AP

#define ESP_MODE_AP   2

◆ ESP_MODE_NONE

#define ESP_MODE_NONE   0

◆ ESP_MODE_STA

#define ESP_MODE_STA   1

◆ ESP_MODE_STA_AP

#define ESP_MODE_STA_AP   3

◆ ESP_MTU

#define ESP_MTU   2048

◆ ESP_PROTO_PASSIVE

#define ESP_PROTO_PASSIVE (   proto)    0

◆ ESP_SCAN_TIMEOUT

#define ESP_SCAN_TIMEOUT   K_SECONDS(10)

◆ INVALID_LINK_ID

#define INVALID_LINK_ID   255

◆ MDM_RECV_BUF_SIZE

#define MDM_RECV_BUF_SIZE   CONFIG_WIFI_ESP_AT_MDM_RX_BUF_SIZE

◆ MDM_RECV_MAX_BUF

#define MDM_RECV_MAX_BUF   CONFIG_WIFI_ESP_AT_MDM_RX_BUF_COUNT

◆ MDM_RING_BUF_SIZE

#define MDM_RING_BUF_SIZE   CONFIG_WIFI_ESP_AT_MDM_RING_BUF_SIZE

Enumeration Type Documentation

◆ esp_data_flag

Enumerator
EDF_STA_CONNECTING 
EDF_STA_CONNECTED 
EDF_STA_LOCK 
EDF_AP_ENABLED 

◆ esp_socket_flags

Enumerator
ESP_SOCK_IN_USE 
ESP_SOCK_CONNECTING 
ESP_SOCK_CONNECTED 
ESP_SOCK_CLOSE_PENDING 
ESP_SOCK_WORKQ_STOPPED 

Function Documentation

◆ esp_close_work()

void esp_close_work ( struct k_work work)

◆ esp_cmd_send()

static int esp_cmd_send ( struct esp_data data,
const struct modem_cmd *  handlers,
size_t  handlers_len,
const char *  buf,
k_timeout_t  timeout 
)
inlinestatic

◆ esp_connect_work()

void esp_connect_work ( struct k_work work)

◆ esp_flags_are_set()

static bool esp_flags_are_set ( struct esp_data dev,
uint8_t  flags 
)
inlinestatic

◆ esp_flags_clear()

static void esp_flags_clear ( struct esp_data dev,
uint8_t  flags 
)
inlinestatic

◆ esp_flags_set()

static void esp_flags_set ( struct esp_data dev,
uint8_t  flags 
)
inlinestatic

◆ esp_offload_init()

int esp_offload_init ( struct net_if iface)

◆ esp_recvdata_work()

void esp_recvdata_work ( struct k_work work)

◆ esp_send_work()

void esp_send_work ( struct k_work work)

◆ esp_socket_close()

void esp_socket_close ( struct esp_socket sock)

◆ esp_socket_connected()

static bool esp_socket_connected ( struct esp_socket sock)
inlinestatic

◆ esp_socket_flags()

static atomic_val_t esp_socket_flags ( struct esp_socket sock)
inlinestatic

◆ esp_socket_flags_clear()

static atomic_val_t esp_socket_flags_clear ( struct esp_socket sock,
atomic_val_t  flags 
)
inlinestatic

◆ esp_socket_flags_clear_and_set()

static atomic_val_t esp_socket_flags_clear_and_set ( struct esp_socket sock,
atomic_val_t  clear_flags,
atomic_val_t  set_flags 
)
inlinestatic

◆ esp_socket_flags_set()

static atomic_val_t esp_socket_flags_set ( struct esp_socket sock,
atomic_val_t  flags 
)
inlinestatic

◆ esp_socket_flags_test_and_clear()

static bool esp_socket_flags_test_and_clear ( struct esp_socket sock,
atomic_val_t  flags 
)
inlinestatic

◆ esp_socket_flags_test_and_set()

static bool esp_socket_flags_test_and_set ( struct esp_socket sock,
atomic_val_t  flags 
)
inlinestatic

◆ esp_socket_flags_update()

static atomic_val_t esp_socket_flags_update ( struct esp_socket sock,
atomic_val_t  value,
atomic_val_t  mask 
)
inlinestatic

◆ esp_socket_get()

struct esp_socket * esp_socket_get ( struct esp_data data,
struct net_context context 
)

◆ esp_socket_init()

void esp_socket_init ( struct esp_data data)

◆ esp_socket_ip_proto()

static enum net_ip_protocol esp_socket_ip_proto ( struct esp_socket sock)
inlinestatic

◆ esp_socket_put()

int esp_socket_put ( struct esp_socket sock)

◆ esp_socket_queue_tx()

static int esp_socket_queue_tx ( struct esp_socket sock,
struct net_pkt pkt 
)
inlinestatic

◆ esp_socket_ref()

struct esp_socket * esp_socket_ref ( struct esp_socket sock)

◆ esp_socket_ref_from_link_id()

static struct esp_socket * esp_socket_ref_from_link_id ( struct esp_data data,
uint8_t  link_id 
)
inlinestatic

◆ esp_socket_rx()

void esp_socket_rx ( struct esp_socket sock,
struct net_buf buf,
size_t  offset,
size_t  len 
)

◆ esp_socket_to_dev()

static struct esp_data * esp_socket_to_dev ( struct esp_socket sock)
inlinestatic

◆ esp_socket_type()

static enum net_sock_type esp_socket_type ( struct esp_socket sock)
inlinestatic

◆ esp_socket_unref()

void esp_socket_unref ( struct esp_socket sock)

◆ esp_socket_work_submit()

static int esp_socket_work_submit ( struct esp_socket sock,
struct k_work work 
)
inlinestatic

◆ esp_socket_workq_stop_and_flush()

void esp_socket_workq_stop_and_flush ( struct esp_socket sock)

Variable Documentation

◆ esp_driver_data

struct esp_data esp_driver_data
extern