using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using v8::Number;
using v8::Exception;
void js_Exchange(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
int slot = args[0]->NumberValue();
String::Utf8Value param1(args[1]->ToString());
char *szApdu = *param1;
uint8_t apdu[300] = "\0";
MyAHex((uint8_t *)szApdu, apdu, strlen(szApdu));
uint8_t rpdu[300] = "\0";
uint32_t rpdu_len = 0;
char szResult[300] = "\0";
int ret = Exchange(slot, apdu, strlen(szApdu) / 2, rpdu, &rpdu_len);
if(0 == ret) {
MyHexA(rpdu, (uint8_t *)szResult, rpdu_len);
args.GetReturnValue().Set(String::NewFromUtf8(isolate, szResult));
} else {
args.GetReturnValue().Set(String::NewFromUtf8(isolate, ""));
}
}