API  2.2
TSmarT Software Library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions

Functions

int8_t TSMART_XBEE_WIFI_Init (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_config_t *TSMART_XBEE_WIFI_config)
 Initialize the XBee module.. More...
 
int8_t TSMART_XBEE_WIFI_InitStruct (tsmart_xbee_wifi_config_device_t *TSMART_XBEE_WIFI_config_device)
 Init Struct function. More...
 
int8_t TSMART_XBEE_WIFI_Config (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_config_device_t *TSMART_XBEE_WIFI_config_device)
 Configuration for XBee wifi device. More...
 
int8_t TSMART_XBEE_WIFI_ReadIp (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, uint8_t *TSMART_XBEE_WIFI_ip)
 Reads IP. More...
 
int8_t TSMART_XBEE_WIFI_ReadMask (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, uint8_t *TSMART_XBEE_WIFI_mask)
 Reads local IP mask address. More...
 
int8_t TSMART_XBEE_WIFI_ReadIpGw (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, uint8_t *TSMART_XBEE_WIFI_ip_gw)
 Reads IP gateway address. More...
 
tsmart_xbee_wifi_status_message_t TSMART_XBEE_WIFI_ReadSatus (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, portTickType TSMART_XBEE_WIFI_timeout)
 Reads one status message. More...
 
tsmart_xbee_wifi_ai_t TSMART_XBEE_WIFI_AssociationIndication (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI)
 Association Indication. More...
 
int8_t TSMART_XBEE_WIFI_NetworkReset (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI)
 Network resets. More...
 
int8_t TSMART_XBEE_WIFI_PowerSignalReceived (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI)
 Reports the RF power signal (RSSI) of last received packet. More...
 
uint8_t TSMART_XBEE_WIFI_ReadXBeeAddress (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_addr_t *TSMART_XBEE_WIFI_addr)
 Reads the XBee address. More...
 
int32_t TSMART_XBEE_WIFI_Send (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, uint8_t *TSMART_XBEE_WIFI_buf, uint32_t TSMART_XBEE_WIFI_nbytes, portTickType TSMART_XBEE_WIFI_xticks)
 Sends data to XBee module. More...
 
int32_t TSMART_XBEE_WIFI_Receive (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, uint8_t *TSMART_XBEE_WIFI_buf, uint32_t TSMART_XBEE_WIFI_nbytes, portTickType TSMART_XBEE_WIFI_xticks)
 Receives data from the XBee module. More...
 
int8_t TSMART_XBEE_WIFI_AtCommandMode (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_flag_t TSMART_XBEE_WIFI_flag)
 Enter or exit from the AT command mode. More...
 
int8_t TSMART_XBEE_WIFI_TransparentMode (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_flag_t TSMART_XBEE_WIFI_flag)
 Enter/Exit from transparent mode to receive or send data. More...
 
void TSMART_XBEE_WIFI_ResetHw (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI)
 Resets hardware. More...
 
int8_t TSMART_XBEE_WIFI_ReciveIpv4Frame (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_ipv4_data_received_t *TSMART_XBEE_WIFI_ipv4_data, portTickType TSMART_XBEE_WIFI_xticks)
 Receives a IPv4 frame in API mode. More...
 
int8_t TSMART_XBEE_WIFI_SendIpv4Frame (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_ipv4_data_to_send_t *TSMART_XBEE_WIFI_data, portTickType TSMART_XBEE_WIFI_xticks)
 Sends a IPv4 frame in API mode. More...
 
int8_t TSMART_XBEE_WIFI_Recive802Frame (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_802_data_received_t *TSMART_XBEE_WIFI_802_data, portTickType TSMART_XBEE_WIFI_xticks)
 Receives a 802 frame in API mode. More...
 
int8_t TSMART_XBEE_WIFI_Send802Frame (tsmart_xbee_wifi_t *TSMART_XBEE_WIFI, tsmart_xbee_wifi_802_data_to_send_t *TSMART_XBEE_WIFI_data, portTickType TSMART_XBEE_WIFI_xticks)
 Sends 802 frame in API mode. More...
 

Detailed Description

Function Documentation

tsmart_xbee_wifi_ai_t TSMART_XBEE_WIFI_AssociationIndication ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI)

Association Indication.

Reads information regarding last node join request.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
Returns
        @arg TSMART_XBEE_WIFI_AI_1 - Successfully joined an access point, established IP addresses and IP listening sockets.
        @arg TSMART_XBEE_WIFI_AI_2 - WiFi initialization in progress. This status should only be seen for a few milliseconds.
        @arg TSMART_XBEE_WIFI_AI_3 - Disconnecting from access point.
        @arg TSMART_XBEE_WIFI_AI_4 - Selected SSID not found.
        @arg TSMART_XBEE_WIFI_AI_5 - SSID not configured (an active scan can occur in this state).
        @arg TSMART_XBEE_WIFI_AI_6 - SSID was found, but join failed.
        @arg TSMART_XBEE_WIFI_AI_7 - Module joined a network and is waiting for IP configuration to complete, which usually means it is waiting for a DHCP provided address.
        @arg TSMART_XBEE_WIFI_AI_8 - Module is joined, IP is configured, and listening sockets are being set up.
        @arg TSMART_XBEE_WIFI_AI_9 - Module is currently scanning for the configured SSID.
    @arg TSMART_XBEE_WIFI_AI_10 - Wrong answer or there's not answer.
int8_t TSMART_XBEE_WIFI_AtCommandMode ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_flag_t  TSMART_XBEE_WIFI_flag 
)

Enter or exit from the AT command mode.

Using this function is possible to send AT commands to the XBee module using the TSMART_XBEE_WIFI_Send() and TSMART_XBEE_WIFI_Receive() functions.

Parameters
TSMART_XBEE_WIFIXBee structure handler.
TSMART_XBEE_WIFI_flagLabel to enter/exit the AT command mode. This parameter shall be selected amongst the following values:
  • TSMART_XBEE_WIFI_ENABLE
  • TSMART_XBEE_WIFI_DISABLE
Returns
  • TSMART_PASS - OK
  • TSMART_XBEE_WIFI_FAULT_CODE_1 - Fails trying to enter AT command mode
  • TSMART_XBEE_WIFI_FAULT_CODE_2 - Fails trying to exit from AT command mode
  • TSMART_XBEE_WIFI_FAULT_CODE_3 - Fails trying to change the receiving mode
int8_t TSMART_XBEE_WIFI_Config ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_config_device_t TSMART_XBEE_WIFI_config_device 
)

Configuration for XBee wifi device.

This function configures XBee wifi device with user's values.

Parameters
TSMART_XBEE_WIFIXBee Wifi structure handler.
TSMART_XBEE_WIFI_config_deviceXBee Wifi configuration structure.
Returns
  • TSMART_PASS - OK
  • TSMART_XBEE_WIFI_FAULT_CODE_1 - Configuration error: Fails enter in command mode
  • TSMART_XBEE_WIFI_FAULT_CODE_2 - Configuration error: Fails changing API mode
  • TSMART_XBEE_WIFI_FAULT_CODE_3 - Configuration error: Fails applying changes
  • TSMART_XBEE_WIFI_FAULT_CODE_4 - Configuration error: Fails checking API mode
  • TSMART_XBEE_WIFI_FAULT_CODE_5 - Configuration error: Fails exit from command mode
  • TSMART_XBEE_WIFI_FAULT_CODE_6 - Configuration error: Fails setting kind of network
  • TSMART_XBEE_WIFI_FAULT_CODE_7 - Configuration error: Fails setting Channel
  • TSMART_XBEE_WIFI_FAULT_CODE_8 - Configuration error: Fails setting baud rate
  • TSMART_XBEE_WIFI_FAULT_CODE_9 - Configuration error: Fails setting flow control RTS
  • TSMART_XBEE_WIFI_FAULT_CODE_10 - Configuration error: Fails setting flow control CTS
  • TSMART_XBEE_WIFI_FAULT_CODE_11 - Configuration error: Fails setting timeout connection
  • TSMART_XBEE_WIFI_FAULT_CODE_12 - Configuration error: Fails enabling/disabling dhcp
  • TSMART_XBEE_WIFI_FAULT_CODE_13 - Configuration error: Fails changing local port
  • TSMART_XBEE_WIFI_FAULT_CODE_14 - Configuration error: Fails setting IP address device
  • TSMART_XBEE_WIFI_FAULT_CODE_15 - Configuration error: Fails setting IP address mask
  • TSMART_XBEE_WIFI_FAULT_CODE_16 - Configuration error: Fails setting IP address gateway address
  • TSMART_XBEE_WIFI_FAULT_CODE_17 - Configuration error: Fails setting destination IP
  • TSMART_XBEE_WIFI_FAULT_CODE_18 - Configuration error: Fails setting destination port
  • TSMART_XBEE_WIFI_FAULT_CODE_19 - Configuration error: Fails setting protocol
  • TSMART_XBEE_WIFI_FAULT_CODE_20 - Configuration error: Fails setting power signal
  • TSMART_XBEE_WIFI_FAULT_CODE_21 - Configuration error: Fails setting bit rate
  • TSMART_XBEE_WIFI_FAULT_CODE_22 - Configuration error: Fails setting SSID
  • TSMART_XBEE_WIFI_FAULT_CODE_23 - Configuration error: Fails setting Encrytion type
  • TSMART_XBEE_WIFI_FAULT_CODE_24 - Configuration error: Fails setting security key
  • TSMART_XBEE_WIFI_FAULT_CODE_25 - Configuration error: Fails setting API mode
Examples:
wifi_receiver.c, and wifi_sender.c.
int8_t TSMART_XBEE_WIFI_Init ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_config_t TSMART_XBEE_WIFI_config 
)

Initialize the XBee module..

This functions initializes the hardware configuration of the selected XBee wifi and the associated OS mechanisms.

Attention
This function creates one task to receive, reception task. This task should set with a high priority in the user application (14 is advisable) and has a own stack. Its target is to pick packets up quickly avoiding lose packets and parsing them. In addition this function creates several queues to manage the information received properly. This task can be change its operation mode, API to transparent or command mode and transparent or command to API mode. Check the specific TSmarT functions to make this change of operation:
Parameters
TSMART_XBEE_WIFIXBee Wifi structure handler.
TSMART_XBEE_WIFI_configIndicates the Baud rate for the microcontroller's UART, enables/disables flow control and priority reception task.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Fail
Examples:
wifi_receiver.c, and wifi_sender.c.
int8_t TSMART_XBEE_WIFI_InitStruct ( tsmart_xbee_wifi_config_device_t TSMART_XBEE_WIFI_config_device)

Init Struct function.

This function shall be called before configure the XBee wifi module to make sure having a good configuration for Xbee module. Check default values in tsmart_xbee_wifi_config_device_t definition.

Parameters
TSMART_XBEE_WIFI_config_deviceConfiguration device structure. It shall be empty.
Returns
  • TSMART_PASS - OK
Examples:
wifi_receiver.c, and wifi_sender.c.
int8_t TSMART_XBEE_WIFI_NetworkReset ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI)

Network resets.

Resets network layer. For Wifi, this means to disassociate from the access point and set SSID to NULL, thereby preventing the node from immediately establishing the same connection with the same access point. This also allows the active scan command to be executed so that access point candidates can be selected from the resultant list.

Parameters
TSMART_XBEE_WIFIXBee structure handler.
Returns
  • TSMART_PASS - OK
  • TAMART_FAIL - Failure
int8_t TSMART_XBEE_WIFI_PowerSignalReceived ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI)

Reports the RF power signal (RSSI) of last received packet.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
Returns
  • Power signal (-X dBm)
  • TSMART_FAIL - Failure
int8_t TSMART_XBEE_WIFI_ReadIp ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
uint8_t *  TSMART_XBEE_WIFI_ip 
)

Reads IP.

Parameters
TSMART_XBEE_WIFIXBee Wifi structure handler.
TSMART_XBEE_WIFI_ipLocal IP address buffer.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Failure
int8_t TSMART_XBEE_WIFI_ReadIpGw ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
uint8_t *  TSMART_XBEE_WIFI_ip_gw 
)

Reads IP gateway address.

Parameters
TSMART_XBEE_WIFIXBee Wifi structure handler.
TSMART_XBEE_WIFI_ip_gwIP gateway address buffer.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Failure
int8_t TSMART_XBEE_WIFI_ReadMask ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
uint8_t *  TSMART_XBEE_WIFI_mask 
)

Reads local IP mask address.

Parameters
TSMART_XBEE_WIFIXBee Wifi structure handler.
TSMART_XBEE_WIFI_maskLocal IP mask address buffer.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Failure
tsmart_xbee_wifi_status_message_t TSMART_XBEE_WIFI_ReadSatus ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
portTickType  TSMART_XBEE_WIFI_timeout 
)

Reads one status message.

This function remains blocked until expires a selected timeout or until one status message is received. The messages will be queued in the proper buffer until it's full (it can store 5 messages). Users should empty the buffer executing this function to avoid lose new messages.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_timeoutMaximum waiting timeout.
Returns
    @arg 0x00 - Hardware reset or power up
    @arg 0x01 - Watchdog timer reset
    @arg 0x02 - Joined
    @arg 0x03 - No longer joined to access point
    @arg 0x04 - IP configuration error
    @arg 0x82 - Send or join command issued without first connecting from access point
    @arg 0x83 - Access point not found
    @arg 0x84 - PSK not configured
    @arg 0x87 - SSID not found
    @arg 0x88 - Failed to join with security enabled
    @arg 0x8A - Invalid channel
    @arg 0x8E - Failed to join access point
    @arg TSMART_FAIL - Failure
Examples:
wifi_receiver.c, and wifi_sender.c.
uint8_t TSMART_XBEE_WIFI_ReadXBeeAddress ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_addr_t TSMART_XBEE_WIFI_addr 
)

Reads the XBee address.

This functions reads the module's unique 48-bit address.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_addrXBee wifi addr structure.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Failure
int32_t TSMART_XBEE_WIFI_Receive ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
uint8_t *  TSMART_XBEE_WIFI_buf,
uint32_t  TSMART_XBEE_WIFI_nbytes,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Receives data from the XBee module.

This function can be used to receive AT response command in command mode or to receive data in transparent mode.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_bufData buffer to store data.
TSMART_XBEE_WIFI_nbytesNumber of bytes to receive.
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
  • Bytes received
int8_t TSMART_XBEE_WIFI_Recive802Frame ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_802_data_received_t TSMART_XBEE_WIFI_802_data,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Receives a 802 frame in API mode.

This frame is used by XBee when RF data is received using the serial data service on the local port defined.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_802_dataData structure to store data.
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
nBytes sent
int8_t TSMART_XBEE_WIFI_ReciveIpv4Frame ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_ipv4_data_received_t TSMART_XBEE_WIFI_ipv4_data,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Receives a IPv4 frame in API mode.

This frame is used by XBee when RF data is received using the serial data service on the local port defined.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_ipv4_dataData structure to store data.
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
nBytes sent
Examples:
wifi_receiver.c.
void TSMART_XBEE_WIFI_ResetHw ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI)

Resets hardware.

It makes a reset of the module using a proper reset line. Not creates any message to read.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
Examples:
wifi_receiver.c, and wifi_sender.c.
int32_t TSMART_XBEE_WIFI_Send ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
uint8_t *  TSMART_XBEE_WIFI_buf,
uint32_t  TSMART_XBEE_WIFI_nbytes,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Sends data to XBee module.

This function can be used to send AT command in command mode or to send data in transparent mode.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_bufData buffer to send.
TSMART_XBEE_WIFI_nbytesNumber of bytes to send
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
  • Bytes sent
int8_t TSMART_XBEE_WIFI_Send802Frame ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_802_data_to_send_t TSMART_XBEE_WIFI_data,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Sends 802 frame in API mode.

This function can be waiting for ACK setting the ID frame different than 0. Waiting ACK can delay the sent but ensures it.

Parameters
TSMART_XBEE_WIFIXBee WIFI structure handler.
TSMART_XBEE_WIFI_dataData buffer to send.
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
  • 0x00 = Success
  • 0x03 = Transmission was purged because it was attempted before stack was completely up.
  • 0x04 = Physical error occurred on the interface with the WiFi transceiver.
  • 0x21 = TX64 transmission timed out awaiting an acknowledgement from the remote device.
  • 0x32 = Resource Error; Either buffers or sockets were depleted, preventing a transmission from occurring.
  • 0x74 = Message not sent because it was too long
  • 0x76 = Attempt to create a client socket failed
int8_t TSMART_XBEE_WIFI_SendIpv4Frame ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_ipv4_data_to_send_t TSMART_XBEE_WIFI_data,
portTickType  TSMART_XBEE_WIFI_xticks 
)

Sends a IPv4 frame in API mode.

This frame type utilizes the serial data service. The frame gives greater control to the application over the IP setting for the data. This function can be waiting for ACK setting the ID frame different than 0. Waiting ACK can delay the sent but ensures it.

If IP address is a broadcast address (0xFFFFFFFF), then UDP will be used, ignoring the TCP configuration.

Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_dataData buffer to send.
TSMART_XBEE_WIFI_xticksMaximum waiting timeout.
Returns
  • 0x00 = Success
  • 0x03 = Transmission was purged because it was attempted before stack was completely up.
  • 0x04 = Physical error occurred on the interface with the WiFi transceiver.
  • 0x21 = TX64 transmission timed out awaiting an acknowledgement from the remote device.
  • 0x32 = Resource Error; Either buffers or sockets were depleted, preventing a transmission from occurring.
  • 0x74 = Message not sent because it was too long
  • 0x76 = Attempt to create a client socket failed
  • TSMART_FAIL - Failure
Examples:
wifi_sender.c.
int8_t TSMART_XBEE_WIFI_TransparentMode ( tsmart_xbee_wifi_t TSMART_XBEE_WIFI,
tsmart_xbee_wifi_flag_t  TSMART_XBEE_WIFI_flag 
)

Enter/Exit from transparent mode to receive or send data.

Using this function is possible to send or receive transparent data to the XBee module using the TSMART_XBEE_WIFI_Send() and TSMART_XBEE_WIFI_Receive() functions.

Note
It must be executed after a guard time (1sg by default) because uses the "+++" sequence to enter in transparent mode.
Parameters
TSMART_XBEE_WIFIXBee wifi structure handler.
TSMART_XBEE_WIFI_flagLabel to enter/exit the transparent internal mode.
Returns
  • TSMART_PASS - OK
  • TSMART_XBEE_WIFI_FAULT_CODE_1 - Fails applying changes.
  • TSMART_XBEE_WIFI_FAULT_CODE_2 - Impossible enter to command mode.
  • TSMART_XBEE_WIFI_FAULT_CODE_3 - Impossible exit form command mode.