CMSIS-Driver  
Peripheral Interface for Middleware and Application Code
 
Loading...
Searching...
No Matches
WiFi Bypass Mode

Transfer Ethernet frames by WiFi module. More...

Functions

int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode)
 Enable or disable bypass (pass-through) mode. Transmit and receive Ethernet frames (IP layer bypassed and WiFi/Ethernet translation).
 
int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len)
 Send Ethernet frame (in bypass mode only).
 
int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len)
 Read data of received Ethernet frame (in bypass mode only).
 
uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface)
 Get size of received Ethernet frame (in bypass mode only).
 

Description

Transfer Ethernet frames by WiFi module.

The WiFi Bypass Mode functions are an optional interface and enable the transmission of Ethernet frames with WiFi modules. The use of this interface requires that the TCP/IP stack is running on the microcontroller (usually a third-party or open-source networking component). The internal TCP/IP stack of the WiFi module is therefore not used, and this usually means that the WiFi Socket functions can not be used.

Function Documentation

◆ ARM_WIFI_BypassControl()

int32_t ARM_WIFI_BypassControl ( uint32_t  interface,
uint32_t  mode 
)

Enable or disable bypass (pass-through) mode. Transmit and receive Ethernet frames (IP layer bypassed and WiFi/Ethernet translation).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]mode
  • value = 1: all packets bypass internal IP stack
  • value = 0: all packets processed by internal IP stack
Returns
execution status

The function ARM_WIFI_BypassControl enables or disables the WiFi bypass mode.

The WiFi Bypass mode can only be enabled, if there is a bypass mode supported in the WiFi driver. You can check this by checking the driver's capabilities.

Note
Bypass mode is enabled by default if the module does not support the Socket interface.

The argument mode specifies the desired state of the WiFi Bypass mode, which is enabled or disabled.

Example:

extern ARM_DRIVER_WIFI Driver_WiFi0;
static ARM_DRIVER_WIFI *wifi;
static ARM_ETH_MAC_ADDR own_mac_address;
static void wifi_notify (uint32_t event, ,void *arg) {
switch (event) {
:
}
}
void initialize_wifi_bypass (void) {
ARM_WIFI_CAPABILITIES capabilities;
wifi = &Driver_WiFi0;
capabilities = wifi->GetCapabilities ();
if (capabilities.bypass_mode == 0) {
// error handling
}
// Initialize and Power-on WiFi Interface
wifi->Initialize ((capabilities.eth_rx_frame_event) ? wifi_notify : NULL);
// populate own_mac_address with the address to use for station
wifi->SetOption(0U, ARM_WIFI_MAC, &own_mac_address, 6U);
wifi->BypassControl (0U, 1U); // Enable bypass mode for station
}
@ ARM_POWER_FULL
Power on: full operation at maximum performance.
Definition: Driver_Common.h:66
#define ARM_WIFI_MAC
Station/AP Set/Get MAC; data = &mac, len = 6, uint8_t[6].
Ethernet MAC Address.
Definition: Driver_ETH.h:83
uint32_t bypass_mode
Bypass or pass-through mode (Ethernet interface)
Definition: Driver_WiFi.h:615
WiFi Driver Capabilities.
Definition: Driver_WiFi.h:606
ARM_WIFI_CAPABILITIES(* GetCapabilities)(void)
Definition: Driver_WiFi.h:627
int32_t(* PowerControl)(ARM_POWER_STATE state)
Definition: Driver_WiFi.h:630
int32_t(* BypassControl)(uint32_t interface, uint32_t mode)
Definition: Driver_WiFi.h:639
int32_t(* SetOption)(uint32_t interface, uint32_t option, const void *data, uint32_t len)
Definition: Driver_WiFi.h:632
int32_t(* Initialize)(ARM_WIFI_SignalEvent_t cb_event)
Definition: Driver_WiFi.h:628
Access structure of the WiFi Driver.
Definition: Driver_WiFi.h:625

◆ ARM_WIFI_EthSendFrame()

int32_t ARM_WIFI_EthSendFrame ( uint32_t  interface,
const uint8_t *  frame,
uint32_t  len 
)

Send Ethernet frame (in bypass mode only).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]framePointer to frame buffer with data to send
[in]lenFrame buffer length in bytes
Returns
execution status

The function ARM_WIFI_EthSendFrame writes an Ethernet frame to the WiFi transmit buffer.

The WiFi bypass mode must be enabled by using the function ARM_WIFI_BypassControl before a call to this function.

The frame data addressed by frame starts with MAC destination and ends with the last Payload data byte. The frame data is copied into the transmit buffer of the WiFi interface.

The maximum value for len is implied by the size restrictions of the Ethernet frame but is not verified. Using an invalid value for len may generate unpredicted results.

Example:

status = wifi->EthSendFrame (0U, &frame_data[0], frame_length);
if (status != ARM_DRIVER_OK) {
// error handling
}
#define ARM_DRIVER_OK
Operation succeeded.

◆ ARM_WIFI_EthReadFrame()

int32_t ARM_WIFI_EthReadFrame ( uint32_t  interface,
uint8_t *  frame,
uint32_t  len 
)

Read data of received Ethernet frame (in bypass mode only).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]framePointer to frame buffer for data to read into
[in]lenFrame buffer length in bytes
Returns
number of data bytes read or error code

The function ARM_WIFI_EthReadFrame reads an Ethernet frame from the WiFi interface in the bypass mode.

The len of the Ethernet frame can be checked using the function ARM_WIFI_EthGetRxFrameSize.

The frame data addressed by frame starts with MAC destination and ends with the last Payload data byte. The frame data is read from the receive buffer of the WiFi interface and the number of bytes written into the memory addressed by frame is returned. A negative return value indicates an error whereby the status code is defined with driver common return codes.

The function ARM_WIFI_EthReadFrame may be called with buf = NULL and len = 0 to discard or release a frame. This is useful when an incorrect frame has been received or no memory is available to hold the Ethernet frame.

Example:

size = wifi->EthGetRxFrameSize ();
if ((size < 14) || (size > 1514)) { // frame excludes CRC
wifi->EthReadFrame (NULL, 0); // Frame error, release it
}
len = wifi->ReadFrame (0U, &frame_data[0], size);
if (len < 0) {
// error handling
}

◆ ARM_WIFI_EthGetRxFrameSize()

uint32_t ARM_WIFI_EthGetRxFrameSize ( uint32_t  interface)

Get size of received Ethernet frame (in bypass mode only).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
Returns
number of bytes in received frame

The function ARM_WIFI_EthGetRxFrameSize returns the size of a received Ethernet frame in the bypass mode. This function can be called before ARM_WIFI_EthReadFrame and retrieves the value len.

The frame size includes MAC destination and ends with the last Payload data byte. Value 0 indicates that no Ethernet frame is available in the receive buffer. Values smaller than minimum size of Ethernet frame or larger than maximum size of Ethernet frame indicate an invalid frame which needs to be discarded by calling ARM_WIFI_EthReadFrame.

Example: