option.remove(NULL, KEY_RETENTION);
}
+ IF_FAIL_RETURN(verifyOption(option), ERR_INVALID_PARAMETER);
+
if (operation == VAL_START)
return __addClient(pkgId, retentionPeriod, option);
else if (operation == VAL_STOP)
return ERR_NOT_SUPPORTED;
}
+bool SensorProvider::verifyOption(Json option)
+{
+ std::list<std::string> keys;
+ option.getKeys(&keys);
+ return keys.size() == 0;
+}
+
int SensorProvider::__addClient(std::string pkgId, int retentionPeriod, Json option)
{
Json tmp;
protected:
virtual Querier* getQuerier(Json option) = 0;
+ virtual bool verifyOption(Json option);
SensorLogger *sensorLogger;
IF_FAIL_RETURN_TAG(querier, NULL, _E, "Memory allocation failed");
return querier;
}
+
+bool HeartRateProvider::verifyOption(Json option)
+{
+ std::list<std::string> keys;
+ option.getKeys(&keys);
+
+ IF_FAIL_RETURN(keys.size() <= 1, false);
+
+ int interval = 0;
+ if (option.get(NULL, KEY_INTERVAL, &interval)) {
+ if (interval < MIN_MEASURING_INTERVAL || interval > MAX_MEASURING_INTERVAL)
+ return false;
+ }
+
+ return true;
+}
protected:
Querier* getQuerier(Json option);
+ bool verifyOption(Json option);
};
}
#define SAMPLING_INTERVAL 200 /* ms */
#define VALID_HR_LB 30 /* BPM */
#define MIN_VALID_COUNT 3
-#define MAX_TIMER_INTERVAL 1440 /* minutes */
#define MEASURING_LIMIT 10000 /* ms */
using namespace ctx;
{
std::vector<Json> options;
ClientInfo clientInfo;
- float interval = MAX_TIMER_INTERVAL;
+ float interval = MAX_MEASURING_INTERVAL;
if (clientInfo.get(SUBJ_SENSOR_HEART_RATE, options) != ERR_NONE)
return false;
#include "../SensorLogger.h"
#include "../SensorProxy.h"
+#define MIN_MEASURING_INTERVAL 10 /* minutes */
+#define MAX_MEASURING_INTERVAL 1440 /* minutes */
+
namespace ctx {
class HeartRateLogger : public SensorLogger, public SensorProxy, public ITimerListener {