1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 #include "ocstackconfig.h"
34 #include "ocpresence.h"
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
40 * OIC Virtual resources supported by every OIC device.
42 #define OC_RSRVD_WELL_KNOWN_URI "/oic/res"
43 #define OC_RSRVD_DEVICE_URI "/oic/d"
44 #define OC_RSRVD_PLATFORM_URI "/oic/p"
45 #define OC_RSRVD_RESOURCE_TYPES_URI "/oic/res/types/d"
47 #define OC_RSRVD_PRESENCE_URI "/oic/ad"
48 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
49 /// OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
50 /// NOTE: Changing the setting to a longer duration may lead to unsupported and untested
52 #define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24) // 60 sec/min * 60 min/hr * 24 hr/day
55 ///Separtor for multiple query string
56 #define OC_QUERY_SEPARATOR "&;"
59 * Attributes used to form a proper OIC conforming JSON message.
61 //#define OC_RSRVD_OC "oic"
62 #define OC_RSRVD_PAYLOAD "payload"
63 #define OC_RSRVD_HREF "href"
64 #define OC_RSRVD_PROPERTY "prop"
65 #define OC_RSRVD_REPRESENTATION "rep"
66 #define OC_RSRVD_CONTENT_TYPE "ct"
67 #define OC_RSRVD_RESOURCE_TYPE "rt"
68 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
69 #define OC_RSRVD_INTERFACE "if"
70 #define OC_RSRVD_TTL "ttl"
71 #define OC_RSRVD_NONCE "non"
72 #define OC_RSRVD_TRIGGER "trg"
73 #define OC_RSRVD_LINKS "links"
75 #define OC_RSRVD_INTERFACE_DEFAULT "oic.if.baseline"
76 #define OC_RSRVD_INTERFACE_LL "oic.if.ll"
77 #define OC_RSRVD_INTERFACE_BATCH "oic.if.b"
78 #define OC_RSRVD_INTERFACE_GROUP "oic.mi.grp"
79 #define OC_RSRVD_MFG_DATE "mndt"
80 #define OC_RSRVD_FW_VERSION "mnfv"
81 #define OC_RSRVD_HOST_NAME "hn"
82 #define OC_RSRVD_VERSION "icv"
83 #define OC_RSRVD_POLICY "p"
84 #define OC_RSRVD_BITMAP "bm"
85 #define OC_RSRVD_SECURE "sec"
86 #define OC_RSRVD_HOSTING_PORT "port"
87 #define OC_RSRVD_SERVER_INSTANCE_ID "sid"
89 //**** Presence "Announcement Triggers" ****
90 #define OC_RSRVD_TRIGGER_CREATE "create"
91 #define OC_RSRVD_TRIGGER_CHANGE "change"
92 #define OC_RSRVD_TRIGGER_DELETE "delete"
96 #define OC_RSRVD_PLATFORM_ID "pi"
97 #define OC_RSRVD_MFG_NAME "mnmn"
98 #define OC_RSRVD_MFG_URL "mnml"
99 #define OC_RSRVD_MODEL_NUM "mnmo"
100 #define OC_RSRVD_MFG_DATE "mndt"
101 #define OC_RSRVD_PLATFORM_VERSION "mnpv"
102 #define OC_RSRVD_OS_VERSION "mnos"
103 #define OC_RSRVD_HARDWARE_VERSION "mnhw"
104 #define OC_RSRVD_FIRMWARE_VERSION "mnfv"
105 #define OC_RSRVD_SUPPORT_URL "mnsl"
106 #define OC_RSRVD_SYSTEM_TIME "st"
107 //*******************
110 #define OC_RSRVD_DEVICE_ID "di"
111 #define OC_RSRVD_DEVICE_NAME "n"
112 #define OC_RSRVD_SPEC_VERSION "lcv"
113 #define OC_RSRVD_DATA_MODEL_VERSION "dmv"
115 #define OC_SPEC_VERSION "0.9.0"
116 #define OC_DATA_MODEL_VERSION "sec.0.95"
117 //*******************
119 // These provide backward compatibility - their use is deprecated
121 #define OC_MULTICAST_PREFIX "224.0.1.187:5683"
122 #define OC_MULTICAST_IP "224.0.1.187"
123 #define OC_MULTICAST_PORT 5683
126 //-----------------------------------------------------------------------------
128 //-----------------------------------------------------------------------------
130 #define MAX_ADDR_STR_SIZE (256)
132 #define MAX_ADDR_STR_SIZE (40)
135 #define MAX_IDENTITY_SIZE (32)
139 * These enums (OCTransportAdapter and OCTransportFlags) must
140 * be kept synchronized with OCConnectivityType (below) as well as
141 * CATransportAdapter and CATransportFlags (in CACommon.h).
146 OC_DEFAULT_ADAPTER = 0,
148 // value zero indicates discovery
149 OC_ADAPTER_IP = (1 << 0), // IPv4 and IPv6, including 6LoWPAN
150 OC_ADAPTER_GATT_BTLE = (1 << 1), // GATT over Bluetooth LE
151 OC_ADAPTER_RFCOMM_BTEDR = (1 << 2), // RFCOMM over Bluetooth EDR
154 OC_ADAPTER_REMOTE_ACCESS = (1 << 3) // Remote Access over XMPP.
156 } OCTransportAdapter;
158 // enum layout assumes some targets have 16-bit integer (e.g., Arduino)
161 OC_DEFAULT_FLAGS = 0,
163 // Insecure transport is the default (subject to change)
164 OC_FLAG_SECURE = (1 << 4), // secure the transport path
166 // IPv4 & IPv6 autoselection is the default
167 OC_IP_USE_V6 = (1 << 5), // IP adapter only
168 OC_IP_USE_V4 = (1 << 6), // IP adapter only
170 OC_RESERVED1 = (1 << 7), // internal use only
172 // Link-Local multicast is the default multicast scope for IPv6.
173 // These are placed here to correspond to the IPv6 multicast address bits.
174 OC_SCOPE_INTERFACE = 0x1, // IPv6 Interface-Local scope (loopback)
175 OC_SCOPE_LINK = 0x2, // IPv6 Link-Local scope (default)
176 OC_SCOPE_REALM = 0x3, // IPv6 Realm-Local scope
177 OC_SCOPE_ADMIN = 0x4, // IPv6 Admin-Local scope
178 OC_SCOPE_SITE = 0x5, // IPv6 Site-Local scope
179 OC_SCOPE_ORG = 0x8, // IPv6 Organization-Local scope
180 OC_SCOPE_GLOBAL = 0xE, // IPv6 Global scope
183 #define OC_MASK_SCOPE (0x000F)
184 #define OC_MASK_MODS (0x0FF0)
185 #define OC_MASK_FAMS (OC_IP_USE_V6|OC_IP_USE_V4)
193 unsigned char id[MAX_IDENTITY_SIZE];
197 * Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
199 * OCDevAddr must be the same as CAEndpoint (in CACommon.h).
203 OCTransportAdapter adapter; // adapter type
204 OCTransportFlags flags; // transport modifiers
205 char addr[MAX_ADDR_STR_SIZE]; // address for all adapters
206 uint32_t interface; // usually zero for default interface
207 uint16_t port; // for IP
208 OCIdentity identity; // secure node identity
212 * OCConnectivityType includes elements of both OCTransportAdapter
213 * and OCTransportFlags. It is defined conditionally because the
214 * smaller definition limits expandability on 32/64 bit integer machines,
215 * and the larger definition won't fit into an enum on 16-bit integer
216 * machines like Arduino.
218 * This structure must directly correspond to OCTransportAdapter
219 * and OCTransportFlags.
223 CT_DEFAULT = 0, // use when defaults are ok
225 #if defined (__UINT32_MAX__) && (__UINT32_MAX__ == 65535) // 16-bit int
226 CT_ADAPTER_IP = (1 << 10), // IPv4 and IPv6, including 6LoWPAN
227 CT_ADAPTER_GATT_BTLE = (1 << 11), // GATT over Bluetooth LE
228 CT_ADAPTER_RFCOMM_BTEDR = (1 << 12), // RFCOMM over Bluetooth EDR
230 CT_ADAPTER_REMOTE_ACCESS = (1 << 13), // Remote Access over XMPP
232 #define CT_ADAPTER_SHIFT 10
233 #define CT_MASK_FLAGS 0x03FF
234 #define CT_MASK_ADAPTER 0xFC00
235 #else // assume 32-bit int
236 CT_ADAPTER_IP = (1 << 16), // IPv4 and IPv6, including 6LoWPAN
237 CT_ADAPTER_GATT_BTLE = (1 << 17), // GATT over Bluetooth LE
238 CT_ADAPTER_RFCOMM_BTEDR = (1 << 18), // RFCOMM over Bluetooth EDR
240 CT_ADAPTER_REMOTE_ACCESS = (1 << 19), // Remote Access over XMPP
242 #define CT_ADAPTER_SHIFT 16
243 #define CT_MASK_FLAGS 0xFFFF
244 #define CT_MASK_ADAPTER 0xFFFF0000
247 // Insecure transport is the default (subject to change)
248 CT_FLAG_SECURE = (1 << 4), // secure the transport path
250 // IPv4 & IPv6 autoselection is the default
251 CT_IP_USE_V6 = (1 << 5), // IP adapter only
252 CT_IP_USE_V4 = (1 << 6), // IP adapter only
254 // Link-Local multicast is the default multicast scope for IPv6.
255 // These are placed here to correspond to the IPv6 address bits.
256 CT_SCOPE_INTERFACE = 0x1, // IPv6 Interface-Local scope (loopback)
257 CT_SCOPE_LINK = 0x2, // IPv6 Link-Local scope (default)
258 CT_SCOPE_REALM = 0x3, // IPv6 Realm-Local scope
259 CT_SCOPE_ADMIN = 0x4, // IPv6 Admin-Local scope
260 CT_SCOPE_SITE = 0x5, // IPv6 Site-Local scope
261 CT_SCOPE_ORG = 0x8, // IPv6 Organization-Local scope
262 CT_SCOPE_GLOBAL = 0xE, // IPv6 Global scope
263 } OCConnectivityType;
266 * OCDoResource methods
270 OC_REST_NOMETHOD = 0,
271 OC_REST_GET = (1 << 0), ///< Read
272 OC_REST_PUT = (1 << 1), ///< Write
273 OC_REST_POST = (1 << 2), ///< Update
274 OC_REST_DELETE = (1 << 3), ///< Delete
275 /// Register observe request for most up date notifications ONLY.
276 OC_REST_OBSERVE = (1 << 4),
277 /// Register observe request for all notifications, including stale notifications.
278 OC_REST_OBSERVE_ALL = (1 << 5),
279 /// Deregister observation, intended for internal use
280 OC_REST_CANCEL_OBSERVE = (1 << 6),
282 /// Subscribe for all presence notifications of a particular resource.
283 OC_REST_PRESENCE = (1 << 7),
285 /// Allows OCDoResource caller to do discovery.
286 OC_REST_DISCOVER = (1 << 8)
290 * Host Mode of Operation.
300 * Quality of Service.
302 * OCQualityOfService attempts to abstract the guarantees provided by the underlying transport
303 * protocol. The precise definitions of each quality of service level depend on the
304 * implementation. In descriptions below are for the current implementation and may changed
309 /// Packet delivery is best effort
311 /// Packet delivery is best effort
313 /// Acknowledgements are used to confirm delivery
315 /// No Quality is defined, let the stack decide
317 } OCQualityOfService;
320 * Resource Properties.
321 * The value of a policy property is defined as bitmap.
322 * The LSB represents OC_DISCOVERABLE and Second LSB bit represents OC_OBSERVABLE and so on.
323 * Not including the policy property is equivalent to zero.
325 * ::OC_RES_PROP_NONE When none of the bits are set, the resource is non-discoverable &
326 * non-observable by the client.
327 * ::OC_DISCOVERABLE When this bit is set, the resource is allowed to be discovered by clients.
328 * ::OC_OBSERVABLE When this bit is set, the resource is allowed to be observed by clients.
329 * ::OC_ACTIVE When this bit is set, the resource is initialized, otherwise the resource
330 * is 'inactive'. 'inactive' signifies that the resource has been marked for
331 * deletion or is already deleted.
332 * ::OC_SLOW When this bit is set, the resource has been marked as 'slow'. 'slow'
333 * signifies that responses from this resource can expect delays in
334 * processing its requests from clients.
335 * ::OC_SECURE When this bit is set, the resource is a secure resource.
336 * ::OC_EXPLICIT_DISCOVERABLE When this bit is set, the resource is allowed to be discovered only
337 * if discovery request contains an explicit querystring.
338 * Ex: GET /oic/res?rt=oic.sec.acl
342 OC_RES_PROP_NONE = (0),
343 OC_DISCOVERABLE = (1 << 0),
344 OC_OBSERVABLE = (1 << 1),
345 OC_ACTIVE = (1 << 2),
347 OC_SECURE = (1 << 4),
348 OC_EXPLICIT_DISCOVERABLE = (1 << 5)
349 } OCResourceProperty;
352 * Transport Protocol IDs.
356 OC_INVALID_ID = (1 << 0),
357 OC_COAP_ID = (1 << 1)
358 } OCTransportProtocolID;
361 * Declares Stack Results & Errors.
365 /* Success status code - START HERE */
367 OC_STACK_RESOURCE_CREATED,
368 OC_STACK_RESOURCE_DELETED,
370 /* Success status code - END HERE */
371 /* Error status code - START HERE */
372 OC_STACK_INVALID_URI = 20,
373 OC_STACK_INVALID_QUERY,
375 OC_STACK_INVALID_PORT,
376 OC_STACK_INVALID_CALLBACK,
377 OC_STACK_INVALID_METHOD,
378 OC_STACK_INVALID_PARAM,
379 OC_STACK_INVALID_OBSERVE_PARAM,
383 OC_STACK_ADAPTER_NOT_ENABLED,
385 OC_STACK_NO_RESOURCE, /* resource not found */
386 OC_STACK_RESOURCE_ERROR, /* ex: not supported method or interface */
387 OC_STACK_SLOW_RESOURCE,
388 OC_STACK_DUPLICATE_REQUEST,
389 OC_STACK_NO_OBSERVERS, /* resource has no registered observers */
390 OC_STACK_OBSERVER_NOT_FOUND,
391 OC_STACK_VIRTUAL_DO_NOT_HANDLE,
392 OC_STACK_INVALID_OPTION,
393 OC_STACK_MALFORMED_RESPONSE, /* the remote reply contained malformed data */
394 OC_STACK_PERSISTENT_BUFFER_REQUIRED,
395 OC_STACK_INVALID_REQUEST_HANDLE,
396 OC_STACK_INVALID_DEVICE_INFO,
397 OC_STACK_INVALID_JSON,
398 OC_STACK_UNAUTHORIZED_REQ, /**< Request is not authorized by Resource Server. */
399 /* NOTE: Insert all new error codes here!*/
401 OC_STACK_PRESENCE_STOPPED = 128,
402 OC_STACK_PRESENCE_TIMEOUT,
403 OC_STACK_PRESENCE_DO_NOT_HANDLE,
406 /* Error status code - END HERE */
410 * Handle to an @ref OCDoResource invocation.
412 typedef void * OCDoHandle;
415 * Handle to an OCResource object owned by the OCStack.
417 typedef void * OCResourceHandle;
419 typedef void * OCRequestHandle;
422 * Unique identifier for each observation request. Used when observations are
423 * registered or deregistering. Used by entity handler to signal specific
424 * observers to be notified of resource changes.
425 * There can be maximum of 256 observations per server.
427 typedef uint8_t OCObservationId;
430 * Action associated with observation.
434 OC_OBSERVE_REGISTER = 0,
435 OC_OBSERVE_DEREGISTER = 1,
436 OC_OBSERVE_NO_OPTION = 2
441 * Persistent storage handlers. An app must provide OCPersistentStorage handler pointers when it
442 * calls OCRegisterPersistentStorageHandler.
446 * Persistent storage open handler points to default file path.
447 * Application can point to appropriate SVR database path for its Iotivity Server.
449 FILE* (* open)(const char *path, const char *mode);
450 // Persistent storage read handler
451 size_t (* read)(void *ptr, size_t size, size_t nmemb, FILE *stream);
452 // Persistent storage write handler
453 size_t (* write)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
454 // Persistent storage close handler
455 int (* close)(FILE *fp);
456 // Persistent storage unlink handler
457 int (* unlink)(const char *path);
458 } OCPersistentStorage;
462 // Action associated with observation request
463 OCObserveAction action;
464 // Identifier for observation being registered/deregistered
465 OCObservationId obsId;
469 * Possible returned values from entity handler.
475 OC_EH_RESOURCE_CREATED,
476 OC_EH_RESOURCE_DELETED,
479 OC_EH_RESOURCE_NOT_FOUND
480 } OCEntityHandlerResult;
483 * This structure will be used to define the vendor specific header options to be included
484 * in communication packets.
486 typedef struct OCHeaderOption
488 // The protocol ID this option applies to
489 OCTransportProtocolID protocolID;
490 // The header option ID which will be added to communication packets
493 uint16_t optionLength;
494 // pointer to its data
495 uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
498 OCHeaderOption() = default;
499 OCHeaderOption(OCTransportProtocolID pid,
502 const uint8_t* optData)
508 // parameter includes the null terminator.
509 optionLength = optionLength < MAX_HEADER_OPTION_DATA_LENGTH ?
510 optionLength : MAX_HEADER_OPTION_DATA_LENGTH;
511 memcpy(optionData, optData, optionLength);
512 optionData[optionLength - 1] = '\0';
518 * This structure describes the platform properties. All non-Null properties will be included
519 * in a platform discovery request.
524 char *manufacturerName;
525 char *manufacturerUrl;
527 char *dateOfManufacture;
528 char *platformVersion;
529 char *operatingSystemVersion;
530 char *hardwareVersion;
531 char *firmwareVersion;
539 * @brief CA Remote Access information for XMPP Client
544 char *hostname; /**< XMPP server hostname */
545 uint16_t port; /**< XMPP server serivce port */
546 char *xmpp_domain; /**< XMPP login domain */
547 char *username; /**< login username */
548 char *password; /**< login password */
549 char *resource; /**< specific resource for login */
550 char *user_jid; /**< specific JID for login */
552 #endif /* RA_ADAPTER */
555 * This structure is expected as input for device properties.
556 * device name is mandatory and expected from the application.
557 * device id of type UUID will be generated by the stack.
565 // Enum to describe the type of object held by the OCPayload object
568 PAYLOAD_TYPE_INVALID,
569 PAYLOAD_TYPE_DISCOVERY,
571 PAYLOAD_TYPE_PLATFORM,
572 PAYLOAD_TYPE_REPRESENTATION,
573 PAYLOAD_TYPE_SECURITY,
574 PAYLOAD_TYPE_PRESENCE
579 // The type of message that was received
592 }OCRepPayloadPropType;
594 #define MAX_REP_ARRAY_DEPTH 3
597 OCRepPayloadPropType type;
598 size_t dimensions[MAX_REP_ARRAY_DEPTH];
606 struct OCRepPayload** objArray;
608 } OCRepPayloadValueArray;
610 typedef struct OCRepPayloadValue
613 OCRepPayloadPropType type;
620 struct OCRepPayload* obj;
621 OCRepPayloadValueArray arr;
623 struct OCRepPayloadValue* next;
627 typedef struct OCStringLL
629 struct OCStringLL *next;
633 // used for get/set/put/observe/etc representations
634 typedef struct OCRepPayload
639 OCStringLL* interfaces;
640 OCRepPayloadValue* values;
641 struct OCRepPayload* next;
644 // used inside a discovery payload
645 typedef struct OCResourcePayload
650 OCStringLL* interfaces;
654 struct OCResourcePayload* next;
660 OCResourcePayload* resources;
661 } OCDiscoveryPayload;
670 char* dataModelVersion;
689 uint32_t sequenceNumber;
691 OCPresenceTrigger trigger;
697 * Incoming requests handled by the server. Requests are passed in as a parameter to the
698 * @ref OCEntityHandler callback API.
699 * @brief The @ref OCEntityHandler callback API must be implemented in the application in order
700 * to receive these requests.
704 // Associated resource
705 OCResourceHandle resource;
706 OCRequestHandle requestHandle;
707 // the REST method retrieved from received request PDU
709 // description of endpoint that sent the request
711 // resource query send by client
713 // Information associated with observation - valid only when OCEntityHandler
714 // flag includes OC_OBSERVE_FLAG
715 OCObservationInfo obsInfo;
716 // An array of the received vendor specific header options
717 uint8_t numRcvdVendorSpecificHeaderOptions;
718 OCHeaderOption * rcvdVendorSpecificHeaderOptions;
719 // the payload from the request PDU
721 } OCEntityHandlerRequest;
724 * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
728 /// Address of remote server
730 OCDevAddr *addr; // backward compatibility (points to devAddr)
731 OCConnectivityType connType; // backward compatibility
732 /// the is the result of our stack, OCStackResult should contain coap/other error codes;
733 OCStackResult result;
734 /// If associated with observe, this will represent the sequence of notifications from server.
735 uint32_t sequenceNumber;
737 const char * resourceUri;
738 // the payload for the response PDU
740 /// An array of the received vendor specific header options
741 uint8_t numRcvdVendorSpecificHeaderOptions;
742 OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
747 // Request handle is passed to server via the entity handler for each incoming request.
748 // Stack assigns when request is received, server sets to indicate what request response is for
749 OCRequestHandle requestHandle;
751 OCResourceHandle resourceHandle;
752 // Allow the entity handler to pass a result with the response
753 OCEntityHandlerResult ehResult;
754 // this is the pointer to server payload data to be transferred
756 // An array of the vendor specific header options the entity handler wishes to use in response
757 uint8_t numSendVendorSpecificHeaderOptions;
758 OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
759 // URI of new resource that entity handler might create
760 char resourceUri[MAX_URI_LENGTH];
761 // Server sets to true for persistent response buffer, false for non-persistent response buffer
762 uint8_t persistentBufferFlag;
763 } OCEntityHandlerResponse;
767 OC_REQUEST_FLAG = (1 << 1),
768 OC_OBSERVE_FLAG = (1 << 2)
769 } OCEntityHandlerFlag; //entity_handler_flag_t ;
772 * Possible returned values from client application.
776 OC_STACK_DELETE_TRANSACTION = 0,//!< OC_STACK_DELETE_TRANSACTION
777 OC_STACK_KEEP_TRANSACTION //!< OC_STACK_KEEP_TRANSACTION
778 } OCStackApplicationResult;
780 //-----------------------------------------------------------------------------
781 // Callback function definitions
782 //-----------------------------------------------------------------------------
785 * Client applications implement this callback to consume responses received from Servers.
787 typedef OCStackApplicationResult (* OCClientResponseHandler)(void *context, OCDoHandle handle,
788 OCClientResponse * clientResponse);
791 * Client applications using a context pointer implement this callback to delete the
792 * context upon removal of the callback/context pointer from the internal callback-list.
794 typedef void (* OCClientContextDeleter)(void *context);
797 * This info is passed from application to OC Stack when initiating a request to Server.
799 typedef struct OCCallbackData
802 /// The pointer to a function the stack will call to handle the requests
803 OCClientResponseHandler cb;
804 /// A pointer to a function to delete the context when this callback is removed
805 OCClientContextDeleter cd;
807 OCCallbackData() = default;
808 OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)
809 :context(ctx), cb(callback), cd(deleter){}
814 * Application server implementations must implement this callback to consume requests OTA.
815 * Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
817 typedef OCEntityHandlerResult (*OCEntityHandler)
818 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* callbackParam);
821 * Device Entity handler need to use this call back instead of OCEntityHandler.
823 typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
824 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
828 #endif // __cplusplus
830 #endif /* OCTYPES_H_ */