This section contains the Quessence™ Wireless APIs used to establish connections over Wi-Fi.

Click here to download  WLAN & BT library

rsi_driver_init

Prototype int32_t rsi_driver_init (uint8_t *buffer, uint32_t length)
Input Arguments uint8_t *buffer: Pointer to buffer from application. The driver uses this buffer to hold driver control block for its operations.

uint32_t length: Length of the buffer.

Minimum length required by driver is 3500 bytes(without any socket).

1550bytes additional memory is required for each socket.

Return Value int32_t: Status of initialization.
  • 0: Successful initialization of the driver
  • >0: Buffer provided by application is less than the driver requirement. Return value represents number of bytes required for driver to initialize.
Description This API is used to initialize the Quessence™ wireless driver.
Example Usage rsi_driver_init (global_buf, GLOBAL_BUFF_LEN);

rsi_wireless_init

Prototype int32_t rsi_wireless_init (uint16_t opermode,uint16_t coex_mode)
Input Arguments uint16_t opermode: Operating mode
  • 0 – Wi-Fi Client mode without Enterprise Security
  • 2 – Wi-Fi Client mode with Enterprise Security

uint16_t coex_mode: Coexistence mode

  • 0: WLAN only mode
  • 3: WLAN & ZigBee coexistence mode (not supported presently)
  • 5: WLAN & Bluetooth coexistence mode (not supported presently)
  • 13: WLAN & Bluetooth Low Energy coexistence mode (not supported presently)
Return Value int32_t: Status of embedded wireless features’ initialization.
  • 0: Successful Initialization of the embedded wireless features.
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • 0x0021, 0x0025, 0xFF73, 0x002C, 0xFF6E, 0xFF6F, 0xFF70, 0xFFC5: Refer to the section on Error Codes for a description of these error codes
Description This API is used to enable and initialize the module’s embedded wireless features.
Example Usage rsi_wireless_init(0, 0);

rsi_wlan_scan

Prototype int32_t rsi_wlan_scan(int8_t *ssid, uint8_t chno, rsi_rsp_scan_t *result, uint32_t length)
Input Arguments int8_t *ssid: Pointer to a buffer containing the SSID of the Access points to be scanned. This parameter is used to scan Wi-Fi network with given SSID. SSID size should be less than or equal to 32 bytes.

uint8_t chno: Channel number to perform scan. If this is ‘0’, the scan will be done in all channels. Refer to the section on Channels Supported for the values that correspond to each channel.

rsi_rsp_scan_t *result: Pointer to application buffer to be used for storing the scanned Wi-Fi networks’ information. Refer to the Scan Response Structure section for a description of the structure.

uint32_t length: Length of the result buffer in bytes to hold scan results.  Maximum of 11 scan results will be given to user.

Minimum length for application buffer is (8 + (46 * Number of scan results))

 

Return Value int32_t: Status of scan operation.
  • 0: Successful scan operation.
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • 0x0002, 0x0003, 0x0005, 0x000A, 0x0014, 0x0015, 0x001A, 0x0021, 0x0024, 0x0025, 0x0026, 0x002C: Refer to the section on Error Codes for a description of these error codes
Description This API is used to scan for the available Wi-Fi networks in the vicinity and posts the scan response to the application
Example Usage rsi_wlan_scan(“REDPINE_AP”, 0, NULL, 0);

rsi_wlan_connect

Prototype int32_t rsi_wlan_connect(int8_t *ssid, rsi_security_mode_t sec_type, void *secret_key)
Input Arguments int8_t *ssid: Pointer to buffer containing the SSID of Access point to connect to. SSID should be less than or equal to 32 bytes

rsi_security_mode_t sec_type: Security type of the Access point to connect to.

  • RSI_OPEN: Open
  • RSI_WPA: WPA-PSK
  • RSI_WPA2: WPA2-PSK

RSI_WPA_PMK:WPA-PMK

  • RSI_WPA2_PMK:WPA2-PMK
  • RSI_WEP: WEP
  • RSI_WPA_EAP: WPA-EAP
  • RSI_WAP2_EAP: WPA2-EAP
  • RSI_WPA_WPA2_MIXED: WPA/WPA2-PSK/PMK Mixed

void *secret_key: Pointer to buffer containing

·        PSK (Personal security key) for WPA/WPA2-PSK,or

·        PMK(Parwise Master Key) for WPA/WPA2-PMK or

·        password for WPA/WPA2-EAP based on security mode.

PSK should be less than 64 bytes.

PMK should be always 32 bytes.

Password should be less than 128 bytes.

 

Return Value int32_t: Status of connection to a Wi-Fi network
  • 0: Successful connection to a Wi-Fi network
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • 0x0002, 0x0003, 0x0005, 0x0008, 0x0009, 0x000A, 0x000E, 0x0014, 0x0015, 0x0016, 0x0019, 0x001A, 0x001E, 0x0020, 0x0021, 0x0024, 0x0025, 0x0026, 0x0028, 0x0039, 0x003C, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0xFFF8: Refer to the section on Error Codes for a description of these error codes
Description This API is used to connect to the specified Wi-Fi network.
Example Usage rsi_wlan_connect(“REDPINE_AP”, RSI_OPEN, NULL);

rsi_wlan_disconnect

Prototype int32_t rsi_wlan_disconnect(void)
Input Arguments None
Return Value int32_t: Status of disconnection from a Wi-Fi network
  • 0: Successful disconnection from a Wi-Fi network.
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • 0x0006, 0x0021, 0x002C, 0x0015: Refer to the section on Error Codes for a description of these error codes
Description This API is used to disconnect from a Wi-Fi network.
Example Usage rsi_wlan_disconnect();

rsi_wireless_deinit

Prototype int32_t rsi_wireless_deinit(void)
Input Arguments None.
Return Value int32_t: Status of de-initialization the wireless driver
  • 0: Successful de-initialization of the wireless driver.
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
Description This API is used to de-initialize module’s embedded wireless features.. This API should be called before rsi_wireless_init if user wants to change previous configuration.
Example Usage rsi_wireless_deinit();

rsi_wlan_set_certificate

Prototype Int32_t rsi_wlan_set_certificate (uint8_t certificate_type, uint8_t *buffer, uint32_t certificate_length)
Input Arguments uint8_t certificate_type: Type of certificate

·        1 : TLS Client Certificate

·        2 : FAST PAC File

·        3 : SSL Client Certificate

·        4 : SSL Client Private Key

·        5 : SSL CA Certificate

·        6 : SSL Server Certificate

·        7 : SSL Server Private Key

uint8_t *buffer: Pointer to the buffer which contains the certificate

uint32_t certificate_length: Certificate length

Return Value int32_t: Status of SSL/EAP certification configuration
  • 0: Successful configuration of SSL/EAP certification
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • 0x0015, 0x0021, 0x0025, 0x0026, 0x002C: Refer to the section on Error Codes for a description of these error codes.
Description This API is used to configure or load the SSL/EAP certificate into the module.
Example Usage rsi_wlan_set_certificate(RSI_SSL_CA_CERTIFICATE, cacert, (sizeof(cacert)-1));

rsi_config_ipaddress

Prototype int32_t  rsi_config_ipaddress(rsi_ip_version_t version, rsi_ip_config_mode_t mode, uint8_t *ip_addr, uint8_t *mask, uint8_t *gw, uint8_t *ipconfig_rsp, uint16_t length, uint8_t vap_id)
Input Arguments rsi_ip_version_t version: IP version
  • RSI_IP_VERSION_4: IPv4
  • RSI_IP_VERSION_6: IPv6 (not supported currently)

rsi_ip_config_mode_t mode: IP configuration mode

  • RSI_STATIC: Static IP address
  • RSI_DHCP: DHCP

uint8_t *ip_addr: Pointer to IP address (for Static IP address only)

uint8_t *mask: Pointer to network mask (for Static IP address only)

uint8_t *mask,uint8_t *gw: Pointer to gateway address (for Static IP address only)

uint8_t *ipconfig_rsp: Pointer the buffer To store the IP configuration received using DHCP. On successful DHCP this buffer holds in sequence.

uint16_t length: Length of the ipconfig_rsp buffer.

Minimum length required is 18 bytes.

uint8_t vap_id: Vap id is bit to differentiate AP and station in concurrent mode

·        0 – for station

·        1 – for Access point

Return Value int32_t: Status of IP address configuration
  • 0: Successful Configuration of IP address.
  • -2 : Invalid parameters
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • Error: 0x0021,0x0025,0x002C,0xFFFC,0xFF74,0xFF9C,0xFF9D

(Refer to the section on Error codes for a description of above error codes)

Description This API is used to assign the ip address to the module after connection establishment
Example Usage rsi_config_ipaddress(RSI_IP_VERSION_4, RSI_DHCP, 0, 0, 0, &ipv4_rsp, sizeof(ipv4_rsp),0);

 

 

rsi_wlan_get_status

Prototype int32_t rsi_wlan_get_status (void)
Input Arguments None
Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.
  • Other: Refer to the section on Error Codes for a description of the error codes.
Description This API is used to check the status (specific error code) of error encountered during a call to a WLAN API or BSD sockets functions or WLAN asynchronous events. User can call this API to check the actual error code.
Example Usage rsi_wlan_get_status ();

rsi_wlan_ap_start

Prototype int32_t rsi_wlan_ap_start(int8_t *ssid, uint8_t channel,

rsi_security_mode_t security_type,rsi_encryption_mode_t encryption_mode, uint8_t *password, uint16_t beacon_interval, uint8_t dtim_period);

Input Arguments int8_t *ssid : SSID of the Access Point. Length of the SSID should less than or equal to 32 bytes.

uint8_t channel:channel number

Note: channel number 0 is not valid in Access Point mode

rsi_security_mode_t security_type:Type of the Security mode the Access point to operate

·        0 :  RSI_OPEN

·        2:  RSI_WPA

·        3:  RSI_WPA2

·        6  :  RSI_WPA_WPA2_MIXED

·        9  :  RSI_WPS_PIN

·        10  :  RSI_USE_GENERATED_WPSPIN

·        11  :  RSI_WPS_PUSH_BUTTON

rsi_encryption_mode_t encryption_mode:Type of the encryption mode

·        0 :  RSI_NONE

·        :  RSI_TKIP

·        :  RSI_CCMP

uint8_t *password: Pointer to the buffer containing the PSK to use in security mode.

uint16_t beacon_interval:Beacon interval

uint8_t dtim_period :DTIM period

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        -4 : Buffer not available to serve the command

·        Other: Refer to the section on Error Codes for a description of the error codes.

Description This API is used to start the module in Access point mode with the given configuration. 
Example Usage rsi_wlan_ap_start(“REDPINAP”,11,RSI_OPEN,RSI_NONE,NULL,

100,4);

rsi_wireless_driver_task

Prototype void rsi_wireless_driver_task(void);
Input Arguments None
Return Value None
Description This API is used to handle driver’s events, ex: whenever an on-air packet is sent to the device/module this api is used to receive that packet. 

This API should be called in application main loop for non-OS platforms.

Example Usage rsi_wireless_driver_task ();

 

rsi_wlan_disconnect_stations

Prototype int32_t  rsi_wlan_disconnect_stations(uint8_t *mac_address);
Input Arguments uint8_t *mac_address: Pointer to the buffer containing Mac address (6 bytes) of the station to be disconnected.
Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        -4 : Buffer not available to serve the command

·        Other: Refer to the section on Error Codes for a description of the error codes.

Description This API is used to disconnect the connected stations in AP mode(device acts as AP).
Example Usage rsi_wlan_disconnect_stations (“00:23:A7:53:95:83”);

rsi_wlan_get

Prototype int32_t  rsi_wlan_get(rsi_wlan_query_cmd_t cmd_type,

uint8_t *response, uint16_t length);

Input Arguments rsi_wlan_query_cmd_t cmd_type: Query command type:

·        1: RSI_FW_VERSION

·        2: RSI_MAC_ADDRESS

·        3: RSI_RSSI

·        4: RSI_WLAN_INFO

·        5: RSI_CONNECTION_STATUS

·        6: RSI_STATIONS_INFO

·        7: RSI_SOCKETS_INFO

uint8_t *response: Pointer to the Response of the requested command, this is an output parameter. Refer to the WLAN Get Response Structure section for a description of the structure.

uint16_t length:Length of the response buffer in bytes to hold result.

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        -4 : Buffer not available to serve the command

·        Other: Refer to the section on Error Codes for a description of the error codes.

Description This API is used to get required information based on the type of command.
Example Usage rsi_wlan_get (RSI_MAC_ADDRESS,mac_addr,6);

rsi_wlan_set

Prototype int32_t  rsi_wlan_set(rsi_wlan_set_cmd_t cmd_type, uint8_t *request, uint16_t length);
Input Arguments rsi_wlan_query_cmd_t cmd_type: Set Command type

·        1: RSI_SET_MAC_ADDRESS

·        2: RSI_MULTICAST_FILTER

uint8_t *response: Request Buffer.

uint16_t length:Length of the request buffer in bytes.

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        -4 : Buffer not available to serve the command

·        Other: Refer to the section on Error Codes for a description of the error codes.

Description This API is used to set the requested configuration based on the command type.
Example Usage rsi_wlan_set (RSI_SET_MAC_ADDRESS,mac_addr,6);

rsi_transmit_test_start

Prototype int32_t  rsi_transmit_test_start( uint16_t power,uint32_t rate,uint16_t length, uint16_t mode, uint16_t channel);
Input Arguments uint16_t power: To set Tx power in dbm. The valid values are from 2dbm to 18dbm for RS9113 module.

uint32_t rate: To set transmit data rate. Refer to the Data Rate Mapping section for a description of the values supported.

uint16_t length: To configure length of the tx packet. Valid values are in the range of 24 to 1500 bytes in the burst mode and range of 24 to 260 bytes in the continuous mode

uint16_t mode:

·        Burst Mode

·        Continuous Mode

·        Continuous wave Mode (non modulation) in DC mode

·        Continuous wave Mode (non modulation) in single tone mode (center

·        frequency -2.5MHz)

·        Continuous wave Mode (non modulation) in single tone mode (center frequency +5MHz)

uint16_t channel: For setting the channel number in  2.4 GHz/5GHz . Refer to the Channel Number Mapping section for a description of the values supported.

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        -4 : Buffer not available to serve the command

·        Other: Refer to the section on Error Codes for a description of the error codes.

Description This API is used to start the transmit test.
Example Usage rsi_transmit_test_start(4,RSI_RATE_1,30,RSI_BURST_MODE,1);

rsi_transmit_test_stop

Prototype int32_t  rsi_transmit_test_stop(void);
Input Arguments None
Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.
  • Other: Refer to the section on Error Codes for a description of the error codes.
Description This API is used to stop the transmit test.
Example Usage rsi_transmit_test_stop ();

rsi_wlan_receive_stats_start

Prototype int32_t  rsi_wlan_receive_stats_start(uint16_ channel);
Input Arguments uint16_ channel: Valid channel number 2.4GHz or 5GHz.
Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.
  • Other: Refer to the section on Error Codes for a description of the error codes.
Description This API is used to get the Receive (RX) packets statistics. When this API is called by the host with valid channel number, module gives the statistics to host for every second.
Example Usage rsi_wlan_receive_stats_start (11);

rsi_wlan_receive_stats_stop

Prototype int32_t  rsi_wlan_receive_stats_stop(void);
Input Arguments None.
Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.
  • Other: Refer to the section on Error Codes for a description of the error codes.
Description This API is used to stop the Receive(RX) packets statistics.
Example Usage rsi_wlan_receive_stats_stop ();

rsi_wlan_send_data

Prototype int32_t  rsi_wlan_send_data(uint8_t *buffer, uint32_t length);
Input Arguments int8_t *buffer: Pointer to the buffer containing data to be sent.

uint32_t length: Length of the buffer.

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.
  • Other: Refer to the section on Error Codes for a description of the error codes.
Description This API is used to send raw data packet to module
Example Usage rsi_wlan_send_data (“TEST”,(sizeof(“TEST”)-1));

rsi_wlan_register_callbacks

Prototype uint16_t rsi_wlan_register_callbacks(uint32_t callback_id, void (*callback_handler_ptr)(uint16_t status, const uint8_t *buffer, const uint32_t length));
Input Arguments uint32_t call_back_id: Id of call back function

Following ids are supported:

·        0 – RSI_JOIN_FAIL_CB

·        1 – RSI_IP_FAIL_CB

·        2 -RSI_REMOTE_SOCKET_TERMINATE_CB

·        3- RSI_IP_CHANGE_NOTIFY_CB

·        4- RSI_STATIONS_CONNECT_NOTIFY_CB

·        5- RSI_STATIONS_DISCONNECT_NOTIFY_CB

·        6– RSI_WLAN_DATA_RECEIVE_NOTIFY_CB

*call_back_handler_ptr(uint32_t *status, const uint8_t *buffer, const uint32_t length: Call back handler

·        Status : status of the asynchronous response

·        Buffer : payload of the asynchronous response

·        Length : length of the payload

Return Value int32_t: Error Code for failures in Wi-Fi connection or socket communication
  • 0: No failure.

·        1: Failed Callback

  • If call_back_id is greater than Maximum call backs to register , returns 1
Description This API is used to register wlan call back based on the call back id.
Example Usage rsi_wlan_register_callbacks (RSI_STATIONS_CONNECT_NOTIFY_CB,rsi_stations_connect_notify_handler);