Distributed Publish & Subscribe for IoT
|
Publications. More...
Data Structures | |
struct | _DPS_Buffer |
A buffer. More... | |
Typedefs | |
typedef void(* | DPS_AcknowledgementHandler) (DPS_Publication *pub, uint8_t *payload, size_t len) |
Function prototype for a publication acknowledgement handler called when an acknowledgement for a publication is received from a remote subscriber. More... | |
typedef void(* | DPS_AckPublicationBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data) |
Called when DPS_AckPublicationBufs() completes. More... | |
typedef struct _DPS_Buffer | DPS_Buffer |
A buffer. | |
typedef void(* | DPS_OnPublicationDestroyed) (DPS_Publication *pub) |
Function prototype for callback function called when a publication is destroyed. More... | |
typedef struct _DPS_Publication | DPS_Publication |
Opaque type for a publication. | |
typedef void(* | DPS_PublishBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data) |
Called when DPS_PublishBufs() completes. More... | |
Functions | |
const DPS_KeyId * | DPS_AckGetSenderKeyId (const DPS_Publication *pub) |
Get the key identifier of an acknowledgement, only valid with the body of the DPS_AcknowledgementHandler function. More... | |
uint32_t | DPS_AckGetSequenceNum (const DPS_Publication *pub) |
Get the sequence number being acknowledged, only valid with the body of the DPS_AcknowledgementHandler function. More... | |
DPS_Status | DPS_AckPublication (const DPS_Publication *pub, const uint8_t *ackPayload, size_t len) |
Acknowledge a publication. More... | |
DPS_Status | DPS_AckPublicationBufs (const DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_AckPublicationBufsComplete cb, void *data) |
Acknowledge a publication. More... | |
DPS_Publication * | DPS_CopyPublication (const DPS_Publication *pub) |
Creates a partial copy of a publication that can be used to acknowledge the publication. More... | |
DPS_Publication * | DPS_CreatePublication (DPS_Node *node) |
Allocates storage for a publication. More... | |
DPS_Status | DPS_DestroyPublication (DPS_Publication *pub, DPS_OnPublicationDestroyed cb) |
Delete a publication and frees any resources allocated. More... | |
void * | DPS_GetPublicationData (const DPS_Publication *pub) |
Get application data pointer previously set by DPS_SetPublicationData() More... | |
DPS_Status | DPS_InitPublication (DPS_Publication *pub, const char **topics, size_t numTopics, int noWildCard, const DPS_KeyId *keyId, DPS_AcknowledgementHandler handler) |
Initializes a newly created publication with a set of topics. More... | |
DPS_Status | DPS_PublicationAddSubId (DPS_Publication *pub, const DPS_KeyId *keyId) |
Adds a key identifier to use for encrypted publications. More... | |
DPS_Node * | DPS_PublicationGetNode (const DPS_Publication *pub) |
Get the local node associated with a publication. More... | |
size_t | DPS_PublicationGetNumTopics (const DPS_Publication *pub) |
Get the number of topics in a publication. More... | |
const DPS_KeyId * | DPS_PublicationGetSenderKeyId (const DPS_Publication *pub) |
Get the key identifier of a publication. More... | |
uint32_t | DPS_PublicationGetSequenceNum (const DPS_Publication *pub) |
Get the sequence number for a publication. More... | |
const char * | DPS_PublicationGetTopic (const DPS_Publication *pub, size_t index) |
Get a topic for a publication. More... | |
int16_t | DPS_PublicationGetTTL (const DPS_Publication *pub) |
Get the TTL for a publication. More... | |
const DPS_UUID * | DPS_PublicationGetUUID (const DPS_Publication *pub) |
Get the UUID for a publication. More... | |
int | DPS_PublicationIsAckRequested (const DPS_Publication *pub) |
Check if an acknowledgement was requested for a publication. More... | |
void | DPS_PublicationRemoveSubId (DPS_Publication *pub, const DPS_KeyId *keyId) |
Removes a key identifier to use for encrypted publications. More... | |
DPS_Status | DPS_Publish (DPS_Publication *pub, const uint8_t *pubPayload, size_t len, int16_t ttl) |
Publish a set of topics along with an optional payload. More... | |
DPS_Status | DPS_PublishBufs (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, int16_t ttl, DPS_PublishBufsComplete cb, void *data) |
Publish a set of topics along with an optional payload. More... | |
DPS_Status | DPS_SetPublicationData (DPS_Publication *pub, void *data) |
Store a pointer to application data in a publication. More... | |
Publications.
typedef void(* DPS_AcknowledgementHandler) (DPS_Publication *pub, uint8_t *payload, size_t len) |
Function prototype for a publication acknowledgement handler called when an acknowledgement for a publication is received from a remote subscriber.
The handler is called for each subscriber that generates an acknowledgement so may be called numerous times for same publication.
pub | Opaque handle for the publication that was received |
payload | Payload accompanying the acknowledgement if any |
len | Length of the payload |
typedef void(* DPS_AckPublicationBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data) |
Called when DPS_AckPublicationBufs() completes.
pub | The publication |
bufs | The payload buffers passed to DPS_AckPublicationBufs() |
numBufs | The number of payload buffers passed to DPS_AckPublicationBufs() |
status | The status of the publish |
data | Application data passed to DPS_AckPublicationBufs() |
typedef void(* DPS_OnPublicationDestroyed) (DPS_Publication *pub) |
Function prototype for callback function called when a publication is destroyed.
pub | The publication that was destroyed. This is valid during the callback. |
typedef void(* DPS_PublishBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data) |
Called when DPS_PublishBufs() completes.
pub | The publication |
bufs | The payload buffers passed to DPS_PublishBufs() |
numBufs | The number of payload buffers passed to DPS_PublishBufs() |
status | The status of the publish |
data | Application data passed to DPS_PublishBufs() |
const DPS_KeyId* DPS_AckGetSenderKeyId | ( | const DPS_Publication * | pub | ) |
Get the key identifier of an acknowledgement, only valid with the body of the DPS_AcknowledgementHandler function.
pub | The pub parameter of DPS_AcknowledgementHandler |
uint32_t DPS_AckGetSequenceNum | ( | const DPS_Publication * | pub | ) |
Get the sequence number being acknowledged, only valid with the body of the DPS_AcknowledgementHandler function.
pub | The pub parameter of DPS_AcknowledgementHandler |
DPS_Status DPS_AckPublication | ( | const DPS_Publication * | pub, |
const uint8_t * | ackPayload, | ||
size_t | len | ||
) |
Acknowledge a publication.
A publication should be acknowledged as soon as possible after receipt, ideally from within the publication handler callback function. If the publication cannot be acknowledged immediately in the publication handler callback, call DPS_CopyPublication() to make a partial copy of the publication that can be passed to this function at a later time.
pub | The publication to acknowledge |
ackPayload | Optional payload to accompany the acknowledgement |
len | The length of the payload |
DPS_Status DPS_AckPublicationBufs | ( | const DPS_Publication * | pub, |
const DPS_Buffer * | bufs, | ||
size_t | numBufs, | ||
DPS_AckPublicationBufsComplete | cb, | ||
void * | data | ||
) |
Acknowledge a publication.
A publication should be acknowledged as soon as possible after receipt, ideally from within the publication handler callback function. If the publication cannot be acknowledged immediately in the publication handler callback, call DPS_CopyPublication() to make a partial copy of the publication that can be passed to this function at a later time.
pub | The publication to acknowledge |
bufs | Optional payload buffers - this memory must remain valid until the callback function is called |
numBufs | The number of buffers |
cb | Callback function called when the acknowledge is complete |
data | Data to be passed to the callback function |
DPS_Publication* DPS_CopyPublication | ( | const DPS_Publication * | pub | ) |
Creates a partial copy of a publication that can be used to acknowledge the publication.
The copy is not useful for anything other than in a call to DPS_AckPublication() and should be freed by calling DPS_DestroyPublication() when no longer needed.
The partial copy can be used with DPS_PublicationGetUUID() and DPS_PublicationGetSequenceNum()
pub | The publication to copy |
DPS_Publication* DPS_CreatePublication | ( | DPS_Node * | node | ) |
Allocates storage for a publication.
node | The local node to use |
DPS_Status DPS_DestroyPublication | ( | DPS_Publication * | pub, |
DPS_OnPublicationDestroyed | cb | ||
) |
Delete a publication and frees any resources allocated.
This does not cancel retained publications that have an unexpired TTL. To expire a retained publication call DPS_Publish() with a negative TTL.
This function should only be called for publications created by DPS_CreatePublication() or DPS_CopyPublication().
pub | The publication to destroy |
cb | Callback function to be called when the publication is destroyed |
void* DPS_GetPublicationData | ( | const DPS_Publication * | pub | ) |
Get application data pointer previously set by DPS_SetPublicationData()
pub | The publication |
DPS_Status DPS_InitPublication | ( | DPS_Publication * | pub, |
const char ** | topics, | ||
size_t | numTopics, | ||
int | noWildCard, | ||
const DPS_KeyId * | keyId, | ||
DPS_AcknowledgementHandler | handler | ||
) |
Initializes a newly created publication with a set of topics.
Each publication has a UUID and a sequence number. The sequence number is incremented each time the publication is published. This allows subscriber to determine that publications received form a series. The acknowledgement handler is optional, if present the publication is marked as requesting acknowledgement and that information is provided to the subscribers.
Call the accessor function DPS_PublicationGetUUID() to get the UUID for this publication.
pub | The publication to initialize |
topics | The topic strings to publish |
numTopics | The number of topic strings to publish - must be >= 1 |
noWildCard | If TRUE the publication will not match wildcard subscriptions |
keyId | Optional key identifier to use for encrypted publications |
handler | Optional handler for receiving acknowledgements |
DPS_Status DPS_PublicationAddSubId | ( | DPS_Publication * | pub, |
const DPS_KeyId * | keyId | ||
) |
Adds a key identifier to use for encrypted publications.
pub | The publication to initialize |
keyId | Key identifier to use for encrypted publications |
DPS_Node* DPS_PublicationGetNode | ( | const DPS_Publication * | pub | ) |
Get the local node associated with a publication.
pub | The publication |
size_t DPS_PublicationGetNumTopics | ( | const DPS_Publication * | pub | ) |
Get the number of topics in a publication.
pub | The publication |
const DPS_KeyId* DPS_PublicationGetSenderKeyId | ( | const DPS_Publication * | pub | ) |
Get the key identifier of a publication.
pub | The publication |
uint32_t DPS_PublicationGetSequenceNum | ( | const DPS_Publication * | pub | ) |
Get the sequence number for a publication.
Serial numbers are always > 0.
pub | The publication |
const char* DPS_PublicationGetTopic | ( | const DPS_Publication * | pub, |
size_t | index | ||
) |
Get a topic for a publication.
pub | The publication |
index | The topic index |
int16_t DPS_PublicationGetTTL | ( | const DPS_Publication * | pub | ) |
Get the TTL for a publication.
pub | The publication |
const DPS_UUID* DPS_PublicationGetUUID | ( | const DPS_Publication * | pub | ) |
Get the UUID for a publication.
pub | The publication |
int DPS_PublicationIsAckRequested | ( | const DPS_Publication * | pub | ) |
Check if an acknowledgement was requested for a publication.
pub | The publication |
void DPS_PublicationRemoveSubId | ( | DPS_Publication * | pub, |
const DPS_KeyId * | keyId | ||
) |
Removes a key identifier to use for encrypted publications.
pub | The publication to initialize |
keyId | Key identifier to remove |
DPS_Status DPS_Publish | ( | DPS_Publication * | pub, |
const uint8_t * | pubPayload, | ||
size_t | len, | ||
int16_t | ttl | ||
) |
Publish a set of topics along with an optional payload.
The topics will be published immediately to matching subscribers and then re-published whenever a new matching subscription is received.
Call the accessor function DPS_PublicationGetUUID() to get the UUID for this publication. Call the accessor function DPS_PublicationGetSequenceNum() to get the current sequence number for this publication. The sequence number is incremented each time DPS_Publish() is called for the same publication.
pub | The publication to send |
pubPayload | Optional payload |
len | Length of the payload |
ttl | Time to live in seconds - maximum TTL is about 9 hours |
DPS_Status DPS_PublishBufs | ( | DPS_Publication * | pub, |
const DPS_Buffer * | bufs, | ||
size_t | numBufs, | ||
int16_t | ttl, | ||
DPS_PublishBufsComplete | cb, | ||
void * | data | ||
) |
Publish a set of topics along with an optional payload.
The topics will be published immediately to matching subscribers and then re-published whenever a new matching subscription is received.
Call the accessor function DPS_PublicationGetUUID() to get the UUID for this publication. Call the accessor function DPS_PublicationGetSequenceNum() to get the current sequence number for this publication. The sequence number is incremented each time DPS_Publish() is called for the same publication.
pub | The publication to send |
bufs | Optional payload buffers - this memory must remain valid until the callback function is called |
numBufs | The number of buffers |
ttl | Time to live in seconds - maximum TTL is about 9 hours |
cb | Callback function called when the publish is complete |
data | Data to be passed to the callback function |
DPS_Status DPS_SetPublicationData | ( | DPS_Publication * | pub, |
void * | data | ||
) |
Store a pointer to application data in a publication.
pub | The publication |
data | The data pointer to store |