NanoOcp
Minimal AES70 / OCP.1 TCP client/server library for d&b Soundscape devices
Loading...
Searching...
No Matches
NanoOcp1::NanoOcp1Base Class Referenceabstract

Abstract base class shared by NanoOcp1Client and NanoOcp1Server. More...

#include <NanoOcp1.h>

+ Inheritance diagram for NanoOcp1::NanoOcp1Base:

Public Member Functions

 NanoOcp1Base (const juce::String &address, const int port)
 
virtual ~NanoOcp1Base ()
 
void setAddress (const juce::String &address)
 Sets the IP address or hostname of the remote OCA device.
 
const juce::String & getAddress ()
 Returns the current target address.
 
void setPort (const int port)
 Sets the TCP port number of the remote OCA device. DS100 default: 50014.
 
const int getPort ()
 Returns the current target port number.
 
virtual bool start ()=0
 Starts the client/server. For the client, begins periodic reconnect attempts.
 
virtual bool stop ()=0
 Stops the client/server and closes any open TCP connection.
 
virtual bool sendData (const ByteVector &data)=0
 Sends raw bytes over the active TCP connection.
 

Public Attributes

std::function< bool(const ByteVector &)> onDataReceived
 Fired when a complete OCP.1 frame is received.
 
std::function< void()> onConnectionEstablished
 Fired once after a successful TCP connection is established.
 
std::function< void()> onConnectionLost
 Fired when the TCP connection is dropped or a connect attempt fails.
 

Protected Member Functions

bool processReceivedData (const ByteVector &data)
 Called by derived classes when bytes arrive from the socket. Invokes onDataReceived if set; the frame has already been delimited by Ocp1Connection::readNextMessage().
 

Detailed Description

Abstract base class shared by NanoOcp1Client and NanoOcp1Server.

Holds the target address/port, exposes the three user-facing callbacks, and provides processReceivedData() which invokes onDataReceived — the only point at which raw received bytes are handed to the caller.

Concrete subclasses implement start(), stop(), and sendData().

Definition at line 129 of file NanoOcp1.h.

Constructor & Destructor Documentation

◆ NanoOcp1Base()

NanoOcp1::NanoOcp1Base::NanoOcp1Base ( const juce::String &  address,
const int  port 
)

Definition at line 27 of file NanoOcp1.cpp.

References setAddress(), and setPort().

◆ ~NanoOcp1Base()

NanoOcp1::NanoOcp1Base::~NanoOcp1Base ( )
virtual

Definition at line 33 of file NanoOcp1.cpp.

Member Function Documentation

◆ getAddress()

const juce::String & NanoOcp1::NanoOcp1Base::getAddress ( )

Returns the current target address.

Definition at line 42 of file NanoOcp1.cpp.

Referenced by NanoOcp1::NanoOcp1Client::start(), NanoOcp1::NanoOcp1Server::start(), and NanoOcp1::NanoOcp1Client::timerCallback().

◆ getPort()

const int NanoOcp1::NanoOcp1Base::getPort ( )

Returns the current target port number.

Definition at line 52 of file NanoOcp1.cpp.

Referenced by NanoOcp1::NanoOcp1Client::start(), NanoOcp1::NanoOcp1Server::start(), and NanoOcp1::NanoOcp1Client::timerCallback().

◆ processReceivedData()

bool NanoOcp1::NanoOcp1Base::processReceivedData ( const ByteVector data)
protected

Called by derived classes when bytes arrive from the socket. Invokes onDataReceived if set; the frame has already been delimited by Ocp1Connection::readNextMessage().

Definition at line 57 of file NanoOcp1.cpp.

References onDataReceived.

Referenced by NanoOcp1::NanoOcp1Client::messageReceived().

◆ sendData()

virtual bool NanoOcp1::NanoOcp1Base::sendData ( const ByteVector data)
pure virtual

Sends raw bytes over the active TCP connection.

Parameters
dataSerialized OCP.1 message bytes (from Ocp1Message::GetSerializedData()).
Returns
True if the bytes were handed to the socket layer successfully.

Implemented in NanoOcp1::NanoOcp1Client, and NanoOcp1::NanoOcp1Server.

◆ setAddress()

void NanoOcp1::NanoOcp1Base::setAddress ( const juce::String &  address)

Sets the IP address or hostname of the remote OCA device.

Definition at line 37 of file NanoOcp1.cpp.

Referenced by NanoOcp1Base().

◆ setPort()

void NanoOcp1::NanoOcp1Base::setPort ( const int  port)

Sets the TCP port number of the remote OCA device. DS100 default: 50014.

Definition at line 47 of file NanoOcp1.cpp.

Referenced by NanoOcp1Base().

◆ start()

virtual bool NanoOcp1::NanoOcp1Base::start ( )
pure virtual

Starts the client/server. For the client, begins periodic reconnect attempts.

Implemented in NanoOcp1::NanoOcp1Client, and NanoOcp1::NanoOcp1Server.

◆ stop()

virtual bool NanoOcp1::NanoOcp1Base::stop ( )
pure virtual

Stops the client/server and closes any open TCP connection.

Implemented in NanoOcp1::NanoOcp1Client, and NanoOcp1::NanoOcp1Server.

Member Data Documentation

◆ onConnectionEstablished

std::function<void()> NanoOcp1::NanoOcp1Base::onConnectionEstablished

Fired once after a successful TCP connection is established.

DeviceController usage: resets the device state and sends the first GetValue command to read Fixed_GUID for firmware/model detection.

Threading: same thread as onDataReceived.

Definition at line 183 of file NanoOcp1.h.

Referenced by NanoOcp1::NanoOcp1Client::connectionMade().

◆ onConnectionLost

std::function<void()> NanoOcp1::NanoOcp1Base::onConnectionLost

Fired when the TCP connection is dropped or a connect attempt fails.

DeviceController usage: clears all pending command handles, resets the connection state, and lets the client's internal retry timer re-attempt.

Threading: same thread as onDataReceived.

Definition at line 193 of file NanoOcp1.h.

Referenced by NanoOcp1::NanoOcp1Client::connectionLost(), and NanoOcp1::NanoOcp1Client::stop().

◆ onDataReceived

std::function<bool(const ByteVector&)> NanoOcp1::NanoOcp1Base::onDataReceived

Fired when a complete OCP.1 frame is received.

The caller should unmarshal the bytes with Ocp1Message::UnmarshalOcp1Message(), then dispatch on GetMessageType().

Threading: fires on the socket thread when callbacksOnMessageThread=false (as used by DeviceController), or on the JUCE message thread otherwise.

Returns
Return true to indicate the data was handled; returning false has no special effect in the current implementation.

Definition at line 173 of file NanoOcp1.h.

Referenced by NanoOcp1::NanoOcp1Server::createConnectionObject(), and processReceivedData().


The documentation for this class was generated from the following files: