Refactor start listening channel to provide PSM and channel opened callback separately.

PiperOrigin-RevId: 750065027
This commit is contained in:
Edwin Wu
2025-04-21 23:43:07 -07:00
committed by Copybara-Service
parent 15a59a7969
commit d2144cac1b
13 changed files with 232 additions and 257 deletions
@@ -32,15 +32,15 @@ namespace apple {
// A BLE L2CAP server socket for listening incoming L2CAP socket.
class BleL2capServerSocket : public api::ble_v2::BleL2capServerSocket {
public:
// Creates a BLE L2CAP server socket.
//
// @param l2cap_server The L2CAP server to use.
explicit BleL2capServerSocket(GNCBLEL2CAPServer* l2cap_server);
BleL2capServerSocket() = default;
~BleL2capServerSocket() override = default;
// Gets PSM value has been published by the server.
int GetPSM() const override;
// Sets PSM value has been published by the server.
void SetPSM(int PSM);
// Blocks until either:
// - at least one incoming connection request is available, or
// - ServerSocket is closed.
@@ -53,10 +53,12 @@ class BleL2capServerSocket : public api::ble_v2::BleL2capServerSocket {
// Closes the L2CAP server socket.
Exception Close() override;
// Connects to the L2CAP server socket.
bool Connect(std::unique_ptr<BleL2capSocket> socket);
private:
// The L2CAP server to use for listening incoming L2CAP socket and publishing
// PSM value.
GNCBLEL2CAPServer* l2cap_server_;
// The PSM value of the L2CAP server socket.
int PSM_ = 0;
};
} // namespace apple