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

Functions

int8_t TSMART_XV_CELLULAR_2G_Init (void)
 Initializes cellular 2G interface. More...
 
int8_t TSMART_XV_CELLULAR_2G_Start (tsmart_xv_cellular_2g_config_t *TSMART_XV_CELLULLAR_2G_config)
 Starts module. More...
 
int8_t TSMART_XV_CELLULAR_2G_Stop (void)
 Stops Cellular 2G interface. More...
 
int8_t TSMART_XV_CELLULAR_2G_NetworkAttachment (tsmart_xv_cellular_2g_network_t *TSMART_XV_CELLULAR_2G_network)
 Attaches to the network 2G. More...
 
int8_t TSMART_XV_CELLULAR_2G_NetworkDeAtachment (void)
 Network detachment. More...
 
int8_t TSMART_XV_WIFI_Init (void)
 Initializes wifi interface. More...
 
int8_t TSMART_XV_WIFI_Start (void)
 Starts the wifi interface. More...
 
void TSMART_XV_WIFI_Stop (void)
 Stops the wifi interface. More...
 
int8_t TSMART_XV_WIFI_ConnectToAP (tsmart_xv_wifi_wlan_t *TSMART_XV_WIFI_wlan)
 Connects to an access point. More...
 
int8_t TSMART_XV_WIFI_DisconnectfromAP (void)
 Disconnects form the access point. More...
 
int8_t TSMART_XV_StartServer (uint16_t TSMART_XV_server_port)
 Starts a server. More...
 
int8_t TSMART_XV_ReadIP (tsmart_xv_ipv4_format_t *TSMART_XV_ipv4_format)
 Reads the current IP address. More...
 
int8_t TSMART_XV_ReceiveNotification (tsmart_xv_notif_t *TSMART_XV_notif, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Receives notifications. More...
 
int8_t TSMART_XV_CreateProduct (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_product_id, tsmart_xv_product_t *TSMART_XV_product, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Creates a product. More...
 
int8_t TSMART_XV_DeleteProduct (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_product_id, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Deletes a product. More...
 
int8_t TSMART_XV_CreateDevice (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_product_id, uint8_t *TSMART_XV_serial_number, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Creates a device. More...
 
int8_t TSMART_XV_DeleteDevice (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_product_id, uint8_t *TSMART_XV_serial_number, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Deletes a device. More...
 
int8_t TSMART_XV_GetActivationCode (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_product_id, uint8_t *TSMART_XV_serial_number, uint8_t *TSMART_XV_activation_code, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Gets an activation code. More...
 
int32_t TSMART_XV_ActivateDevice (uint8_t *TSMART_XV_key, uint8_t *TSMART_XV_activation_code, uint8_t *TSMART_XV_device_api_key, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Actives a device. More...
 
int8_t TSMART_XV_SetDeviceLocation (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_feed_id, tsmart_xv_location_t *TSMART_XV_location, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Sets the device location. More...
 
int32_t TSMART_XV_CreateTrigger (uint8_t *TSMART_XV_key, tsmart_xv_trigger_t *TSMART_XV_trigger, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Creates a trigger. More...
 
int8_t TSMART_XV_WriteDataStream (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_feed_id, tsmart_xv_datastream_t *TSMART_XV_datastream, uint8_t TSMART_XV_n_datastreams, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Sends DataStreams. More...
 
int8_t TSMART_XV_ReadDataStream (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_feed_id, uint8_t *TSMART_XV_datastream_id, tsmart_xv_value_type_id_t TSMART_XV_value_type_id, tsmart_xv_datastream_read_t *TSMART_XV_xv_datastream_read, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Gets datastream. More...
 
int8_t TSMART_XV_AddDataStream (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_feed_id, uint8_t *TSMART_XV_datastream_id, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Creates a datastream. More...
 
int8_t TSMART_XV_DeleteDataStream (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_feed_id, uint8_t *TSMART_XV_datastream_id, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Deletes a datastream. More...
 
int8_t TSMART_XV_UpdateTrigger (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_trigger_id, tsmart_xv_trigger_t *TSMART_XV_trigger, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Updates a trigger. More...
 
int8_t TSMART_XV_DeleteTrigger (uint8_t *TSMART_XV_key, uint32_t TSMART_XV_trigger_id, tsmart_xv_buffer_t *TSMART_XV_buffer)
 Deletes a trigger. More...
 

Detailed Description

Function Documentation

int32_t TSMART_XV_ActivateDevice ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_activation_code,
uint8_t *  TSMART_XV_device_api_key,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Actives a device.

Parameters
TSMART_XV_keyXively API Key.
TSMART_XV_activation_codeActivation code.
TSMART_XV_device_api_keyDevice API Key(output parameter)
TSMART_XV_bufferXively buffer.
Returns
  • Feed identifier - Device activated.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_AddDataStream ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_feed_id,
uint8_t *  TSMART_XV_datastream_id,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Creates a datastream.

Parameters
TSMART_XV_keyDevice API key.
TSMART_XV_feed_idFeed identifier.
TSMART_XV_datastream_idDataStream identier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - DataStream added.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_CELLULAR_2G_Init ( void  )

Initializes cellular 2G interface.

Initializes the hardware configuration of the cellular 2g module and the associated OS mechanisms.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Not possible to get software resources (queues, mutext and so on).
int8_t TSMART_XV_CELLULAR_2G_NetworkAttachment ( tsmart_xv_cellular_2g_network_t TSMART_XV_CELLULAR_2G_network)

Attaches to the network 2G.

Parameters
TSMART_XV_CELLULAR_2G_networkCellular 2g network structure
Returns
  • TSMART_PASS - OK
  • TSMART_XV_FAULT_CODE1 - Bearer configuration failure
  • TSMART_XV_FAULT_CODE2 - Start bearer failure
  • TSMART_XV_FAULT_CODE3 - 2g network registration failure
int8_t TSMART_XV_CELLULAR_2G_NetworkDeAtachment ( void  )

Network detachment.

This function disconnects the cellular 2g form the 2G network.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Stop bearer failure, it was impossible to do a network detachment.
int8_t TSMART_XV_CELLULAR_2G_Start ( tsmart_xv_cellular_2g_config_t TSMART_XV_CELLULLAR_2G_config)

Starts module.

This functions starts the cellular 2g interface for Xively middleware. It turns on and sets the cellular 2g device.

Parameters
TSMART_XV_CELLULLAR_2G_configCelullar 2G configuration structure
Returns
  • TSMART_PASS - OK
  • TSMART_XV_FAULT_CODE1 - Turn on failure.
  • TSMART_XV_FAULT_CODE2 - Configuration failure.
  • TSMART_XV_FAULT_CODE3 - Start TCP/IP stack failure.
  • TSMART_XV_FAULT_CODE4 - TCP/IP statck configuration failure.
int8_t TSMART_XV_CELLULAR_2G_Stop ( void  )

Stops Cellular 2G interface.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - It's not possible to stop.
int8_t TSMART_XV_CreateDevice ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_product_id,
uint8_t *  TSMART_XV_serial_number,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Creates a device.

A device represents an individual physical device of some defined product with a unique serial number. When devices are created, they are in a pre-registered state. They do not yet have a Feed or API key associated with them. When a device is activated, the device becomes registered, a Feed is generated for it based on the default template defined in the product if one exists and an API key is generated. The collection of devices created in the context of a specific product defines a product batch.

Parameters
TSMART_XV_keyXively API key
TSMART_XV_product_idProduct Identifier
TSMART_XV_serial_numberDevice Serial number
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Device created.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_CreateProduct ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_product_id,
tsmart_xv_product_t TSMART_XV_product,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Creates a product.

Product is the highest level of abstraction in the Xively data hierarchy. A product in Xively represents a specific type of actual device, for example the ‘Acme Smart Thermostat’.

Parameters
TSMART_XV_productProduct structure.
TSMART_XV_keyXively API-Key.
TSMART_XV_product_idProduct identifier(output parameter).
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Product created
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int32_t TSMART_XV_CreateTrigger ( uint8_t *  TSMART_XV_key,
tsmart_xv_trigger_t TSMART_XV_trigger,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Creates a trigger.

This function creates a trigger vinculated to a specific DataStream in a specific feed.

Parameters
TSMART_XV_keyXively API key.
TSMART_XV_triggerTrigger structure.
TSMART_XV_bufferXively buffer.
Returns
  • Trigger identifier - Trigger created.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_DeleteDataStream ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_feed_id,
uint8_t *  TSMART_XV_datastream_id,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Deletes a datastream.

Parameters
TSMART_XV_keyDevice API key.
TSMART_XV_feed_idFeed identifier.
TSMART_XV_datastream_idDatastream identifier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - DataStream deleted.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_DeleteDevice ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_product_id,
uint8_t *  TSMART_XV_serial_number,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Deletes a device.

Parameters
TSMART_XV_keyXively API key.
TSMART_XV_product_idProduct identifier.
TSMART_XV_serial_numberDevice serial number.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Device deleted.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_DeleteProduct ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_product_id,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Deletes a product.

Parameters
TSMART_XV_keyXively API-Key.
TSMART_XV_product_idProduct identifier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Product deteled.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_DeleteTrigger ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_trigger_id,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Deletes a trigger.

This function deletes an existing trigger.

Parameters
TSMART_XV_keyXively API key.
TSMART_XV_trigger_idTrigger identifier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Trigger updated.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_GetActivationCode ( uint8_t *  TSMART_XV_key,
uint8_t *  TSMART_XV_product_id,
uint8_t *  TSMART_XV_serial_number,
uint8_t *  TSMART_XV_activation_code,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Gets an activation code.

This funciton gets the activation code of a specific device.

Parameters
TSMART_XV_keyXively API Key.
TSMART_XV_product_idProduct identifer.
TSMART_XV_serial_numberDevice serial number.
TSMART_XV_activation_codeActivation code(output parameter).
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Code OK.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_ReadDataStream ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_feed_id,
uint8_t *  TSMART_XV_datastream_id,
tsmart_xv_value_type_id_t  TSMART_XV_value_type_id,
tsmart_xv_datastream_read_t TSMART_XV_datastream_read,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Gets datastream.

This function gets information from the selected datastream

Parameters
TSMART_XV_keyDevice API key.
TSMART_XV_feed_idFeed identifier.
TSMART_XV_datastream_idDatastream identifier.
TSMART_XV_value_type_idValue type to be read.
TSMART_XV_datastream_readDataStream reading structure.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - DataStream read.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_ReadIP ( tsmart_xv_ipv4_format_t TSMART_XV_ipv4_format)

Reads the current IP address.

Parameters
TSMART_XV_ipv4_formatipv4 structure (output parameter).
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Read IP failure.
int8_t TSMART_XV_ReceiveNotification ( tsmart_xv_notif_t TSMART_XV_notif,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Receives notifications.

This function is blocked permanently until a notification happends. The available notifications can change depending on the interface in use.

  • Cellular interface:
    • - TSMART_XV_TRIGGER_ALARM: a trigger alarm was received.
    • - TSMART_XV_2G_NOTIF: The 2G interface notification has a code associtated to the action to do:
      • TSMART_XV_CELLULAR_2G_STOP - Reset interface is requiered.
      • TSMART_XV_CELLULAR_2G_NETWORK_FAILURE - Re-attach network is required.
  • Wifi interface:
    • - TSMART_XV_TRIGGER_ALARM: a trigger alarm was received.
Parameters
TSMART_XV_notifNotification struture.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Fail
int8_t TSMART_XV_SetDeviceLocation ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_feed_id,
tsmart_xv_location_t TSMART_XV_location,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Sets the device location.

Parameters
TSMART_XV_keyDevice API key.
TSMART_XV_locationLocation structure.
TSMART_XV_feed_idFeed identifier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Location OK.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_StartServer ( uint16_t  TSMART_XV_server_port)

Starts a server.

This function starts a server to receive commands. User shall use TSMART_XV_ReceiveNotification() function to receive commands.

Parameters
TSMART_XV_server_portLocal server port
Returns
  • TSMART_PASS - OK
  • TSMART_XV_FAULT_CODE1 - Server initialization failure for the cellular 2g interface or impossible get a socket for the wifi interface.
  • TSMART_XV_FAULT_CODE2 - Bind socket failure (only for wifi interface).
  • TSMART_XV_FAULT_CODE3 - Listen socket failure (only for wifi interface).
int8_t TSMART_XV_UpdateTrigger ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_trigger_id,
tsmart_xv_trigger_t TSMART_XV_trigger,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Updates a trigger.

This function updates an existing trigger.

Parameters
TSMART_XV_keyXively API key.
TSMART_XV_triggerTrigger structure.
TSMART_XV_trigger_idTrigger identifier.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - Trigger updated.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).
int8_t TSMART_XV_WIFI_ConnectToAP ( tsmart_xv_wifi_wlan_t TSMART_XV_WIFI_wlan)

Connects to an access point.

Parameters
TSMART_XV_WIFI_wlanWireless network parameters estructure
Returns
  • TSMART_PASS - OK
  • TSMART_XV_FAULT_CODE1 - Set IP failure.
  • TSMART_XV_FAULT_CODE2 - Connection failure.
int8_t TSMART_XV_WIFI_DisconnectfromAP ( void  )

Disconnects form the access point.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Diosconnection failure.
int8_t TSMART_XV_WIFI_Init ( void  )

Initializes wifi interface.

Initializes the hardware configuration of the WIFI module and the associated OS mechanisms.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Not possible to get software resources (queues, mutext and so on).
int8_t TSMART_XV_WIFI_Start ( void  )

Starts the wifi interface.

Returns
  • TSMART_PASS - OK
  • TSMART_FAIL - Event mask failure.
void TSMART_XV_WIFI_Stop ( void  )

Stops the wifi interface.

The wifi interface will be set to default values. And it will be turned off.

int8_t TSMART_XV_WriteDataStream ( uint8_t *  TSMART_XV_key,
uint32_t  TSMART_XV_feed_id,
tsmart_xv_datastream_t TSMART_XV_datastream,
uint8_t  TSMART_XV_n_datastreams,
tsmart_xv_buffer_t TSMART_XV_buffer 
)

Sends DataStreams.

Parameters
TSMART_XV_keyDevice API key.
TSMART_XV_feed_idFeed identifier.
TSMART_XV_datastreamDataStream strucutre.
TSMART_XV_n_datastreamsNumber of DataStream to send.
TSMART_XV_bufferXively buffer.
Returns
  • TSMART_PASS - DataStream sent.
  • TSMART_XV_FAULT_CODE1 - Xively connection failure.
  • TSMART_XV_FAULT_CODE2 - Sending failure.
  • TSMART_XV_FAULT_CODE3 - Closing client failure.
  • TSMART_XV_FAULT_CODE4 - Parsing failure (wrong or there wasn't anwser).