#include <OCApi.h>
#include <OCPlatform.h>
#pragma GCC diagnostic pop
-#include <unistd.h>
-#include "nmexceptions.h"
-#include "nmlib.h"
#include <logging.h>
+using namespace std;
using namespace OC;
#define TAG "NetworkManager"
}
}
-void guardTimeout(bool timeout, std::string message)
+inline void guardTimeout(bool timeout, std::string message)
{
if (timeout)
throw IoTInternalError(message + " timeout exceed", EC_TIMEOUT_ERROR);
}
-void guardSignErrorCode(int resultCode, std::string message)
+inline void guardSignErrorCode(int resultCode, std::string message)
{
if (resultCode != 4)
throw IoTInternalError(message + " callback error:" + std::to_string(resultCode), EC_IOTIVITY_ERROR);
}
-void guardErrorCode(OCStackResult resultCode, std::string message)
+inline void guardErrorCode(OCStackResult resultCode, std::string message)
{
if (resultCode != OC_STACK_OK)
throw IoTInternalError(message + " error:" + std::to_string(resultCode), EC_IOTIVITY_ERROR);
return signedIn;
}
-using namespace std;
-
string IoTivity::getDeviceID()
{
OCUUIdentity deviceId;
}
+void IoTivity::subscribeNotifications(NotificationCallback callback) {
+ throw IoTInternalError("subscribeNotifications() not implemented", EC_NOT_IMPLEMENTED_YET);
+}
+
+void IoTivity::unsubscribeNotifications() {
+ throw IoTInternalError("unsubscribeNotifications() not implemented", EC_NOT_IMPLEMENTED_YET);
+}
+
}
#ifndef __IOTIVITY_H__
#define __IOTIVITY_H__
+#include "nmlib.h"
#include "nmexceptions.h"
#include "iotdevice.h"
#include <memory>
typedef std::map<std::string, std::shared_ptr<IoTDevice> > IoTDevicesMap;
+typedef std::function<void(const std::string&, bool)> PresenceHook;
+
+typedef std::function<void(const std::string)> NotificationCallback;
+
/**
* @brief The OAuthCredential struct contains information about current session with cloud server. Filled after signIn().
*/
std::string password;
};
-typedef std::function<void(const std::string&, bool)> PresenceHook;
-
class IoTivity
{
public:
*/
IoTDevicesMap getUnOwnedDevices();
+ /**
+ * @brief getDeviceID returns device id (DUID) from iotivity persistant storage
+ * @return string that indicates duid
+ */
static std::string getDeviceID();
+ /**
+ * @brief subscribeNotifications subscribes to secure server notifications.
+ * Only one subscription allowed.
+ * @param callback method to receive notifications after subscription
+ */
+ void subscribeNotifications(NotificationCallback callback);
+
+ /**
+ * @brief unsubscribeNotifications unsubscribes to current secure server notifications
+ */
+ void unsubscribeNotifications();
+
private:
static const std::string DEFAULT_PROVIDER;
static const int DEFAULT_TIMEOUT;