Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Data Structures

struct  bt_ftp_server_cb
 FTP server callback structure. More...
struct  bt_ftp_server
 FTP server structure. More...
struct  bt_ftp_server_rfcomm
 FTP server RFCOMM registration structure. More...
struct  bt_ftp_server_l2cap
 FTP server L2CAP registration structure. More...

Functions

int bt_ftp_server_register (struct bt_ftp_server *server, const struct bt_ftp_server_cb *cb)
 Register an FTP server instance with the OBEX layer.
int bt_ftp_server_rfcomm_register (struct bt_ftp_server_rfcomm *server)
 Register an FTP RFCOMM server.
int bt_ftp_server_l2cap_register (struct bt_ftp_server_l2cap *server)
 Register an FTP L2CAP server.
int bt_ftp_server_rfcomm_disconnect (struct bt_ftp_server *server)
 Disconnect the FTP server RFCOMM transport.
int bt_ftp_server_l2cap_disconnect (struct bt_ftp_server *server)
 Disconnect the FTP server L2CAP transport.
int bt_ftp_server_connect (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send an OBEX CONNECT response from the FTP server.
int bt_ftp_server_disconnect (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send an OBEX DISCONNECT response from the FTP server.
int bt_ftp_server_abort (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send an OBEX ABORT response from the FTP server.
int bt_ftp_server_set_folder (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a set folder response from the FTP server.
int bt_ftp_server_pull_folder_listing (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a pull folder listing response from the FTP server.
int bt_ftp_server_push_file (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a push file response from the FTP server.
int bt_ftp_server_pull_file (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a pull file response from the FTP server.
int bt_ftp_server_remove (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a remove response from the FTP server.
int bt_ftp_server_rename (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a rename/move response from the FTP server.
int bt_ftp_server_copy (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a copy response from the FTP server.
int bt_ftp_server_set_permission (struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
 Send a set permission response from the FTP server.
struct net_buf * bt_ftp_server_create_pdu (struct bt_ftp_server *server, struct net_buf_pool *pool)
 Allocate a PDU buffer for an FTP server response.

Detailed Description

Function Documentation

◆ bt_ftp_server_abort()

int bt_ftp_server_abort ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send an OBEX ABORT response from the FTP server.

Responds to an OBEX ABORT request from the remote FTP client. Called from the abort callback bt_ftp_server_cb::abort.

Parameters
serverFTP server object.
rsp_codeResponse code, typically BT_FTP_RSP_CODE_SUCCESS.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no ABORT request is pending.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_connect()

int bt_ftp_server_connect ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send an OBEX CONNECT response from the FTP server.

Responds to an OBEX CONNECT request from the remote FTP client. Called from the connect callback bt_ftp_server_cb::connect.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL, the server is not in the connecting OBEX state, the CONN_ID header in buf does not match the session's connection ID, the WHO header in buf is malformed or does not match the FTP service UUID, or rsp_code is BT_FTP_RSP_CODE_CONTINUE.
-ENODATAThe CONN_ID or WHO header in buf is present but empty or malformed.
-ENOBUFSBuffer allocation failed when buf is NULL.
-ENOMEMbuf has insufficient tailroom for the CONN_ID or WHO header.

◆ bt_ftp_server_copy()

int bt_ftp_server_copy ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a copy response from the FTP server.

Responds to a copy ACTION request from the remote FTP client. Called from the copy callback bt_ftp_server_cb::copy.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no copy operation is pending.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_create_pdu()

struct net_buf * bt_ftp_server_create_pdu ( struct bt_ftp_server * server,
struct net_buf_pool * pool )

#include <zephyr/bluetooth/classic/ftp.h>

Allocate a PDU buffer for an FTP server response.

Allocates a buffer for building FTP response packets. Only headroom for the OBEX and transport headers is reserved; the data size is that of the buffers of pool.

Depending on the calling thread, the allocation may wait until a buffer is free. Must not be called from an ISR.

Parameters
serverFTP server object, FTP Server.
poolBuffer pool to allocate from, or NULL for the default pool.
Returns
Allocated buffer, or NULL on allocation failure.

◆ bt_ftp_server_disconnect()

int bt_ftp_server_disconnect ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send an OBEX DISCONNECT response from the FTP server.

Responds to an OBEX DISCONNECT request from the remote FTP client. Called from the disconnect callback bt_ftp_server_cb::disconnect.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL, the server is not in the disconnecting OBEX state, or rsp_code is BT_FTP_RSP_CODE_CONTINUE.

◆ bt_ftp_server_l2cap_disconnect()

int bt_ftp_server_l2cap_disconnect ( struct bt_ftp_server * server)

#include <zephyr/bluetooth/classic/ftp.h>

Disconnect the FTP server L2CAP transport.

Closes the L2CAP transport connection. On success, the l2cap_disconnected callback bt_ftp_server_cb::l2cap_disconnected will be called.

Parameters
serverFTP server object, FTP Server.
Returns
0 on success, a negative error code from the underlying GOEP L2CAP transport layer, or one of the following error codes.
Return values
-EINVALserver is NULL.
-EINPROGRESSThe server's transport is not currently connected.

◆ bt_ftp_server_l2cap_register()

int bt_ftp_server_l2cap_register ( struct bt_ftp_server_l2cap * server)

#include <zephyr/bluetooth/classic/ftp.h>

Register an FTP L2CAP server.

Register the server to listen for incoming L2CAP connections. The allocated PSM is stored in bt_l2cap_server::psm of bt_ftp_server_l2cap::server and is advertised via SDP.

bt_ftp_server_rfcomm_register must also be called, before or after this function. The SDP record is registered once both the RFCOMM and the L2CAP servers have been registered.

Note
This function can only be called once per application; only a single listening L2CAP PSM is tracked for SDP registration. A second call returns -EALREADY.
Parameters
serverL2CAP server registration structure, bt_ftp_server_l2cap.
Returns
0 on success, a negative error code from the underlying GOEP L2CAP transport layer or SDP registration, or one of the following error codes.
Return values
-EINVALserver or server->accept is NULL.
-EALREADYAn L2CAP server is already registered.

◆ bt_ftp_server_pull_file()

int bt_ftp_server_pull_file ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a pull file response from the FTP server.

Responds to a GET file request from the remote FTP client. Called from the pull_file callback bt_ftp_server_cb::pull_file. Set rsp_code to BT_FTP_RSP_CODE_CONTINUE when there are more fragments to send, or BT_FTP_RSP_CODE_SUCCESS for the final fragment.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer containing the file data and headers. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL, no pull_file operation is pending, or rsp_code is BT_FTP_RSP_CODE_SUCCESS before the final request packet has been received.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_pull_folder_listing()

int bt_ftp_server_pull_folder_listing ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a pull folder listing response from the FTP server.

Responds to a GET folder listing request from the remote FTP client. Called from the pull_folder_listing callback bt_ftp_server_cb::pull_folder_listing. Set rsp_code to BT_FTP_RSP_CODE_CONTINUE when there are more fragments to send, or BT_FTP_RSP_CODE_SUCCESS for the final fragment.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer containing the folder listing data and headers. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL, no pull_folder_listing operation is pending, or rsp_code is BT_FTP_RSP_CODE_SUCCESS before the final request packet has been received.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_push_file()

int bt_ftp_server_push_file ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a push file response from the FTP server.

Responds to a PUT file request from the remote FTP client. Called from the push_file callback bt_ftp_server_cb::push_file. Set rsp_code to BT_FTP_RSP_CODE_CONTINUE to request more data from the client, or BT_FTP_RSP_CODE_SUCCESS when the file upload is complete.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL, no push_file operation is pending, or rsp_code is BT_FTP_RSP_CODE_SUCCESS before the final request packet has been received.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_register()

int bt_ftp_server_register ( struct bt_ftp_server * server,
const struct bt_ftp_server_cb * cb )

#include <zephyr/bluetooth/classic/ftp.h>

Register an FTP server instance with the OBEX layer.

Associates a callback table with the server object and registers it with the underlying OBEX server.

Note
The server object must be zero-initialized by the caller before this call. Each server instance can only be registered once; if it is already registered, this function returns -EALREADY rather than overwriting its state.
cb must provide the rfcomm_connected, rfcomm_disconnected, l2cap_connected, l2cap_disconnected, connect, disconnect, abort, set_folder and pull_folder_listing callbacks, and at least one of push_file and pull_file; this is checked with an assertion.
Parameters
serverFTP server object, FTP Server.
cbCallback table, bt_ftp_server_cb.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver or cb is NULL.
-EALREADYserver is already registered.

◆ bt_ftp_server_remove()

int bt_ftp_server_remove ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a remove response from the FTP server.

Responds to a remove (DELETE) request from the remote FTP client. Called from the remove callback bt_ftp_server_cb::remove.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no remove operation is pending.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_rename()

int bt_ftp_server_rename ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a rename/move response from the FTP server.

Responds to a rename/move ACTION request from the remote FTP client. Called from the rename callback bt_ftp_server_cb::rename.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no rename operation is pending.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_rfcomm_disconnect()

int bt_ftp_server_rfcomm_disconnect ( struct bt_ftp_server * server)

#include <zephyr/bluetooth/classic/ftp.h>

Disconnect the FTP server RFCOMM transport.

Closes the RFCOMM transport connection. On success, the rfcomm_disconnected callback bt_ftp_server_cb::rfcomm_disconnected will be called.

Parameters
serverFTP server object, FTP Server.
Returns
0 on success, a negative error code from the underlying GOEP RFCOMM transport layer, or one of the following error codes.
Return values
-EINVALserver is NULL.
-EINPROGRESSThe server's transport is not currently connected.

◆ bt_ftp_server_rfcomm_register()

int bt_ftp_server_rfcomm_register ( struct bt_ftp_server_rfcomm * server)

#include <zephyr/bluetooth/classic/ftp.h>

Register an FTP RFCOMM server.

Register the server to listen for incoming RFCOMM connections. The allocated channel is stored in bt_rfcomm_server::channel of bt_ftp_server_rfcomm::server and is advertised via SDP.

bt_ftp_server_l2cap_register must also be called, before or after this function. The SDP record is registered once both the RFCOMM and the L2CAP servers have been registered.

Note
This function can only be called once per application; only a single listening RFCOMM channel is tracked for SDP registration. A second call returns -EALREADY.
Parameters
serverRFCOMM server registration structure, bt_ftp_server_rfcomm.
Returns
0 on success, a negative error code from the underlying GOEP RFCOMM transport layer or SDP registration, or one of the following error codes.
Return values
-EINVALserver or server->accept is NULL.
-EALREADYAn RFCOMM server is already registered.

◆ bt_ftp_server_set_folder()

int bt_ftp_server_set_folder ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a set folder response from the FTP server.

Responds to a SetPath request from the remote FTP client. Called from the set_folder callback bt_ftp_server_cb::set_folder.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no SetPath request is pending.
-ENOTCONNThe server is not in the connected OBEX state.

◆ bt_ftp_server_set_permission()

int bt_ftp_server_set_permission ( struct bt_ftp_server * server,
uint8_t rsp_code,
struct net_buf * buf )

#include <zephyr/bluetooth/classic/ftp.h>

Send a set permission response from the FTP server.

Responds to a set-permissions ACTION request from the remote FTP client. Called from the set_permission callback bt_ftp_server_cb::set_permission.

Parameters
serverFTP server object.
rsp_codeResponse code, bt_ftp_rsp_code.
bufBuffer with response headers, or NULL. If success returned, the function has taken the ownership of buf.
Returns
0 on success, a negative error code from the underlying OBEX layer, or one of the following error codes.
Return values
-EINVALserver is NULL or no set_permission operation is pending.
-ENOTCONNThe server is not in the connected OBEX state.