From ac9c946525f8819dbad162dae644617cc9e0e548 Mon Sep 17 00:00:00 2001 From: Andriy Gudz Date: Wed, 10 May 2017 11:05:50 +0300 Subject: [PATCH] Added empty unimplemented methods for notification subscribtion --- network-manager/nmlib/IoT/src/iotivity.cpp | 20 ++++++++++++-------- network-manager/nmlib/include/iotivity.h | 23 +++++++++++++++++++++-- network-manager/nmlib/include/nmlib.h | 2 ++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/network-manager/nmlib/IoT/src/iotivity.cpp b/network-manager/nmlib/IoT/src/iotivity.cpp index 6eee3b9..88e3e37 100644 --- a/network-manager/nmlib/IoT/src/iotivity.cpp +++ b/network-manager/nmlib/IoT/src/iotivity.cpp @@ -13,11 +13,9 @@ #include #include #pragma GCC diagnostic pop -#include -#include "nmexceptions.h" -#include "nmlib.h" #include +using namespace std; using namespace OC; #define TAG "NetworkManager" @@ -154,19 +152,19 @@ void IoTivity::cleanUp() } } -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); @@ -398,8 +396,6 @@ bool IoTivity::isSignedIn() return signedIn; } -using namespace std; - string IoTivity::getDeviceID() { OCUUIdentity deviceId; @@ -423,4 +419,12 @@ string IoTivity::getDeviceID() } +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); +} + } diff --git a/network-manager/nmlib/include/iotivity.h b/network-manager/nmlib/include/iotivity.h index b7ccb80..2645f0d 100644 --- a/network-manager/nmlib/include/iotivity.h +++ b/network-manager/nmlib/include/iotivity.h @@ -1,6 +1,7 @@ #ifndef __IOTIVITY_H__ #define __IOTIVITY_H__ +#include "nmlib.h" #include "nmexceptions.h" #include "iotdevice.h" #include @@ -12,6 +13,10 @@ namespace NetworkManager typedef std::map > IoTDevicesMap; +typedef std::function PresenceHook; + +typedef std::function NotificationCallback; + /** * @brief The OAuthCredential struct contains information about current session with cloud server. Filled after signIn(). */ @@ -28,8 +33,6 @@ struct OAuthCredential std::string password; }; -typedef std::function PresenceHook; - class IoTivity { public: @@ -97,8 +100,24 @@ 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; diff --git a/network-manager/nmlib/include/nmlib.h b/network-manager/nmlib/include/nmlib.h index 16e3682..e6f1f7a 100644 --- a/network-manager/nmlib/include/nmlib.h +++ b/network-manager/nmlib/include/nmlib.h @@ -10,6 +10,8 @@ #ifndef __NMLIB_H__ #define __NMLIB_H__ +#include + #ifdef __cplusplus extern "C" { #endif -- 2.7.4