WIFI
Common API
- group WIFI
The WIFI driver provides support for wireless data transfer between the host and an external peripheral such as a smartphone, using WiFi connection.
Typedefs
-
typedef struct pi_wifi_api_s pi_wifi_api_t
WIFI specific API.
Structure holding WIFI specific API.
Functions
-
int32_t pi_wifi_open(struct pi_device *device)
Open a WIFI device.
This function opens and intializes a WIFI device. This function must be called before using device.
- Parameters:
device – Pointer to the WIFI device structure.
- Return values:
0 – If the operation is successful.
ERRNO – Error code otherwise.
- Returns:
int32_t Operation status.
-
int32_t pi_wifi_close(struct pi_device *device)
Close a WIFI device.
This function closes an opened WIFI device. It frees all allocated objects and interfaces used.
- Parameters:
device – Pointer to the WIFI device structure.
- Return values:
0 – If the operation is successful.
ERRNO – Error code otherwise.
- Returns:
int32_t Operation status.
-
int32_t pi_wifi_ioctl(struct pi_device *device, uint32_t cmd, void *arg)
IOctl commands.
This function is used to send special command to WIFI device.
- Parameters:
device – Pointer to the WIFI device structure.
cmd – Ioctl command.
arg – Ioctl command arg.
- Returns:
Value Value depends on ioctl command.
-
int32_t pi_wifi_at_cmd(struct pi_device *device, char *cmd, char *resp)
Send AT command to WIFI device.
This function is used to send AT commands to WIFI device.
Note
The command string should be plain command, i.e. without the “AT” part.
Note
The command may or may not return a response.
- Parameters:
device – Pointer to the WIFI device structure.
cmd – Command string to send.
resp – Buffer to store response.
- Return values:
0 – If operation is successful.
ERRNO – Error code otherwise.
-
int8_t pi_wifi_connect_to_ap(struct pi_device *device, const char *ssid, const char *pwd, pi_evt_t *callback)
Connect to an access point.
This function should be used to connect to an access point.
- Parameters:
device – Pointer to the WIFI device structure.
ssid – SSID in string format.
pwd – Password in string format.
callback – Task to notify when the module is connected to the AP.
- Return values:
0 – If operation is successful.
ERRNO – Error code otherwise.
-
int8_t pi_wifi_disconnect_from_ap(struct pi_device *device)
Close a connection to the access point.
This function closes an existing access point connection.
- Parameters:
device – Pointer to the WIFI device structure.
- Return values:
0 – If operation is successful.
ERRNO – Error code otherwise.
-
int8_t pi_wifi_data_send(struct pi_device *device, char *buffer, uint32_t size)
Send data to WIFI device. Blocking API.
This function is used to send data to WIFI device.
Note
This function is synchronous, caller is blocked until transfer is finished. The pending asynchronous function is below : pi_wifi_data_send_async().
- Parameters:
device – Pointer to the WIFI structure.
buffer – Buffer to send.
size – Size of data to send.
-
ssize_t pi_wifi_data_send_async(struct pi_device *device, char *buffer, uint32_t size, pi_evt_t *task)
Send data to WIFI device. Blocking API.
This function is used to send data to WIFI device.
Note
This function is asynchronous. The pending synchronous function is : pi_wifi_data_send().
- Parameters:
device – Pointer to the WIFI structure.
buffer – Buffer to send.
size – Size of data to send.
task – Event task used to check end of transfer.
-
void pi_wifi_data_get(struct pi_device *device, char *buffer, uint32_t size)
Get data from WIFI device. Blocking API.
This function is used to retrieve data from WIFI device.
Note
This function is synchronous, caller is blocked until transfer is finished. The pending asynchronous function is below : pi_wifi_data_get_async().
- Parameters:
device – Pointer to the WIFI structure.
buffer – Buffer to store data.
size – Size of data.
-
ssize_t pi_wifi_data_get_async(struct pi_device *device, char *buffer, uint32_t size, pi_evt_t *task)
Get data from WIFI device. Non blocking API.
This function is used to retrieve data from WIFI device.
Note
This function is asynchronous. The pending synchronous function is : pi_wifi_data_get().
- Parameters:
device – Pointer to the WIFI structure.
buffer – Buffer to store data.
size – Size of data.
task – Event task used to check end of transfer.
-
int8_t pi_wifi_create_tcp_server(struct pi_device *device, uint16_t port)
Open a TCP server socket on the device.
- Parameters:
device – Device to configure as a TCP server
port – Local port number of the socket
- Return values:
0 – for success
- Returns:
int8_t Code for success/error operation
-
int8_t pi_wifi_create_tcp_client(struct pi_device *device, char *server_ip, uint16_t server_port, uint16_t port)
Open a TCP client socket on the device.
- Parameters:
device – Device to configure as a TCP client
server_ip – IP of the server
server_port – Port number of the server
port – Local port number of the socket
- Return values:
0 – for success
- Returns:
int8_t Code for success/error operation
-
int8_t pi_wifi_close_session(struct pi_device *device)
Close the previously open session it detect autmatically if it was a TCP client or server one.
- Parameters:
device – Device to configure as a TCP client
- Return values:
0 – for success
- Returns:
int8_t Code for success/error operation
-
int8_t pi_wifi_catch_client_connection(struct pi_device *device, char *resp, pi_evt_t *callback)
Look for an incoming client connection on the device (pre-configured as a TCP server)
- Parameters:
device – Device pre-configured as a TCP server
resp – [out] Pointer for the response got from the client connection. Useful to know the IP and the port of the client.
callback – [in] Task to notify when a client is connecting.
- Return values:
0 – for success
- Returns:
int8_t Code for success/error operation
-
int8_t pi_wifi_catch_event(struct pi_device *device, char *resp, pi_evt_t *callback)
Look for an incoming event, and catch it.
- Parameters:
device – Device pre-configured as a TCP server or a TCP client
resp – [out] Buffer to store the event
callback – [in] Task to notify when an event appears
- Return values:
0 – for success
- Returns:
int8_t Code for success/error operation
-
struct pi_wifi_api_s
- #include <wifi.h>
WIFI specific API.
Structure holding WIFI specific API.
Public Members
-
int32_t (*at_cmd)(struct pi_device *device, char *cmd, char *resp)
Function to send AT command.
-
int8_t (*connect_to_ap)(struct pi_device *device, const char *ssid, const char *pwd, pi_evt_t *callback)
Function to connect WIFI device to an AP.
-
int8_t (*disconnect_from_ap)(struct pi_device *device)
Function to disconnect WIFI device from a currently associated AP.
-
int8_t (*create_tcp_server)(struct pi_device *device, uint16_t port)
Function to create a TCP server.
-
int8_t (*create_tcp_client)(struct pi_device *device, char *server_ip, uint16_t server_port, uint16_t port)
Function to create a TCP client.
-
int8_t (*close_session)(struct pi_device *device)
Function to close TCP client or server.
-
int8_t (*catch_client_connection)(struct pi_device *device, char *resp, pi_evt_t *callback)
Function to catch a client connection.
-
int8_t (*catch_event)(struct pi_device *device, char *resp, pi_evt_t *callback)
Function to catch an event.
-
int32_t (*at_cmd)(struct pi_device *device, char *cmd, char *resp)
-
typedef struct pi_wifi_api_s pi_wifi_api_t
DA16200
- group DA16200
The da16200 driver provides support for data transfer using a WiFi module, here a da16200 WiFi module. This module is interfaced on GAP9_EVK through UART. SPI isn’t supported for now.
Typedefs
-
typedef pi_da16200_data_t da16200_t
Enums
Functions
-
void pi_wifi_da16200_client_ip_port_set(pi_device_t *device, const char *client_ip_port)
Set struct pi_da16200_data_t’s client_ip_port field.
- Parameters:
device – [in]
client_ip_port – [in]
-
void pi_wifi_da16200_dpm_set(pi_device_t *device, uint8_t enable)
-
uint8_t pi_wifi_da16200_dpm_get(pi_device_t *device)
-
int32_t pi_wifi_da16200_get_all_sessions_info_async(pi_device_t *device, char *resp, pi_evt_t *callback)
Variables
-
pi_device_api_t da16200_api
-
struct pi_da16200_conf_t
Public Members
-
uint8_t uart_itf
UART interface used to connect WiFi module.
-
uint32_t uart_baudrate
UART baudrate.
-
char uart_parity_bits
UART parity bits: n (None), e (Even), o (Odd)
-
uint8_t stop_bits
UART stop bits.
-
uint8_t use_ctrl_flow
UART flow control.
-
int32_t (*bsp_open)(pi_device_t*)
Open function to call to initialize the BSP part of the module.
-
int32_t (*bsp_close)(pi_device_t*)
Close function to call to deinitialize the BSP part of the module.
-
void *bsp_conf
BSP related data (May vary depending on the board used)
-
uint8_t uart_itf
-
struct pi_da16200_data_t
- #include <da16200.h>
Structure for BSP WiFi DA16200 module.
-
struct pi_da16200_conf
- #include <da16200.h>
DA16200 configuration structure.
-
typedef pi_da16200_data_t da16200_t