CMSIS-Driver: WiFi Bypass Mode

| CMSIS-Driver Version 2.7.1 Peripheral Interface for Middleware and Application Code

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
WiFi Bypass Mode
WiFi Interface

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). More...
int32_t | ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len)
| Send Ethernet frame (in bypass mode only). More...
int32_t | ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len)
| Read data of received Ethernet frame (in bypass mode only). More...
uint32_t | ARM_WIFI_EthGetRxFrameSize (uint32_t interface)
| Get size of received Ethernet frame (in bypass mode only). More...

## 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 IP stack is running on the microcontroller. The internal 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

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] | interface | Interface (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
  - ARM_DRIVER_OK : Operation successful
  - ARM_DRIVER_ERROR : Operation failed
  - ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
  - ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or mode)

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);
wifi->PowerControl (ARM_POWER_FULL);
// 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
}

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

Send Ethernet frame (in bypass mode only).

Parameters

  [in] | interface | Interface (0 = Station, 1 = Access Point)
  [in] | frame | Pointer to frame buffer with data to send
  [in] | len | Frame buffer length in bytes

Returns
  execution status
  - ARM_DRIVER_OK : Operation successful
  - ARM_DRIVER_ERROR : Operation failed
  - ARM_DRIVER_ERROR_BUSY : Driver is busy
  - ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
  - ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or NULL frame pointer)

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
}

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] | interface | Interface (0 = Station, 1 = Access Point)
  [in] | frame | Pointer to frame buffer for data to read into
  [in] | len | Frame buffer length in bytes

Returns
  number of data bytes read or error code
  - value >= 0 : Number of data bytes read
  - ARM_DRIVER_ERROR : Operation failed
  - ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
  - ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or NULL frame pointer)

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
}

uint32_t ARM_WIFI_EthGetRxFrameSize | ( | uint32_t | interface | ) |

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

Parameters

  [in] | interface | Interface (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:

- see ARM_WIFI_EthReadFrame