ManagementFrame

class

Public Functions

ManagementFrame::ManagementFrame()

Construct an empty (uninitialized) management frame This is used when you need to allocate memory on the stack for a frame, and pass it to another function.

ManagementFrame::ManagementFrame(mgmtFrameRaw *rawFrame)

Construct a management frame from reponse data

The contructed object will not reference the raw data in any way.

Parameters
  • rawFrame -

    A pointer to the raw frame data structure

ManagementFrame::ManagementFrame(RxTxCommandIds commandId)

Construct a outgoing management frame, having the TX_FRAME direction parameter set. No other frame parameters are initailzed

Parameters
  • commandId -

    The TX command id

virtual bool ManagementFrame::commit()

If this frame is of type TX_FRAME this method will sent it to the module.

When the command frame is sent, the method will wait for a response and then check the response against the request. If the property responsePayload is set to true, the method responsePayloadHandler is called automatically.

If the command takes multiple responses, like TCP data receive on sockets, you should see the lastResponseParsed property.

When the method returns, the frame response (with payload data) is expected to be present.

Return
true on success, false otherwise

virtual void ManagementFrame::commitAsync()

Send a TX_FRAME to the module asynchronous.

Same as commit, but but asynchronous and return immediately. You should set the completion callback handler (setCompletionCallback) before calling this method.

See
commit
See
setCompletionCallback

virtual void ManagementFrame::abort()

Abort the execution (commit) of the frame.

If the frame is pending, it is aborted and removed from the to-be-sent request queue. If the frame has already been sent to the module, the abort is ignored.

Still the completion callback handler if removed, to avoid calling freed objects.

virtual bool ManagementFrame::writeFrame()

Internal method used by commitAsync method to send the frame to the module, inside the async function handler.

You should not call this directly.

virtual void ManagementFrame::triggerCompletionHandler()

Internal method to trigger the completion handler callback - if any This method should only be used by the Module member method moduleEventHandler.

virtual void ManagementFrame::rawFrameFormat(mgmtFrameRaw *data)

Gets the frames raw data format for transfer via the communication channel. This format is only the frame itself, not any data payload

Return
raw data struct
Parameters
  • data -

    A pointer to the raw frame structure were the data is written to.

virtual int ManagementFrame::payloadLength()

Get the byte length of the data payload for this management frame The payload length varys for every subclass.

Return
payload data byte length

virtual void ManagementFrame::dataPayload(uint8_t *dataBuffer)

Write the payload data for the frame into the provided buffer. The payload data is dependent on the specific management frame subclass.

If the managament frame subclass does not have any payload data, this method not do anything. The target buffer will be left untouched. Before you call this method, you should check if payload data exists using the payloadLength method.

The data returned to ready to be transferred to the module, it is 4-byte aligned as required. It is you responsibility to ensure the provided data buffer is large enought to contain the needed bytes.

Parameters
  • dataBuffer -

    A pointer to the target buffer, where the payload data is written.

virtual void ManagementFrame::responsePayloadHandler(uint8_t *payloadBuffer)

When frames need to parse or react to response payloads, there are received after a call to commit.

You must overload this method in your subclass and handle the parsing of the response payload. This parsing should set object properties that can later be accessed by outside objects.

This mehod is called internally by the commit method, only if property responsePayload is set to true.

Parameters
  • payloadBuffer -

    A pointer to the raw payload data buffer

template <typename Owner>
void mono::redpine::ManagementFrame::setCompletionCallback(Owner * obj, void(Owner::*)( FrameCompletionData *) memPtr)

Set the frame completion callback handler.

The member function you provide is called when the frame is successfully committed. This means it has been sent to the module, and a response has been received.

The callback function must accept an input parameter:

void functionName(ManagementFrame::FrameCompletionData *);

Parameters
  • obj -

    The member functions context pointer (the this pointer)

  • memPtr -

    A pointer to the member function on the class

Public Members

uint16_t mono::redpine::ManagementFrame::status

Management response status

bool mono::redpine::ManagementFrame::responsePayload

The length of this frames payload data, differs for every subclass. Frames can handle responses from the module themselves This bool indicates that a frame subclass can handle a resposne frame and data payload.

Normally the (commit) method handles and parses a frames response, but when there is a payload, it needs a response payload handler

This you set this property to true in your subclass, when you must overload the method (responsePayloadHandler).

The default value for this property is falsefalse

bool mono::redpine::ManagementFrame::lastResponseParsed

As long as this property is false the frame will continue to process reponses.

Some commands gets multiple reponses from the module. Say you use the HTTP GET command or a socket receive command, the received data arrive in chunks of different lengths.

Set this protoperty to false and the commit method will know, it whould parse multiple responses for the command.

If you set this property to false, the method reposnePayloadHandler will be called multiple times.

Finally, when you know the module will not sent any further response frames, you must indicate this by setting this property to true

If a command frame takes only one response, your subclass can ignore this property.

true

bool mono::redpine::ManagementFrame::autoReleaseWhenParsed

The module handle class (Module) should dealloc this object when it has parsed the last chunk of response data.

mbed::FunctionPointerArg1<void, FrameCompletionData *> mono::redpine::ManagementFrame::completionHandler

The handler called when commit finishes.

To handle frame request and responses asynchronously, this handler is triggered when the frame is committed.

void *mono::redpine::ManagementFrame::handlerContextObject

A reference to the completion handler context object

struct

The datastructure provided by the Management Frames async completion handler.

You should use the member variable Context to reference any frame response data. You should expect the frame to be deallocated right after you callback handler functions returns.

Note: You type safety you can check the frames CommandId before downcasting the Context pointer to a specific frame subclass.

Public Members

bool mono::redpine::ManagementFrame::FrameCompletionData::Success

See if the request was successfull

ManagementFrame *mono::redpine::ManagementFrame::FrameCompletionData::Context

A pointer to the request frame object