Exemple #1
0
TNodejsDHT11Sensor* TNodejsDHT11Sensor::NewFromArgs(const v8::FunctionCallbackInfo<v8::Value>& Args) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	PJsonVal ParamJson = TNodeJsUtil::GetArgJson(Args, 0);

	const int Pin = ParamJson->GetObjInt("pin");
	const TStr& TempId = ParamJson->GetObjStr("temperatureId");
	const TStr& HumId = ParamJson->GetObjStr("humidityId");
	const uint64 MxSampleTm = ParamJson->GetObjUInt64("timeout", 10000);
	const bool Verbose = ParamJson->GetObjBool("verbose", false);

	const PNotify Notify = Verbose ? TNotify::StdNotify : TNotify::NullNotify;

	return new TNodejsDHT11Sensor(new TDHT11Sensor(Pin, Notify), TempId, HumId, MxSampleTm, Notify);
}