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

OPP Push Server callback operations structure. More...

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

Data Fields

void(* transport_connected )(struct bt_conn *conn, struct bt_opp_server *server)
 Transport connected callback.
void(* transport_disconnected )(struct bt_opp_server *server)
 Transport disconnected callback.
void(* connect )(struct bt_opp_server *server, uint8_t version, uint16_t mopl, struct net_buf *buf)
 OBEX connect request callback.
void(* disconnect )(struct bt_opp_server *server, struct net_buf *buf)
 OBEX disconnect request callback.
void(* push )(struct bt_opp_server *server, bool final, struct net_buf *buf)
 Object push (PUT) request callback.
void(* pull )(struct bt_opp_server *server, bool final, struct net_buf *buf)
 Business card pull (GET) request callback.
void(* abort )(struct bt_opp_server *server, struct net_buf *buf)
 Abort request callback.

Detailed Description

OPP Push Server callback operations structure.

Defines the handlers invoked when the Push Server receives requests from a Push Client. Every callback is mandatory except bt_opp_server_cb::transport_connected(), and bt_opp_server_register validates that they are all set: OPP Spec Table 5.1 requires the Connect, Disconnect, Put, Get and Abort operations, and bt_opp_server_cb::transport_disconnected() is the only signal that the instance handed out by bt_opp_server_transport::accept() is free again. transport_connected() is optional because accept() already reported the connection.

The stack itself answers a request that is invalid on its own terms, such as a push that does not name the object it carries or a pull that addresses something other than the Default Get Object. The corresponding callback is not invoked for those; see each callback for the response code the case gets. Every request that does reach a callback has to be answered by the application.

The structure must remain valid and constant for the lifetime of the server.

Field Documentation

◆ abort

void(* bt_opp_server_cb::abort) (struct bt_opp_server *server, struct net_buf *buf)

Abort request callback.

Called when an OBEX ABORT request is received from the Push Client. The application must call bt_opp_server_abort to respond. It also has to drop the object it was receiving, or rewind the Default Get Object it was sending so that the next pull starts from the beginning, because the transfer the abort cancels is tracked by the application and not by the stack.

Note
buf is owned by the stack and is only valid for the duration of this callback. The application must not unref it and has to copy any data it needs afterwards.
Parameters
serverOPP Push Server object.
bufOptional request headers buffer, or NULL.

◆ connect

void(* bt_opp_server_cb::connect) (struct bt_opp_server *server, uint8_t version, uint16_t mopl, struct net_buf *buf)

OBEX connect request callback.

Called when the Push Server receives an OBEX CONNECT request. The application must call bt_opp_server_connect to respond.

The stack answers a connect request that carries a Target header (BT_OBEX_HEADER_ID_TARGET) with BT_OPP_RSP_CODE_FORBIDDEN and does not invoke this callback.

Note
buf is owned by the stack and is only valid for the duration of this callback. The application must not unref it and has to copy any data it needs afterwards.
Parameters
serverOPP Push Server object.
versionOBEX version requested by the client.
moplMaximum OBEX packet length proposed by the client.
bufOptional request headers buffer, or NULL.

◆ disconnect

void(* bt_opp_server_cb::disconnect) (struct bt_opp_server *server, struct net_buf *buf)

OBEX disconnect request callback.

Called when the Push Server receives an OBEX DISCONNECT request. The application must call bt_opp_server_disconnect to respond. The request cannot be refused.

Note
buf is owned by the stack and is only valid for the duration of this callback. The application must not unref it and has to copy any data it needs afterwards.
Parameters
serverOPP Push Server object.
bufOptional request headers buffer, or NULL.

◆ pull

void(* bt_opp_server_cb::pull) (struct bt_opp_server *server, bool final, struct net_buf *buf)

Business card pull (GET) request callback.

Called when a GET request for the Default Get Object is received. On the first request, the Type header (BT_OBEX_HEADER_ID_TYPE) is set to BT_OPP_TYPE_VCARD and the Name header (BT_OBEX_HEADER_ID_NAME) is absent or empty. The stack does not invoke this callback for a request that addresses something else: a non-empty Name header is answered with BT_OPP_RSP_CODE_FORBIDDEN and another object format with BT_OPP_RSP_CODE_NOT_FOUND.

An absent Type header is accepted and reported here: a continuation request carries no headers, and a server holding a single object may serve a request that does not describe it.

If an invalid request is received after a multi-packet pull has started, the stack closes the transport after rejecting it. The bt_opp_server_cb::transport_disconnected callback then signals the application to reset the partial pull state.

The application must call bt_opp_server_pull to respond, with BT_OPP_RSP_CODE_NOT_FOUND if no default object exists, including when the server does not support business card pull.

Note
buf is owned by the stack and is only valid for the duration of this callback. The application must not unref it and has to copy any data it needs afterwards.
Parameters
serverOPP Push Server object.
finalFinal bit of the received GET opcode. A request with final false is still part of the request phase and has to be answered with BT_OPP_RSP_CODE_CONTINUE and no body: the object may only be sent once the whole request has been received.
bufRequest headers buffer. The first request of a pull operation carries the Type header; a continuation request carries no headers at all.

◆ push

void(* bt_opp_server_cb::push) (struct bt_opp_server *server, bool final, struct net_buf *buf)

Object push (PUT) request callback.

Called when a PUT request is received from the Push Client. buf contains OBEX headers such as Name (BT_OBEX_HEADER_ID_NAME), Type (BT_OBEX_HEADER_ID_TYPE), Length (BT_OBEX_HEADER_ID_LEN) and Body (BT_OBEX_HEADER_ID_BODY). For multi-packet objects this callback is invoked for each PUT packet; final is set in the last one. The End-of-Body header (BT_OBEX_HEADER_ID_END_BODY) carries the last chunk of the object body; the stack does not check that it arrives in the packet with final set.

The stack checks the request before invoking this callback and answers it on its own when it is not a valid push:

  • A push has to name its object before the body starts, with a non-empty, valid UTF-16BE name that holds no path character; otherwise BT_OPP_RSP_CODE_BAD_REQ. Length is not enforced.
  • A push without any object body is a delete request, which OPP does not support, so its last request is answered with BT_OPP_RSP_CODE_FORBIDDEN.
  • An invalid request in a started multi-packet push closes the transport after it is rejected; bt_opp_server_cb::transport_disconnected then tells the application to discard the partial object.

The application must call bt_opp_server_push to respond, with BT_OPP_RSP_CODE_UNSUPP_MEDIA_TYPE for an unsupported format or BT_OPP_RSP_CODE_ENTITY_TOO_LARGE for an object that is too large.

Note
buf is owned by the stack and is only valid for the duration of this callback. The application must not unref it and has to copy any data it needs afterwards.
Parameters
serverOPP Push Server object.
finalFinal bit of the received PUT opcode: true in the last request of the operation.
bufRequest headers buffer.

◆ transport_connected

void(* bt_opp_server_cb::transport_connected) (struct bt_conn *conn, struct bt_opp_server *server)

Transport connected callback.

Called when a new transport connection from a Push Client is accepted. This callback is optional; bt_opp_server_transport::accept() has already reported the same connection.

Parameters
connACL connection object.
serverOPP Push Server object.

◆ transport_disconnected

void(* bt_opp_server_cb::transport_disconnected) (struct bt_opp_server *server)

Transport disconnected callback.

Called when the transport connection from a Push Client is closed. The bt_opp_server instance is no longer in use once this returns, so this is where the application releases it.

Parameters
serverOPP Push Server object.

The documentation for this struct was generated from the following file:
  • zephyr/bluetooth/classic/opp.h