Tizen Native API  9.0
Wi-Fi Aware Subscribe

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

Required Header

#include <wifi-aware.h>

Overview

This set of functions is used to configure a Wi-Fi Aware session for subscription. To use This kind of APIs, You should create a Wi-Fi Aware subscribe handle using wifi_aware_subscribe_create(). After that, configure the subscription using functions like wifi_aware_subscribe_set_type(), wifi_aware_subscribe_set_service_name(), etc. You should destroy the created subscribe handle if you do not need it anymore using wifi_aware_subscribe_destroy(). Once all configurations have been completed, You can initiate the subscription of a Wi-Fi Aware session using wifi_aware_session_subscribe().

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_subscribe_create (wifi_aware_subscribe_h *subscribe)
 Creates a Subscribe request.
int wifi_aware_subscribe_destroy (wifi_aware_subscribe_h subscribe)
 Destroys a Subscribe request.
int wifi_aware_subscribe_set_ttl (wifi_aware_subscribe_h subscribe, unsigned short ttl)
 Sets TTL (Time To Live) for Subscribe session.
int wifi_aware_subscribe_set_type (wifi_aware_subscribe_h subscribe, wifi_aware_subscribe_type_e subscribe_type)
 Sets the type of the service as passive or active.
int wifi_aware_subscribe_set_service_name (wifi_aware_subscribe_h subscribe, const char *service_name)
 Sets the name of the service to subscribe.
int wifi_aware_subscribe_set_service_specific_info (wifi_aware_subscribe_h subscribe, const unsigned char *service_specific_info, size_t len)
 Sets the specific information for the service to subscribe.
int wifi_aware_subscribe_set_match_filter (wifi_aware_subscribe_h subscribe, const unsigned char *match_filter, size_t len)
 Sets the match filter of the service to subscribe.
int wifi_aware_subscribe_set_max_distance (wifi_aware_subscribe_h subscribe, int distance)
 Sets the maximum distance.
int wifi_aware_subscribe_set_min_distance (wifi_aware_subscribe_h subscribe, int distance)
 Sets the minimum distance.

Enumeration Type Documentation

Enumeration for Wi-Fi Aware subscribe type.

Since :
9.0
Enumerator:
WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE 

Passive type

WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE 

Active type


Function Documentation

Creates a Subscribe request.

Since :
9.0
Remarks:
The subscribe should be released using wifi_aware_subscribe_destroy().
Parameters:
[out]subscribeThe Wi-Fi Aware Subscribe 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;
    wifi_aware_subscribe_h subscribe_handle = NULL;

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

    ret = wifi_aware_subscribe_create(&subscribe_handle);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to create subscribe handle\n");
        return;
    }

    // Setup and use the subscribe handle

    wifi_aware_subscribe_destroy(subscribe_handle);
    wifi_aware_session_destroy(wifi_aware_session);
See also:
wifi_aware_subscribe_destroy()

Destroys a Subscribe request.

Since :
9.0
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe 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_subscribe_create()
int wifi_aware_subscribe_set_match_filter ( wifi_aware_subscribe_h  subscribe,
const unsigned char *  match_filter,
size_t  len 
)

Sets the match filter of the service to subscribe.

Since :
9.0
Remarks:
The match filter is used to decide whether accepting a subscribe request or not.
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe 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_subscribe_create()
int wifi_aware_subscribe_set_max_distance ( wifi_aware_subscribe_h  subscribe,
int  distance 
)

Sets the maximum distance.

Since :
9.0
Remarks:
Only for the services within the distance are searched.
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]distanceThe maximum distance
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_subscribe_create()
int wifi_aware_subscribe_set_min_distance ( wifi_aware_subscribe_h  subscribe,
int  distance 
)

Sets the minimum distance.

Since :
9.0
Remarks:
Only for the services at least at the distance are searched.
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]distanceThe minimum distance
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_subscribe_create()
int wifi_aware_subscribe_set_service_name ( wifi_aware_subscribe_h  subscribe,
const char *  service_name 
)

Sets the name of the service to subscribe.

Since :
9.0
Remarks:
The length should be less than or equal to 255
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe 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_subscribe_create()
int wifi_aware_subscribe_set_service_specific_info ( wifi_aware_subscribe_h  subscribe,
const unsigned char *  service_specific_info,
size_t  len 
)

Sets the specific information for the service to subscribe.

Since :
9.0
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]service_specific_infoThe Sequence of values that are conveyed in the Subscribe 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_subscribe_create()
int wifi_aware_subscribe_set_ttl ( wifi_aware_subscribe_h  subscribe,
unsigned short  ttl 
)

Sets TTL (Time To Live) for Subscribe session.

Since :
9.0
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]ttlThe lifetime(seconds) of subscribe session.
0 means forever until wifi_aware_service_discovered_cb().
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_subscribe_create()

Sets the type of the service as passive or active.

Since :
9.0
Parameters:
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]subscribe_typeThe Subscribe 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_subscribe_create()