@@ -8,6 +8,7 @@ using namespace v8;
88
99#define DBR_NO_MEMORY 0
1010#define DBR_SUCCESS 1
11+ #define DEFAULT_MEMORY_SIZE 4096
1112
1213// barcode reader handler
1314void * hBarcode = NULL ;
@@ -389,6 +390,28 @@ void DecodeBase64Async(const FunctionCallbackInfo<Value>& args) {
389390 uv_queue_work (uv_default_loop (), &worker->request , (uv_work_cb)DetectionWorking, (uv_after_work_cb)DetectionDone);
390391}
391392
393+ /*
394+ * setParameters(json)
395+ */
396+ void SetParameters (const FunctionCallbackInfo<Value>& args) {
397+ if (!createDBR ()) {return ;}
398+
399+ Isolate* isolate = Isolate::GetCurrent ();
400+ HandleScope scope (isolate);
401+
402+ // Get arguments
403+ String::Utf8Value params (args[0 ]->ToString ()); // json string
404+ char *json = *params;
405+
406+ // Update template setting
407+ char errorMessage[DEFAULT_MEMORY_SIZE ];
408+ int ret = DBR_InitRuntimeSettingsWithString (hBarcode, json, CM_OVERWRITE , errorMessage, 256 );
409+ if (ret)
410+ {
411+ printf (" Returned value: %d, error message: %s\n " , ret, errorMessage);
412+ }
413+ }
414+
392415void Init (Handle<Object> exports) {
393416 NODE_SET_METHOD (exports, " create" , Create);
394417 NODE_SET_METHOD (exports, " destroy" , Destroy);
@@ -397,6 +420,7 @@ void Init(Handle<Object> exports) {
397420 NODE_SET_METHOD (exports, " initLicense" , InitLicense);
398421 NODE_SET_METHOD (exports, " decodeFileAsync" , DecodeFileAsync);
399422 NODE_SET_METHOD (exports, " decodeBase64Async" , DecodeBase64Async);
423+ NODE_SET_METHOD (exports, " setParameters" , SetParameters);
400424}
401425
402426NODE_MODULE (dbr, Init)
0 commit comments