* @note Any calls made to this AFTER the first call to OCPlatform::Instance
* will have no affect
*/
- void Configure(const PlatformConfig& config);
+ OCStackResult Configure(const PlatformConfig& config);
// typedef for handle to cancel presence info with
typedef OCDoHandle OCPresenceHandle;
/**
+ * API for stop Base layer including resource and connectivity abstraction.
+ *
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult stop();
+
+ /**
+ * API for start Base layer including resource and connectivity abstraction.
+ * OCInit will be invoked.
+ *
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult start();
+
+ /**
* API for notifying base that resource's attributes have changed.
*
* @param resourceHandle resource handle of the resource
* @param resourceURI name of the resource. If null or empty, performs search for all
* resource names
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param resourceHandler Handles callbacks, success states and failure states.
*
* Four modes of discovery defined as follows:
* @param resourceURI name of the resource. If null or empty, performs search for all
* resource names
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param resourceHandler Handles callbacks, success states and failure states.
*
* Four modes of discovery defined as follows:
OCConnectivityType connectivityType, FindCallback resourceHandler,
FindErrorCallback errorHandler, QualityOfService QoS);
+ OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
+ OCConnectivityType connectivityType, FindResListCallback resourceHandler,
+ QualityOfService QoS = QualityOfService::LowQos);
+
+ OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
+ OCConnectivityType connectivityType, FindResListCallback resourceHandler,
+ FindErrorCallback errorHandler, QualityOfService QoS = QualityOfService::LowQos);
+
+ OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::string& value);
+ OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::vector<std::string>& value);
+ OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::string& value);
+ OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::vector<std::string>& value);
/**
* API for Device Discovery
*
* @param deviceURI Uri containing address to the virtual device in C Stack
("/oic/d")
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param deviceInfoHandler device discovery callback
*
* @return Returns ::OC_STACK_OK if success.
* @param deviceURI Uri containing address to the virtual device in C Stack
("/oic/d")
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param deviceInfoHandler device discovery callback
* @param QoS the quality of communication
* @see getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback)
* @param platformURI Uri containing address to the virtual platform in C Stack
("/oic/p")
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param platformInfoHandler platform discovery callback
*
* @return Returns ::OC_STACK_OK if success.
* @param platformURI Uri containing address to the virtual platform in C Stack
("/oic/p")
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param platformInfoHandler platform discovery callback
* @param QoS the quality of communication
* @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback)
* first parameter can take fully qualified URI and core will take that as is for further
* operations
* @note OCStackResult is defined in ocstack.h.
+ * @note entity handler callback :
+ * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
+ * OC_EH_SLOW and etc in entity handler callback,
+ * ocstack will be not send response automatically to client
+ * except for error return value like OC_EH_ERROR
+ * If you want to send response to client with specific result,
+ * OCDoResponse API should be called with the result value.
*/
OCStackResult registerResource(OCResourceHandle& resourceHandle,
std::string& resourceURI,
* any undefined resources or default actions.
* if NULL is passed it removes the device default entity handler.
* @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
+ * @note entity handler callback :
+ * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
+ * OC_EH_SLOW and etc in entity handler callback,
+ * ocstack will be not send response automatically to client
+ * except for error return value like OC_EH_ERROR
+ * If you want to send response to client with specific result,
+ * sendResponse API should be called with the result value.
*/
OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler);
* @param host The IP address/addressable name of the server to subscribe to.
* This should be in the format coap://address:port
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param presenceHandler callback function that will receive notifications/subscription
* events
*
* This should be in the format coap://address:port
* @param resourceType a resource type specified as a filter for subscription callbacks.
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
* @param presenceHandler callback function that will receive notifications/subscription
* events
* @see subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
*/
OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle);
+#ifdef WITH_CLOUD
+ /**
+ * Subscribes to a server's device presence change events.
+ *
+ * @param presenceHandle a handle object that can be used to identify this subscription
+ * request. It can be used to unsubscribe from these events in the future.
+ * It will be set upon successful return of this method.
+ * @param host The IP address/addressable name of the server to subscribe to.
+ * This should be in the format coap://address:port
+ * @param di Vector which can have the devices id.
+ * @param connectivityType ::OCConnectivityType type of connectivity indicating the
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
+ * @param observeHandler handles callback
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this observe operation
+ * This will have error codes
+ *
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host,
+ const std::vector<std::string>& di,
+ OCConnectivityType connectivityType,
+ ObserveCallback callback);
+#endif
+
/**
* Creates a resource proxy object so that get/put/observe functionality
* can be used without discovering the object in advance. Note that the
* properly routed. Example: /a/light
*
* @param connectivityType ::OCConnectivityType type of connectivity indicating the
- * interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
+ * if you want to use a specific Flag like IPv4,
+ * you should apply OR operation for the flag in here.
+ * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
+ * | OC_IP_USE_V4)
*
* @param isObservable a boolean containing whether the resource supports observation
*
OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
const std::string& pinNumber,
DirectPairingCallback resultCallback);
- }
-}
+#ifdef WITH_CLOUD
+ /**
+ * Create an account manager object that can be used for doing request to account server.
+ * You can only create this object if OCPlatform was initialized to be a Client or
+ * Client/Server. Otherwise, this will return an empty shared ptr.
+ *
+ * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
+ * methods of this object to work since device id is not generated on Client mode.
+ *
+ * @param host Host IP Address of a account server.
+ * @param connectivityType ::OCConnectivityType type of connectivity indicating the
+ * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
+ * if you want to use a specific Flag like IPv4,
+ * you should apply OR operation for the flag in here.
+ * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
+ * | OC_IP_USE_V4)
+ *
+ * @return OCAccountManager::Ptr a shared pointer to the new account manager object
+ */
+ OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
+ OCConnectivityType connectivityType);
+#endif // WITH_CLOUD
-#endif // OC_PLATFORM_H_
+#ifdef TCP_ADAPTER
+ /**
+ * gets OCRepresentation of KeepAlive resource from given host.
+ *
+ * @param host Host IP Address of KeepAlive resource
+ * @param resultCallback Function to callback with result code and OCRepresentation.
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult findKeepAliveResource(std::string host, KeepAliveCallback resultCallback);
+ /**
+ * send KeepAlive request to given host.
+ *
+ * @param rep include interval time of expected pong response
+ * @param resultCallback handles callback
+ *
+ * @return Returns ::OC_STACK_OK on success, some other value upon failure.
+ *
+ */
+ OCStackResult sendKeepAliveRequest(std::string host, const OCRepresentation& rep,
+ KeepAliveCallback resultCallback);
+#endif
+ /**
+ * gets the deviceId of the client
+ *
+ * @param deviceId pointer.
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult getDeviceId(OCUUIdentity *deviceId);
+ /**
+ * sets the deviceId of the client
+ *
+ * @param deviceId pointer.
+ * @return Returns ::OC_STACK_OK if success.
+ */
+ OCStackResult setDeviceId(const OCUUIdentity *deviceId);
+ }
+}
+#endif // OC_PLATFORM_H_