Tizen Native API
Bluetooth OPP Server

Bluetooth OPP(Object Push Profile) Server API provides functions for accepting objects such as pictures.

Required Header

#include <bluetooth.h>

Overview

This is OPP server APIs.

Related Features

This API is related with the following features:

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 bt_opp_server_initialize_by_connection_request (const char *destination, bt_opp_server_connection_requested_cb connection_requested_cb, void *user_data)
 Initializes the Bluetooth OPP server requested by bt_opp_server_connection_requested_cb().
int bt_opp_server_deinitialize (void)
 Deinitializes the Bluetooth OPP server.
int bt_opp_server_accept (bt_opp_server_transfer_progress_cb progress_cb, bt_opp_server_transfer_finished_cb finished_cb, const char *name, void *user_data, int *transfer_id)
 Accepts the push request from the remote device.
int bt_opp_server_reject (void)
 Rejects the push request from the remote device.
int bt_opp_server_cancel_transfer (int transfer_id)
 Cancels the transfer.
int bt_opp_server_set_destination (const char *destination)
 Sets the destination path of file to be pushed.

Typedefs

typedef void(* bt_opp_server_connection_requested_cb )(const char *remote_address, void *user_data)
 Called when an OPP connection is requested.
typedef void(* bt_opp_server_transfer_progress_cb )(const char *file, long long size, int percent, void *user_data)
 Called when a file is being transferred.
typedef void(* bt_opp_server_transfer_finished_cb )(int result, const char *file, long long size, void *user_data)
 Called when a transfer is finished.

Typedef Documentation

typedef void(* bt_opp_server_connection_requested_cb)(const char *remote_address, void *user_data)

Called when an OPP connection is requested.

Since :
2.3

You must call bt_opp_server_accept_connection() if you want to accept. Otherwise, you must call bt_opp_server_reject_connection().

Parameters:
[in]remote_addressThe address of remote device
[in]user_dataThe user data passed from the callback registration function
See also:
bt_opp_server_accept()
bt_opp_server_reject()
typedef void(* bt_opp_server_transfer_finished_cb)(int result, const char *file, long long size, void *user_data)

Called when a transfer is finished.

Since :
2.3
Parameters:
[in]error_codeThe result of push
[in]fileThe path of file to be pushed
[in]sizeThe file size (bytes)
[in]user_dataThe user data passed from the callback registration function
See also:
bt_opp_server_accept()
bt_opp_server_accept_connection()
typedef void(* bt_opp_server_transfer_progress_cb)(const char *file, long long size, int percent, void *user_data)

Called when a file is being transferred.

Since :
2.3
Parameters:
[in]fileThe path of file to be pushed
[in]sizeThe file size (bytes)
[in]percentThe progress in percentage (1 ~ 100)
[in]user_dataThe user data passed from the callback registration function
See also:
bt_opp_server_accept()
bt_opp_server_accept_connection()

Function Documentation

int bt_opp_server_accept ( bt_opp_server_transfer_progress_cb  progress_cb,
bt_opp_server_transfer_finished_cb  finished_cb,
const char *  name,
void *  user_data,
int *  transfer_id 
)

Accepts the push request from the remote device.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/bluetooth
Remarks:
If you initialize OPP server by bt_opp_server_initialize_by_connection_request(), then name is ignored. You can cancel the pushes by bt_opp_server_cancel_transfer() with transfer_id.
Parameters:
[in]progress_cbThe callback called when a file is being transferred
[in]finished_cbThe callback called when a transfer is finished
[in]nameThe name to store. This can be NULL if you initialize OPP server by bt_opp_server_initialize_by_connection_request().
[in]user_dataThe user data to be passed to the callback function
[out]transfer_idThe ID of transfer
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_INVALID_PARAMETERInvalid parameter
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_NOW_IN_PROGRESSOperation now in progress
BT_ERROR_PERMISSION_DENIEDPermission denied
BT_ERROR_NOT_SUPPORTEDNot supported
See also:
bt_opp_server_reject()
int bt_opp_server_cancel_transfer ( int  transfer_id)

Cancels the transfer.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/bluetooth
Parameters:
[in]transfer_idThe ID of transfer
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_INVALID_PARAMETERInvalid parameter
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_PERMISSION_DENIEDPermission denied
BT_ERROR_NOT_SUPPORTEDNot supported
See also:
bt_opp_server_accept()

Deinitializes the Bluetooth OPP server.

Since :
2.3
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_NOT_SUPPORTEDNot supported
See also:
bt_opp_server_deinitialize()
int bt_opp_server_initialize_by_connection_request ( const char *  destination,
bt_opp_server_connection_requested_cb  connection_requested_cb,
void *  user_data 
)

Initializes the Bluetooth OPP server requested by bt_opp_server_connection_requested_cb().

Since :
2.3

No popup appears when an OPP connection is requested from a remote device. Instead, connection_requested_cb() will be called. At that time, you can call either bt_opp_server_accept() or bt_opp_server_reject().

Remarks:
This function must be called to start Bluetooth OPP server.
You must free all resources of the Bluetooth service by calling bt_opp_server_deinitialize() if Bluetooth OPP service is no longer needed.
Parameters:
[in]destinationThe destination path
[in]connection_requested_cbThe callback called when an OPP connection is requested
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_INVALID_PARAMETERInvalid parameter
BT_ERROR_RESOURCE_BUSYDevice or resource busy
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_NOT_SUPPORTEDNot supported
See also:
bt_opp_server_connection_requested_cb()
bt_opp_server_deinitialize()
bt_opp_server_accept()
bt_opp_server_reject()
int bt_opp_server_reject ( void  )

Rejects the push request from the remote device.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/bluetooth
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_INVALID_PARAMETERInvalid parameter
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_PERMISSION_DENIEDPermission denied
BT_ERROR_NOT_SUPPORTEDNot supported
See also:
bt_opp_server_accept()
int bt_opp_server_set_destination ( const char *  destination)

Sets the destination path of file to be pushed.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/bluetooth
Parameters:
[in]destinationThe destination path of file to be pushed
Returns:
0 on success, otherwise a negative error value.
Return values:
BT_ERROR_NONESuccessful
BT_ERROR_NOT_INITIALIZEDNot initialized
BT_ERROR_NOT_ENABLEDNot enabled
BT_ERROR_INVALID_PARAMETERInvalid parameter
BT_ERROR_OPERATION_FAILEDOperation failed
BT_ERROR_PERMISSION_DENIEDPermission denied
BT_ERROR_NOT_SUPPORTEDNot supported