public void Init() { String msg_str_of_find = "find"; String msg_str_of_enable = "enable"; FelicaError("Start\n"); UInt32 card_find_message = RegisterWindowMessage(msg_str_of_find); if (card_find_message == 0) { FelicaError("Failed: RegisterWindowMessage\n"); ErrorRoutine(); } UInt32 card_enable_message = RegisterWindowMessage(msg_str_of_enable); if (card_enable_message == 0) { FelicaError("Failed: RegisterWindowMessage\n"); ErrorRoutine(); } MessageHandler messageHandler = new MessageHandler(card_find_message, card_enable_message); ListenerWindow lw = new ListenerWindow(messageHandler); lw.handler += new MessageReceivedEventHandler(messageHandler.messageHandlerFunc); bRet = lw.WatchMessage(card_find_message); if (bRet == false) { FelicaError("Failed: WatchMessage\n"); ErrorRoutine(); } bRet = lw.WatchMessage(card_enable_message); if (bRet == false) { FelicaError("Failed: WatchMessage\n"); ErrorRoutine(); } bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcInitialize(); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcInitialize\n"); ErrorRoutine(); } StringBuilder port_name = new StringBuilder("USB0"); bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcOpen(port_name); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcOpen\n"); ErrorRoutine(); } bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcSetPollCallbackParameters( lw.Handle, msg_str_of_find, msg_str_of_enable); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcSetPollCallbackParameters\n"); ErrorRoutine(); } const Int32 DEVICE_TYPE_NFC_18092_212_424K = 0x00000006; UInt32 target_device = DEVICE_TYPE_NFC_18092_212_424K; bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcStartPollMode(target_device); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcStartPollMode\n"); ErrorRoutine(); } FelicaError("MessageLoopStart\n"); Application.Run(lw); if (messageHandler.bRet == false) { ErrorRoutine(); } getIDm(); UInt32 RE_NOTIFICATION_SAME_DEVICE = 0x00; UInt32 stop_mode = RE_NOTIFICATION_SAME_DEVICE; bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcStopDevAccess(stop_mode); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcStopDevAccess\n"); ErrorRoutine(); } bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcStopPollMode(); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcStopPollMode\n"); ErrorRoutine(); } bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcClose(); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcClose\n"); ErrorRoutine(); } bRet = FeliCaNfcDllWrapperClass.FeliCaLibNfcUninitialize(); if (bRet == false) { FelicaError("Failed: FeliCaLibNfcUninitialize\n"); ErrorRoutine(); } FelicaError("Finish\n"); }
public ListenerWindow(MessageHandler _message) { message = _message; }