#ifndef OCSTACK_H_
#define OCSTACK_H_
+#include <stdio.h>
#include <stdint.h>
#include "octypes.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
-#define WITH_PRESENCE
#define USE_RANDOM_PORT (0)
//-----------------------------------------------------------------------------
/**
* Initialize the OC Stack. Must be called prior to starting the stack.
*
+ * @param mode
+ * Host device is client, server, or client-server.
+ * @param serverFlags
+ * Default server transport flags.
+ * @param clientFlags
+ * Default client transport flags.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags);
+
+/**
+ * Initialize the OC Stack. Must be called prior to starting the stack.
+ *
* @param ipAddr
* IP Address of host device. Deprecated parameter.
* @param port
*/
OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode);
+#ifdef RA_ADAPTER
+/**
+ * @brief Set Remote Access information for XMPP Client.
+ * @param raInfo [IN] remote access info.
+ *
+ * @return #CA_STATUS_OK
+ */
+OCStackResult OCSetRAInfo(const OCRAInfo_t *raInfo);
+#endif
+
/**
* Stop the OC stack. Use for a controlled shutdown.
*
* should not be free'd by the consumer. A NULL handle is permitted
* in the event where the caller has no use for the return value.
* @param method @ref OCMethod to perform on the resource.
- * @param requiredUri URI of the resource to interact with.
- * @param referenceUri URI of the reference resource.
+ * @param requiredUri URI of the resource to interact with. (Address prefix
+ * is deprecated in favor of destination.)
+ * @param destination Complete description of destination.
* @param request JSON encoded request.
- * @param conType @ref OCConnectivityType type of connectivity indicating the
- * interface. Example: ::OC_WIFI, ::OC_ETHERNET, ::OC_ALL.
+ * @param connectivityType Modifier flags when destination is not given.
* @param qos Quality of service. Note that if this API is called on a uri with
* the well-known multicast IP address, the qos will be forced to
* ::OC_LOW_QOS
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
-OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
- const char *referenceUri, const char *request, OCConnectivityType conType,
- OCQualityOfService qos, OCCallbackData *cbData,
- OCHeaderOption * options, uint8_t numOptions);
-
+OCStackResult OCDoResource(OCDoHandle *handle,
+ OCMethod method,
+ const char *requestUri,
+ const OCDevAddr *destination,
+ OCPayload* payload,
+ OCConnectivityType connectivityType,
+ OCQualityOfService qos,
+ OCCallbackData *cbData,
+ OCHeaderOption *options,
+ uint8_t numOptions);
/**
* Cancel a request associated with a specific @ref OCDoResource invocation.
*
OCStackResult OCCancel(OCDoHandle handle, OCQualityOfService qos, OCHeaderOption * options,
uint8_t numOptions);
+/**
+ * @brief Register Persistent storage callback.
+ * @param persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
+ * @return
+ * OC_STACK_OK - No errors; Success
+ * OC_STACK_INVALID_PARAM - Invalid parameter
+ */
+OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
+
#ifdef WITH_PRESENCE
/**
* When operating in @ref OCServer or @ref OCClientServer mode, this API will start sending out
* @param entityHandler Entity handler function that is called by ocstack to handle requests for
* any undefined resources or default actions.
* If NULL is passed it removes the device default entity handler.
+ * @param callbackParameter paramter passed back when entityHandler is called.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
-OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler);
+OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler, void* callbackParameter);
/**
* Set device information.
* @param uri URI of the resource. Example: "/a/led".
* @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
* NULL for default entity handler.
+ * @param callbackParameter paramter passed back when entityHandler is called.
* @param resourceProperties Properties supported by resource.
* Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE.
*
const char *resourceInterfaceName,
const char *uri,
OCEntityHandler entityHandler,
+ void* callbackParam,
uint8_t resourceProperties);
-/**
- * Create a resource. with host ip address for remote resource.
- *
- * @param handle Pointer to handle to newly created resource. Set by ocstack.
- * Used to refer to resource.
- * @param resourceTypeName Name of resource type. Example: "core.led".
- * @param resourceInterfaceName Name of resource interface. Example: "core.rw".
- * @param host HOST address of the remote resource. Example: "coap://xxx.xxx.xxx.xxx:xxxxx".
- * @param uri URI of the resource. Example: "/a/led".
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- * NULL for default entity handler.
- * @param resourceProperties Properties supported by resource.
- * Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE
- *
- * @return ::OC_STACK_OK on success, some other value upon failure.
- */
-OCStackResult OCCreateResourceWithHost(OCResourceHandle *handle,
- const char *resourceTypeName,
- const char *resourceInterfaceName,
- const char *host,
- const char *uri,
- OCEntityHandler entityHandler,
- uint8_t resourceProperties);
/**
* Add a resource to a collection resource.
*
* @param handle Handle to the resource that the contained resource is to be bound.
* @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
+ * @param callbackParameter context paremeter that will be passed to entityHandler
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
-OCStackResult OCBindResourceHandler(OCResourceHandle handle, OCEntityHandler entityHandler);
+OCStackResult OCBindResourceHandler(OCResourceHandle handle, OCEntityHandler entityHandler,
+ void *callbackParameter);
/**
* Get the number of resources that have been created in the stack.
* @param handle Handle of resource.
* @param obsIdList List of observation ids that need to be notified.
* @param numberOfIds Number of observation ids included in obsIdList.
- * @param notificationJSONPayload JSON encoded payload to send in notification.
+ * @param payload OCRepresentationPayload object representing the notification
* @param qos Desired quality of service of the observation notifications.
* NOTE: The memory for obsIdList and notificationJSONPayload is managed by the
* entity invoking the API. The maximum size of the notification is 1015 bytes
OCNotifyListOfObservers (OCResourceHandle handle,
OCObservationId *obsIdList,
uint8_t numberOfIds,
- const char *notificationJSONPayload,
+ const OCRepPayload *payload,
OCQualityOfService qos);
*/
OCStackResult OCDoResponse(OCEntityHandlerResponse *response);
-
-//Utility methods
-
-/**
- * This method is used to retrieved the IPv4 address from OCDev address
- * data structure.
- *
- * @param ipAddr OCDevAddr address.
- * @param a first byte of IPv4 address.
- * @param b second byte of IPv4 address.
- * @param c third byte of IPv4 address.
- * @param d fourth byte of IPv4 address.
- * @return ::OC_STACK_OK on success, some other value upon failure.
- */
-int32_t OCDevAddrToIPv4Addr(OCDevAddr *ipAddr, uint8_t *a, uint8_t *b,
- uint8_t *c, uint8_t *d );
-
-/**
- * This method is used to retrieve the port number from OCDev address
- * data structure.
- *
- * @param ipAddr OCDevAddr address.
- * @param port Port number.
- * @return ::OC_STACK_OK on success, some other value upon failure.
- */
-int32_t OCDevAddrToPort(OCDevAddr *ipAddr, uint16_t *port);
-
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /* OCSTACK_H_ */
-
-