X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Finclude%2Focstack.h;h=44c926de5601d51f3e9685a444a0b74c2d6afa94;hb=refs%2Ftags%2Fupstream%2F0.9.2;hp=73bcd8c3d0c32e1cfb8d459b8bf34bacf50deb4e;hpb=935fdb9b67b6c10d007e652e9e2e028fd6ccfe09;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/include/ocstack.h b/resource/csdk/stack/include/ocstack.h index 73bcd8c..44c926d 100644 --- a/resource/csdk/stack/include/ocstack.h +++ b/resource/csdk/stack/include/ocstack.h @@ -21,13 +21,13 @@ #ifndef OCSTACK_H_ #define OCSTACK_H_ +#include #include #include "octypes.h" #ifdef __cplusplus extern "C" { #endif // __cplusplus -#define WITH_PRESENCE #define USE_RANDOM_PORT (0) //----------------------------------------------------------------------------- @@ -37,6 +37,20 @@ extern "C" { /** * 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 @@ -48,6 +62,16 @@ extern "C" { */ 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. * @@ -79,11 +103,11 @@ OCStackResult OCProcess(); * 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 @@ -100,11 +124,16 @@ OCStackResult OCProcess(); * * @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. * @@ -119,6 +148,15 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ 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 @@ -159,10 +197,11 @@ OCStackResult OCStopPresence(); * @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. @@ -202,6 +241,7 @@ OCStackResult OCSetPlatformInfo(OCPlatformInfo platformInfo); * @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. * @@ -212,31 +252,9 @@ OCStackResult OCCreateResource(OCResourceHandle *handle, 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. @@ -284,9 +302,11 @@ OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle, * * @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. @@ -428,7 +448,7 @@ OCStackResult OCNotifyAllObservers(OCResourceHandle handle, OCQualityOfService q * @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 @@ -440,7 +460,7 @@ OCStackResult OCNotifyListOfObservers (OCResourceHandle handle, OCObservationId *obsIdList, uint8_t numberOfIds, - const char *notificationJSONPayload, + const OCRepPayload *payload, OCQualityOfService qos); @@ -455,37 +475,8 @@ OCNotifyListOfObservers (OCResourceHandle handle, */ 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_ */ - -