Distributed Publish & Subscribe for IoT
discovery.h
Go to the documentation of this file.
1 
6 /*
7  *******************************************************************
8  *
9  * Copyright 2019 Intel Corporation All rights reserved.
10  *
11  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26  */
27 
28 #ifndef _DPS_DISCOVERY_H
29 #define _DPS_DISCOVERY_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
47 #include <dps/dps.h>
48 
52 typedef struct _DPS_DiscoveryService DPS_DiscoveryService;
53 
62 DPS_DiscoveryService* DPS_CreateDiscoveryService(DPS_Node* node, const char* serviceId);
63 
73 
82 
91 typedef void (*DPS_DiscoveryHandler)(DPS_DiscoveryService* service, const DPS_Publication* pub,
92  uint8_t* payload, size_t len);
93 
104 DPS_Status DPS_DiscoveryPublish(DPS_DiscoveryService* service, const uint8_t* payload, size_t len,
105  DPS_DiscoveryHandler handler);
106 
114 typedef void (*DPS_OnDiscoveryServiceDestroyed)(DPS_DiscoveryService* service, void* data);
115 
129  DPS_OnDiscoveryServiceDestroyed cb, void* data);
130  // end of discovery group
132  // end of services group
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif
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.
Definition: discovery.h:91
Public APIs.
void * DPS_GetDiscoveryServiceData(DPS_DiscoveryService *service)
Get application data pointer previously set by DPS_SetDiscoveryServiceData()
void(* DPS_OnDiscoveryServiceDestroyed)(DPS_DiscoveryService *service, void *data)
Function prototype for callback function called when a service is destroyed.
Definition: discovery.h:114
struct _DPS_DiscoveryService DPS_DiscoveryService
Opaque type for the discovery service.
Definition: discovery.h:52
DPS_DiscoveryService * DPS_CreateDiscoveryService(DPS_Node *node, const char *serviceId)
Allocate resources for a discovery service.
struct _DPS_Publication DPS_Publication
Opaque type for a publication.
Definition: dps.h:712
int DPS_Status
The status code type.
Definition: err.h:41
DPS_Status DPS_DiscoveryPublish(DPS_DiscoveryService *service, const uint8_t *payload, size_t len, DPS_DiscoveryHandler handler)
Publish this node&#39;s discovery information and receive other node&#39;s discovery information.
DPS_Status DPS_SetDiscoveryServiceData(DPS_DiscoveryService *service, void *data)
Store a pointer to application data in a discovery service.
DPS_Status DPS_DestroyDiscoveryService(DPS_DiscoveryService *service, DPS_OnDiscoveryServiceDestroyed cb, void *data)
Free resources for a discovery service.
struct _DPS_Node DPS_Node
Opaque type for a node.
Definition: dps.h:450