Tizen Native API  9.0
Wi-Fi Aware Publish

Wifi Aware Publish API provides functions for configuring a Publish session.

Required Header

#include <wifi-aware.h>

Overview

This set of functions is used to configure a Wi-Fi Aware session for publication To use This kind of APIs, You should create a Wi-Fi Aware publish handle using wifi_aware_publish_create(). After that, configure the publication using functions like wifi_aware_publish_set_type(), wifi_aware_publish_set_service_name(), etc. You should destroy the created publish handle if you do not need it anymore using wifi_aware_publish_destroy(). Once all configurations have been completed, You can initiate the publication of a Wi-Fi Aware session using wifi_aware_session_publish().

Related Features

This API is related with the following features:

  • http://tizen.org/feature/network.wifi.aware
    It is recommended to design feature related codes in your application for reliability.
    You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
    To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
    More details on featuring your application can be found from Feature Element.

Functions

int wifi_aware_publish_create (wifi_aware_publish_h *publish)
 Creates a Publish request.
int wifi_aware_publish_destroy (wifi_aware_publish_h publish)
 Destroys a Publish request.
int wifi_aware_publish_set_ttl (wifi_aware_publish_h publish, unsigned short ttl)
 Sets TTL (Time To Live) for Publish session.
int wifi_aware_publish_set_type (wifi_aware_publish_h publish, wifi_aware_publish_type_e publish_type)
 Sets the type of the service as solicited or unsolicited.
int wifi_aware_publish_set_service_name (wifi_aware_publish_h publish, const char *service_name)
 Sets the name of the service to publish.
int wifi_aware_publish_set_service_specific_info (wifi_aware_publish_h publish, const unsigned char *service_specific_info, size_t len)
 Sets the specific information for the service to publish.
int wifi_aware_publish_set_match_filter (wifi_aware_publish_h publish, const unsigned char *match_filter, size_t len)
 Sets the match filter of the service to publish.
int wifi_aware_publish_enable_ranging (wifi_aware_publish_h publish, bool enable)
 Sets whether the ranging function is supported or not.

Enumeration Type Documentation

Enumeration for Wi-Fi Aware publish type.

Since :
9.0
Enumerator:
WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED 

Unsolicited type

WIFI_AWARE_PUBLISH_TYPE_SOLICITED 

Solicited type


Function Documentation

Creates a Publish request.

Since :
9.0
Remarks:
The publish should be released using wifi_aware_publish_destroy().
Parameters:
[out]publishThe Wi-Fi Aware Publish handle.
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
Here is an example of the usage:
    int ret = 0;
    wifi_aware_session_h wifi_aware_session = NULL;
    static wifi_aware_publish_h publish_handle = NULL;

    ret = wifi_aware_session_create(WIFI_AWARE_SESSION_PUBLISH, &wifi_aware_session);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to create session\n");
        return;
    }

    ret = wifi_aware_publish_create(&publish_handle);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to create publish request\n");
        return;
    }

    printf("Publish request is created Successfully\n");

    wifi_aware_publish_destroy(publish_handle);
    wifi_aware_session_destroy(wifi_aware_session);
See also:
wifi_aware_publish_destroy()

Destroys a Publish request.

Since :
9.0
Parameters:
[in]publishThe Wi-Fi Aware Publish handle.
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()
int wifi_aware_publish_enable_ranging ( wifi_aware_publish_h  publish,
bool  enable 
)

Sets whether the ranging function is supported or not.

Since :
9.0
Parameters:
[in]publishThe Wi-Fi Aware Publish handle
[in]enabletrue if ranging is enabled, otherwise false if ranging is disabled.
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()
int wifi_aware_publish_set_match_filter ( wifi_aware_publish_h  publish,
const unsigned char *  match_filter,
size_t  len 
)

Sets the match filter of the service to publish.

Since :
9.0
Remarks:
The match filter is used to decide whether accepting a subscribe request or not.
Parameters:
[in]publishThe Wi-Fi Aware Publish handle
[in]match_filterAn ordered sequence of <length, value> pairs
[in]lenThe whole length of match_filter
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()
int wifi_aware_publish_set_service_name ( wifi_aware_publish_h  publish,
const char *  service_name 
)

Sets the name of the service to publish.

Since :
9.0
Remarks:
The length should be less than or equal to 255.
Parameters:
[in]publishThe Wi-Fi Aware Publish handle
[in]service_nameUTF-8 name which identifies the service
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()
int wifi_aware_publish_set_service_specific_info ( wifi_aware_publish_h  publish,
const unsigned char *  service_specific_info,
size_t  len 
)

Sets the specific information for the service to publish.

Since :
9.0
Parameters:
[in]publishThe Wi-Fi Aware Publish handle
[in]service_specific_infoThe Sequence of values that are conveyed in the Publish message
[in]lenThe length of service specific information
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()
int wifi_aware_publish_set_ttl ( wifi_aware_publish_h  publish,
unsigned short  ttl 
)

Sets TTL (Time To Live) for Publish session.

Since :
9.0
Parameters:
[in]publishThe Wi-Fi Aware Publish handle.
[in]ttlThe lifetime(seconds) of publish session. 0 means forever until canceled.
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()

Sets the type of the service as solicited or unsolicited.

Since :
9.0
Parameters:
[in]publishThe Wi-Fi Aware Publish handle
[in]publish_typeThe Publish type
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_publish_create()