Distributed Publish & Subscribe for IoT
Discovery

A discovery service. More...

Typedefs

typedef void(* DPS_DiscoveryHandler) (DPS_DiscoveryService *service, const DPS_Publication *pub, uint8_t *payload, size_t len)
 Function prototype for a discovery handler called when a discovery message is received. More...
 
typedef struct _DPS_DiscoveryService DPS_DiscoveryService
 Opaque type for the discovery service.
 
typedef void(* DPS_OnDiscoveryServiceDestroyed) (DPS_DiscoveryService *service, void *data)
 Function prototype for callback function called when a service is destroyed. More...
 

Functions

DPS_DiscoveryServiceDPS_CreateDiscoveryService (DPS_Node *node, const char *serviceId)
 Allocate resources for a discovery service. More...
 
DPS_Status DPS_DestroyDiscoveryService (DPS_DiscoveryService *service, DPS_OnDiscoveryServiceDestroyed cb, void *data)
 Free resources for a discovery service. More...
 
DPS_Status DPS_DiscoveryPublish (DPS_DiscoveryService *service, const uint8_t *payload, size_t len, DPS_DiscoveryHandler handler)
 Publish this node's discovery information and receive other node's discovery information. More...
 
void * DPS_GetDiscoveryServiceData (DPS_DiscoveryService *service)
 Get application data pointer previously set by DPS_SetDiscoveryServiceData() More...
 
DPS_Status DPS_SetDiscoveryServiceData (DPS_DiscoveryService *service, void *data)
 Store a pointer to application data in a discovery service. More...
 

Detailed Description

A discovery service.

Typedef Documentation

◆ DPS_DiscoveryHandler

typedef void(* DPS_DiscoveryHandler) (DPS_DiscoveryService *service, const DPS_Publication *pub, uint8_t *payload, size_t len)

Function prototype for a discovery handler called when a discovery message is received.

Parameters
servicethe service
pubopaque handle for the message that was received
payloadpayload from the message if any
lenlength of the payload

◆ DPS_OnDiscoveryServiceDestroyed

typedef void(* DPS_OnDiscoveryServiceDestroyed) (DPS_DiscoveryService *service, void *data)

Function prototype for callback function called when a service is destroyed.

Parameters
servicethe service that was destroyed
datadata passed to DPS_DestroyDiscoveryService()

Function Documentation

◆ DPS_CreateDiscoveryService()

DPS_DiscoveryService* DPS_CreateDiscoveryService ( DPS_Node node,
const char *  serviceId 
)

Allocate resources for a discovery service.

Parameters
nodethe node
serviceIdan application-defined topic segment for discovery information
Returns
the service, or NULL if creation failed

◆ DPS_DestroyDiscoveryService()

DPS_Status DPS_DestroyDiscoveryService ( DPS_DiscoveryService service,
DPS_OnDiscoveryServiceDestroyed  cb,
void *  data 
)

Free resources for a discovery service.

Parameters
servicethe service
cbcallback function to be called when the service is destroyed
datadata to be passed to the callback function
Returns
  • DPS_OK if the service will be destroyed and the callback called
  • DPS_ERR_NULL service or cb was null
  • Or an error status code in which case the callback will not be called.

◆ DPS_DiscoveryPublish()

DPS_Status DPS_DiscoveryPublish ( DPS_DiscoveryService service,
const uint8_t *  payload,
size_t  len,
DPS_DiscoveryHandler  handler 
)

Publish this node's discovery information and receive other node's discovery information.

Parameters
servicethe service
payloadoptional payload
lenlength of the payload
handleroptional callback function to be called when a discovery message is received
Returns
DPS_OK if successful, an error otherwise

◆ DPS_GetDiscoveryServiceData()

void* DPS_GetDiscoveryServiceData ( DPS_DiscoveryService service)

Get application data pointer previously set by DPS_SetDiscoveryServiceData()

Parameters
servicethe service
Returns
A pointer to the data or NULL if the service is invalid

◆ DPS_SetDiscoveryServiceData()

DPS_Status DPS_SetDiscoveryServiceData ( DPS_DiscoveryService service,
void *  data 
)

Store a pointer to application data in a discovery service.

Parameters
servicethe service
datathe data pointer to store
Returns
DPS_OK or an error