|
@@ -1,3720 +1,3772 @@
|
|
|
-/*
|
|
|
- * Copyright (C) 2014 Android WallPad Project
|
|
|
- *
|
|
|
- * FileName : SmartKeyRfDoor_Controller.java
|
|
|
- * Project : Android WallPad Project
|
|
|
- * Company : HDC I-CONTROLS ( www.icontrols.co.kr )
|
|
|
- * Author : Kang Sang Ho , lairu@icontrols.co.kr
|
|
|
- */
|
|
|
-
|
|
|
-package com.artncore.wallpaddevservice.driver;
|
|
|
-
|
|
|
-import java.security.SecureRandom;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.GregorianCalendar;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Random;
|
|
|
-
|
|
|
-import kr.co.icontrols.iencryptor.aes128.AES_128;
|
|
|
-import kr.co.icontrols.wallpadsupport.Version;
|
|
|
-import kr.co.icontrols.wallpadsupport.WpadSound;
|
|
|
-import android.annotation.SuppressLint;
|
|
|
-import android.app.ActivityManager;
|
|
|
-import android.app.ActivityManager.RunningTaskInfo;
|
|
|
-import android.content.BroadcastReceiver;
|
|
|
-import android.content.ComponentName;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
-import android.content.IntentFilter;
|
|
|
-import android.os.CountDownTimer;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.widget.Toast;
|
|
|
-
|
|
|
-import com.artncore.WallPadDataMgr.WallpadAccessData;
|
|
|
-import com.artncore.WallPadDataMgr.WallpadDeviceSet;
|
|
|
-import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
|
|
|
-import com.artncore.WallPadDataMgr.WallpadStatusData;
|
|
|
-import com.artncore.WallPadDataMgr.wallpaddbmgr;
|
|
|
-import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
|
|
|
-import com.artncore.commons.APIErrorCode;
|
|
|
-import com.artncore.commons.define;
|
|
|
-import com.artncore.devicectr.WallPadInterface;
|
|
|
-import com.util.LogUtil;
|
|
|
-import com.artncore.wallpaddevservice.ServiceMain;
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 스마트키 RF 현관카메라의 드라이버 모듈이다.
|
|
|
- */
|
|
|
-@SuppressLint("HandlerLeak")
|
|
|
-public class SmartKeyRfDoor_Controller extends DeviceManager {
|
|
|
- private final static String TAG = "SmartKeyRfDoor_DRV";
|
|
|
-
|
|
|
- private final byte DEVICE_ADDRESS = (byte) 0xA2;
|
|
|
-
|
|
|
- private final byte MAX_SMARTKEY_COUNT = (byte) 5;
|
|
|
-
|
|
|
- /** RSSI 동기화 시간 (1시간) */
|
|
|
- //private final long RSSI_SYNC_TICK = (long)(60 * TIME_MINUTE);
|
|
|
- private final long RSSI_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
- /** LED 모드 동기화 시간 (5분) */
|
|
|
- //private final long LED_SYNC_TICK = (long)(5 * TIME_MINUTE);
|
|
|
- private final long LED_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
- /** 카메라 모드 동기화 시간 (5분) */
|
|
|
- //private final long CAM_SYNC_TICK = (long)(5 * TIME_MINUTE);
|
|
|
- private final long CAM_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
- /** 시간정보 동기화 시간 (1시간) */
|
|
|
- private final long TIME_SYNC_TICK = (long) TIME_MINUTE;
|
|
|
-
|
|
|
- private boolean firstSensor = true;
|
|
|
-
|
|
|
- /** 도어락 문열림 대기모드 설정 시간*/
|
|
|
- private final byte DLOCK_STANDBYMODE_SEC = (byte) 5;
|
|
|
-
|
|
|
- /** 등록후 대기시간 (초) */
|
|
|
- private final long REGISTERPAUSE_TIMEOUT_TICK = (long)(5 * TIME_SEC);
|
|
|
-
|
|
|
- /** 등록모드 시작 */
|
|
|
- public final static byte STATUS_REGMODE_START = (byte) 0x00;
|
|
|
- /** 등록완료 */
|
|
|
- public final static byte STATUS_REGMODE_KEY_COMPLETE = (byte) 0x10;
|
|
|
- /** 이미 등록된 키 */
|
|
|
- public final static byte STATUS_REGMODE_KEY_ALREADY = (byte) 0x20;
|
|
|
- /** 무선 통신실패 */
|
|
|
- public final static byte STATUS_REGMODE_ER_WIRELESSCOMMFAIL = (byte) 0x30;
|
|
|
- /** DB 저장 실패 */
|
|
|
- public final static byte STATUS_REGMODE_ER_DBWRITE = (byte) 0x40;
|
|
|
- /** 등록모드 종료 */
|
|
|
- public final static byte STATUS_REGMODE_END = (byte) 0xA0;
|
|
|
- /** 등록할 공간 없음 */
|
|
|
- public final static byte STATUS_REGMODE_FULL = (byte) 0xB0;
|
|
|
-
|
|
|
- private static byte CheckSmartKeyNo = 0x00;
|
|
|
- public static byte GetCheckSmartKeyNo() { return CheckSmartKeyNo; }
|
|
|
- private static String CheckSmartKeySn = null;
|
|
|
- public static String GetCheckSmartKeySn() { return CheckSmartKeySn; }
|
|
|
-
|
|
|
- /** 도어락 타입 - WallpadDeviceSet.DOORLOCK_TYPE_NORMAL or WallpadDeviceSet.DOORLOCK_TYPE_RF*/
|
|
|
- private int mDoorLockType = WallpadDeviceSet.DOORLOCK_TYPE_NORMAL;
|
|
|
-
|
|
|
- private int mModelType = Version.getModelType();
|
|
|
-
|
|
|
- /////////////////////////////////////////////////////////////
|
|
|
- // 무선도어락 연동
|
|
|
- /////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- /** 문열림 대기모드 상태 true:사용, false:사용하지 않음 */
|
|
|
- private boolean mDoorOpenDelay = false;
|
|
|
-
|
|
|
- /** 자체 문열림 모드 상태 true:허용, false:비허용 */
|
|
|
- private boolean mDoorStdOpenMode = false;
|
|
|
-
|
|
|
- /** 현관카메라 전원ON을 위한 타이머*/
|
|
|
- private CountDownTimer PowerOnTimer = null;
|
|
|
- /** WallpadCall 패키지 명*/
|
|
|
- private static final String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
|
|
|
-
|
|
|
-
|
|
|
- /** WallpadCall 호출 가능 여부 true:허용, false:비허용
|
|
|
- * 초인종 눌림 -> WallpadCall 실행 가능하도록 초기 설정
|
|
|
- * */
|
|
|
- private boolean CallAppEnable = true;
|
|
|
- /**
|
|
|
- * 자체 문열림 모드 상태
|
|
|
- * @return (boolean) true:허용, false:비허용
|
|
|
- */
|
|
|
- private boolean GetDoorStdOpenMode() { return mDoorStdOpenMode; }
|
|
|
- /**
|
|
|
- * 자체 문열림 모드를 설정한다.
|
|
|
- *
|
|
|
- * @param OnOff (boolean) true:허용, false:비허용
|
|
|
- */
|
|
|
- private void SetDoorStdOpenMode(boolean OnOff) {
|
|
|
- mDoorStdOpenModeHandler.removeMessages(0);
|
|
|
- mDoorStdOpenModeHandler.removeMessages(1);
|
|
|
- if (OnOff) {
|
|
|
- Log.i(TAG, "[SetDoorStdOpenMode] ON");
|
|
|
- mDoorStdOpenMode = true;
|
|
|
- mDoorStdOpenModeHandler.sendEmptyMessage(0);
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.i(TAG, "[SetDoorStdOpenMode] OFF");
|
|
|
- mDoorStdOpenMode = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Handler mDoorStdOpenModeHandler = new Handler()
|
|
|
- {
|
|
|
- @Override
|
|
|
- public void handleMessage(Message msg)
|
|
|
- {
|
|
|
- if (msg.what == 0) {
|
|
|
- Log.i(TAG, "[mDoorStdOpenModeHandler] Start !!!");
|
|
|
- mDoorStdOpenModeHandler.sendEmptyMessageDelayed(1, (long)((long)DLOCK_STANDBYMODE_SEC * (long)1000));
|
|
|
- }
|
|
|
- else if (msg.what == 1) {
|
|
|
- Log.i(TAG, "[mDoorStdOpenModeHandler] TimeOut...");
|
|
|
- mDoorStdOpenMode = false;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- /////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- /** 초기 기기 검색 횟수 */
|
|
|
- private final int MAX_SEARCH_COUNT = 3;
|
|
|
-
|
|
|
- private class InfoList {
|
|
|
- /** 센서지원 유무(거동수상자 감지용)*/
|
|
|
- private boolean bSensorUsage;
|
|
|
- /** LED 제어 지원 유무*/
|
|
|
- private boolean bLEDLightCtrlable;
|
|
|
- /** RSSI 제어 지원 유무*/
|
|
|
- private boolean bRSSICtrlable;
|
|
|
- /** 카메라 제어 지원 유무*/
|
|
|
- private boolean bCameraCtrlable;
|
|
|
- /** PIR센서 지원 유무*/
|
|
|
- private boolean bPIRSensorUsage;
|
|
|
- /** 시간정보 지원 유무*/
|
|
|
- private boolean bTimeUsage;
|
|
|
-
|
|
|
- /** 제조사 코드 ( 0x01 : 아이콘트롤스 ) */
|
|
|
- private byte hVendor;
|
|
|
-
|
|
|
- /** 펌웨어 Build Date (년) */
|
|
|
- private byte hFWVer_Year;
|
|
|
- /** 펌웨어 Build Date (월) */
|
|
|
- private byte hFWVer_Month;
|
|
|
- /** 펌웨어 Build Date (일) */
|
|
|
- private byte hFWVer_Date;
|
|
|
- /** 펌웨어 Build Date (일련번호) */
|
|
|
- private byte hFWVer_No;
|
|
|
-
|
|
|
- /** 지원 프로토콜 버전 Main */
|
|
|
- private byte hProtocolVer_Main;
|
|
|
- /** 지원 프로토콜 버전 Sub */
|
|
|
- private byte hProtocolVer_Sub;
|
|
|
-
|
|
|
- private InfoList() {
|
|
|
- bSensorUsage = false;
|
|
|
- bLEDLightCtrlable = false;
|
|
|
- bRSSICtrlable = false;
|
|
|
- bCameraCtrlable = false;
|
|
|
- bPIRSensorUsage = false;
|
|
|
- bTimeUsage = false;
|
|
|
-
|
|
|
- hVendor = 0x00;
|
|
|
-
|
|
|
- hFWVer_Year = 0x00;
|
|
|
- hFWVer_Month = 0x00;
|
|
|
- hFWVer_Date = 0x00;
|
|
|
- hFWVer_No = 0x00;
|
|
|
-
|
|
|
- hProtocolVer_Main = 0x00;
|
|
|
- hProtocolVer_Sub = 0x00;
|
|
|
- }
|
|
|
-
|
|
|
- public String ToDebugString() {
|
|
|
- String retStr =
|
|
|
- "==========================\r\n" +
|
|
|
- "InfoList\r\n" +
|
|
|
- "==========================\r\n" +
|
|
|
- "bSensorUsage : " + bSensorUsage + "\r\n" +
|
|
|
- "bLEDLightCtrlable : " + bLEDLightCtrlable + "\r\n" +
|
|
|
- "bRSSICtrlable : " + bRSSICtrlable + "\r\n" +
|
|
|
- "bCameraCtrlable: " + bCameraCtrlable + "\r\n" +
|
|
|
- "bPIRSensorUsage : " + bPIRSensorUsage + "\r\n" +
|
|
|
- "bTimeUsage: " + bTimeUsage + "\r\n" +
|
|
|
-
|
|
|
- "Vender : " + String.format("0x%02X", hVendor) + "\r\n" +
|
|
|
-
|
|
|
- "FW Ver. : " + (int)(hFWVer_Year +2000) + "." + hFWVer_Month + "." + hFWVer_Date + "." + hFWVer_No + "\r\n" +
|
|
|
- "Protocol Ver. : " + "V" + hProtocolVer_Main + "." + hProtocolVer_Sub + "\r\n" +
|
|
|
- "==========================";
|
|
|
- return retStr;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /** 기본 상태 응답값 정의 */
|
|
|
- private class StatusList {
|
|
|
- /** 거동수상자 센서감지 : true:감지 , false:미감지 */
|
|
|
- private boolean bSensorDetect;
|
|
|
- /** 카메라 센서감지 : true:동작중 , false:꺼짐 */
|
|
|
- private boolean bCameraStatus;
|
|
|
- /** LED 상태 : true:동작중 , false:꺼짐 */
|
|
|
- private boolean bLedStatus;
|
|
|
- /** 카메라 Auto 상태 : true:동작중 , false:꺼짐 */
|
|
|
- private boolean bCameraAuto;
|
|
|
- /** LED Auto 상태 : true:동작중 , false:꺼짐 */
|
|
|
- private boolean bLedAuto;
|
|
|
- /** 현관벨 상태 : true:눌림 , false:평상시 */
|
|
|
- private boolean bDoorBtnStatus;
|
|
|
- /** 에러상태 : true:에러 , false:정상 */
|
|
|
- private boolean bError;
|
|
|
- /** 인식된 RF 스마트키 개수 */
|
|
|
- private byte SmartKeyCount;
|
|
|
-
|
|
|
- private StatusList() {
|
|
|
- bSensorDetect = false;
|
|
|
- bCameraStatus = false;
|
|
|
- bLedStatus = false;
|
|
|
- bCameraAuto = false;
|
|
|
- bLedAuto = false;
|
|
|
-
|
|
|
- bDoorBtnStatus = false;
|
|
|
- bError = false;
|
|
|
- SmartKeyCount = 0;
|
|
|
- }
|
|
|
-
|
|
|
- public String ToDebugString() {
|
|
|
- String retStr =
|
|
|
- "==========================\r\n" +
|
|
|
- "StatusList\r\n" +
|
|
|
- "==========================\r\n" +
|
|
|
- "bSensorDetect : " + bSensorDetect + "\r\n" +
|
|
|
- "bLedStatus : " + bLedStatus + "\r\n" +
|
|
|
- "bCameraStatus : " + bCameraStatus + "\r\n" +
|
|
|
- "bLedAuto : " + bLedAuto + "\r\n" +
|
|
|
- "bCameraAuto : " + bCameraAuto + "\r\n" +
|
|
|
- "bDoorBtnStatus : " + bDoorBtnStatus + "\r\n" +
|
|
|
- "bError : " + bError + "\r\n" +
|
|
|
- "SmartKeyCount : " + SmartKeyCount + "\r\n" +
|
|
|
- "==========================";
|
|
|
- return retStr;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /** 거동수상자 관련 센서값 */
|
|
|
- private class SensorValue {
|
|
|
- /** 센서 감도 */
|
|
|
- private byte Sensor_Sensitivity;
|
|
|
- /** 거동수상자 판별시간 */
|
|
|
- private byte Sensor_DetectTime;
|
|
|
- /** LED 모드 */
|
|
|
- private byte Sensor_LedMode;
|
|
|
- /** 감지센서 RSSI Read */
|
|
|
- private byte Sensor_RSSI_Read;
|
|
|
- /** 감지센서 RSSI Write */
|
|
|
- private byte Sensor_RSSI_Write;
|
|
|
- /** 거동수상자 판별빈도 */
|
|
|
- private byte Sensor_DetectRatio;
|
|
|
- /** 카메라 모드 */
|
|
|
- private byte Sensor_CameraMode;
|
|
|
-
|
|
|
- private SensorValue() {
|
|
|
- Sensor_Sensitivity = 0;
|
|
|
- Sensor_DetectTime = 0;
|
|
|
-
|
|
|
- Sensor_LedMode = -1;
|
|
|
- Sensor_CameraMode = -1;
|
|
|
-
|
|
|
- Sensor_DetectRatio = 100; // 현관카메라의 감지빈도는 기본 100%로 설정되어 있음
|
|
|
- Sensor_RSSI_Read = -101; // 기본값 : 범위 이탈
|
|
|
- Sensor_RSSI_Write = -101; // 기본값 : 범위 이탈
|
|
|
- }
|
|
|
-
|
|
|
- public String ToDebugString() {
|
|
|
- String retStr =
|
|
|
- "==========================\r\n" +
|
|
|
- "SensorValue\r\n" +
|
|
|
- "==========================\r\n" +
|
|
|
- "Sensor_Sensitivity : " + Sensor_Sensitivity + "\r\n" +
|
|
|
- "Sensor_DetectTime : " + Sensor_DetectTime + "\r\n" +
|
|
|
- "Sensor_DetectRatio : " + Sensor_DetectRatio + "\r\n" +
|
|
|
- "Sensor_RSSI_Read : " + Sensor_RSSI_Read + "\r\n" +
|
|
|
- "Sensor_RSSI_Write : " + Sensor_RSSI_Write + "\r\n" +
|
|
|
- "Sensor_LedMode : " + Sensor_LedMode + "\r\n" +
|
|
|
- "Sensor_CameraMode : " + Sensor_CameraMode + "\r\n" +
|
|
|
- "==========================";
|
|
|
- return retStr;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private class EncryptionList {
|
|
|
- private byte [] Data;
|
|
|
- private EncryptionList() {
|
|
|
- Data = new byte [16];
|
|
|
- for (int i = 0; i < Data.length; i++) Data[i] = 0x00;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean Input(byte [] in, int startIdx) {
|
|
|
- if (in == null) return false;
|
|
|
- if ((in.length - startIdx) < 16) return false;
|
|
|
-
|
|
|
- if (Data == null) return false;
|
|
|
-
|
|
|
- for (int i = 0; i < Data.length; i++) Data[i] = in[startIdx + i];
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- public String ToDebugString(int KeyIndex) {
|
|
|
- if (Data == null) return "null";
|
|
|
-
|
|
|
- String retStr = "[" + KeyIndex + "] ";
|
|
|
-
|
|
|
- for (int i = 0; i < Data.length; i++) {
|
|
|
- retStr += String.format("%02X ", Data[i]);
|
|
|
- }
|
|
|
- return retStr;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private class KeyDataList {
|
|
|
- private byte Count;
|
|
|
-
|
|
|
- public EncryptionList [] Encryption;
|
|
|
-
|
|
|
- private KeyDataList() {
|
|
|
- Count = 0;
|
|
|
- Encryption = null;
|
|
|
- }
|
|
|
-
|
|
|
- private KeyDataList(byte setcount) {
|
|
|
- Count = 0;
|
|
|
- Encryption = null;
|
|
|
-
|
|
|
- SetCount(setcount);
|
|
|
- }
|
|
|
-
|
|
|
- private int SetCount(byte setcount) {
|
|
|
- if (setcount <= 0 || setcount > MAX_SMARTKEY_COUNT) return -1;
|
|
|
-
|
|
|
- Count = setcount;
|
|
|
- Encryption = new EncryptionList[setcount];
|
|
|
- for (byte i = 0; i < setcount; i++) Encryption[i] = new EncryptionList();
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- private byte [] getByteArray() {
|
|
|
- if (Encryption == null) return null;
|
|
|
-
|
|
|
- byte [] retdata = new byte [(Count * 16) + 1];
|
|
|
- int index = 0;
|
|
|
- retdata[index++] = Count;
|
|
|
-
|
|
|
- for (byte dataIdx = 0; dataIdx < Count; dataIdx++) {
|
|
|
- for (int i = 0; i < 16; i++) {
|
|
|
- retdata[index++] = Encryption[dataIdx].Data[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return retdata;
|
|
|
- }
|
|
|
-
|
|
|
- public String ToDebugString() {
|
|
|
- String retStr =
|
|
|
- "==========================\r\n" +
|
|
|
- "KeyDataList\r\n" +
|
|
|
- "==========================\r\n";
|
|
|
-
|
|
|
- retStr += "Count : " + Count + "\r\n";
|
|
|
-
|
|
|
- if (Count > 0) {
|
|
|
- for(byte i = 0; i < Count; i++) retStr += Encryption[i].ToDebugString(i+1) + "\r\n";
|
|
|
- }
|
|
|
- retStr += "==========================\r\n";
|
|
|
-
|
|
|
- return retStr;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private class GetRegisterDataList {
|
|
|
- boolean Exit;
|
|
|
- byte RegResult;
|
|
|
- public EncryptionList Encryption;
|
|
|
-
|
|
|
- private GetRegisterDataList() {
|
|
|
- Exit = false;
|
|
|
- RegResult = 0x00;
|
|
|
- Encryption = null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private class SetRegisterDataList {
|
|
|
- byte [] LocalCode;
|
|
|
- byte [] SiteCode;
|
|
|
- byte [] DongCode;
|
|
|
- byte [] HoCode;
|
|
|
- byte CardRegNo;
|
|
|
-
|
|
|
- private SetRegisterDataList() {
|
|
|
- LocalCode = new byte [] { 0x00, 0x00 };
|
|
|
- SiteCode = new byte [] { 0x00, 0x00 };
|
|
|
- DongCode = new byte [] { 0x00, 0x00 };
|
|
|
- HoCode = new byte [] { 0x00, 0x00 };
|
|
|
- CardRegNo = 0x00;
|
|
|
- }
|
|
|
-
|
|
|
- public int setSiteCode(byte [] InCode) {
|
|
|
- if (InCode == null) return -1;
|
|
|
- if (InCode.length < 4) return -2;
|
|
|
- if (LocalCode == null) return -3;
|
|
|
- if (SiteCode == null) return -4;
|
|
|
-
|
|
|
- LocalCode[0] = InCode[0];
|
|
|
- LocalCode[1] = InCode[1];
|
|
|
- SiteCode[0] = InCode[2];
|
|
|
- SiteCode[1] = InCode[3];
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- public int setDongHoCode(byte [] InCode) {
|
|
|
- if (InCode == null) return -1;
|
|
|
- if (InCode.length < 4) return -2;
|
|
|
- if (DongCode == null) return -3;
|
|
|
- if (HoCode == null) return -4;
|
|
|
-
|
|
|
- DongCode[0] = InCode[0];
|
|
|
- DongCode[1] = InCode[1];
|
|
|
- HoCode[0] = InCode[2];
|
|
|
- HoCode[1] = InCode[3];
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- public int setLocalCode(byte [] InCode) {
|
|
|
- if (InCode == null) return -1;
|
|
|
- if (InCode.length < 2) return -2;
|
|
|
- if (LocalCode == null) return -3;
|
|
|
-
|
|
|
- LocalCode[0] = InCode[0];
|
|
|
- LocalCode[1] = InCode[1];
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- public byte [] getByteArray() {
|
|
|
- if (LocalCode == null) return null;
|
|
|
- if (SiteCode == null) return null;
|
|
|
- if (DongCode == null) return null;
|
|
|
- if (HoCode == null) return null;
|
|
|
-
|
|
|
- byte [] retArray = new byte [9];
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- retArray[index++] = LocalCode[0];
|
|
|
- retArray[index++] = LocalCode[1];
|
|
|
- retArray[index++] = SiteCode[0];
|
|
|
- retArray[index++] = SiteCode[1];
|
|
|
- retArray[index++] = DongCode[0];
|
|
|
- retArray[index++] = DongCode[1];
|
|
|
- retArray[index++] = HoCode[0];
|
|
|
- retArray[index++] = HoCode[1];
|
|
|
- retArray[index++] = CardRegNo;
|
|
|
-
|
|
|
- return retArray;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public class Driver {
|
|
|
- private PollingList Polling;
|
|
|
-
|
|
|
- private InfoList Info;
|
|
|
-
|
|
|
- private StatusList Status;
|
|
|
-
|
|
|
- private SensorValue Sensor_Value;
|
|
|
-
|
|
|
- private byte [] DongHoBCD;
|
|
|
-
|
|
|
- private byte [] SiteCodeBCD;
|
|
|
-
|
|
|
- private boolean RegisterInitMode;
|
|
|
-
|
|
|
- private byte CardRegNo;
|
|
|
-
|
|
|
- public Driver() {
|
|
|
- Polling = new PollingList();
|
|
|
-
|
|
|
- Info = new InfoList();
|
|
|
-
|
|
|
- Status = new StatusList();
|
|
|
-
|
|
|
- Sensor_Value = new SensorValue();
|
|
|
-
|
|
|
- DongHoBCD = new byte [] { 0, 0, 0, 0 };
|
|
|
- SiteCodeBCD = new byte [] { 0, 0, 0, 0 };
|
|
|
-
|
|
|
- RegisterInitMode = false;
|
|
|
-
|
|
|
- CardRegNo = 0x00;
|
|
|
- }
|
|
|
-
|
|
|
- /** Polling 관련 */
|
|
|
- private class PollingList {
|
|
|
- private final class STATUS {
|
|
|
- /** 초기화 과정 */
|
|
|
- public final static byte First = 0;
|
|
|
- /** 초기화 타임아웃 */
|
|
|
- public final static byte FirstTimeOut = 1;
|
|
|
- /** 평상시 */
|
|
|
- public final static byte Normal = 2;
|
|
|
- /** 등록모드 시작 버튼 체크 */
|
|
|
- public final static byte RegisterStartCheck = 4;
|
|
|
- /** 등록모드 */
|
|
|
- public final static byte Register = 5;
|
|
|
- /** 등록후 일시정지 */
|
|
|
- public final static byte RegisterPause = 6;
|
|
|
- }
|
|
|
-
|
|
|
- public byte Status;
|
|
|
- public int SearchTryCount;
|
|
|
- public boolean bRandomKeyGeneration;
|
|
|
- public byte [] RandomKeyBuffer;
|
|
|
-
|
|
|
- public long RegisterPauseTimeOutTick;
|
|
|
-
|
|
|
- public long RssiSyncTick;
|
|
|
- public long LedSyncTick;
|
|
|
- public long CamSyncTick;
|
|
|
- public long TimeSyncTick;
|
|
|
-
|
|
|
- private PollingList() {
|
|
|
- SetStatus(STATUS.First);
|
|
|
- SearchTryCount = 0;
|
|
|
-
|
|
|
- bRandomKeyGeneration = true;
|
|
|
- RandomKeyBuffer = new byte [] { 0x00, 0x00 };
|
|
|
- RegisterPauseTimeOutTick = 0;
|
|
|
-
|
|
|
- RssiSyncTick = 0;
|
|
|
- LedSyncTick = 0;
|
|
|
- CamSyncTick = 0;
|
|
|
- TimeSyncTick = 0;
|
|
|
- }
|
|
|
-
|
|
|
- public void SetStatus(byte ChangeStatus) {
|
|
|
- switch (ChangeStatus) {
|
|
|
- case STATUS.First:
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
-
|
|
|
- case STATUS.FirstTimeOut:
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
-
|
|
|
- case STATUS.Normal:
|
|
|
- if ((Status == STATUS.RegisterStartCheck) || (Status == STATUS.Register) || (Status == STATUS.RegisterPause)) {
|
|
|
- StatusChanged(STATUS_REGMODE_END);
|
|
|
- }
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
-
|
|
|
- case STATUS.RegisterStartCheck:
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
-
|
|
|
- case STATUS.Register:
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
-
|
|
|
- case STATUS.RegisterPause:
|
|
|
- RegisterPauseTimeOutTick = System.currentTimeMillis();
|
|
|
- Status = ChangeStatus;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Driver mDriver = null;
|
|
|
-
|
|
|
- private DriverInterOpAPI driverInterOpAPI;
|
|
|
-
|
|
|
- /**
|
|
|
- * 생성자
|
|
|
- */
|
|
|
- public SmartKeyRfDoor_Controller() {
|
|
|
- /* 로그 초기상태 */
|
|
|
-// log_sw = true;
|
|
|
-// SerialLog = true;
|
|
|
-
|
|
|
- /* 통신성공률 변수 초기화 */
|
|
|
- super.CommDataGeneration(1);
|
|
|
-
|
|
|
- /* 드라이버 내부 변수 초기화 */
|
|
|
- mDriver = new Driver();
|
|
|
-
|
|
|
- /* 동호 가져오기 */
|
|
|
- byte [] DongHoBCD = getDongHo_BCD();
|
|
|
- if (DongHoBCD != null) mDriver.DongHoBCD = DongHoBCD;
|
|
|
- Log.i(TAG, "DongHoBCD : " + ToByteString(mDriver.DongHoBCD));
|
|
|
-
|
|
|
- /* 사이트코드 가져오기 */
|
|
|
- byte [] SiteCodeBCD = getSiteCode_BCD();
|
|
|
- if (SiteCodeBCD != null) mDriver.SiteCodeBCD = SiteCodeBCD;
|
|
|
- Log.i(TAG, "SiteCodeBCD : " + ToByteString(mDriver.SiteCodeBCD));
|
|
|
-
|
|
|
- /* 도어락 타입 가져오기 */
|
|
|
- int getDoorLockType = getDoorLockType();
|
|
|
- if (getDoorLockType >= 0) {
|
|
|
- mDoorLockType = getDoorLockType;
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.i(TAG, "getDoorLockType Error (ret:" + getDoorLockType + ")");
|
|
|
- }
|
|
|
-
|
|
|
- if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_RF || mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
- int getDoorOpenDelayUse = getDoorLockOpenDelayUse();
|
|
|
- if (getDoorOpenDelayUse > 0) {
|
|
|
- mDoorOpenDelay = true;
|
|
|
- Log.i(TAG, "mDoorOpenDelay : " + mDoorOpenDelay);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Log.i(TAG, "=========================================");
|
|
|
- Log.i(TAG, "SmartKeyRfDoor_Controller - create");
|
|
|
- Log.i(TAG, "=========================================");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void DeviceLog(String msg) {
|
|
|
- if (!log_sw) return;
|
|
|
- Log.d(TAG, msg);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * BroadcastReceiver
|
|
|
- */
|
|
|
- private BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver()
|
|
|
- {
|
|
|
- public void onReceive(Context context, Intent intent)
|
|
|
- {
|
|
|
- String acname = intent.getAction();
|
|
|
-
|
|
|
- DeviceLog("Receive Notify BR [" + acname + "]");
|
|
|
-
|
|
|
- if (mDriver.Polling.Status != Driver.PollingList.STATUS.Normal) return;
|
|
|
-
|
|
|
- if (acname.equals(define.NOTIFY_ACNAME)) {
|
|
|
- int kind = intent.getIntExtra("KIND", 0);
|
|
|
- DeviceLog("Receive Notify BR " + define.NOTIFY_ACNAME + " : " + kind);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * BroadcastReceiver 용 필터를 등록한다.
|
|
|
- *
|
|
|
- * @return (boolean) true : 성공 , false : 실패
|
|
|
- */
|
|
|
- private boolean Device_BrRegistration() {
|
|
|
- DeviceLog("Device_BrRegistration - Start");
|
|
|
-
|
|
|
- if (mDriver == null) return false;
|
|
|
- if (mDriver.Polling.Status != Driver.PollingList.STATUS.Normal) return false;
|
|
|
-
|
|
|
- IntentFilter filter = new IntentFilter();
|
|
|
-
|
|
|
- // 1. NOTIFY_ACNAME
|
|
|
- DeviceLog("Device_BrRegistration - filter.addAction - " + define.NOTIFY_ACNAME);
|
|
|
- filter.addAction(define.NOTIFY_ACNAME);
|
|
|
-
|
|
|
- ServiceMain.svcContext.registerReceiver(mWallPadNotifyBR, filter);
|
|
|
-
|
|
|
- DeviceLog("Device_BrRegistration - OK");
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 로딩후 처음 폴링 시퀀스
|
|
|
- */
|
|
|
- @Override
|
|
|
- protected void do_boot()
|
|
|
- {
|
|
|
- driverInterOpAPI = new DriverInterOpAPI(MainHandler);
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // Polling
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- /**
|
|
|
- * do_ctr : 폴링스케쥴러
|
|
|
- */
|
|
|
- @Override
|
|
|
- protected void do_ctr() {
|
|
|
- DeviceLog("Polling ");
|
|
|
-
|
|
|
- /* [[ First & FirstTimeOut ]]
|
|
|
- * 초기 디바이스정보 검색 */
|
|
|
- if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
- // 1. TimeOut Check
|
|
|
- if (mDriver.Polling.Status == Driver.PollingList.STATUS.First) {
|
|
|
- if (mDriver.Polling.SearchTryCount++ > MAX_SEARCH_COUNT) {
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.FirstTimeOut);
|
|
|
-
|
|
|
- Log.i(TAG, "--------------------------------------------------");
|
|
|
- Log.i(TAG, "SearchDevice Fail... FirstTimeOut ");
|
|
|
- Log.i(TAG, "--------------------------------------------------");
|
|
|
-
|
|
|
- ServiceMain.deviceInitChecker.Remove(super.DeviceName);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 기기정보 읽기
|
|
|
- InfoList Info = Send_GetDeviceInfo();
|
|
|
- if (Info != null) {
|
|
|
- mDriver.Info = Info;
|
|
|
- Log.i(TAG, "First Smart Cam Information ~~~");
|
|
|
- Log.i(TAG, mDriver.Info.ToDebugString());
|
|
|
-
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
-
|
|
|
- ServiceMain.deviceInitChecker.Remove(super.DeviceName);
|
|
|
-
|
|
|
- Device_BrRegistration();
|
|
|
- }
|
|
|
- }
|
|
|
- /* [[ Normal ]]
|
|
|
- * 평상시 */
|
|
|
- else if (mDriver.Polling.Status == Driver.PollingList.STATUS.Normal) {
|
|
|
- long currentTimeMillis = 0;
|
|
|
-
|
|
|
- if (mDriver.Info.bSensorUsage) {
|
|
|
- if (firstSensor) {
|
|
|
- Log.i(TAG, "First Smart Cam Send_SetSensorConfig Sending @@@@@@@");
|
|
|
- if (Send_SetSensorConfig((byte)0xFF, (byte)0xFF) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Get Sensor Config !!!");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- Log.i(TAG, "First Smart Cam Send_SetDetectRatio Sending @@@@@@@");
|
|
|
- if (Send_SetDetectRatio((byte)0xFF) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Get Ratio !!!");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- Log.i(TAG, "First Smart Cam Send_SetLedMode Sending @@@@@@@");
|
|
|
- if (Send_SetLedMode( (byte)0xFF) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Get Led Mode !!!");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- Log.i(TAG, "First Smart Cam Send_SetRSSIMode1 Sending @@@@@@@");
|
|
|
- if (Send_SetRSSIMode((byte)0x01, (byte)0xFF) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Get RSSI mode !!!");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- Log.i(TAG, "First Smart Cam Send_SetCameraMode Sending @@@@@@@");
|
|
|
- if (Send_SetCameraMode( (byte)0xFF) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Get Camera Mode !!!");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 기본 상태 요청
|
|
|
- StatusList Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, true);
|
|
|
- if (Status != null) {
|
|
|
- Send_SetStatusClr(Status);
|
|
|
- }
|
|
|
-
|
|
|
- if (mDriver.Sensor_Value.Sensor_LedMode == (byte)0x01) {
|
|
|
- // 최초에 LED 켜져있으면 끈다.
|
|
|
- if (Send_SetLedMode( (byte)0x00) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam - Turn Off LED $$$");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (mDriver.Sensor_Value.Sensor_CameraMode == (byte)0x01) {
|
|
|
- // 최초에 카메라 열려있으면 닫는다.
|
|
|
- if (Send_SetCameraMode( (byte)0x00) >= 0) {
|
|
|
- Log.i(TAG, "First Smart Cam Turn Off Camera $$$");
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- firstSensor = false;
|
|
|
- Log.d(TAG, "@@@@@@@ First SmartCam Status @@@@@@@");
|
|
|
- if(mDriver.Sensor_Value!=null)
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // LED 모드 설정값 확인
|
|
|
- if (mDriver.Info.bLEDLightCtrlable) {
|
|
|
- currentTimeMillis = System.currentTimeMillis();
|
|
|
- if (Math.abs(currentTimeMillis - mDriver.Polling.LedSyncTick) > LED_SYNC_TICK) {
|
|
|
- mDriver.Polling.LedSyncTick = currentTimeMillis;
|
|
|
-
|
|
|
- if (Send_SetSensorConfig((byte)0xFF, (byte)0xFF) >= 0) {
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
-
|
|
|
- if (Send_SetLedMode( (byte)0xFF) >= 0) {
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // RSSI 설정값 확인
|
|
|
- if (mDriver.Info.bRSSICtrlable) {
|
|
|
- currentTimeMillis = System.currentTimeMillis();
|
|
|
- if (Math.abs(currentTimeMillis - mDriver.Polling.RssiSyncTick) > RSSI_SYNC_TICK) {
|
|
|
- mDriver.Polling.RssiSyncTick = currentTimeMillis;
|
|
|
-
|
|
|
- if (Send_SetRSSIMode((byte)0x01, (byte)0xFF) >= 0) {
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 카메라 모드 설정값 확인
|
|
|
- if (mDriver.Info.bCameraCtrlable) {
|
|
|
- currentTimeMillis = System.currentTimeMillis();
|
|
|
- if (Math.abs(currentTimeMillis - mDriver.Polling.CamSyncTick) > CAM_SYNC_TICK) {
|
|
|
- mDriver.Polling.CamSyncTick = currentTimeMillis;
|
|
|
-
|
|
|
- if (Send_SetCameraMode( (byte)0xFF) >= 0) {
|
|
|
- Sleep(150);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 1. RandomKey 생성여부
|
|
|
- if (mDriver.Polling.bRandomKeyGeneration) {
|
|
|
- mDriver.Polling.bRandomKeyGeneration = false;
|
|
|
-
|
|
|
- SecureRandom rd = new SecureRandom();
|
|
|
- rd.nextBytes(mDriver.Polling.RandomKeyBuffer);
|
|
|
-
|
|
|
- Log.i(TAG, "RandomKey Generation!!! RandomKeyValue " + "1:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[0]) + ", " + "2:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[1]));
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 기본 상태 요청
|
|
|
- // 시간정보 지원 확인
|
|
|
- StatusList Status = null;
|
|
|
- if (mDriver.Info.bTimeUsage) {
|
|
|
- currentTimeMillis = System.currentTimeMillis();
|
|
|
- if (Math.abs(currentTimeMillis - mDriver.Polling.TimeSyncTick) > TIME_SYNC_TICK) {
|
|
|
- mDriver.Polling.TimeSyncTick = currentTimeMillis;
|
|
|
- Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, true);
|
|
|
- if (Status == null) return;
|
|
|
- }
|
|
|
- else {
|
|
|
- Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, false);
|
|
|
- if (Status == null) return;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, false);
|
|
|
- if (Status == null) return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 3. 기본 상태에서 버튼 눌림 처리
|
|
|
- UpdateVariables(Status);
|
|
|
-
|
|
|
- // 4. 스마트 키값 확인
|
|
|
- if (Status.SmartKeyCount > 0) {
|
|
|
- mDriver.Polling.bRandomKeyGeneration = true;
|
|
|
-
|
|
|
- // 스마트 키값 요청
|
|
|
- KeyDataList KeyData = Send_GetSmartKey(Status.SmartKeyCount);
|
|
|
- if (KeyData == null) return;
|
|
|
- Log.i(TAG, KeyData.ToDebugString());
|
|
|
-
|
|
|
- // 스마트 키값 확인
|
|
|
- boolean bRet = Send_SetSmartKeyVerify(KeyData);
|
|
|
- if (!bRet) return;
|
|
|
- Log.i(TAG, "SmartKeyVerify OK!!!");
|
|
|
-
|
|
|
- // 키값 업데이트
|
|
|
- UpdateVariables(KeyData);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /* [[ RegisterStartCheck ]]
|
|
|
- * 등록모드 시작버튼 체크 */
|
|
|
- else if (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterStartCheck) {
|
|
|
- int ret = Send_SetSmartKeyRegisterStart();
|
|
|
- if (ret >= 0) {
|
|
|
- UpdateVariables(ret);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /* [[ Register ]]
|
|
|
- * 등록모드 */
|
|
|
- else if (mDriver.Polling.Status == Driver.PollingList.STATUS.Register) {
|
|
|
- SetRegisterDataList setRegisterDataList = new SetRegisterDataList();
|
|
|
- if (!mDriver.RegisterInitMode) {
|
|
|
- setRegisterDataList.setSiteCode(mDriver.SiteCodeBCD);
|
|
|
- setRegisterDataList.setDongHoCode(mDriver.DongHoBCD);
|
|
|
-
|
|
|
- setRegisterDataList.CardRegNo = mDriver.CardRegNo;
|
|
|
- }
|
|
|
-
|
|
|
- GetRegisterDataList getRegisterDataList = Send_GetSmartKeyRegister(setRegisterDataList);
|
|
|
- if (getRegisterDataList != null) {
|
|
|
- UpdateVariables(getRegisterDataList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /* [[ RegisterPause ]]
|
|
|
- * 등록후 일시정지 */
|
|
|
- else if (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterPause) {
|
|
|
- long currentTimeMillis = System.currentTimeMillis();
|
|
|
- if (Math.abs(currentTimeMillis - mDriver.Polling.RegisterPauseTimeOutTick) > REGISTERPAUSE_TIMEOUT_TICK) {
|
|
|
- Send_SetSmartKeyRegisterEnd();
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * 예외처리 */
|
|
|
- else {
|
|
|
- mDriver = new Driver();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // Ctrl
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- /**
|
|
|
- * NoSink 제어
|
|
|
- *
|
|
|
- * @param StrArg
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String NoSinkCtrl(String StrArg) {
|
|
|
- DeviceLog("[NoSinkCtrl] Start");
|
|
|
-
|
|
|
- // 1. 디바이스 초기화시 에러리턴
|
|
|
- if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
- Log.w(TAG, "[NoSinkCtrl] - Not Yet !!!");
|
|
|
- return "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
- }
|
|
|
-
|
|
|
- CtrDevFormat ctrDevFormat = GetCtrDevParamParsing(StrArg, 5);
|
|
|
- if (ctrDevFormat.ret != APIErrorCode.C_SUCCESS) {
|
|
|
- Log.w(TAG, "[NoSinkCtrl] GetCtrDevParamParsing Error (ret:" + ctrDevFormat.ret + ")");
|
|
|
- return "FAIL;" + APIErrorCode.DEFAULT_PARSING_ERR;
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // Refresh : 데이터 갱신 (No Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- if (ctrDevFormat.CmdStr!=null && ctrDevFormat.CmdStr.equals("Refresh")) {
|
|
|
- DeviceLog("[Refresh] Enter ~~~");
|
|
|
-
|
|
|
- return RefreshResult();
|
|
|
- }
|
|
|
-
|
|
|
- return "FAIL;" + APIErrorCode.UNKNOWNCOMMAND;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * do_ctrEmm : 싱크 제어
|
|
|
- */
|
|
|
- @Override
|
|
|
- @SuppressLint("DefaultLocale")
|
|
|
- protected String do_ctrEmm(DeviceCtrSHMem SHMem) {
|
|
|
- DeviceLog("[do_ctrEmm] Start");
|
|
|
- DeviceLog("cmd : " + SHMem.cmd);
|
|
|
- DeviceLog("StrArg : " + SHMem.StrArg);
|
|
|
-
|
|
|
- // 1. 디바이스 초기화시 에러리턴
|
|
|
- if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
- Log.w(TAG, "[do_ctrEmm] - Not Yet !!!");
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
- }
|
|
|
-
|
|
|
- CtrDevFormat ctrDevFormat = GetCtrDevParamParsing(SHMem.StrArg, 5);
|
|
|
- if (ctrDevFormat.ret != APIErrorCode.C_SUCCESS) {
|
|
|
- Log.w(TAG, "[do_ctrEmm] GetCtrDevParamParsing Error (ret:" + ctrDevFormat.ret + ")");
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEFAULT_PARSING_ERR;
|
|
|
- }
|
|
|
-
|
|
|
- if(ctrDevFormat.CmdStr!=null)
|
|
|
- {
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetRegisterModeStart : 등록모드 시작 요청 (Sink)
|
|
|
- //
|
|
|
- // [0] - 초기화옵션 ( 0 : 노말 , 1 : 키 초기화 (시험용) )
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- if (ctrDevFormat.CmdStr.equals("SetRegisterModeStart")) {
|
|
|
- int ret = 0;
|
|
|
-
|
|
|
- // 1. Mode Check
|
|
|
- if ((mDriver.Polling.Status == Driver.PollingList.STATUS.Register) || (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterPause)) {
|
|
|
- // 이전 상태가 등록모드였다면 등록모드 종료
|
|
|
- Log.w(TAG, "Old Mode Register - RegisterModeEnd !!!");
|
|
|
-
|
|
|
- ret = Send_SetSmartKeyRegisterEnd();
|
|
|
- if (ret != 1) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 등록모드 시작
|
|
|
- ret = Send_SetSmartKeyRegisterStart();
|
|
|
- if (ret < 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 사이트 코드 가져오기
|
|
|
- byte [] SiteCodeBCD = getSiteCode_BCD();
|
|
|
- if (SiteCodeBCD != null) mDriver.SiteCodeBCD = SiteCodeBCD;
|
|
|
- Log.i(TAG, "SiteCodeBCD : " + ToByteString(mDriver.SiteCodeBCD));
|
|
|
-
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterStartCheck);
|
|
|
-
|
|
|
- // 4. Param 적용
|
|
|
- if (ctrDevFormat.param[0] == 0) mDriver.RegisterInitMode = false;
|
|
|
- else mDriver.RegisterInitMode = true;
|
|
|
-
|
|
|
- UpdateVariables(ret);
|
|
|
-
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetRegisterModeNext : 등록모드 연장 진행 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetRegisterModeNext")) {
|
|
|
- // 1. Mode Check
|
|
|
-
|
|
|
- // 이전 상태가 [등록후 일시정지]가 아니라면 에러
|
|
|
- if (mDriver.Polling.Status != Driver.PollingList.STATUS.RegisterPause) {
|
|
|
- // 이전 상태 [등록모드] 였을 경우
|
|
|
- if (mDriver.Polling.Status == Driver.PollingList.STATUS.Register) {
|
|
|
- //
|
|
|
- int id = DB_GetId();
|
|
|
- if (id <= 0) {
|
|
|
- Log.w(TAG, "SetRegisterModeNext - DB_GetId Out Of Range #1 (id:" + id + ")");
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
- }
|
|
|
- else {
|
|
|
- mDriver.CardRegNo = (byte)id;
|
|
|
- super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- }
|
|
|
- // 이전 상태가 [등록후 일시정지] or [등록모드] 둘다 아님
|
|
|
- else {
|
|
|
- Log.w(TAG, "[SetRegisterModeNext] Old Mode 'RegisterPause' is Not !!!");
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. Next id 가져오기
|
|
|
- if (!mDriver.RegisterInitMode) {
|
|
|
- int id = DB_GetId();
|
|
|
- if (id <= 0) {
|
|
|
- Log.w(TAG, "SetRegisterModeNext - DB_GetId Out Of Range #2 (id:" + id + ")");
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- if (id == -1) super.StatusChanged(STATUS_REGMODE_FULL);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
- }
|
|
|
- else {
|
|
|
- mDriver.CardRegNo = (byte)id;
|
|
|
- super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // RegisterModeEnd : 등록모드 종료 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetRegisterModeEnd")) {
|
|
|
- int ret = 0;
|
|
|
-
|
|
|
- for (int ReTryCount = 0; ReTryCount < 3; ReTryCount++) {
|
|
|
- ret = Send_SetSmartKeyRegisterEnd();
|
|
|
- if (ret == 1) break;
|
|
|
- }
|
|
|
-
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
-
|
|
|
- if (ret == 1) {
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetDeleteKey : 카드 삭제 알림 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetDeleteKey")) {
|
|
|
- SetRegisterDataList setRegisterDataList = new SetRegisterDataList();
|
|
|
- setRegisterDataList.setSiteCode(mDriver.SiteCodeBCD);
|
|
|
- setRegisterDataList.setDongHoCode(mDriver.DongHoBCD);
|
|
|
-
|
|
|
- byte[] TempLocalCode = new byte[2];
|
|
|
- if (ctrDevFormat.param[0] == 1) {
|
|
|
- //전체
|
|
|
- TempLocalCode[0] = (byte) 0xFA;
|
|
|
- TempLocalCode[1] = (byte) 0xFA;
|
|
|
- }
|
|
|
- else if (ctrDevFormat.param[0] == 0) {
|
|
|
- //개별
|
|
|
- TempLocalCode[0] = (byte) 0xF0;
|
|
|
- TempLocalCode[1] = (byte) 0xF0;
|
|
|
- setRegisterDataList.CardRegNo = ctrDevFormat.param[1];
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "SetDeleteKey - ctrDevFormat.param[1] Out Of Range #1 (ctrDevFormat.param[1]:" + ctrDevFormat.param[1] + ")");
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
-
|
|
|
- setRegisterDataList.setLocalCode(TempLocalCode);
|
|
|
- boolean ret = Send_DeleteKey(setRegisterDataList);
|
|
|
- if (ret) {
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetSensorConfig : 센서 감도/시간 설정 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetSensorConfig")) {
|
|
|
- //if(ctrDevFormat.param.length != 2) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
-
|
|
|
- byte Sensivity = ctrDevFormat.param[0];
|
|
|
- byte Time = ctrDevFormat.param[1];
|
|
|
- Log.i(TAG, "Sensor Api data : " + Sensivity + " / " + Time);
|
|
|
-
|
|
|
- try {
|
|
|
- if (mDriver.Sensor_Value!=null && Send_SetSensorConfig(Sensivity, Time) >= 0) {
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
- }
|
|
|
-
|
|
|
- if (mDriver.Sensor_Value != null) {
|
|
|
- return SHMem.retVal = "SUCCESS;" + mDriver.Sensor_Value.Sensor_Sensitivity + ";" + mDriver.Sensor_Value.Sensor_DetectTime;
|
|
|
- }
|
|
|
- else {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetLEDmode : LED 모드 설정 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if(ctrDevFormat.CmdStr.equals("SetLEDmode")) {
|
|
|
- //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
-
|
|
|
- byte LEDmode = ctrDevFormat.param[0];
|
|
|
- Log.i(TAG, "LED Api data : " + LEDmode);
|
|
|
- if (LEDmode < 0 || LEDmode > 6) {
|
|
|
- if (LEDmode == 0xFF) { }
|
|
|
- else { return "FAIL"; }
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- int ret = Send_SetLedMode(LEDmode);
|
|
|
- Log.i(TAG, "[Sink Ctr] Led Control ret 1 : " + ret);
|
|
|
- if (ret < 0) {
|
|
|
- Log.i(TAG, "[Sink Ctr] Led Control ret 2 : " + ret);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
- }
|
|
|
- else if (ret == 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
- }
|
|
|
- else if (ret == 1) {
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
-
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else if (ret == 2) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- else {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetRSSImode : RSSI 모드 설정 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetRSSImode")) {
|
|
|
- //if(ctrDevFormat.param.length != 2) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
-
|
|
|
- byte RSSImode = ctrDevFormat.param[0];
|
|
|
- byte RSSIlevel = ctrDevFormat.param[1];
|
|
|
- Log.i(TAG, "RSSI Api mode : " + RSSImode);
|
|
|
- Log.i(TAG, "RSSI Api level : " + RSSIlevel);
|
|
|
-
|
|
|
- if (RSSImode < 0 || RSSImode > 2) {return "FAIL";}
|
|
|
- if (RSSIlevel < -100 || RSSIlevel > 100) {
|
|
|
- if (RSSIlevel == 0xFF) { }
|
|
|
- else { return "FAIL"; }
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- int ret = Send_SetRSSIMode(RSSImode, RSSIlevel);
|
|
|
- if (ret < 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- else if (ret == 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
- }
|
|
|
- else if (ret == 1) {
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
-
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else if (ret == 2) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetStrangerDetectRatio : 판별 감지 빈도 설정 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetStrangerDetectRatio")) {
|
|
|
- //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
-
|
|
|
- byte DetectRatio = ctrDevFormat.param[0];
|
|
|
- Log.i(TAG, "Detect Ratio Api data : " + DetectRatio);
|
|
|
-// if(DetectRatio < 0 || DetectRatio > 100)
|
|
|
-// {
|
|
|
-// if(DetectRatio == 0xFF) { }
|
|
|
-// else { return "FAIL"; }
|
|
|
-// }
|
|
|
-
|
|
|
- try {
|
|
|
- int ret = Send_SetDetectRatio(DetectRatio);
|
|
|
- if (ret < 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- else if (ret == 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
- }
|
|
|
- else if (ret == 1) {
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
-
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else if (ret == 2) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- // SetCAMERAmode : 카메라 모드 설정 요청 (Sink)
|
|
|
- //////////////////////////////////////////////////////////
|
|
|
- else if (ctrDevFormat.CmdStr.equals("SetCAMERAmode")) {
|
|
|
- //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
-
|
|
|
- byte CameraMode = ctrDevFormat.param[0];
|
|
|
- Log.i(TAG, "Camera Mode Api data : " + CameraMode);
|
|
|
- if (CameraMode < 0 || CameraMode > 3) {
|
|
|
- if (CameraMode == 0xFF) { }
|
|
|
- else { return "FAIL"; }
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- int ret = Send_SetCameraMode(CameraMode);
|
|
|
- if (ret < 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- else if (ret == 0) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
- }
|
|
|
- else if (ret == 1) {
|
|
|
- Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
-
|
|
|
- return SHMem.retVal = "SUCCESS";
|
|
|
- }
|
|
|
- else if (ret == 2) {
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return SHMem.retVal = "UNKNOWNCMD";
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // Refresh Result
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- private String RefreshResult() {
|
|
|
- String result;
|
|
|
-
|
|
|
- DeviceLog("RefreshResult call : ");
|
|
|
-
|
|
|
- // 1. Check Polling Status
|
|
|
- if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
- result = "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. Make Return String Format
|
|
|
- try {
|
|
|
- if (mDriver == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
- if (mDriver.Status == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
- if (mDriver.Info == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
-
|
|
|
- /*
|
|
|
- * [Format]
|
|
|
- *
|
|
|
- * SUCCESS - (String) 성공
|
|
|
- *
|
|
|
- * [Status]
|
|
|
- * bDoorBtnStatus - (boolean) 버튼 눌림 상태
|
|
|
- * bSensorDetect - (boolean) 거동수상자 감지여부
|
|
|
- * bLedStatus - (boolean) LED 상태
|
|
|
- * bCameraStatus - (boolean) 카메라 상태
|
|
|
- * bLedAuto - (boolean) LED Auto 상태
|
|
|
- * bCameraAuto - (boolean) 카메라 Auto 상태
|
|
|
- * bError - (boolean) 에러 상태
|
|
|
- * SmartKeyCount - (byte) 인식된 스마트키 수
|
|
|
- *
|
|
|
- * [Sensor_Value]
|
|
|
- * Sensor_Sensitivity - (byte) 센서 감도
|
|
|
- * Sensor_DetectTime - (byte) 센서 감지시간
|
|
|
- * Sensor_LedMode - (byte) LED 모드
|
|
|
- * Sensor_RSSI_Read - (byte) 읽기 RSSI 세기
|
|
|
- * Sensor_RSSI_Write - (byte) 쓰기 RSSI 세기
|
|
|
- * Sensor_DetectRatio - (byte) 판별빈도
|
|
|
- * Sensor_CameraMode - (byte) 카메라 모드
|
|
|
- */
|
|
|
-
|
|
|
- result = APIErrorCode.SUCCESS + ";";
|
|
|
-
|
|
|
- result += mDriver.Status.bDoorBtnStatus + ";";
|
|
|
- result += mDriver.Status.bSensorDetect + ";";
|
|
|
- result += mDriver.Status.bLedStatus + ";";
|
|
|
- result += mDriver.Status.bCameraStatus + ";";
|
|
|
- result += mDriver.Status.bLedAuto + ";";
|
|
|
- result += mDriver.Status.bCameraAuto + ";";
|
|
|
- result += mDriver.Status.bError + ";";
|
|
|
- result += mDriver.Status.SmartKeyCount + ";";
|
|
|
-
|
|
|
- result += mDriver.Sensor_Value.Sensor_Sensitivity + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_DetectTime + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_LedMode + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_RSSI_Read + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_RSSI_Write + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_DetectRatio + ";";
|
|
|
- result += mDriver.Sensor_Value.Sensor_CameraMode;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- result = "FAIL;"+APIErrorCode.EXCEPTION;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[Exception Error] RefreshResult");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- result = "FAIL;"+APIErrorCode.EXCEPTION;
|
|
|
- }
|
|
|
- DeviceLog(" RefreshResult_Sample return : "+result);
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // Protocol Command Send Func
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- /**
|
|
|
- * 기기 정보 요청 응답.
|
|
|
- *
|
|
|
- * @return (InfoList) null - Error , Not null - OK
|
|
|
- */
|
|
|
- private InfoList Send_GetDeviceInfo() {
|
|
|
- DeviceLog("[Send_GetDeviceInfo] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = null;
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable((byte)(DEVICE_ADDRESS), CMDList.Req.GetDeviceInfo, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
- boolean bError = false;
|
|
|
- while (true) {
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[GetDeviceInfo_RepParsing] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- if (Reply.length != 9) {
|
|
|
- Log.w(TAG, "[GetDeviceInfo_RepParsing] Reply.length fail ... " + Reply.length);
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // 1.2. Details Data Check
|
|
|
- data = 0x00;
|
|
|
- index = 0;
|
|
|
-
|
|
|
- // - D1 : 기능 지원 정보#1
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte) (BIT6 | BIT7)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_GetDeviceInfo] D1:Unused Bit Set !!! " + String.format("0x%02X", Reply[2]));
|
|
|
- }
|
|
|
-
|
|
|
- // - D2 : 기능 지원 정보#2
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // - D3 : 제조사구분정보
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // - D4 : 펌웨어 Build Date (Year)
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // - D5 : 펌웨어 Build Date (Month)
|
|
|
- data = Reply[index++];
|
|
|
- if ((data > 12) || (data <= 0)) {
|
|
|
- Log.w(TAG, "[GetDeviceInfo_RepParsing] D5 (Build Date - Month) : Out of Range !!! (data:" + data + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // - D6 : 펌웨어 Build Date (Day)
|
|
|
- data = Reply[index++];
|
|
|
- if ((data > 31) || (data <= 0)) {
|
|
|
- Log.w(TAG, "[GetDeviceInfo_RepParsing] D6 (Build Date - Day) : Out of Range !!! (data:" + data + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // - D7 : 펌웨어 Build Date (Number)
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // - D8 : Protocol 버전정보 (Main)
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // - D9 : Protocol 버전정보 (Sub)
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_GetDeviceInfo] FAIL");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 5. Data return
|
|
|
- InfoList Info = new InfoList();
|
|
|
- index = 0;
|
|
|
- data = 0;
|
|
|
-
|
|
|
- // - D1 : 기능 지원 정보#1
|
|
|
- if ((Reply[index] & BIT0) != 0x00) Info.bSensorUsage = true;
|
|
|
- else Info.bSensorUsage = false;
|
|
|
-
|
|
|
- if ((Reply[index] & BIT1) != 0x00) Info.bLEDLightCtrlable = true;
|
|
|
- else Info.bLEDLightCtrlable = false;
|
|
|
-
|
|
|
- if ((Reply[index] & BIT2) != 0x00) Info.bRSSICtrlable = true;
|
|
|
- else Info.bRSSICtrlable = false;
|
|
|
-
|
|
|
- if ((Reply[index] & BIT3) != 0x00) Info.bCameraCtrlable = true;
|
|
|
- else Info.bCameraCtrlable = false;
|
|
|
-
|
|
|
- if ((Reply[index] & BIT4) != 0x00) Info.bPIRSensorUsage = true;
|
|
|
- else Info.bPIRSensorUsage = false;
|
|
|
-
|
|
|
- if ((Reply[index] & BIT5) != 0x00) Info.bTimeUsage = true;
|
|
|
- else Info.bTimeUsage = false;
|
|
|
-
|
|
|
- index++;
|
|
|
- // - D2 : 기능 지원 정보#2
|
|
|
- index++;
|
|
|
-
|
|
|
- // - D3 : 제조사 구분정보
|
|
|
- Info.hVendor = Reply[index++];
|
|
|
- // - D4 : 펌웨어 Build Date (Year)
|
|
|
- Info.hFWVer_Year = Reply[index++];
|
|
|
- // - D5 : 펌웨어 Build Date (Month)
|
|
|
- Info.hFWVer_Month = Reply[index++];
|
|
|
- // - D6 : 펌웨어 Build Date (Day)
|
|
|
- Info.hFWVer_Date = Reply[index++];
|
|
|
- // - D7 : 펌웨어 Build Date (Number)
|
|
|
- Info.hFWVer_No = Reply[index++];
|
|
|
- // - D8 : Protocol 버전정보 (Main)
|
|
|
- Info.hProtocolVer_Main = Reply[index++];
|
|
|
- // - D9 : Protocol 버전정보 (Sub)
|
|
|
- Info.hProtocolVer_Sub = Reply[index++];
|
|
|
-
|
|
|
- DeviceLog("[Send_GetDeviceInfo] END");
|
|
|
- return Info;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 기본상태 요청 응답.
|
|
|
- *
|
|
|
- * @return (StatusList) null - Error , Not null - OK
|
|
|
- */
|
|
|
- private StatusList Send_GetStatus(byte[] RandomKey, boolean bSendTime) {
|
|
|
- DeviceLog("[Send_GetStatus] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if (RandomKey == null) {
|
|
|
- Log.w(TAG, "[Send_GetStatus] Param - RandomKey is null !!!");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- if (RandomKey.length != 2) {
|
|
|
- Log.w(TAG, "[Send_GetStatus] Param - RandomKey length Not Match !!! (length:" + RandomKey.length + ")");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte[] ReqData = new byte [] { RandomKey[0], RandomKey[1] };
|
|
|
- if (bSendTime) {
|
|
|
- byte[] TempReqData = new byte[8];
|
|
|
- Calendar cal = new GregorianCalendar();
|
|
|
- int index = 0;
|
|
|
- TempReqData[index++] = RandomKey[0];
|
|
|
- TempReqData[index++] = RandomKey[1];
|
|
|
- TempReqData[index++] = (byte) (cal.get(Calendar.YEAR) - 2000);
|
|
|
- TempReqData[index++] = (byte) (cal.get(Calendar.MONTH) + 1);
|
|
|
- TempReqData[index++] = (byte) cal.get(Calendar.DAY_OF_MONTH);
|
|
|
- TempReqData[index++] = (byte) cal.get(Calendar.HOUR_OF_DAY);
|
|
|
- TempReqData[index++] = (byte) cal.get(Calendar.MINUTE);
|
|
|
- TempReqData[index++] = (byte) cal.get(Calendar.SECOND);
|
|
|
- ReqData = TempReqData;
|
|
|
- }
|
|
|
- else {
|
|
|
- byte[] TempReqData = new byte [] { RandomKey[0], RandomKey[1] };
|
|
|
- ReqData = TempReqData;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable((byte) (DEVICE_ADDRESS), CMDList.Req.GetStatus, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- boolean bError = false;
|
|
|
- while (true) {
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[GetStatus_RepParsing] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- if (Reply.length != 2) {
|
|
|
- Log.w(TAG, "[GetStatus_RepParsing] Reply.length fail ... " + Reply.length);
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // 1.2. Details Data Check
|
|
|
- // - D1 : 현관카메라 상태
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (BIT6)) != 0x00) {
|
|
|
- Log.w(TAG, "[GetStatus_RepParsing] D1 (Mode) : Unused Bit Set !!! " + String.format("0x%02X", data));
|
|
|
- //bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // - D2 : 인식된 RF 스마트키 개수
|
|
|
- data = Reply[index++];
|
|
|
- if (!((data >= 0) && (data <= 5))) {
|
|
|
- Log.w(TAG, "[GetStatus_RepParsing] D2 (KeyCount) : Out Of Range !!! " + String.format("0x%02X", data));
|
|
|
- //bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_GetStatus] FAIL");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 5. Data return
|
|
|
- StatusList Status = new StatusList();
|
|
|
- index = 0;
|
|
|
- data = 0;
|
|
|
-
|
|
|
- // - D1 : 현관카메라 상태
|
|
|
- data = Reply[index++];
|
|
|
- if ((byte)(data & BIT0) != 0x00) Status.bDoorBtnStatus = true;
|
|
|
- else Status.bDoorBtnStatus = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT1) != 0x00) Status.bSensorDetect = true;
|
|
|
- else Status.bSensorDetect = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT2) != 0x00) Status.bLedStatus = true;
|
|
|
- else Status.bLedStatus = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT3) != 0x00) Status.bCameraStatus = true;
|
|
|
- else Status.bCameraStatus = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT4) != 0x00) Status.bLedAuto = true;
|
|
|
- else Status.bLedAuto = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT5) != 0x00) Status.bCameraAuto = true;
|
|
|
- else Status.bCameraAuto = false;
|
|
|
-
|
|
|
- if ((byte)(data & BIT7) != 0x00) Status.bError = true;
|
|
|
- else Status.bError = false;
|
|
|
-
|
|
|
- // - D2 : 인식된 RF 스마트키 개수
|
|
|
- data = Reply[index++];
|
|
|
- if (!((data >= 0) && (data <= 5))) {
|
|
|
- // 현관카메라 버그로 인한 예외처리 요구사항
|
|
|
- Log.w(TAG, "[GetStatus_RepParsing] Status.SmartKeyCount will be 5 ");
|
|
|
- data = 5;
|
|
|
- }
|
|
|
- Status.SmartKeyCount = data;
|
|
|
-
|
|
|
- DeviceLog("[Send_GetStatus] END");
|
|
|
- return Status;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 기본상태값 해제 요청
|
|
|
- *
|
|
|
- * @return (boolean) true : 정상 , false : 실패
|
|
|
- */
|
|
|
- private boolean Send_SetStatusClr(StatusList ClearStatus) {
|
|
|
- DeviceLog("[Send_SetStatusClr] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if (ClearStatus == null) {
|
|
|
- Log.w(TAG, "[Send_SetStatusClr] Param - ClearStatus is null !!!");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = new byte [] { 0x00 };
|
|
|
-
|
|
|
- if (ClearStatus.bDoorBtnStatus || firstSensor) ReqData[0] |= BIT0;
|
|
|
- if (ClearStatus.bSensorDetect || firstSensor) ReqData[0] |= BIT1;
|
|
|
- if (ClearStatus.bError || firstSensor) ReqData[0] |= BIT7;
|
|
|
-
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetStatusClr, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
- while (true) {
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetStatusClr] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- if (Reply.length != 1) {
|
|
|
- Log.w(TAG, "[Send_SetStatusClr] Reply.length fail ... " + Reply.length);
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // 1.2. Details Data Check
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
- // - D1 : 현관카메라 상태
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte)( BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_SetStatusClr] D1 (Mode) : Unused Bit Set !!! " + String.format("0x%02X", data));
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetStatusClr] FAIL");
|
|
|
- return false;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- DeviceLog("[Send_SetStatusClr] END");
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트 키값 요청/반환
|
|
|
- *
|
|
|
- * @param ReqSmartKeyCount - (byte) 요청할 스마트RF키 개수
|
|
|
- *
|
|
|
- * @return (KeyDataList) 응답받은 KayData : null - Error , Not null - OK
|
|
|
- */
|
|
|
- private KeyDataList Send_GetSmartKey(byte ReqSmartKeyCount) {
|
|
|
- DeviceLog("[Send_GetSmartKey] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if ((ReqSmartKeyCount <= 0) || (ReqSmartKeyCount > MAX_SMARTKEY_COUNT)) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKey] Param - ClearStatus is null !!!");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = new byte [] { ReqSmartKeyCount };
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKey, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_GetSmartKey] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- // Length Check
|
|
|
-
|
|
|
- //Reply[0] bit7 Clear 필요 (현관카메라 버그로 인한 예외처리 요구사항)
|
|
|
- Reply[0] = (byte) (Reply[0] & 0x7F); //7번 비트 Clear
|
|
|
-
|
|
|
- int CalcLen = (int) ((byte)(Reply[0] * 16) + 1);
|
|
|
- if (Reply.length != CalcLen) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKey] Reply.length fail ... (length:" + Reply.length + ", CalcLen:" + CalcLen + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- // D1 : 응답할 스마트RF키 개수
|
|
|
- data = Reply[index++];
|
|
|
- if (data != ReqSmartKeyCount) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKey] D1 : Req/Rep SmartKeyCount Not Match!!! ReqSmartKeyCount:" + ReqSmartKeyCount + " RepSmartKeyCount:" + data);
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_GetSmartKey] FAIL");
|
|
|
- return null;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 5. Data return
|
|
|
- KeyDataList keyDataList = new KeyDataList(ReqSmartKeyCount);
|
|
|
- try {
|
|
|
- for (byte i = 0; i < ReqSmartKeyCount; i++) {
|
|
|
- keyDataList.Encryption[i].Input(Reply, (int)(1+(i*16)));
|
|
|
- }
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return null;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[Send_GetSmartKey] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- DeviceLog("[Send_GetSmartKey] END");
|
|
|
- return keyDataList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트 키값 요청/반환
|
|
|
- *
|
|
|
- * @param ReqKeyData - (KeyDataList) 확인 요청할 스마트키 Class
|
|
|
- *
|
|
|
- * @return (KeyDataList) 응답받은 KayData : null - Error , Not null - OK
|
|
|
- */
|
|
|
- private boolean Send_SetSmartKeyVerify(KeyDataList ReqKeyData) {
|
|
|
- DeviceLog("[Send_SetSmartKeyVerify] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if (ReqKeyData == null) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyVerify] Param - ReqKeyData is null !!!");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = ReqKeyData.getByteArray();
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyVerify, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetSmartKeyVerify] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply.length != 3) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyVerify] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- // D1 : 응답할 스마트RF키 개수
|
|
|
- data = Reply[index++];
|
|
|
- if (data != ReqKeyData.Count) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyVerify] D1 : Req/Rep SmartKeyCount Not Match!!! ReqSmartKeyCount:" + ReqKeyData.Count + " RepSmartKeyCount:" + data);
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetSmartKeyVerify] FAIL");
|
|
|
- return false;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 5. 데이터 확인
|
|
|
- byte[] Result = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
- for (int i = 0; i < 5; i++) {
|
|
|
- if (i < 4) Result[i] = (byte)((byte)(Reply[1] >> (i * 2)) & (byte)(BIT0 | BIT1)); // 0 ~ 4
|
|
|
- else Result[i] = (byte)((byte)(Reply[2] >> 0) & (byte)(BIT0 | BIT1)); // 5
|
|
|
- }
|
|
|
-
|
|
|
- for (byte i = 0; i < Reply[0]; i++) {
|
|
|
- switch (Result[i]) {
|
|
|
- case 0x00:
|
|
|
- Log.w(TAG, "Send_SetSmartKeyVerify - CheckVerify Error0( Index:" + i + ", data:" + String.format("0x%02X", Result[i]) + ")");
|
|
|
- return false;
|
|
|
-
|
|
|
- case 0x01:
|
|
|
- // 정상
|
|
|
- break;
|
|
|
-
|
|
|
- case 0x02:
|
|
|
- // 오류
|
|
|
- Log.w(TAG, "Send_SetSmartKeyVerify - CheckVerify Error2( Index:" + i + ", data:" + String.format("0x%02X", Result[i]) + ")");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- DeviceLog("[Send_SetSmartKeyVerify] END");
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 등록모드 시작 요청
|
|
|
- *
|
|
|
- * @return (int) 진입결과 - >=0 : 성공(0:미진입 , 1:진입) , <0 : 실패
|
|
|
- */
|
|
|
- private int Send_SetSmartKeyRegisterStart() {
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterStart] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = null;
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyRegisterStart, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
- boolean bError = false;
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterStart] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply.length != 1) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterStart] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- data = 0x00;
|
|
|
- index = 0;
|
|
|
-
|
|
|
- // D1 : 등록모드 시작 상태값
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte)(BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterStart] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterStart] FAIL");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
-
|
|
|
- // 5. 데이터 확인
|
|
|
- data = 0x00;
|
|
|
- index = 0;
|
|
|
- // D1 : 등록모드 시작 상태값
|
|
|
- data = Reply[index++];
|
|
|
- if ((byte)(data & BIT7) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterStart] D1 : Error Bit Set !!!");
|
|
|
- return -10;
|
|
|
- }
|
|
|
-
|
|
|
- if ((byte)(data & BIT0) != 0x00) {
|
|
|
- // 진입 성공
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterStart] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- // 진입 실패
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterStart] END");
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 등록 스마트 키값 요청/응답
|
|
|
- *
|
|
|
- * @return (GetRegisterDataList) null - Error , Not null - OK
|
|
|
- */
|
|
|
- private GetRegisterDataList Send_GetSmartKeyRegister(SetRegisterDataList setRegisterData) {
|
|
|
- DeviceLog("[Send_GetSmartKeyRegister] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if (setRegisterData == null) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKeyRegister] Param - RegisterData is null !!!");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = setRegisterData.getByteArray();
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKeyRegister, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- byte RegResult = 0;
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_GetSmartKeyRegister] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply.length < 1) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKeyRegister] Reply.length fail #1... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- index = 0;
|
|
|
-
|
|
|
- // D1 : 등록모드 상태값
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte)(BIT4 | BIT5 | BIT6 | BIT7)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKeyRegister] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- if ((data & BIT0) != 0x00) {
|
|
|
- if (Reply.length != (int)(1+16)) {
|
|
|
- Log.w(TAG, "[Send_GetSmartKeyRegister] Reply.length fail #2... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- RegResult = (byte)((data >> 2) & (byte)(BIT0|BIT1));
|
|
|
- switch (RegResult) {
|
|
|
- case 0x00: case 0x01: case 0x02: break;
|
|
|
- default:
|
|
|
- Log.w(TAG, "[Send_GetSmartKeyRegister] RegResult Out Of Range !!!(RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_GetSmartKeyRegister] FAIL");
|
|
|
- return null;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
-
|
|
|
- // 5. 데이터 확인
|
|
|
- index = 0;
|
|
|
- GetRegisterDataList getRegisterDataList = new GetRegisterDataList();
|
|
|
-
|
|
|
- data = Reply[index++];
|
|
|
-
|
|
|
- // D1 : BIT0 - 등록데이터 준재여부
|
|
|
- if ((byte)(data & BIT0) != 0x00) {
|
|
|
- getRegisterDataList.Encryption = new EncryptionList();
|
|
|
- getRegisterDataList.Encryption.Input(Reply, 1);
|
|
|
- }
|
|
|
-
|
|
|
- // BIT1 - 종료 여부
|
|
|
- if ((byte)(data & BIT1) != 0x00) {
|
|
|
- getRegisterDataList.Exit = true;
|
|
|
- }
|
|
|
-
|
|
|
- // BIT2 ~ BIT3 - 등록 결과
|
|
|
- getRegisterDataList.RegResult = RegResult;
|
|
|
-
|
|
|
- DeviceLog("[Send_GetSmartKeyRegister] END");
|
|
|
- return getRegisterDataList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 등록모드 종료 요청
|
|
|
- *
|
|
|
- * @return (int) 진입결과 - >=0 : 성공(0:미진입 , 1:진입) , <0 : 실패
|
|
|
- */
|
|
|
- private int Send_SetSmartKeyRegisterEnd() {
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterEnd] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = null;
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyRegisterEnd, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterEnd] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply.length != 1) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- // D1 : 등록모드 시작 상태값
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte)(BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterEnd] FAIL");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
-
|
|
|
- // 5. 데이터 확인
|
|
|
- if ((byte)(Reply[0] & BIT7) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] D1 : Error Bit Set !!!");
|
|
|
- return -10;
|
|
|
- }
|
|
|
-
|
|
|
- if ((byte)(Reply[0] & BIT0) != 0x00) {
|
|
|
- // 종료 성공
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterEnd] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- // 종료 실패
|
|
|
- DeviceLog("[Send_SetSmartKeyRegisterEnd] END");
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 센서 감도/시간 설정 보내기
|
|
|
- *
|
|
|
- * @return (int) >0 : 성공, <0 : 실패
|
|
|
- */
|
|
|
- private int Send_SetSensorConfig(byte Sensivity, byte Time) {
|
|
|
- DeviceLog("[Send_SetSensorConfig] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if ((Sensivity < 1 || Sensivity > 5)) {
|
|
|
- if ((Sensivity == (byte)0xFF)) {
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.e(TAG, "[SetSensorConfig] - Sensing Range ERROR : " + Sensivity);
|
|
|
- return -1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ((getInt(Time) < 1 || getInt(Time) > 250)) {
|
|
|
- if ((Time == (byte)0xFF)) {
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.e(TAG, "[SetSensorConfig] - Time Range ERROR :" + Time);
|
|
|
- return -2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = {Sensivity, Time};
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSensorStatus, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetSensorConfig] Reply is null");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply != null && Reply.length != 2) {
|
|
|
- DeviceLog("[Send_SetSensorConfig] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetSensorConfig] FAIL");
|
|
|
- return -3;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- byte data = 0x00;
|
|
|
-
|
|
|
- /*for(int i = 0; i < 2; i++)
|
|
|
- {
|
|
|
- Log.i(TAG, "SmartDcam Reply[" + i + "] = " + Reply[i]);
|
|
|
- }*/
|
|
|
-
|
|
|
- // D1 : 센서 감도
|
|
|
- data = Reply[0];
|
|
|
- if (data < 1 || data > 5) {
|
|
|
- if ((data == (byte)0xFF)) {
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "[Send_SetSensorConfig] D1 : Range Error (data:" + String.format("0x%02X", data) + ")");
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- // D1 정상 수신
|
|
|
- //Log.d(TAG, "[Send_SetSensorConfig] D1 Accepted ~");
|
|
|
- mDriver.Sensor_Value.Sensor_Sensitivity = data;
|
|
|
- }
|
|
|
-
|
|
|
- data = Reply[1];
|
|
|
- if (data < 1 || data > 250) {
|
|
|
- if ((data == (byte)0xFF)) {
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "[Send_SetSensorConfig] D2 : Range Error (data:" + String.format("0x%02X", data) + ")");
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- // D2 정상 수신
|
|
|
- //Log.d(TAG, "[Send_SetSensorConfig] D2 Accepted ~");
|
|
|
- mDriver.Sensor_Value.Sensor_DetectTime = data;
|
|
|
- }
|
|
|
-
|
|
|
- CompareStatus_Sensivity_DetectTime();
|
|
|
-
|
|
|
- DeviceLog("[Send_SetSensorConfig] END");
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- private void CompareStatus_Sensivity_DetectTime() {
|
|
|
- if (mDriver.Sensor_Value == null) { return;}
|
|
|
-
|
|
|
- int sensitivity = -1;
|
|
|
- int dura = -1;
|
|
|
-
|
|
|
- if (mDriver.Sensor_Value.Sensor_Sensitivity > 0) {
|
|
|
- // DB 저장
|
|
|
- try {
|
|
|
- WallpadStatusData wsd = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
- sensitivity = wsd.GetSmartDoorCamSensorSensitivity();
|
|
|
-
|
|
|
- if (sensitivity != mDriver.Sensor_Value.Sensor_Sensitivity) {
|
|
|
- wsd.SetSmartDoorSensorSensitivity(mDriver.Sensor_Value.Sensor_Sensitivity);
|
|
|
- }
|
|
|
- wsd.closeDB();
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (mDriver.Sensor_Value.Sensor_DetectTime > 0) {
|
|
|
- // DB 저장
|
|
|
- try {
|
|
|
- WallpadStatusData wsd = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
- dura = wsd.GetSmartDoorCamSensorDuration();
|
|
|
-
|
|
|
- if (dura != mDriver.Sensor_Value.Sensor_DetectTime) {
|
|
|
- wsd.SetSmartDoorSensorDuration(mDriver.Sensor_Value.Sensor_DetectTime);
|
|
|
- }
|
|
|
- wsd.closeDB();
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * LED 제어 기능이 있는 현관카메라의 LED 모드를 제어한다.
|
|
|
- * @param mode 범위(0~6, FF)
|
|
|
- * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
- */
|
|
|
- private int Send_SetLedMode(byte mode) {
|
|
|
- DeviceLog("[Send_SetLedMode] Start");
|
|
|
-
|
|
|
- if (mode < 0 || mode > 6) {
|
|
|
- if (mode == (byte)0xFF) {
|
|
|
- //Log.i(TAG, "[Send_SetLedMode] 0xFF : Get Value");
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "[Send_SetLedMode] mode range error");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = {mode};
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetLedMode, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetLedMode] Reply is null");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply != null && Reply.length != 2) {
|
|
|
- DeviceLog("[Send_SetLedMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- //Log.w(TAG,"[Send_SetLedMode] bError fail");
|
|
|
- DeviceLog("[Send_SetLedMode] FAIL");
|
|
|
- AddDoCount(false);
|
|
|
- return -100;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 동작 성공 여부 확인
|
|
|
- // 스마트현관카메라 버그 : LED 제어명령에 대해 D1을 00(실패)로 무조건 응답함 -> 주석처리 : 2019.06.17
|
|
|
- /*if(Reply[0] == 0)
|
|
|
- {
|
|
|
- Log.w(TAG, "[Send_SetLedMode] Device Act Fail !!!");
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else if(Reply[0] == 1)*/
|
|
|
- {
|
|
|
- //Log.d(TAG, "[Send_SetLedMode] Device Act Run ~~~");
|
|
|
-
|
|
|
- if (Reply[1] == mode || mode == (byte)0xFF) {
|
|
|
- //Log.d(TAG, "[Send_SetLedMode] Device Act Success ~~~");
|
|
|
- //Log.d(TAG, "[Send_SetLedMode] Device LED mode Same : " + Reply[1]);
|
|
|
- mDriver.Sensor_Value.Sensor_LedMode = Reply[1];
|
|
|
- StatusChanged();
|
|
|
-
|
|
|
- DeviceLog("[Send_SetLedMode] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else {
|
|
|
- //Log.d(TAG, "[Send_SetLedMode] Device LED mode Diff : " + Reply[1]);
|
|
|
- DeviceLog("[Send_SetLedMode] END");
|
|
|
- return 2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * RSSI 제어 기능이 있는 현관카메라의 RSSI 모드, 단계를 제어한다.
|
|
|
- * @param mode 범위(0~2 , FF)
|
|
|
- * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
- */
|
|
|
- private int Send_SetRSSIMode(byte mode, byte level) {
|
|
|
- DeviceLog("[Send_SetRSSIMode] Start");
|
|
|
-
|
|
|
- if (mode < (byte)0 || mode > (byte)2) {
|
|
|
- Log.w(TAG, "[Send_SetRSSIMode] mode range error");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- if (level < (byte)-100 || level > (byte)100) {
|
|
|
- if (mode == (byte)0xFF) {
|
|
|
- DeviceLog("[Send_SetRSSIMode] 0xFF : Get Value");
|
|
|
- }
|
|
|
- else {
|
|
|
- DeviceLog("[Send_SetRSSIMode] level range error");
|
|
|
- return -2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = {mode, level};
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable(DEVICE_ADDRESS, CMDList.Req.SetRssiMode, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetRSSIMode] Reply is null");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply != null && Reply.length != 2) {
|
|
|
- DeviceLog("[Send_SetRSSIMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- //Log.w(TAG, "[Send_SetRSSIMode] bError fail");
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetRSSIMode] FAIL");
|
|
|
- return -100;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 동작 성공 여부 확인
|
|
|
- if (Reply[0] == 0) {
|
|
|
- Log.w(TAG, "[Send_SetRSSIMode] Device Act Fail !!!");
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else if (Reply[0] == 1) {
|
|
|
- //Log.d(TAG, "[Send_SetRSSIMode] Device Act Run ~~~");
|
|
|
-
|
|
|
- if (Reply[1] == level || level == (byte)0xFF) {
|
|
|
- // 변경한 단계와 동일하거나, 현재상태값을 요청이 성공한 경우
|
|
|
- //Log.d(TAG, "[Send_SetRSSIMode] Device Act Success ~~~");
|
|
|
- //Log.d(TAG, "[Send_SetRSSIMode] Device RSSI level Same : " + Reply[1]);
|
|
|
-
|
|
|
- if (mode == 1) {
|
|
|
- // 읽기 모드
|
|
|
- mDriver.Sensor_Value.Sensor_RSSI_Read = Reply[1];
|
|
|
- }
|
|
|
- else if (mode == 2) {
|
|
|
- // 쓰기 모드
|
|
|
- mDriver.Sensor_Value.Sensor_RSSI_Write = Reply[1];
|
|
|
- }
|
|
|
- StatusChanged();
|
|
|
-
|
|
|
- DeviceLog("[Send_SetRSSIMode] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else {
|
|
|
- //Log.d(TAG, "[Send_SetRSSIMode] Device RSSI level Diff : " + Reply[1]);
|
|
|
- DeviceLog("[Send_SetRSSIMode] END");
|
|
|
- return 2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 판별 감지빈도 제어 기능이 있는 현관카메라의 빈도(%)를 제어한다.
|
|
|
- * @param level 범위(0~4, FF)
|
|
|
- * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
- */
|
|
|
- private int Send_SetDetectRatio(byte level) {
|
|
|
- DeviceLog("[Send_SetDetectRatio] Start");
|
|
|
- //Log.i(TAG, "[Send_SetDetectRatio] Start");
|
|
|
-
|
|
|
- if (level < (byte)0 || level > (byte)100) {
|
|
|
- if (level == (byte)0xFF) {
|
|
|
- //Log.i(TAG, "[Send_SetDetectRatio] 0xFF : Get Value");
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "[Send_SetDetectRatio] level range error");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- }
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = {level };
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetDetectRatio, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetDetectRatio] Reply is null");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply != null && Reply.length != 2) {
|
|
|
- DeviceLog("[Send_SetDetectRatio] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetDetectRatio] FAIL");
|
|
|
- return -100;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 동작 성공 여부 확인
|
|
|
- if (Reply[0] == 0) {
|
|
|
- Log.w(TAG, "[Send_SetDetectRatio] Device Act Fail !!!");
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else if (Reply[0] == 1) {
|
|
|
- //Log.d(TAG, "[Send_SetDetectRatio] Device Act Run ~~~");
|
|
|
- if (Reply[1] == level || level == (byte)0xFF) {
|
|
|
- //Log.d(TAG, "[Send_SetDetectRatio] Device Act Success ~~~");
|
|
|
- //Log.d(TAG, "[Send_SetDetectRatio] Device DetectRatio level Same : " + Reply[1]);
|
|
|
- mDriver.Sensor_Value.Sensor_DetectRatio = Reply[1];
|
|
|
- StatusChanged();
|
|
|
-
|
|
|
- DeviceLog("[Send_SetDetectRatio] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else {
|
|
|
- //Log.d(TAG, "[Send_SetDetectRatio] Device DetectRatio level Diff : " + Reply[1]);.
|
|
|
- DeviceLog("[Send_SetDetectRatio] END");
|
|
|
- return 2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 카메라 상태 제어 기능이 있는 현관카메라의 카메라모드를 제어한다.
|
|
|
- * @param mode 범위(0~3, FF)
|
|
|
- * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
- */
|
|
|
- private int Send_SetCameraMode(byte mode) {
|
|
|
- DeviceLog("[Send_SetCameraMode] Start");
|
|
|
-
|
|
|
- if (mode < (byte)0 || mode > (byte)3) {
|
|
|
- if (mode == (byte)0xFF) {
|
|
|
- //Log.i(TAG, "[Send_SetCameraMode] 0xFF : Get Value");
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "[Send_SetCameraMode] mode range error");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = {mode };
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetCameraMode, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
-
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_SetCameraMode] Reply is null");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply != null && Reply.length != 2) {
|
|
|
- DeviceLog("[Send_SetCameraMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
- bError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- //Log.w(TAG, "[Send_SetCameraMode] bError fail");
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_SetCameraMode] FAIL");
|
|
|
- return -100;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
- // 동작 성공 여부 확인
|
|
|
- if (Reply[0] == (byte)0) {
|
|
|
- Log.w(TAG, "[Send_SetCameraMode] Device Act Fail !!!");
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else if (Reply[0] == (byte)1) {
|
|
|
- //Log.d(TAG, "[Send_SetCameraMode] Device Act Run ~~~");
|
|
|
-
|
|
|
- if (Reply[1] == mode || mode == (byte)0xFF) {
|
|
|
- //Log.d(TAG, "[Send_SetCameraMode] Device Act Success ~~~");
|
|
|
- //Log.d(TAG, "[Send_SetCameraMode] Device DetectRatio level Same : " + Reply[1]);
|
|
|
- mDriver.Sensor_Value.Sensor_CameraMode = Reply[1];
|
|
|
- StatusChanged();
|
|
|
-
|
|
|
- DeviceLog("[Send_SetCameraMode] END");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else {
|
|
|
- //Log.d(TAG, "[Send_SetCameraMode] Device DetectRatio level Diff : " + Reply[1]);
|
|
|
- DeviceLog("[Send_SetCameraMode] END");
|
|
|
- return 2;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트키 삭제
|
|
|
- *
|
|
|
- * @return (boolean) false - Error , true - OK
|
|
|
- */
|
|
|
- private boolean Send_DeleteKey(SetRegisterDataList setRegisterData) {
|
|
|
- DeviceLog("[Send_DeleteKey] Start");
|
|
|
-
|
|
|
- // 1. In 파라미터 확인
|
|
|
- if (setRegisterData == null) {
|
|
|
- Log.w(TAG, "[Send_DeleteKey] Param - RegisterData is null !!!");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 패킷 데이터 만들기
|
|
|
- byte [] ReqData = setRegisterData.getByteArray();
|
|
|
-
|
|
|
- // 3. 데이터 전송 및 응답
|
|
|
- byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKeyRegister, ReqData);
|
|
|
-
|
|
|
- // 4. 수신데이터 파싱
|
|
|
- boolean bError = false;
|
|
|
- byte data = 0x00;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- byte RegResult = 0;
|
|
|
- while (true) {
|
|
|
- // null Check
|
|
|
- if (Reply == null) {
|
|
|
- DeviceLog("[Send_DeleteKey] Reply is null");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- // Length Check
|
|
|
- if (Reply.length < 1) {
|
|
|
- Log.w(TAG, "[Send_DeleteKey] Reply.length fail #1... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- index = 0;
|
|
|
-
|
|
|
- // D1 : 등록모드 상태값
|
|
|
- data = Reply[index++];
|
|
|
- if ((data & (byte)(BIT4 | BIT5 | BIT6 | BIT7)) != 0x00) {
|
|
|
- Log.w(TAG, "[Send_DeleteKey] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
-
|
|
|
- if ((data & BIT0) != 0x00) {
|
|
|
- if (Reply.length != (int)(1 + 16)) {
|
|
|
- Log.w(TAG, "[Send_DeleteKey] Reply.length fail #2... (length:" + Reply.length + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- RegResult = (byte)((data >> 2) & (byte)(BIT0|BIT1));
|
|
|
- switch (RegResult) {
|
|
|
- case 0x00: case 0x01: case 0x02: break;
|
|
|
- default:
|
|
|
- Log.w(TAG, "[Send_DeleteKey] RegResult Out Of Range !!!(RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
- bError = true; break;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (bError) {
|
|
|
- AddDoCount(false);
|
|
|
- DeviceLog("[Send_DeleteKey] FAIL");
|
|
|
- return false;
|
|
|
- }
|
|
|
- AddDoCount(true);
|
|
|
-
|
|
|
-
|
|
|
- // 5. 데이터 확인
|
|
|
- if (RegResult == 0) {
|
|
|
- Log.i(TAG, "[Send_DeleteKey] Delete success");
|
|
|
- DeviceLog("[Send_DeleteKey] END");
|
|
|
- return true;
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.i(TAG, "[Send_DeleteKey] Delete Fail -> RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
- DeviceLog("[Send_DeleteKey] END");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // CMDList
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- /**
|
|
|
- * 명령어 리스트
|
|
|
- */
|
|
|
- public static class CMDList {
|
|
|
- public static final class Req {
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- // Board
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- /** 기기 정보 요청 */
|
|
|
- public final static byte GetDeviceInfo = 0x01;
|
|
|
-
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- // 기본 상태 커맨드
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- /** 기본상태 요청 */
|
|
|
- public final static byte GetStatus = 0x11;
|
|
|
- /** 기본상태값 해제 요청 */
|
|
|
- public final static byte SetStatusClr = 0x12;
|
|
|
-
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- // 스마트 키값 읽기 커맨드
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- /** 스마트 키값 요청 */
|
|
|
- public final static byte GetSmartKey = 0x21;
|
|
|
- /** 스마트 키값 확인 요청 */
|
|
|
- public final static byte SetSmartKeyVerify = 0x22;
|
|
|
-
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- // 스마트키 등록 커맨드
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- /** 등록모드 시작 요청 */
|
|
|
- public final static byte SetSmartKeyRegisterStart = 0x31;
|
|
|
- /** 등록 스마트 키값 요청 */
|
|
|
- public final static byte GetSmartKeyRegister = 0x32;
|
|
|
- /** 등록모드 종료 요청 */
|
|
|
- public final static byte SetSmartKeyRegisterEnd = 0x33;
|
|
|
-
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- // 센서 관련 커맨드
|
|
|
- /////////////////////////////////////////////////////////
|
|
|
- /** 센서상태 요청 및 제어 */
|
|
|
- public final static byte SetSensorStatus = 0x41;
|
|
|
- /** LED 모드 제어 */
|
|
|
- public final static byte SetLedMode = 0x42;
|
|
|
- /** RSSI 모드 제어 */
|
|
|
- public final static byte SetRssiMode = 0x43;
|
|
|
- /** 판별감도 제어 */
|
|
|
- public final static byte SetDetectRatio = 0x44;
|
|
|
- /** 카메라 상태 제어 */
|
|
|
- public final static byte SetCameraMode = 0x45;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // UpdateVariables
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- /**
|
|
|
- * [현관콜 , 에러]를 업데이트 한다.
|
|
|
- *
|
|
|
- * @param Status - (StatusList) 업데이트할 기본상태 응답 클래스
|
|
|
- *
|
|
|
- * @return (boolean) 데이터 변경여부 (true:변경 , false:미변경)
|
|
|
- */
|
|
|
- private boolean UpdateVariables(StatusList Status) {
|
|
|
- DeviceLog("[UpdateVariables] (Status) Start");
|
|
|
- if (Status == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- boolean bChanged = false;
|
|
|
-
|
|
|
- // 1. 현관콜
|
|
|
- if (mDriver.Status.bDoorBtnStatus != Status.bDoorBtnStatus) {
|
|
|
- if ((!mDriver.Status.bDoorBtnStatus) && (Status.bDoorBtnStatus)) {
|
|
|
- if (GetDoorStdOpenMode()) {
|
|
|
- SetDoorStdOpenMode(false);
|
|
|
-
|
|
|
- Log.i(TAG, "*****************************");
|
|
|
- Log.i(TAG, "* DLOCK_STANDBYOPEN(RF) *");
|
|
|
- Log.i(TAG, "*****************************");
|
|
|
-
|
|
|
- int ret = -1;
|
|
|
-
|
|
|
- // 도어락 열기
|
|
|
- if (Version.getGatewayUsage()) {
|
|
|
- if (ServiceMain.dataBaseLoader.data.wallpadDeviceSet.Get_DoorLock_Info[1] == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
- ret = driverInterOpAPI.FPdLock_SetDoorOpen();
|
|
|
- Log.i(TAG, "[UpdateVariables] FPdLock_SetDoorOpen - ret : " + ret);
|
|
|
- }
|
|
|
- else {
|
|
|
- ret = driverInterOpAPI.IGW_SetWddrCont(true);
|
|
|
- Log.i(TAG, "[UpdateVariables] IGW_SetWddrCont - ret : " + ret);
|
|
|
- }
|
|
|
- // 현산향 모델에도 무선도어락이 적용되기에
|
|
|
- // 도어락을 터치해서 문을 열 수 없다.
|
|
|
- WallPadInterface devioctr = new WallPadInterface();
|
|
|
- TurnOnDcamPower(devioctr); //현재 통화 상태에서는 동작 X
|
|
|
- }
|
|
|
- else {
|
|
|
- WallPadInterface devioctr = new WallPadInterface();
|
|
|
- devioctr.DoorLockControl(true);
|
|
|
- TurnOnDcamPower(devioctr); //현재 통화 상태에서는 동작 X
|
|
|
- ret = 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (ret >= 0) {
|
|
|
- // 출입 데이터 기록 (스마트키에 의한 문열림)
|
|
|
- WallpadAccessData WpadAccessData = new WallpadAccessData(ServiceMain.svcContext);
|
|
|
- String sn = SmartKeyRfDoor_Controller.GetCheckSmartKeySn();
|
|
|
- ret = WpadAccessData.Insert(WallpadAccessData.KIND.SMART_KEY, sn);
|
|
|
- WpadAccessData.closeDB();
|
|
|
- Log.d(TAG, "WpadAccessData.Insert(SMART_KEY) - ret:" + ret);
|
|
|
-
|
|
|
-
|
|
|
- // 최근사용일자 갱신
|
|
|
- WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
- byte no = SmartKeyRfDoor_Controller.GetCheckSmartKeyNo();
|
|
|
- ret = WpadSmartKeyRegData.UpdateLastUseDate(no);
|
|
|
- Log.d(TAG, "WpadAccessData.UpdateLastUseDate(" + no + ") - ret:" + ret);
|
|
|
- WpadSmartKeyRegData.closeDB();
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- if (CallAppEnable) {
|
|
|
- // 현관콜 시작
|
|
|
- Log.i(TAG, "============================================");
|
|
|
- Log.i(TAG, " DOOR CALL");
|
|
|
- Log.i(TAG, "============================================");
|
|
|
-
|
|
|
- setSendEventBR(WallPadInterface.BTN_DOOR);
|
|
|
- }
|
|
|
- else {
|
|
|
- Log.w(TAG, "CallAppEnable FALSE -> DoorLock Opening, Wait until Turn off the Dcam Light");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- mDriver.Status.bDoorBtnStatus = Status.bDoorBtnStatus;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 거동수상자 감지
|
|
|
- boolean sensorClear = false;
|
|
|
- if (mDriver.Status.bSensorDetect != Status.bSensorDetect) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - Wpad sensor data : " + mDriver.Status.bSensorDetect);
|
|
|
- Log.i(TAG, "[UpdateVariables] - new receive sensor data : " + Status.bSensorDetect);
|
|
|
- // (월패드 : 감지안됨) && (스마트현관 : 감지됨) 인 경우에만 동작 : 거동수상자 발생
|
|
|
- if ((!mDriver.Status.bSensorDetect) && (Status.bSensorDetect)) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - Sensor Detect Occur !!!");
|
|
|
-
|
|
|
- Intent mIntent = new Intent();
|
|
|
- mIntent.setAction(define.NOTIFY_ACNAME);
|
|
|
- mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_DETECT);
|
|
|
- ServiceMain.svcContext.sendBroadcast(mIntent);
|
|
|
-
|
|
|
- sensorClear = true;
|
|
|
-
|
|
|
- Log.i(TAG, "============================================");
|
|
|
- Log.i(TAG, " STRANGE DETECT !");
|
|
|
- Log.i(TAG, "============================================");
|
|
|
- }
|
|
|
- // (월패드 : 감지됨) && (스마트현관 : 감지안됨) 인 경우에만 동작 : 거동수상자 해소
|
|
|
- else if ((mDriver.Status.bSensorDetect) && (!Status.bSensorDetect)) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - Sensor Detect Release !!!");
|
|
|
-
|
|
|
- Intent mIntent = new Intent();
|
|
|
- mIntent.setAction(define.NOTIFY_ACNAME);
|
|
|
- mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_RELEASE);
|
|
|
- ServiceMain.svcContext.sendBroadcast(mIntent);
|
|
|
-
|
|
|
- Log.i(TAG, "============================================");
|
|
|
- Log.i(TAG, " STRANGE RELEASE~~");
|
|
|
- Log.i(TAG, "============================================");
|
|
|
- }
|
|
|
-
|
|
|
- mDriver.Status.bSensorDetect = Status.bSensorDetect;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. LED 상태
|
|
|
- if (mDriver.Status.bLedStatus != Status.bLedStatus) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - past Wpad LedStatus data : " + mDriver.Status.bLedStatus);
|
|
|
- Log.i(TAG, "[UpdateVariables] - new receive LedStatus data : " + Status.bLedStatus);
|
|
|
- mDriver.Status.bLedStatus = Status.bLedStatus;
|
|
|
- }
|
|
|
-
|
|
|
- // 4. 카메라 상태
|
|
|
- if (mDriver.Status.bCameraStatus != Status.bCameraStatus) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - past Wpad CameraStatus data : " + mDriver.Status.bCameraStatus);
|
|
|
- Log.i(TAG, "[UpdateVariables] - new receive CameraStatus data : " + Status.bCameraStatus);
|
|
|
- mDriver.Status.bCameraStatus = Status.bCameraStatus;
|
|
|
- }
|
|
|
-
|
|
|
- // 5. LED Auto 상태
|
|
|
- if (mDriver.Status.bLedAuto != Status.bLedAuto) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - past Wpad LedAuto data : " + mDriver.Status.bLedAuto);
|
|
|
- Log.i(TAG, "[UpdateVariables] - new receive LedAuto data : " + Status.bLedAuto);
|
|
|
- mDriver.Status.bLedAuto = Status.bLedAuto;
|
|
|
- }
|
|
|
-
|
|
|
- // 6. 카메라 Auto 상태
|
|
|
- if (mDriver.Status.bCameraAuto != Status.bCameraAuto) {
|
|
|
- Log.i(TAG, "[UpdateVariables] - past Wpad CameraAuto data : " + mDriver.Status.bCameraAuto);
|
|
|
- Log.i(TAG, "[UpdateVariables] - new receive CameraAuto data : " + Status.bCameraAuto);
|
|
|
- mDriver.Status.bCameraAuto = Status.bCameraAuto;
|
|
|
- }
|
|
|
-
|
|
|
- // 7. 에러
|
|
|
- if (mDriver.Status.bError != Status.bError) {
|
|
|
- if ((!mDriver.Status.bError) && (Status.bError)) {
|
|
|
- Log.i(TAG, "UpdateVariables - ERROR Detection !!!");
|
|
|
- }
|
|
|
- else if ((mDriver.Status.bError) && (!Status.bError)) {
|
|
|
- Log.i(TAG, "UpdateVariables - ERROR Clear !!!");
|
|
|
- }
|
|
|
- mDriver.Status.bError = Status.bError;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 상태 클리어
|
|
|
- if (Status.bDoorBtnStatus || Status.bError || sensorClear) {
|
|
|
- Send_SetStatusClr(Status);
|
|
|
- bChanged = true;
|
|
|
- }
|
|
|
-
|
|
|
- DeviceLog("[UpdateVariables] (Status) End");
|
|
|
- return bChanged;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트키값이 등록된 키값인지 비교한다.
|
|
|
- *
|
|
|
- * @param KeyData - (KeyDataList) 인식된 스마트키값 클래스
|
|
|
- *
|
|
|
- * @return (boolean) 데이터 변경여부 (true:변경 , false:미변경)
|
|
|
- */
|
|
|
- private boolean UpdateVariables(KeyDataList KeyData) {
|
|
|
- if (KeyData == null) return false;
|
|
|
- if (KeyData.Count <= 0) return false;
|
|
|
- if (KeyData.Encryption == null) return false;
|
|
|
-
|
|
|
- boolean FindKey = false;
|
|
|
- for (byte i=0; i < KeyData.Count; i++) {
|
|
|
- if (KeyData.Encryption[i] != null) {
|
|
|
- FindKey = CheckSmartKey(KeyData.Encryption[i].Data);
|
|
|
- if (FindKey) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (FindKey) {
|
|
|
- // 등록된키값 인식
|
|
|
- // 도어락 문열림대기모드 시작
|
|
|
- Log.i(TAG, "[UpdateVariables] FindKey !!!");
|
|
|
-
|
|
|
- int ret = -1;
|
|
|
- if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL) {
|
|
|
- Log.i(TAG, "[UpdateVariables] mDoorLockType 1 : " + mDoorLockType);
|
|
|
- ret = driverInterOpAPI.DLock_SetDoorOpenStandbyMode(true, DLOCK_STANDBYMODE_SEC);
|
|
|
- Log.i(TAG, "[UpdateVariables] DLock_SetDoorOpenStandbyMode - ret : " + ret);
|
|
|
- }
|
|
|
- else if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_RF) {
|
|
|
- Log.i(TAG, "[UpdateVariables] mDoorLockType 2 : " + mDoorLockType);
|
|
|
- if (mDoorOpenDelay) {
|
|
|
- // 문열림 대기모드 동작 신 시나리오 (무선 도어락 터치 시 문열림)
|
|
|
- ret = driverInterOpAPI.IGW_SetWddrOpenDelayCont(DLOCK_STANDBYMODE_SEC);
|
|
|
- Log.i(TAG, "[UpdateVariables] IGW200D_SetWddrOpenDelayCont - ret : " + ret);
|
|
|
- }
|
|
|
- else {
|
|
|
- // 문열림 대기모드 동작 구 시나리오 (현관카메라 버튼 누를 시 문열림)
|
|
|
- SetDoorStdOpenMode(true);
|
|
|
- }
|
|
|
- Log.i(TAG, "[UpdateVariables] SetDoorStdOpenMode(ON) 1");
|
|
|
- }
|
|
|
- else if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
- Log.i(TAG, "[UpdateVariables] mDoorLockType 3 : " + mDoorLockType);
|
|
|
- SetDoorStdOpenMode(true);
|
|
|
- Log.i(TAG, "[UpdateVariables] SetDoorStdOpenMode(ON) 2");
|
|
|
- }
|
|
|
-
|
|
|
- WallpadStatusData wallpadStatusData = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
- boolean SmartKeyDetectionAlarm = wallpadStatusData.GetSmartKeyDetectionAlarm();
|
|
|
- wallpadStatusData.closeDB();
|
|
|
- if (SmartKeyDetectionAlarm) {
|
|
|
- // DB 저장 (스마트키감지)
|
|
|
- WallpadAccessData WpadAccessData = new WallpadAccessData(ServiceMain.svcContext);
|
|
|
- WpadAccessData.setMaxCount(1000);
|
|
|
- ret = WpadAccessData.Insert(WallpadAccessData.KIND.SMART_KEY_DETECTION, CheckSmartKeySn);
|
|
|
- WpadAccessData.closeDB();
|
|
|
- Log.d(TAG, "WpadAccessData.Insert(SMART_KEY_DETECTION) - ret:" + ret);
|
|
|
-
|
|
|
- // 사운드 알람
|
|
|
- WpadSound Sound = new WpadSound(ServiceMain.svcContext);
|
|
|
- Sound.PlayMent(WpadSound.SND.effect.EFFECT1);
|
|
|
-
|
|
|
- // LCD 를 Normal 상태로 변경하는 기능 추가
|
|
|
- //PowerManager pm = (PowerManager) (ServiceMain.svcContext).getSystemService(Context.POWER_SERVICE);
|
|
|
- //pm.userActivity(1, true);
|
|
|
-
|
|
|
- // 인텐트를 전송하여 제어 UI 혹은 스마트키등록 화면에서 flag를 세우도록 설정하기
|
|
|
- //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
-
|
|
|
- // Toast 메시지 표시
|
|
|
- Toast.makeText(ServiceMain.svcContext,
|
|
|
- "SmartKey Detection : [" + CheckSmartKeySn + "]",
|
|
|
- Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 등록모드 시작버튼 체크
|
|
|
- *
|
|
|
- * @param RegisterModeStart - (int) 체크할 시작버튼 상태 (1:감지)
|
|
|
- */
|
|
|
- private void UpdateVariables(int RegisterModeStart) {
|
|
|
- if (RegisterModeStart == 1) {
|
|
|
- Log.i(TAG, "UpdateVariables - Start Button DETECTION !!!");
|
|
|
-
|
|
|
- if (!mDriver.RegisterInitMode) {
|
|
|
- int id = DB_GetId();
|
|
|
- if (id <= 0) {
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- Log.w(TAG, "UpdateVariables - DB_GetId Out Of Range (id:" + id + ")");
|
|
|
- }
|
|
|
- else {
|
|
|
- mDriver.CardRegNo = (byte)id;
|
|
|
- super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- super.StatusChanged(STATUS_REGMODE_START);
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- *
|
|
|
- * @param GetRegisterData
|
|
|
- */
|
|
|
- private void UpdateVariables(GetRegisterDataList GetRegisterData) {
|
|
|
- if (GetRegisterData == null) return;
|
|
|
-
|
|
|
- // 1. 스마트RF현관카메라 에서 종료
|
|
|
- if (GetRegisterData.Exit) {
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
- Log.i(TAG, "UpdateVariables - END Button DETECTION !!!");
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 에러체크
|
|
|
- if (GetRegisterData.RegResult != 0x00) {
|
|
|
- switch (GetRegisterData.RegResult) {
|
|
|
- case 0x01:
|
|
|
- // 이미 등록된 키
|
|
|
- super.StatusChanged(STATUS_REGMODE_KEY_ALREADY);
|
|
|
- Log.i(TAG, "UpdateVariables - STATUS_REGMODE_KEY_ALREADY");
|
|
|
- break;
|
|
|
-
|
|
|
- case 0x02:
|
|
|
- // 무선 통신 실패
|
|
|
- super.StatusChanged(STATUS_REGMODE_ER_WIRELESSCOMMFAIL);
|
|
|
- Log.i(TAG, "UpdateVariables - STATUS_REGMODE_ER_WIRELESSCOMMFAIL");
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 등록 데이터 체크
|
|
|
- if (!(GetRegisterData.Exit) && (GetRegisterData.RegResult == 0x00)) {
|
|
|
- if (GetRegisterData.Encryption != null) {
|
|
|
- if (!mDriver.RegisterInitMode) {
|
|
|
- byte Status = 0;
|
|
|
- int ret = SaveSmartKey(GetRegisterData.Encryption.Data);
|
|
|
- if (ret > 0) {
|
|
|
- Status = STATUS_REGMODE_KEY_COMPLETE;
|
|
|
- Status |= (byte)ret;
|
|
|
- }
|
|
|
- else {
|
|
|
- Status = STATUS_REGMODE_ER_DBWRITE;
|
|
|
- }
|
|
|
- super.StatusChanged(Status);
|
|
|
-
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterPause);
|
|
|
- Log.i(TAG, "UpdateVariables - STATUS_REGMODE_KEY_COMPLETE (Status:" + String.format("0x%02X", Status) + ")");
|
|
|
- }
|
|
|
- else {
|
|
|
- super.StatusChanged(STATUS_REGMODE_KEY_COMPLETE);
|
|
|
- mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterPause);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // DB
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- private int DB_GetId() {
|
|
|
- try {
|
|
|
- WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
- int id = WpadSmartKeyRegData.GetEmptyId();
|
|
|
- WpadSmartKeyRegData.closeDB();
|
|
|
- return id;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return -1000;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[DB_GetId] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return -1000;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private int DB_Register(byte id, byte[] Uid, byte[] SiteCode, byte[] DongHo) {
|
|
|
- try {
|
|
|
- WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
- int ret = WpadSmartKeyRegData.Register((byte) id, Uid, SiteCode, DongHo);
|
|
|
- WpadSmartKeyRegData.closeDB();
|
|
|
- return ret;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return -1000;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[DB_Register] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return -1000;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private String DB_isExist(byte id, byte[] Uid, byte[] SiteCode, byte[] DongHo) {
|
|
|
- try {
|
|
|
- WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
- String sn = WpadSmartKeyRegData.isExist(id, Uid, SiteCode, DongHo);
|
|
|
- WpadSmartKeyRegData.closeDB();
|
|
|
- return sn;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return null;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[DB_Register] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- // Util
|
|
|
- ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트키 데이터를 등록데이터와 비교 체크한다.
|
|
|
- *
|
|
|
- * @param Input - (byte []) 읽은 스마트키 데이터 배열
|
|
|
- *
|
|
|
- * @return (boolean) 결과 - true:있음 , false:아님
|
|
|
- */
|
|
|
- private boolean CheckSmartKey(byte [] Input) {
|
|
|
- boolean DEBUG = false;
|
|
|
-
|
|
|
- if (DEBUG) Log.d(TAG, "[CheckSmartKey] Start");
|
|
|
- try {
|
|
|
- // 1. 복호화 체크
|
|
|
- byte [] Output = null;
|
|
|
-
|
|
|
- if (ServiceMain.dataBaseLoader.data.wallpadDeviceSet.Get_BLE_SmartKey == false) {
|
|
|
- // 기존 스마트키 사용일 경우
|
|
|
- Output = AES_128.Encrypt(AES_128.ENCRYPTTYPE.SMARTKEY_CAM, Input);
|
|
|
- }
|
|
|
- else {
|
|
|
- // BLE스마트키 사용일 경우
|
|
|
- Output = AES_128.Decrypt_ECB(AES_128.ENCRYPTTYPE.SMARTKEY_CAM, Input);
|
|
|
- }
|
|
|
-
|
|
|
- if (DEBUG) Log.d(TAG, "[CheckSmartKey] Input - " + super.ToByteString(Input));
|
|
|
- if (DEBUG) Log.d(TAG, "[CheckSmartKey] Output - " + super.ToByteString(Output));
|
|
|
- if (Output == null) {
|
|
|
- Log.w(TAG, "[CheckSmartKey] AES_128.Encrypt - Output is null !!!");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 복호화 데이터 길이 체크
|
|
|
- if (Output.length != 16) {
|
|
|
- Log.w(TAG, "[CheckSmartKey] Output.length Not Match !!! (length:" + Output.length + ")");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. RandomKey 체크
|
|
|
- if ((Output[0] != mDriver.Polling.RandomKeyBuffer[0]) || (Output[15] != mDriver.Polling.RandomKeyBuffer[1])) {
|
|
|
- Log.w(TAG, "[CheckSmartKey] RandomKey Data Not Match !!!");
|
|
|
-
|
|
|
- Log.i(TAG, "RandomKeyValue " + "1:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[0]) + ", " + "2:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[1]));
|
|
|
- Log.i(TAG, "ReadRandomKeyValue " + "1:" + String.format("0x%02X", Output[0]) + ", " + "2:" + String.format("0x%02X", Output[15]));
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 4. Uid 암호화 및 그외 데이터 분리
|
|
|
- byte [] Uid = new byte [] { Output[1], Output[2], Output[3], Output[4] };
|
|
|
- byte [] EncryptUid = AES_128.Encrypt(AES_128.ENCRYPTTYPE.NORMAL, Uid);
|
|
|
- if (DEBUG) Log.d(TAG, "[CheckSmartKey] EncryptUid - " + super.ToByteString(EncryptUid));
|
|
|
- byte [] SiteCode = new byte [] { Output[5], Output[6], Output[7], Output[8] };
|
|
|
- byte [] DongHo = new byte [] { Output[9], Output[10], Output[11], Output[12] };
|
|
|
- byte CardRegNo = Output[13];
|
|
|
-
|
|
|
- // 5. 존재유무 DB 확인
|
|
|
- String sn = DB_isExist(CardRegNo, EncryptUid, SiteCode, DongHo);
|
|
|
- if (sn != null) {
|
|
|
- CheckSmartKeyNo = CardRegNo;
|
|
|
- CheckSmartKeySn = sn;
|
|
|
- if (DEBUG) Log.d(TAG, "[CheckSmartKey] DB_isExist - true");
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
- else return false;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return false;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[CheckSmartKey] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private int SaveSmartKey(byte [] Input) {
|
|
|
- boolean DEBUG = true;
|
|
|
-
|
|
|
- if (DEBUG) Log.d(TAG, "[SaveSmartKey] Start");
|
|
|
- try {
|
|
|
- if (Input == null) return -1;
|
|
|
- if (Input.length != 16) return -2;
|
|
|
-
|
|
|
- // 1. D1 : 0xCA 체크
|
|
|
- // if(DEBUG) Log.d(TAG, "[SaveSmartKey] Step1 : D1 Check");
|
|
|
- // if(Input[0] != (byte)0xCA)
|
|
|
- // {
|
|
|
- // Log.w(TAG, "[SaveSmartKey] D1 : Data Not Match !!!");
|
|
|
- // return -11;
|
|
|
- // }
|
|
|
-
|
|
|
- boolean bRet = false;
|
|
|
-
|
|
|
- // 2. SiteCode 체크
|
|
|
- if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step2 : SiteCode Check");
|
|
|
- byte [] SiteCode = new byte [] { Input[5], Input[6], Input[7], Input[8] };
|
|
|
- bRet = CompareByteArray(SiteCode, mDriver.SiteCodeBCD);
|
|
|
- if (!bRet) {
|
|
|
- Log.w(TAG, "[SaveSmartKey] SiteCode : Data Not Match !!!");
|
|
|
- return -12;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. DongHo 체크
|
|
|
- if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step3 : DongHo Check");
|
|
|
- byte [] DongHo = new byte [] { Input[9], Input[10], Input[11], Input[12] };
|
|
|
- bRet = CompareByteArray(DongHo, mDriver.DongHoBCD);
|
|
|
- if (!bRet) {
|
|
|
- Log.w(TAG, "[SaveSmartKey] DongHo : Data Not Match !!!");
|
|
|
- return -13;
|
|
|
- }
|
|
|
-
|
|
|
- // 4. Card Reg No. 체크
|
|
|
- if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step4 : Card Reg No Check");
|
|
|
- byte CardRegNo = Input[13];
|
|
|
- if (CardRegNo != mDriver.CardRegNo) {
|
|
|
- Log.w(TAG, "[SaveSmartKey] CardRegNo : Data Not Match !!!");
|
|
|
- return -14;
|
|
|
- }
|
|
|
-
|
|
|
- // 5. Uid 복호화
|
|
|
- byte [] Uid = new byte [] { Input[1], Input[2], Input[3], Input[4] };
|
|
|
- byte [] NormalUid = AES_128.Encrypt(AES_128.ENCRYPTTYPE.NORMAL, Uid);
|
|
|
- if (DEBUG) {
|
|
|
- Log.d(TAG, "[SaveSmartKey] Step5 : Uid");
|
|
|
- Log.d(TAG, " Uid - " + super.ToByteString(Uid));
|
|
|
- Log.d(TAG, " NormalUid - " + super.ToByteString(NormalUid));
|
|
|
- }
|
|
|
-
|
|
|
- // 5. DB 저장
|
|
|
- int ret = DB_Register(CardRegNo, NormalUid, SiteCode, DongHo);
|
|
|
- if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step6 : DB_Register = " + ret);
|
|
|
- if (ret >= 0) {
|
|
|
- return (int) CardRegNo;
|
|
|
- }
|
|
|
-
|
|
|
- return ret;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return -1000;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[SaveSmartKey] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return -1000;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
|
|
|
- *
|
|
|
- * @param code - (int) 송신할 keycode
|
|
|
- * @return (int) - >=0 : 성공, <0 : 실패
|
|
|
- */
|
|
|
- private int setSendEventBR(int code) {
|
|
|
- try {
|
|
|
- KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code);
|
|
|
- Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
|
|
|
- intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
|
|
|
- intent.putExtra("keycode",code);
|
|
|
- ServiceMain.svcContext.sendBroadcast(intent);
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return -100;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[setSendEventBR] - [Exception Error] code:" + code);
|
|
|
- Log.e(TAG, "[setSendEventBR] - " + e.toString());
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return -100;
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 동호 데이터를 BCD Code 로 가져온다.
|
|
|
- *
|
|
|
- * @return (byte []) null - Error , Not null - OK
|
|
|
- */
|
|
|
- private byte [] getDongHo_BCD() {
|
|
|
- try {
|
|
|
- wallpaddbmgr dbmgr = new wallpaddbmgr(ServiceMain.svcContext);
|
|
|
- AddressSet addc = dbmgr.getAddressMGR();
|
|
|
- dbmgr.closeDB();
|
|
|
-
|
|
|
- byte [] RetBytes = new byte [] { 0, 0, 0, 0 };
|
|
|
- byte [] Temp = new byte [] { '0', '0', '0', '0' };
|
|
|
- int offset = 0;
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- // DONG
|
|
|
- byte [] DongBytes = addc.Dong.getBytes();
|
|
|
- if(DongBytes == null) return null;
|
|
|
-
|
|
|
- offset = 0;
|
|
|
- switch (DongBytes.length) {
|
|
|
- case 1: offset = 3; break;
|
|
|
- case 2: offset = 2; break;
|
|
|
- case 3: offset = 1; break;
|
|
|
- case 4: offset = 0; break;
|
|
|
- default:
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- index = 0;
|
|
|
- for (int i = offset; i < 4; i++) Temp[i] = DongBytes[index++];
|
|
|
-
|
|
|
- RetBytes[0] = (byte)((((Temp[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[0] |= (byte)((((Temp[1] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- RetBytes[1] = (byte)((((Temp[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[1] |= (byte)((((Temp[3] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- // HO
|
|
|
- byte [] HoBytes = null;
|
|
|
- if (addc.UseOrNotRentHouse == true) {
|
|
|
- String temp = addc.Ho.substring(0, (addc.Ho.length() - 2));
|
|
|
- HoBytes = temp.getBytes();
|
|
|
- }
|
|
|
- else {
|
|
|
- HoBytes = addc.Ho.getBytes();
|
|
|
- }
|
|
|
-
|
|
|
- if (HoBytes == null) return null;
|
|
|
-
|
|
|
- Temp = new byte [] { '0', '0', '0', '0' };
|
|
|
- offset = 0;
|
|
|
- switch (HoBytes.length) {
|
|
|
- case 1: offset = 3; break;
|
|
|
- case 2: offset = 2; break;
|
|
|
- case 3: offset = 1; break;
|
|
|
- case 4: offset = 0; break;
|
|
|
- default:
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- index = 0;
|
|
|
- for (int i = offset; i < 4; i++) Temp[i] = HoBytes[index++];
|
|
|
-
|
|
|
- RetBytes[2] = (byte)((((Temp[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[2] |= (byte)((((Temp[1] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- RetBytes[3] = (byte)((((Temp[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[3] |= (byte)((((Temp[3] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- return RetBytes;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return null;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[getDongHo_BCD] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * SiteCode 를 String 으로 가져온다.
|
|
|
- *
|
|
|
- * @return (String) SiteCode
|
|
|
- */
|
|
|
- private String getSiteCode_String() {
|
|
|
- String[] getData = null;
|
|
|
- String strSiteCode = null;
|
|
|
-
|
|
|
- WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
- getData = devset.GetSettingData("site_code");
|
|
|
- devset.closeDB();
|
|
|
-
|
|
|
- if ((getData != null) && getData.length > 1) {
|
|
|
- strSiteCode = getData[1];
|
|
|
- }
|
|
|
- return strSiteCode;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * SiteCode 를 BCD 데이터로 가져온다.
|
|
|
- *
|
|
|
- * @return (byte []) null - Error , Not null - OK
|
|
|
- */
|
|
|
- private byte [] getSiteCode_BCD() {
|
|
|
- try {
|
|
|
- String SiteCodeStr = getSiteCode_String();
|
|
|
- if (SiteCodeStr == null) return null;
|
|
|
-
|
|
|
- byte [] RetBytes = new byte [] { 0, 0, 0, 0 };
|
|
|
- byte [] SiteCodeBytes = SiteCodeStr.getBytes();
|
|
|
-
|
|
|
- if (SiteCodeBytes == null) return null;
|
|
|
- if (SiteCodeBytes.length != 8) return null;
|
|
|
-
|
|
|
- RetBytes[0] = (byte)((((SiteCodeBytes[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[0] |= (byte)((((SiteCodeBytes[1] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- RetBytes[1] = (byte)((((SiteCodeBytes[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[1] |= (byte)((((SiteCodeBytes[3] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- RetBytes[2] = (byte)((((SiteCodeBytes[4] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[2] |= (byte)((((SiteCodeBytes[5] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- RetBytes[3] = (byte)((((SiteCodeBytes[6] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
- RetBytes[3] |= (byte)((((SiteCodeBytes[7] - '0') & 0x0F) << 0) );
|
|
|
-
|
|
|
- return RetBytes;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return null;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[getSiteCode_BCD] - [Exception Error] ");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 도어락 타입을 반환한다.
|
|
|
- *
|
|
|
- * @return (int) - >=0 : 도어락 타입, <0 : 실패
|
|
|
- */
|
|
|
- private int getDoorLockType() {
|
|
|
- // 1. get DB
|
|
|
- WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
- int[] Doorinfo = devset.Get_DoorLock_Info();
|
|
|
- devset.closeDB();
|
|
|
-
|
|
|
- // 2. Check
|
|
|
- if (Doorinfo == null) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- if (Doorinfo.length < 2) {
|
|
|
- return -2;
|
|
|
- }
|
|
|
-
|
|
|
- if (Doorinfo[0] == 0) {
|
|
|
- return -3;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. return
|
|
|
- switch (Doorinfo[1]) {
|
|
|
- case WallpadDeviceSet.DOORLOCK_TYPE_RF:
|
|
|
- case WallpadDeviceSet.DOORLOCK_TYPE_NORMAL:
|
|
|
- case WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT:
|
|
|
- return Doorinfo[1];
|
|
|
- default:
|
|
|
- return -4;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 무선 도어락 문열림 대기모드 사용여부
|
|
|
- *
|
|
|
- * @return (int) - >0 : 무선 도어락 문열림 대기모드 사용, <0 : 실패 또는 미사용
|
|
|
- */
|
|
|
- private int getDoorLockOpenDelayUse() {
|
|
|
- // 1. get DB
|
|
|
- WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
- int Doorinfo = devset.GetDeviceSetted("무선도어락문열림대기모드");
|
|
|
- devset.closeDB();
|
|
|
-
|
|
|
- // 2. Check
|
|
|
- if (Doorinfo == WallpadDeviceSet.DEV_DATA_ENABLE) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else if (Doorinfo == WallpadDeviceSet.DEV_DATA_DISABLE) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- else if (Doorinfo == WallpadDeviceSet.DEV_DATA_NONE) {
|
|
|
- return -2;
|
|
|
- }
|
|
|
- else {
|
|
|
- return -3;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean CompareByteArray(byte [] a, byte [] b) {
|
|
|
- if ((a == null) && (b == null)) return true;
|
|
|
- if ((a == null) || (b == null)) return false;
|
|
|
- if (a.length != b.length) return false;
|
|
|
- for(int i = 0; i < a.length; i++) { if(a[i] != b[i]) return false; }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 스마트키 인식하여 문이 열릴 경우,<br>
|
|
|
- * 현관카메라에서 3초간 전원이 유지되도록 한다.
|
|
|
- * @param devioctr (WallPadInterface)
|
|
|
- */
|
|
|
- private void TurnOnDcamPower(final WallPadInterface devioctr) {
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Start");
|
|
|
-
|
|
|
- String topActivityName = getTopActivity();
|
|
|
- if(topActivityName!=null)
|
|
|
- {
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] getTopActivity : " + topActivityName);
|
|
|
-
|
|
|
- if (topActivityName.equals(strWallPadCallPakageName) || getCallAppRunningStatus()) {
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Now WallPadCall ON");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (PowerOnTimer != null) PowerOnTimer.cancel();
|
|
|
-
|
|
|
- CallAppEnable = false; // 문열림 동작 중에는 WallpadCall이 실행되지 않도록 false
|
|
|
-
|
|
|
- // 현관카메라 조명 3초동안 점등 유지한 후, 다시 소등
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Camera Power ON !!!");
|
|
|
- int[] camType = {};
|
|
|
- try {
|
|
|
- WallpadDeviceSet wds = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
- camType = wds.Get_RFDoorCAM_Info();
|
|
|
- wds.closeDB();
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- } catch (Exception e) {
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- if (camType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
|
|
|
- // 여기서 제어하면 안되고
|
|
|
- // 플래그만 세워야 됨
|
|
|
- // 실제 패킷 전송은 폴링구조 안에서 해야함
|
|
|
- /*Send_SetLedMode( (byte)0x01 ); // LED ON*/
|
|
|
- driverInterOpAPI.SmartIotDCam_CtrLed(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|
|
|
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I)
|
|
|
- {
|
|
|
- driverInterOpAPI.IGW_SetLedOnOff(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- devioctr.cameraPowerControll(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- PowerOnTimer = new CountDownTimer(2 * 1000, 1000) {
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] PowerOnTimer Start");
|
|
|
- if (getTopActivity().equals(strWallPadCallPakageName) || getCallAppRunningStatus()) {
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Now WallPadCall ON");
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Do Not TURN LED OFF !!!");
|
|
|
- }
|
|
|
- else {
|
|
|
- WallpadDeviceSet wds = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
- int[] camTypes = wds.Get_RFDoorCAM_Info();
|
|
|
- wds.closeDB();
|
|
|
-
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] Camera Power OFF !!!");
|
|
|
- if (camTypes[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
|
|
|
- int ret = driverInterOpAPI.SmartIotDCam_CtrLed(false);
|
|
|
- if (ret < 0) {
|
|
|
- Log.w(TAG, "[TurnOnDcamPower] Camera Off Timer ERROR !!!");
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|
|
|
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
|
|
|
- driverInterOpAPI.IGW_SetLedOnOff(false);
|
|
|
- }
|
|
|
- else {
|
|
|
- devioctr.cameraPowerControll(false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- CallAppEnable = true; // 현관카메라 파워 off시, WallpadCall 호출 가능
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] PowerOnTimer END");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTick(long arg0) {
|
|
|
- }
|
|
|
- };
|
|
|
- PowerOnTimer.cancel();
|
|
|
- PowerOnTimer.start();
|
|
|
-
|
|
|
- Log.d(TAG, "[TurnOnDcamPower] END");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 최 상위 activity 가져오기
|
|
|
- */
|
|
|
- private String getTopActivity() {
|
|
|
- try {
|
|
|
- ActivityManager mActivityManager = (ActivityManager)ServiceMain.svcContext.getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
- List<RunningTaskInfo> mTaskInfo = null;
|
|
|
- if (mActivityManager != null) {
|
|
|
- mTaskInfo = mActivityManager.getRunningTasks(5);
|
|
|
- }
|
|
|
- if(mTaskInfo!=null)
|
|
|
- {
|
|
|
- ComponentName mComponentName = mTaskInfo.get(0).topActivity;
|
|
|
- return mComponentName.getPackageName();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return null;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[Exception] getTopActivity()");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean getCallAppRunningStatus() {
|
|
|
- boolean bRunning = false;
|
|
|
-
|
|
|
- try {
|
|
|
- WallpadStatusData DBMGR = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
- bRunning = DBMGR.GetCallAPKStatusRunning();
|
|
|
- DBMGR.closeDB();
|
|
|
-
|
|
|
- Log.d(TAG, "[getCallAppRunningStatus] - CALL Running : " + bRunning);
|
|
|
- return bRunning;
|
|
|
- } catch (RuntimeException re) {
|
|
|
- LogUtil.errorLogInfo("", TAG, re);
|
|
|
- return false;
|
|
|
- } catch (Exception e) {
|
|
|
- Log.d(TAG, "[Exception] getCallAppRunningStatus()");
|
|
|
- LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+/*
|
|
|
+ * Copyright (C) 2014 Android WallPad Project
|
|
|
+ *
|
|
|
+ * FileName : SmartKeyRfDoor_Controller.java
|
|
|
+ * Project : Android WallPad Project
|
|
|
+ * Company : HDC I-CONTROLS ( www.icontrols.co.kr )
|
|
|
+ * Author : Kang Sang Ho , lairu@icontrols.co.kr
|
|
|
+ */
|
|
|
+
|
|
|
+package com.artncore.wallpaddevservice.driver;
|
|
|
+
|
|
|
+import java.security.SecureRandom;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.GregorianCalendar;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
+import kr.co.icontrols.iencryptor.aes128.AES_128;
|
|
|
+import kr.co.icontrols.wallpadsupport.Version;
|
|
|
+import kr.co.icontrols.wallpadsupport.WpadSound;
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.ActivityManager;
|
|
|
+import android.app.ActivityManager.RunningTaskInfo;
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
+import android.content.ComponentName;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
+import android.os.CountDownTimer;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.widget.Toast;
|
|
|
+
|
|
|
+import com.artncore.WallPadDataMgr.WallpadAccessData;
|
|
|
+import com.artncore.WallPadDataMgr.WallpadDeviceSet;
|
|
|
+import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
|
|
|
+import com.artncore.WallPadDataMgr.WallpadStatusData;
|
|
|
+import com.artncore.WallPadDataMgr.wallpaddbmgr;
|
|
|
+import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
|
|
|
+import com.artncore.commons.APIErrorCode;
|
|
|
+import com.artncore.commons.define;
|
|
|
+import com.artncore.devicectr.WallPadInterface;
|
|
|
+import com.util.LogUtil;
|
|
|
+import com.artncore.wallpaddevservice.ServiceMain;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 스마트키 RF 현관카메라의 드라이버 모듈이다.
|
|
|
+ */
|
|
|
+@SuppressLint("HandlerLeak")
|
|
|
+public class SmartKeyRfDoor_Controller extends DeviceManager {
|
|
|
+ private final static String TAG = "SmartKeyRfDoor_DRV";
|
|
|
+
|
|
|
+ private final byte DEVICE_ADDRESS = (byte) 0xA2;
|
|
|
+
|
|
|
+ private final byte MAX_SMARTKEY_COUNT = (byte) 5;
|
|
|
+
|
|
|
+ /** RSSI 동기화 시간 (1시간) */
|
|
|
+ //private final long RSSI_SYNC_TICK = (long)(60 * TIME_MINUTE);
|
|
|
+ private final long RSSI_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
+ /** LED 모드 동기화 시간 (5분) */
|
|
|
+ //private final long LED_SYNC_TICK = (long)(5 * TIME_MINUTE);
|
|
|
+ private final long LED_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
+ /** 카메라 모드 동기화 시간 (5분) */
|
|
|
+ //private final long CAM_SYNC_TICK = (long)(5 * TIME_MINUTE);
|
|
|
+ private final long CAM_SYNC_TICK = (long)(10 * TIME_SEC);
|
|
|
+ /** 시간정보 동기화 시간 (1시간) */
|
|
|
+ private final long TIME_SYNC_TICK = (long) TIME_MINUTE;
|
|
|
+
|
|
|
+ private boolean firstSensor = true;
|
|
|
+
|
|
|
+ /** 도어락 문열림 대기모드 설정 시간*/
|
|
|
+ private final byte DLOCK_STANDBYMODE_SEC = (byte) 5;
|
|
|
+
|
|
|
+ /** 등록후 대기시간 (초) */
|
|
|
+ private final long REGISTERPAUSE_TIMEOUT_TICK = (long)(5 * TIME_SEC);
|
|
|
+
|
|
|
+ /** 등록모드 시작 */
|
|
|
+ public final static byte STATUS_REGMODE_START = (byte) 0x00;
|
|
|
+ /** 등록완료 */
|
|
|
+ public final static byte STATUS_REGMODE_KEY_COMPLETE = (byte) 0x10;
|
|
|
+ /** 이미 등록된 키 */
|
|
|
+ public final static byte STATUS_REGMODE_KEY_ALREADY = (byte) 0x20;
|
|
|
+ /** 무선 통신실패 */
|
|
|
+ public final static byte STATUS_REGMODE_ER_WIRELESSCOMMFAIL = (byte) 0x30;
|
|
|
+ /** DB 저장 실패 */
|
|
|
+ public final static byte STATUS_REGMODE_ER_DBWRITE = (byte) 0x40;
|
|
|
+ /** 등록모드 종료 */
|
|
|
+ public final static byte STATUS_REGMODE_END = (byte) 0xA0;
|
|
|
+ /** 등록할 공간 없음 */
|
|
|
+ public final static byte STATUS_REGMODE_FULL = (byte) 0xB0;
|
|
|
+
|
|
|
+ private static byte CheckSmartKeyNo = 0x00;
|
|
|
+ public static byte GetCheckSmartKeyNo() { return CheckSmartKeyNo; }
|
|
|
+ private static String CheckSmartKeySn = null;
|
|
|
+ public static String GetCheckSmartKeySn() { return CheckSmartKeySn; }
|
|
|
+
|
|
|
+ /** 도어락 타입 - WallpadDeviceSet.DOORLOCK_TYPE_NORMAL or WallpadDeviceSet.DOORLOCK_TYPE_RF*/
|
|
|
+ private int mDoorLockType = WallpadDeviceSet.DOORLOCK_TYPE_NORMAL;
|
|
|
+
|
|
|
+ private int mModelType = Version.getModelType();
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////////
|
|
|
+ // 무선도어락 연동
|
|
|
+ /////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ /** 문열림 대기모드 상태 true:사용, false:사용하지 않음 */
|
|
|
+ private boolean mDoorOpenDelay = false;
|
|
|
+
|
|
|
+ /** 자체 문열림 모드 상태 true:허용, false:비허용 */
|
|
|
+ private boolean mDoorStdOpenMode = false;
|
|
|
+
|
|
|
+ /** 현관카메라 전원ON을 위한 타이머*/
|
|
|
+ private CountDownTimer PowerOnTimer = null;
|
|
|
+ /** WallpadCall 패키지 명*/
|
|
|
+ private static final String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
|
|
|
+
|
|
|
+
|
|
|
+ /** WallpadCall 호출 가능 여부 true:허용, false:비허용
|
|
|
+ * 초인종 눌림 -> WallpadCall 실행 가능하도록 초기 설정
|
|
|
+ * */
|
|
|
+ private boolean CallAppEnable = true;
|
|
|
+ /**
|
|
|
+ * 자체 문열림 모드 상태
|
|
|
+ * @return (boolean) true:허용, false:비허용
|
|
|
+ */
|
|
|
+ private boolean GetDoorStdOpenMode() { return mDoorStdOpenMode; }
|
|
|
+ /**
|
|
|
+ * 자체 문열림 모드를 설정한다.
|
|
|
+ *
|
|
|
+ * @param OnOff (boolean) true:허용, false:비허용
|
|
|
+ */
|
|
|
+ private void SetDoorStdOpenMode(boolean OnOff) {
|
|
|
+ mDoorStdOpenModeHandler.removeMessages(0);
|
|
|
+ mDoorStdOpenModeHandler.removeMessages(1);
|
|
|
+ if (OnOff) {
|
|
|
+ Log.i(TAG, "[SetDoorStdOpenMode] ON");
|
|
|
+ mDoorStdOpenMode = true;
|
|
|
+ mDoorStdOpenModeHandler.sendEmptyMessage(0);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.i(TAG, "[SetDoorStdOpenMode] OFF");
|
|
|
+ mDoorStdOpenMode = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Handler mDoorStdOpenModeHandler = new Handler()
|
|
|
+ {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg)
|
|
|
+ {
|
|
|
+ if (msg.what == 0) {
|
|
|
+ Log.i(TAG, "[mDoorStdOpenModeHandler] Start !!!");
|
|
|
+ mDoorStdOpenModeHandler.sendEmptyMessageDelayed(1, (long)((long)DLOCK_STANDBYMODE_SEC * (long)1000));
|
|
|
+ }
|
|
|
+ else if (msg.what == 1) {
|
|
|
+ Log.i(TAG, "[mDoorStdOpenModeHandler] TimeOut...");
|
|
|
+ mDoorStdOpenMode = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ /** 초기 기기 검색 횟수 */
|
|
|
+ private final int MAX_SEARCH_COUNT = 3;
|
|
|
+
|
|
|
+ private class InfoList {
|
|
|
+ /** 센서지원 유무(거동수상자 감지용)*/
|
|
|
+ private boolean bSensorUsage;
|
|
|
+ /** LED 제어 지원 유무*/
|
|
|
+ private boolean bLEDLightCtrlable;
|
|
|
+ /** RSSI 제어 지원 유무*/
|
|
|
+ private boolean bRSSICtrlable;
|
|
|
+ /** 카메라 제어 지원 유무*/
|
|
|
+ private boolean bCameraCtrlable;
|
|
|
+ /** PIR센서 지원 유무*/
|
|
|
+ private boolean bPIRSensorUsage;
|
|
|
+ /** 시간정보 지원 유무*/
|
|
|
+ private boolean bTimeUsage;
|
|
|
+
|
|
|
+ /** 제조사 코드 ( 0x01 : 아이콘트롤스 ) */
|
|
|
+ private byte hVendor;
|
|
|
+
|
|
|
+ /** 펌웨어 Build Date (년) */
|
|
|
+ private byte hFWVer_Year;
|
|
|
+ /** 펌웨어 Build Date (월) */
|
|
|
+ private byte hFWVer_Month;
|
|
|
+ /** 펌웨어 Build Date (일) */
|
|
|
+ private byte hFWVer_Date;
|
|
|
+ /** 펌웨어 Build Date (일련번호) */
|
|
|
+ private byte hFWVer_No;
|
|
|
+
|
|
|
+ /** 지원 프로토콜 버전 Main */
|
|
|
+ private byte hProtocolVer_Main;
|
|
|
+ /** 지원 프로토콜 버전 Sub */
|
|
|
+ private byte hProtocolVer_Sub;
|
|
|
+
|
|
|
+ private InfoList() {
|
|
|
+ bSensorUsage = false;
|
|
|
+ bLEDLightCtrlable = false;
|
|
|
+ bRSSICtrlable = false;
|
|
|
+ bCameraCtrlable = false;
|
|
|
+ bPIRSensorUsage = false;
|
|
|
+ bTimeUsage = false;
|
|
|
+
|
|
|
+ hVendor = 0x00;
|
|
|
+
|
|
|
+ hFWVer_Year = 0x00;
|
|
|
+ hFWVer_Month = 0x00;
|
|
|
+ hFWVer_Date = 0x00;
|
|
|
+ hFWVer_No = 0x00;
|
|
|
+
|
|
|
+ hProtocolVer_Main = 0x00;
|
|
|
+ hProtocolVer_Sub = 0x00;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String ToDebugString() {
|
|
|
+ String retStr =
|
|
|
+ "==========================\r\n" +
|
|
|
+ "InfoList\r\n" +
|
|
|
+ "==========================\r\n" +
|
|
|
+ "bSensorUsage : " + bSensorUsage + "\r\n" +
|
|
|
+ "bLEDLightCtrlable : " + bLEDLightCtrlable + "\r\n" +
|
|
|
+ "bRSSICtrlable : " + bRSSICtrlable + "\r\n" +
|
|
|
+ "bCameraCtrlable: " + bCameraCtrlable + "\r\n" +
|
|
|
+ "bPIRSensorUsage : " + bPIRSensorUsage + "\r\n" +
|
|
|
+ "bTimeUsage: " + bTimeUsage + "\r\n" +
|
|
|
+
|
|
|
+ "Vender : " + String.format("0x%02X", hVendor) + "\r\n" +
|
|
|
+
|
|
|
+ "FW Ver. : " + (int)(hFWVer_Year +2000) + "." + hFWVer_Month + "." + hFWVer_Date + "." + hFWVer_No + "\r\n" +
|
|
|
+ "Protocol Ver. : " + "V" + hProtocolVer_Main + "." + hProtocolVer_Sub + "\r\n" +
|
|
|
+ "==========================";
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 기본 상태 응답값 정의 */
|
|
|
+ private class StatusList {
|
|
|
+ /** 거동수상자 센서감지 : true:감지 , false:미감지 */
|
|
|
+ private boolean bSensorDetect;
|
|
|
+ /** 카메라 센서감지 : true:동작중 , false:꺼짐 */
|
|
|
+ private boolean bCameraStatus;
|
|
|
+ /** LED 상태 : true:동작중 , false:꺼짐 */
|
|
|
+ private boolean bLedStatus;
|
|
|
+ /** 카메라 Auto 상태 : true:동작중 , false:꺼짐 */
|
|
|
+ private boolean bCameraAuto;
|
|
|
+ /** LED Auto 상태 : true:동작중 , false:꺼짐 */
|
|
|
+ private boolean bLedAuto;
|
|
|
+ /** 현관벨 상태 : true:눌림 , false:평상시 */
|
|
|
+ private boolean bDoorBtnStatus;
|
|
|
+ /** 에러상태 : true:에러 , false:정상 */
|
|
|
+ private boolean bError;
|
|
|
+ /** 인식된 RF 스마트키 개수 */
|
|
|
+ private byte SmartKeyCount;
|
|
|
+
|
|
|
+ private StatusList() {
|
|
|
+ bSensorDetect = false;
|
|
|
+ bCameraStatus = false;
|
|
|
+ bLedStatus = false;
|
|
|
+ bCameraAuto = false;
|
|
|
+ bLedAuto = false;
|
|
|
+
|
|
|
+ bDoorBtnStatus = false;
|
|
|
+ bError = false;
|
|
|
+ SmartKeyCount = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String ToDebugString() {
|
|
|
+ String retStr =
|
|
|
+ "==========================\r\n" +
|
|
|
+ "StatusList\r\n" +
|
|
|
+ "==========================\r\n" +
|
|
|
+ "bSensorDetect : " + bSensorDetect + "\r\n" +
|
|
|
+ "bLedStatus : " + bLedStatus + "\r\n" +
|
|
|
+ "bCameraStatus : " + bCameraStatus + "\r\n" +
|
|
|
+ "bLedAuto : " + bLedAuto + "\r\n" +
|
|
|
+ "bCameraAuto : " + bCameraAuto + "\r\n" +
|
|
|
+ "bDoorBtnStatus : " + bDoorBtnStatus + "\r\n" +
|
|
|
+ "bError : " + bError + "\r\n" +
|
|
|
+ "SmartKeyCount : " + SmartKeyCount + "\r\n" +
|
|
|
+ "==========================";
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 거동수상자 관련 센서값 */
|
|
|
+ private class SensorValue {
|
|
|
+ /** 센서 감도 */
|
|
|
+ private byte Sensor_Sensitivity;
|
|
|
+ /** 거동수상자 판별시간 */
|
|
|
+ private byte Sensor_DetectTime;
|
|
|
+ /** LED 모드 */
|
|
|
+ private byte Sensor_LedMode;
|
|
|
+ /** 감지센서 RSSI Read */
|
|
|
+ private byte Sensor_RSSI_Read;
|
|
|
+ /** 감지센서 RSSI Write */
|
|
|
+ private byte Sensor_RSSI_Write;
|
|
|
+ /** 거동수상자 판별빈도 */
|
|
|
+ private byte Sensor_DetectRatio;
|
|
|
+ /** 카메라 모드 */
|
|
|
+ private byte Sensor_CameraMode;
|
|
|
+
|
|
|
+ private SensorValue() {
|
|
|
+ Sensor_Sensitivity = 0;
|
|
|
+ Sensor_DetectTime = 0;
|
|
|
+
|
|
|
+ Sensor_LedMode = -1;
|
|
|
+ Sensor_CameraMode = -1;
|
|
|
+
|
|
|
+ Sensor_DetectRatio = 100; // 현관카메라의 감지빈도는 기본 100%로 설정되어 있음
|
|
|
+ Sensor_RSSI_Read = -101; // 기본값 : 범위 이탈
|
|
|
+ Sensor_RSSI_Write = -101; // 기본값 : 범위 이탈
|
|
|
+ }
|
|
|
+
|
|
|
+ public String ToDebugString() {
|
|
|
+ String retStr =
|
|
|
+ "==========================\r\n" +
|
|
|
+ "SensorValue\r\n" +
|
|
|
+ "==========================\r\n" +
|
|
|
+ "Sensor_Sensitivity : " + Sensor_Sensitivity + "\r\n" +
|
|
|
+ "Sensor_DetectTime : " + Sensor_DetectTime + "\r\n" +
|
|
|
+ "Sensor_DetectRatio : " + Sensor_DetectRatio + "\r\n" +
|
|
|
+ "Sensor_RSSI_Read : " + Sensor_RSSI_Read + "\r\n" +
|
|
|
+ "Sensor_RSSI_Write : " + Sensor_RSSI_Write + "\r\n" +
|
|
|
+ "Sensor_LedMode : " + Sensor_LedMode + "\r\n" +
|
|
|
+ "Sensor_CameraMode : " + Sensor_CameraMode + "\r\n" +
|
|
|
+ "==========================";
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class EncryptionList {
|
|
|
+ private byte [] Data;
|
|
|
+ private EncryptionList() {
|
|
|
+ Data = new byte [16];
|
|
|
+ for (int i = 0; i < Data.length; i++) Data[i] = 0x00;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean Input(byte [] in, int startIdx) {
|
|
|
+ if (in == null) return false;
|
|
|
+ if ((in.length - startIdx) < 16) return false;
|
|
|
+
|
|
|
+ if (Data == null) return false;
|
|
|
+
|
|
|
+ for (int i = 0; i < Data.length; i++) Data[i] = in[startIdx + i];
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String ToDebugString(int KeyIndex) {
|
|
|
+ if (Data == null) return "null";
|
|
|
+
|
|
|
+ String retStr = "[" + KeyIndex + "] ";
|
|
|
+
|
|
|
+ for (int i = 0; i < Data.length; i++) {
|
|
|
+ retStr += String.format("%02X ", Data[i]);
|
|
|
+ }
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class KeyDataList {
|
|
|
+ private byte Count;
|
|
|
+
|
|
|
+ public EncryptionList [] Encryption;
|
|
|
+
|
|
|
+ private KeyDataList() {
|
|
|
+ Count = 0;
|
|
|
+ Encryption = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private KeyDataList(byte setcount) {
|
|
|
+ Count = 0;
|
|
|
+ Encryption = null;
|
|
|
+
|
|
|
+ SetCount(setcount);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int SetCount(byte setcount) {
|
|
|
+ if (setcount <= 0 || setcount > MAX_SMARTKEY_COUNT) return -1;
|
|
|
+
|
|
|
+ Count = setcount;
|
|
|
+ Encryption = new EncryptionList[setcount];
|
|
|
+ for (byte i = 0; i < setcount; i++) Encryption[i] = new EncryptionList();
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private byte [] getByteArray() {
|
|
|
+ if (Encryption == null) return null;
|
|
|
+
|
|
|
+ byte [] retdata = new byte [(Count * 16) + 1];
|
|
|
+ int index = 0;
|
|
|
+ retdata[index++] = Count;
|
|
|
+
|
|
|
+ for (byte dataIdx = 0; dataIdx < Count; dataIdx++) {
|
|
|
+ for (int i = 0; i < 16; i++) {
|
|
|
+ retdata[index++] = Encryption[dataIdx].Data[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return retdata;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String ToDebugString() {
|
|
|
+ String retStr =
|
|
|
+ "==========================\r\n" +
|
|
|
+ "KeyDataList\r\n" +
|
|
|
+ "==========================\r\n";
|
|
|
+
|
|
|
+ retStr += "Count : " + Count + "\r\n";
|
|
|
+
|
|
|
+ if (Count > 0) {
|
|
|
+ for(byte i = 0; i < Count; i++) retStr += Encryption[i].ToDebugString(i+1) + "\r\n";
|
|
|
+ }
|
|
|
+ retStr += "==========================\r\n";
|
|
|
+
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class GetRegisterDataList {
|
|
|
+ boolean Exit;
|
|
|
+ byte RegResult;
|
|
|
+ public EncryptionList Encryption;
|
|
|
+
|
|
|
+ private GetRegisterDataList() {
|
|
|
+ Exit = false;
|
|
|
+ RegResult = 0x00;
|
|
|
+ Encryption = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class SetRegisterDataList {
|
|
|
+ byte [] LocalCode;
|
|
|
+ byte [] SiteCode;
|
|
|
+ byte [] DongCode;
|
|
|
+ byte [] HoCode;
|
|
|
+ byte CardRegNo;
|
|
|
+
|
|
|
+ private SetRegisterDataList() {
|
|
|
+ LocalCode = new byte [] { 0x00, 0x00 };
|
|
|
+ SiteCode = new byte [] { 0x00, 0x00 };
|
|
|
+ DongCode = new byte [] { 0x00, 0x00 };
|
|
|
+ HoCode = new byte [] { 0x00, 0x00 };
|
|
|
+ CardRegNo = 0x00;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int setSiteCode(byte [] InCode) {
|
|
|
+ if (InCode == null) return -1;
|
|
|
+ if (InCode.length < 4) return -2;
|
|
|
+ if (LocalCode == null) return -3;
|
|
|
+ if (SiteCode == null) return -4;
|
|
|
+
|
|
|
+ LocalCode[0] = InCode[0];
|
|
|
+ LocalCode[1] = InCode[1];
|
|
|
+ SiteCode[0] = InCode[2];
|
|
|
+ SiteCode[1] = InCode[3];
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int setDongHoCode(byte [] InCode) {
|
|
|
+ if (InCode == null) return -1;
|
|
|
+ if (InCode.length < 4) return -2;
|
|
|
+ if (DongCode == null) return -3;
|
|
|
+ if (HoCode == null) return -4;
|
|
|
+
|
|
|
+ DongCode[0] = InCode[0];
|
|
|
+ DongCode[1] = InCode[1];
|
|
|
+ HoCode[0] = InCode[2];
|
|
|
+ HoCode[1] = InCode[3];
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int setLocalCode(byte [] InCode) {
|
|
|
+ if (InCode == null) return -1;
|
|
|
+ if (InCode.length < 2) return -2;
|
|
|
+ if (LocalCode == null) return -3;
|
|
|
+
|
|
|
+ LocalCode[0] = InCode[0];
|
|
|
+ LocalCode[1] = InCode[1];
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public byte [] getByteArray() {
|
|
|
+ if (LocalCode == null) return null;
|
|
|
+ if (SiteCode == null) return null;
|
|
|
+ if (DongCode == null) return null;
|
|
|
+ if (HoCode == null) return null;
|
|
|
+
|
|
|
+ byte [] retArray = new byte [9];
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ retArray[index++] = LocalCode[0];
|
|
|
+ retArray[index++] = LocalCode[1];
|
|
|
+ retArray[index++] = SiteCode[0];
|
|
|
+ retArray[index++] = SiteCode[1];
|
|
|
+ retArray[index++] = DongCode[0];
|
|
|
+ retArray[index++] = DongCode[1];
|
|
|
+ retArray[index++] = HoCode[0];
|
|
|
+ retArray[index++] = HoCode[1];
|
|
|
+ retArray[index++] = CardRegNo;
|
|
|
+
|
|
|
+ return retArray;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class Driver {
|
|
|
+ private PollingList Polling;
|
|
|
+
|
|
|
+ private InfoList Info;
|
|
|
+
|
|
|
+ private StatusList Status;
|
|
|
+
|
|
|
+ private SensorValue Sensor_Value;
|
|
|
+
|
|
|
+ private byte [] DongHoBCD;
|
|
|
+
|
|
|
+ private byte [] SiteCodeBCD;
|
|
|
+
|
|
|
+ private boolean RegisterInitMode;
|
|
|
+
|
|
|
+ private byte CardRegNo;
|
|
|
+
|
|
|
+ public Driver() {
|
|
|
+ Polling = new PollingList();
|
|
|
+
|
|
|
+ Info = new InfoList();
|
|
|
+
|
|
|
+ Status = new StatusList();
|
|
|
+
|
|
|
+ Sensor_Value = new SensorValue();
|
|
|
+
|
|
|
+ DongHoBCD = new byte [] { 0, 0, 0, 0 };
|
|
|
+ SiteCodeBCD = new byte [] { 0, 0, 0, 0 };
|
|
|
+
|
|
|
+ RegisterInitMode = false;
|
|
|
+
|
|
|
+ CardRegNo = 0x00;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Polling 관련 */
|
|
|
+ private class PollingList {
|
|
|
+ private final class STATUS {
|
|
|
+ /** 초기화 과정 */
|
|
|
+ public final static byte First = 0;
|
|
|
+ /** 초기화 타임아웃 */
|
|
|
+ public final static byte FirstTimeOut = 1;
|
|
|
+ /** 평상시 */
|
|
|
+ public final static byte Normal = 2;
|
|
|
+ /** 등록모드 시작 버튼 체크 */
|
|
|
+ public final static byte RegisterStartCheck = 4;
|
|
|
+ /** 등록모드 */
|
|
|
+ public final static byte Register = 5;
|
|
|
+ /** 등록후 일시정지 */
|
|
|
+ public final static byte RegisterPause = 6;
|
|
|
+ }
|
|
|
+
|
|
|
+ public byte Status;
|
|
|
+ public int SearchTryCount;
|
|
|
+ public boolean bRandomKeyGeneration;
|
|
|
+ public byte [] RandomKeyBuffer;
|
|
|
+
|
|
|
+ public long RegisterPauseTimeOutTick;
|
|
|
+
|
|
|
+ public long RssiSyncTick;
|
|
|
+ public long LedSyncTick;
|
|
|
+ public long CamSyncTick;
|
|
|
+ public long TimeSyncTick;
|
|
|
+
|
|
|
+ private PollingList() {
|
|
|
+ SetStatus(STATUS.First);
|
|
|
+ SearchTryCount = 0;
|
|
|
+
|
|
|
+ bRandomKeyGeneration = true;
|
|
|
+ RandomKeyBuffer = new byte [] { 0x00, 0x00 };
|
|
|
+ RegisterPauseTimeOutTick = 0;
|
|
|
+
|
|
|
+ RssiSyncTick = 0;
|
|
|
+ LedSyncTick = 0;
|
|
|
+ CamSyncTick = 0;
|
|
|
+ TimeSyncTick = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetStatus(byte ChangeStatus) {
|
|
|
+ switch (ChangeStatus) {
|
|
|
+ case STATUS.First:
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case STATUS.FirstTimeOut:
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case STATUS.Normal:
|
|
|
+ if ((Status == STATUS.RegisterStartCheck) || (Status == STATUS.Register) || (Status == STATUS.RegisterPause)) {
|
|
|
+ StatusChanged(STATUS_REGMODE_END);
|
|
|
+ }
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case STATUS.RegisterStartCheck:
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case STATUS.Register:
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case STATUS.RegisterPause:
|
|
|
+ RegisterPauseTimeOutTick = System.currentTimeMillis();
|
|
|
+ Status = ChangeStatus;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Driver mDriver = null;
|
|
|
+
|
|
|
+ private DriverInterOpAPI driverInterOpAPI;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 생성자
|
|
|
+ */
|
|
|
+ public SmartKeyRfDoor_Controller() {
|
|
|
+ /* 로그 초기상태 */
|
|
|
+// log_sw = true;
|
|
|
+// SerialLog = true;
|
|
|
+
|
|
|
+ /* 통신성공률 변수 초기화 */
|
|
|
+ super.CommDataGeneration(1);
|
|
|
+
|
|
|
+ /* 드라이버 내부 변수 초기화 */
|
|
|
+ mDriver = new Driver();
|
|
|
+
|
|
|
+ ismDoorOpenDelay = false;
|
|
|
+
|
|
|
+ /* 동호 가져오기 */
|
|
|
+ byte [] DongHoBCD = getDongHo_BCD();
|
|
|
+ if (DongHoBCD != null) mDriver.DongHoBCD = DongHoBCD;
|
|
|
+ Log.i(TAG, "DongHoBCD : " + ToByteString(mDriver.DongHoBCD));
|
|
|
+
|
|
|
+ /* 사이트코드 가져오기 */
|
|
|
+ byte [] SiteCodeBCD = getSiteCode_BCD();
|
|
|
+ if (SiteCodeBCD != null) mDriver.SiteCodeBCD = SiteCodeBCD;
|
|
|
+ Log.i(TAG, "SiteCodeBCD : " + ToByteString(mDriver.SiteCodeBCD));
|
|
|
+
|
|
|
+ /* 도어락 타입 가져오기 */
|
|
|
+ int getDoorLockType = getDoorLockType();
|
|
|
+ if (getDoorLockType >= 0) {
|
|
|
+ mDoorLockType = getDoorLockType;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.i(TAG, "getDoorLockType Error (ret:" + getDoorLockType + ")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_RF || mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
+ int getDoorOpenDelayUse = getDoorLockOpenDelayUse();
|
|
|
+ if (getDoorOpenDelayUse > 0) {
|
|
|
+ mDoorOpenDelay = true;
|
|
|
+ Log.i(TAG, "mDoorOpenDelay : " + mDoorOpenDelay);
|
|
|
+ } else {
|
|
|
+ WallPadInterface mWallPadInterface = new WallPadInterface();
|
|
|
+ mWallPadInterface.ctrlDoorlockOpenStandbyMode(2); // 문열림 대기 미설정
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.i(TAG, "=========================================");
|
|
|
+ Log.i(TAG, "SmartKeyRfDoor_Controller - create");
|
|
|
+ Log.i(TAG, "=========================================");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void DeviceLog(String msg) {
|
|
|
+ if (!log_sw) return;
|
|
|
+ Log.d(TAG, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * BroadcastReceiver
|
|
|
+ */
|
|
|
+ private BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver()
|
|
|
+ {
|
|
|
+ public void onReceive(Context context, Intent intent)
|
|
|
+ {
|
|
|
+ String acname = intent.getAction();
|
|
|
+
|
|
|
+ DeviceLog("Receive Notify BR [" + acname + "]");
|
|
|
+
|
|
|
+ if (mDriver.Polling.Status != Driver.PollingList.STATUS.Normal) return;
|
|
|
+
|
|
|
+ if (acname.equals(define.NOTIFY_ACNAME)) {
|
|
|
+ int kind = intent.getIntExtra("KIND", 0);
|
|
|
+ DeviceLog("Receive Notify BR " + define.NOTIFY_ACNAME + " : " + kind);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * BroadcastReceiver 용 필터를 등록한다.
|
|
|
+ *
|
|
|
+ * @return (boolean) true : 성공 , false : 실패
|
|
|
+ */
|
|
|
+ private boolean Device_BrRegistration() {
|
|
|
+ DeviceLog("Device_BrRegistration - Start");
|
|
|
+
|
|
|
+ if (mDriver == null) return false;
|
|
|
+ if (mDriver.Polling.Status != Driver.PollingList.STATUS.Normal) return false;
|
|
|
+
|
|
|
+ IntentFilter filter = new IntentFilter();
|
|
|
+
|
|
|
+ // 1. NOTIFY_ACNAME
|
|
|
+ DeviceLog("Device_BrRegistration - filter.addAction - " + define.NOTIFY_ACNAME);
|
|
|
+ filter.addAction(define.NOTIFY_ACNAME);
|
|
|
+
|
|
|
+ ServiceMain.svcContext.registerReceiver(mWallPadNotifyBR, filter);
|
|
|
+
|
|
|
+ DeviceLog("Device_BrRegistration - OK");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 로딩후 처음 폴링 시퀀스
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ protected void do_boot()
|
|
|
+ {
|
|
|
+ driverInterOpAPI = new DriverInterOpAPI(MainHandler);
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // Polling
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ /**
|
|
|
+ * do_ctr : 폴링스케쥴러
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ protected void do_ctr() {
|
|
|
+ DeviceLog("Polling ");
|
|
|
+
|
|
|
+ /* [[ First & FirstTimeOut ]]
|
|
|
+ * 초기 디바이스정보 검색 */
|
|
|
+ if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
+ // 1. TimeOut Check
|
|
|
+ if (mDriver.Polling.Status == Driver.PollingList.STATUS.First) {
|
|
|
+ if (mDriver.Polling.SearchTryCount++ > MAX_SEARCH_COUNT) {
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.FirstTimeOut);
|
|
|
+
|
|
|
+ Log.i(TAG, "--------------------------------------------------");
|
|
|
+ Log.i(TAG, "SearchDevice Fail... FirstTimeOut ");
|
|
|
+ Log.i(TAG, "--------------------------------------------------");
|
|
|
+
|
|
|
+ ServiceMain.deviceInitChecker.Remove(super.DeviceName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 기기정보 읽기
|
|
|
+ InfoList Info = Send_GetDeviceInfo();
|
|
|
+ if (Info != null) {
|
|
|
+ mDriver.Info = Info;
|
|
|
+ Log.i(TAG, "First Smart Cam Information ~~~");
|
|
|
+ Log.i(TAG, mDriver.Info.ToDebugString());
|
|
|
+
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+
|
|
|
+ ServiceMain.deviceInitChecker.Remove(super.DeviceName);
|
|
|
+
|
|
|
+ Device_BrRegistration();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* [[ Normal ]]
|
|
|
+ * 평상시 */
|
|
|
+ else if (mDriver.Polling.Status == Driver.PollingList.STATUS.Normal) {
|
|
|
+ long currentTimeMillis = 0;
|
|
|
+
|
|
|
+ if (mDriver.Info.bSensorUsage) {
|
|
|
+ if (firstSensor) {
|
|
|
+ Log.i(TAG, "First Smart Cam Send_SetSensorConfig Sending @@@@@@@");
|
|
|
+ if (Send_SetSensorConfig((byte)0xFF, (byte)0xFF) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Get Sensor Config !!!");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.i(TAG, "First Smart Cam Send_SetDetectRatio Sending @@@@@@@");
|
|
|
+ if (Send_SetDetectRatio((byte)0xFF) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Get Ratio !!!");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.i(TAG, "First Smart Cam Send_SetLedMode Sending @@@@@@@");
|
|
|
+ if (Send_SetLedMode( (byte)0xFF) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Get Led Mode !!!");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.i(TAG, "First Smart Cam Send_SetRSSIMode1 Sending @@@@@@@");
|
|
|
+ if (Send_SetRSSIMode((byte)0x01, (byte)0xFF) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Get RSSI mode !!!");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.i(TAG, "First Smart Cam Send_SetCameraMode Sending @@@@@@@");
|
|
|
+ if (Send_SetCameraMode( (byte)0xFF) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Get Camera Mode !!!");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 기본 상태 요청
|
|
|
+ StatusList Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, true);
|
|
|
+ if (Status != null) {
|
|
|
+ Send_SetStatusClr(Status);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDriver.Sensor_Value.Sensor_LedMode == (byte)0x01) {
|
|
|
+ // 최초에 LED 켜져있으면 끈다.
|
|
|
+ if (Send_SetLedMode( (byte)0x00) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam - Turn Off LED $$$");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDriver.Sensor_Value.Sensor_CameraMode == (byte)0x01) {
|
|
|
+ // 최초에 카메라 열려있으면 닫는다.
|
|
|
+ if (Send_SetCameraMode( (byte)0x00) >= 0) {
|
|
|
+ Log.i(TAG, "First Smart Cam Turn Off Camera $$$");
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ firstSensor = false;
|
|
|
+ Log.d(TAG, "@@@@@@@ First SmartCam Status @@@@@@@");
|
|
|
+ if(mDriver.Sensor_Value!=null)
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // LED 모드 설정값 확인
|
|
|
+ if (mDriver.Info.bLEDLightCtrlable) {
|
|
|
+ currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - mDriver.Polling.LedSyncTick) > LED_SYNC_TICK) {
|
|
|
+ mDriver.Polling.LedSyncTick = currentTimeMillis;
|
|
|
+
|
|
|
+ if (Send_SetSensorConfig((byte)0xFF, (byte)0xFF) >= 0) {
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Send_SetLedMode( (byte)0xFF) >= 0) {
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // RSSI 설정값 확인
|
|
|
+ if (mDriver.Info.bRSSICtrlable) {
|
|
|
+ currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - mDriver.Polling.RssiSyncTick) > RSSI_SYNC_TICK) {
|
|
|
+ mDriver.Polling.RssiSyncTick = currentTimeMillis;
|
|
|
+
|
|
|
+ if (Send_SetRSSIMode((byte)0x01, (byte)0xFF) >= 0) {
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 카메라 모드 설정값 확인
|
|
|
+ if (mDriver.Info.bCameraCtrlable) {
|
|
|
+ currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - mDriver.Polling.CamSyncTick) > CAM_SYNC_TICK) {
|
|
|
+ mDriver.Polling.CamSyncTick = currentTimeMillis;
|
|
|
+
|
|
|
+ if (Send_SetCameraMode( (byte)0xFF) >= 0) {
|
|
|
+ Sleep(150);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. RandomKey 생성여부
|
|
|
+ if (mDriver.Polling.bRandomKeyGeneration) {
|
|
|
+ mDriver.Polling.bRandomKeyGeneration = false;
|
|
|
+
|
|
|
+ SecureRandom rd = new SecureRandom();
|
|
|
+ rd.nextBytes(mDriver.Polling.RandomKeyBuffer);
|
|
|
+
|
|
|
+ Log.i(TAG, "RandomKey Generation!!! RandomKeyValue " + "1:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[0]) + ", " + "2:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[1]));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 기본 상태 요청
|
|
|
+ // 시간정보 지원 확인
|
|
|
+ StatusList Status = null;
|
|
|
+ if (mDriver.Info.bTimeUsage) {
|
|
|
+ currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - mDriver.Polling.TimeSyncTick) > TIME_SYNC_TICK) {
|
|
|
+ mDriver.Polling.TimeSyncTick = currentTimeMillis;
|
|
|
+ Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, true);
|
|
|
+ if (Status == null) return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, false);
|
|
|
+ if (Status == null) return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Status = Send_GetStatus(mDriver.Polling.RandomKeyBuffer, false);
|
|
|
+ if (Status == null) return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 3. 기본 상태에서 버튼 눌림 처리
|
|
|
+ UpdateVariables(Status);
|
|
|
+
|
|
|
+ // 4. 스마트 키값 확인
|
|
|
+ if (Status.SmartKeyCount > 0) {
|
|
|
+ mDriver.Polling.bRandomKeyGeneration = true;
|
|
|
+
|
|
|
+ // 스마트 키값 요청
|
|
|
+ KeyDataList KeyData = Send_GetSmartKey(Status.SmartKeyCount);
|
|
|
+ if (KeyData == null) return;
|
|
|
+ Log.i(TAG, KeyData.ToDebugString());
|
|
|
+
|
|
|
+ // 스마트 키값 확인
|
|
|
+ boolean bRet = Send_SetSmartKeyVerify(KeyData);
|
|
|
+ if (!bRet) return;
|
|
|
+ Log.i(TAG, "SmartKeyVerify OK!!!");
|
|
|
+
|
|
|
+ // 키값 업데이트
|
|
|
+ UpdateVariables(KeyData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* [[ RegisterStartCheck ]]
|
|
|
+ * 등록모드 시작버튼 체크 */
|
|
|
+ else if (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterStartCheck) {
|
|
|
+ int ret = Send_SetSmartKeyRegisterStart();
|
|
|
+ if (ret >= 0) {
|
|
|
+ UpdateVariables(ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* [[ Register ]]
|
|
|
+ * 등록모드 */
|
|
|
+ else if (mDriver.Polling.Status == Driver.PollingList.STATUS.Register) {
|
|
|
+ SetRegisterDataList setRegisterDataList = new SetRegisterDataList();
|
|
|
+ if (!mDriver.RegisterInitMode) {
|
|
|
+ setRegisterDataList.setSiteCode(mDriver.SiteCodeBCD);
|
|
|
+ setRegisterDataList.setDongHoCode(mDriver.DongHoBCD);
|
|
|
+
|
|
|
+ setRegisterDataList.CardRegNo = mDriver.CardRegNo;
|
|
|
+ }
|
|
|
+
|
|
|
+ GetRegisterDataList getRegisterDataList = Send_GetSmartKeyRegister(setRegisterDataList);
|
|
|
+ if (getRegisterDataList != null) {
|
|
|
+ UpdateVariables(getRegisterDataList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* [[ RegisterPause ]]
|
|
|
+ * 등록후 일시정지 */
|
|
|
+ else if (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterPause) {
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - mDriver.Polling.RegisterPauseTimeOutTick) > REGISTERPAUSE_TIMEOUT_TICK) {
|
|
|
+ Send_SetSmartKeyRegisterEnd();
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 예외처리 */
|
|
|
+ else {
|
|
|
+ mDriver = new Driver();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // Ctrl
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ /**
|
|
|
+ * NoSink 제어
|
|
|
+ *
|
|
|
+ * @param StrArg
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String NoSinkCtrl(String StrArg) {
|
|
|
+ DeviceLog("[NoSinkCtrl] Start");
|
|
|
+
|
|
|
+ // 1. 디바이스 초기화시 에러리턴
|
|
|
+ if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
+ Log.w(TAG, "[NoSinkCtrl] - Not Yet !!!");
|
|
|
+ return "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ }
|
|
|
+
|
|
|
+ CtrDevFormat ctrDevFormat = GetCtrDevParamParsing(StrArg, 5);
|
|
|
+ if (ctrDevFormat.ret != APIErrorCode.C_SUCCESS) {
|
|
|
+ Log.w(TAG, "[NoSinkCtrl] GetCtrDevParamParsing Error (ret:" + ctrDevFormat.ret + ")");
|
|
|
+ return "FAIL;" + APIErrorCode.DEFAULT_PARSING_ERR;
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // Refresh : 데이터 갱신 (No Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ if (ctrDevFormat.CmdStr!=null && ctrDevFormat.CmdStr.equals("Refresh")) {
|
|
|
+ DeviceLog("[Refresh] Enter ~~~");
|
|
|
+
|
|
|
+ return RefreshResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ return "FAIL;" + APIErrorCode.UNKNOWNCOMMAND;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * do_ctrEmm : 싱크 제어
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @SuppressLint("DefaultLocale")
|
|
|
+ protected String do_ctrEmm(DeviceCtrSHMem SHMem) {
|
|
|
+ DeviceLog("[do_ctrEmm] Start");
|
|
|
+ DeviceLog("cmd : " + SHMem.cmd);
|
|
|
+ DeviceLog("StrArg : " + SHMem.StrArg);
|
|
|
+
|
|
|
+ // 1. 디바이스 초기화시 에러리턴
|
|
|
+ if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
+ Log.w(TAG, "[do_ctrEmm] - Not Yet !!!");
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ }
|
|
|
+
|
|
|
+ CtrDevFormat ctrDevFormat = GetCtrDevParamParsing(SHMem.StrArg, 5);
|
|
|
+ if (ctrDevFormat.ret != APIErrorCode.C_SUCCESS) {
|
|
|
+ Log.w(TAG, "[do_ctrEmm] GetCtrDevParamParsing Error (ret:" + ctrDevFormat.ret + ")");
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEFAULT_PARSING_ERR;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ctrDevFormat.CmdStr!=null)
|
|
|
+ {
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetRegisterModeStart : 등록모드 시작 요청 (Sink)
|
|
|
+ //
|
|
|
+ // [0] - 초기화옵션 ( 0 : 노말 , 1 : 키 초기화 (시험용) )
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ if (ctrDevFormat.CmdStr.equals("SetRegisterModeStart")) {
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ // 1. Mode Check
|
|
|
+ if ((mDriver.Polling.Status == Driver.PollingList.STATUS.Register) || (mDriver.Polling.Status == Driver.PollingList.STATUS.RegisterPause)) {
|
|
|
+ // 이전 상태가 등록모드였다면 등록모드 종료
|
|
|
+ Log.w(TAG, "Old Mode Register - RegisterModeEnd !!!");
|
|
|
+
|
|
|
+ ret = Send_SetSmartKeyRegisterEnd();
|
|
|
+ if (ret != 1) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 등록모드 시작
|
|
|
+ ret = Send_SetSmartKeyRegisterStart();
|
|
|
+ if (ret < 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 사이트 코드 가져오기
|
|
|
+ byte [] SiteCodeBCD = getSiteCode_BCD();
|
|
|
+ if (SiteCodeBCD != null) mDriver.SiteCodeBCD = SiteCodeBCD;
|
|
|
+ Log.i(TAG, "SiteCodeBCD : " + ToByteString(mDriver.SiteCodeBCD));
|
|
|
+
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterStartCheck);
|
|
|
+
|
|
|
+ // 4. Param 적용
|
|
|
+ if (ctrDevFormat.param[0] == 0) mDriver.RegisterInitMode = false;
|
|
|
+ else mDriver.RegisterInitMode = true;
|
|
|
+
|
|
|
+ UpdateVariables(ret);
|
|
|
+
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetRegisterModeNext : 등록모드 연장 진행 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetRegisterModeNext")) {
|
|
|
+ // 1. Mode Check
|
|
|
+
|
|
|
+ // 이전 상태가 [등록후 일시정지]가 아니라면 에러
|
|
|
+ if (mDriver.Polling.Status != Driver.PollingList.STATUS.RegisterPause) {
|
|
|
+ // 이전 상태 [등록모드] 였을 경우
|
|
|
+ if (mDriver.Polling.Status == Driver.PollingList.STATUS.Register) {
|
|
|
+ //
|
|
|
+ int id = DB_GetId();
|
|
|
+ if (id <= 0) {
|
|
|
+ Log.w(TAG, "SetRegisterModeNext - DB_GetId Out Of Range #1 (id:" + id + ")");
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ mDriver.CardRegNo = (byte)id;
|
|
|
+ super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 이전 상태가 [등록후 일시정지] or [등록모드] 둘다 아님
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[SetRegisterModeNext] Old Mode 'RegisterPause' is Not !!!");
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. Next id 가져오기
|
|
|
+ if (!mDriver.RegisterInitMode) {
|
|
|
+ int id = DB_GetId();
|
|
|
+ if (id <= 0) {
|
|
|
+ Log.w(TAG, "SetRegisterModeNext - DB_GetId Out Of Range #2 (id:" + id + ")");
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ if (id == -1) super.StatusChanged(STATUS_REGMODE_FULL);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.STATUS_OUTOFRANGE;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ mDriver.CardRegNo = (byte)id;
|
|
|
+ super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // RegisterModeEnd : 등록모드 종료 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetRegisterModeEnd")) {
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ for (int ReTryCount = 0; ReTryCount < 3; ReTryCount++) {
|
|
|
+ ret = Send_SetSmartKeyRegisterEnd();
|
|
|
+ if (ret == 1) break;
|
|
|
+ }
|
|
|
+
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+
|
|
|
+ if (ret == 1) {
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetDeleteKey : 카드 삭제 알림 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetDeleteKey")) {
|
|
|
+ SetRegisterDataList setRegisterDataList = new SetRegisterDataList();
|
|
|
+ setRegisterDataList.setSiteCode(mDriver.SiteCodeBCD);
|
|
|
+ setRegisterDataList.setDongHoCode(mDriver.DongHoBCD);
|
|
|
+
|
|
|
+ byte[] TempLocalCode = new byte[2];
|
|
|
+ if (ctrDevFormat.param[0] == 1) {
|
|
|
+ //전체
|
|
|
+ TempLocalCode[0] = (byte) 0xFA;
|
|
|
+ TempLocalCode[1] = (byte) 0xFA;
|
|
|
+ }
|
|
|
+ else if (ctrDevFormat.param[0] == 0) {
|
|
|
+ //개별
|
|
|
+ TempLocalCode[0] = (byte) 0xF0;
|
|
|
+ TempLocalCode[1] = (byte) 0xF0;
|
|
|
+ setRegisterDataList.CardRegNo = ctrDevFormat.param[1];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "SetDeleteKey - ctrDevFormat.param[1] Out Of Range #1 (ctrDevFormat.param[1]:" + ctrDevFormat.param[1] + ")");
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+
|
|
|
+ setRegisterDataList.setLocalCode(TempLocalCode);
|
|
|
+ boolean ret = Send_DeleteKey(setRegisterDataList);
|
|
|
+ if (ret) {
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetSensorConfig : 센서 감도/시간 설정 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetSensorConfig")) {
|
|
|
+ //if(ctrDevFormat.param.length != 2) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
+
|
|
|
+ byte Sensivity = ctrDevFormat.param[0];
|
|
|
+ byte Time = ctrDevFormat.param[1];
|
|
|
+ Log.i(TAG, "Sensor Api data : " + Sensivity + " / " + Time);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (mDriver.Sensor_Value!=null && Send_SetSensorConfig(Sensivity, Time) >= 0) {
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDriver.Sensor_Value != null) {
|
|
|
+ return SHMem.retVal = "SUCCESS;" + mDriver.Sensor_Value.Sensor_Sensitivity + ";" + mDriver.Sensor_Value.Sensor_DetectTime;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetLEDmode : LED 모드 설정 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if(ctrDevFormat.CmdStr.equals("SetLEDmode")) {
|
|
|
+ //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
+
|
|
|
+ byte LEDmode = ctrDevFormat.param[0];
|
|
|
+ Log.i(TAG, "LED Api data : " + LEDmode);
|
|
|
+ if (LEDmode < 0 || LEDmode > 6) {
|
|
|
+ if (LEDmode == 0xFF) { }
|
|
|
+ else { return "FAIL"; }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ int ret = Send_SetLedMode(LEDmode);
|
|
|
+ Log.i(TAG, "[Sink Ctr] Led Control ret 1 : " + ret);
|
|
|
+ if (ret < 0) {
|
|
|
+ Log.i(TAG, "[Sink Ctr] Led Control ret 2 : " + ret);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ }
|
|
|
+ else if (ret == 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
+ }
|
|
|
+ else if (ret == 1) {
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else if (ret == 2) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetRSSImode : RSSI 모드 설정 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetRSSImode")) {
|
|
|
+ //if(ctrDevFormat.param.length != 2) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
+
|
|
|
+ byte RSSImode = ctrDevFormat.param[0];
|
|
|
+ byte RSSIlevel = ctrDevFormat.param[1];
|
|
|
+ Log.i(TAG, "RSSI Api mode : " + RSSImode);
|
|
|
+ Log.i(TAG, "RSSI Api level : " + RSSIlevel);
|
|
|
+
|
|
|
+ if (RSSImode < 0 || RSSImode > 2) {return "FAIL";}
|
|
|
+ if (RSSIlevel < -100 || RSSIlevel > 100) {
|
|
|
+ if (RSSIlevel == 0xFF) { }
|
|
|
+ else { return "FAIL"; }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ int ret = Send_SetRSSIMode(RSSImode, RSSIlevel);
|
|
|
+ if (ret < 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ else if (ret == 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
+ }
|
|
|
+ else if (ret == 1) {
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else if (ret == 2) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetStrangerDetectRatio : 판별 감지 빈도 설정 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetStrangerDetectRatio")) {
|
|
|
+ //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
+
|
|
|
+ byte DetectRatio = ctrDevFormat.param[0];
|
|
|
+ Log.i(TAG, "Detect Ratio Api data : " + DetectRatio);
|
|
|
+// if(DetectRatio < 0 || DetectRatio > 100)
|
|
|
+// {
|
|
|
+// if(DetectRatio == 0xFF) { }
|
|
|
+// else { return "FAIL"; }
|
|
|
+// }
|
|
|
+
|
|
|
+ try {
|
|
|
+ int ret = Send_SetDetectRatio(DetectRatio);
|
|
|
+ if (ret < 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ else if (ret == 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
+ }
|
|
|
+ else if (ret == 1) {
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else if (ret == 2) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ // SetCAMERAmode : 카메라 모드 설정 요청 (Sink)
|
|
|
+ //////////////////////////////////////////////////////////
|
|
|
+ else if (ctrDevFormat.CmdStr.equals("SetCAMERAmode")) {
|
|
|
+ //if(ctrDevFormat.param.length != 1) {return SHMem.retVal = "FAIL;" + APIErrorCode.DEVICEISNORESPONSE;}
|
|
|
+
|
|
|
+ byte CameraMode = ctrDevFormat.param[0];
|
|
|
+ Log.i(TAG, "Camera Mode Api data : " + CameraMode);
|
|
|
+ if (CameraMode < 0 || CameraMode > 3) {
|
|
|
+ if (CameraMode == 0xFF) { }
|
|
|
+ else { return "FAIL"; }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ int ret = Send_SetCameraMode(CameraMode);
|
|
|
+ if (ret < 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ else if (ret == 0) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.DEVCTRNULL;
|
|
|
+ }
|
|
|
+ else if (ret == 1) {
|
|
|
+ Log.d(TAG, mDriver.Sensor_Value.ToDebugString());
|
|
|
+
|
|
|
+ return SHMem.retVal = "SUCCESS";
|
|
|
+ }
|
|
|
+ else if (ret == 2) {
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.INVALIDPARAMETER;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return SHMem.retVal = "FAIL;" + APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return SHMem.retVal = "UNKNOWNCMD";
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // Refresh Result
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ private String RefreshResult() {
|
|
|
+ String result;
|
|
|
+
|
|
|
+ DeviceLog("RefreshResult call : ");
|
|
|
+
|
|
|
+ // 1. Check Polling Status
|
|
|
+ if ((mDriver.Polling.Status == Driver.PollingList.STATUS.First) || (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut)) {
|
|
|
+ result = "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. Make Return String Format
|
|
|
+ try {
|
|
|
+ if (mDriver == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ if (mDriver.Status == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
+ if (mDriver.Info == null) return "FAIL;"+APIErrorCode.DEVICEISNOTREADY;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * [Format]
|
|
|
+ *
|
|
|
+ * SUCCESS - (String) 성공
|
|
|
+ *
|
|
|
+ * [Status]
|
|
|
+ * bDoorBtnStatus - (boolean) 버튼 눌림 상태
|
|
|
+ * bSensorDetect - (boolean) 거동수상자 감지여부
|
|
|
+ * bLedStatus - (boolean) LED 상태
|
|
|
+ * bCameraStatus - (boolean) 카메라 상태
|
|
|
+ * bLedAuto - (boolean) LED Auto 상태
|
|
|
+ * bCameraAuto - (boolean) 카메라 Auto 상태
|
|
|
+ * bError - (boolean) 에러 상태
|
|
|
+ * SmartKeyCount - (byte) 인식된 스마트키 수
|
|
|
+ *
|
|
|
+ * [Sensor_Value]
|
|
|
+ * Sensor_Sensitivity - (byte) 센서 감도
|
|
|
+ * Sensor_DetectTime - (byte) 센서 감지시간
|
|
|
+ * Sensor_LedMode - (byte) LED 모드
|
|
|
+ * Sensor_RSSI_Read - (byte) 읽기 RSSI 세기
|
|
|
+ * Sensor_RSSI_Write - (byte) 쓰기 RSSI 세기
|
|
|
+ * Sensor_DetectRatio - (byte) 판별빈도
|
|
|
+ * Sensor_CameraMode - (byte) 카메라 모드
|
|
|
+ */
|
|
|
+
|
|
|
+ result = APIErrorCode.SUCCESS + ";";
|
|
|
+
|
|
|
+ result += mDriver.Status.bDoorBtnStatus + ";";
|
|
|
+ result += mDriver.Status.bSensorDetect + ";";
|
|
|
+ result += mDriver.Status.bLedStatus + ";";
|
|
|
+ result += mDriver.Status.bCameraStatus + ";";
|
|
|
+ result += mDriver.Status.bLedAuto + ";";
|
|
|
+ result += mDriver.Status.bCameraAuto + ";";
|
|
|
+ result += mDriver.Status.bError + ";";
|
|
|
+ result += mDriver.Status.SmartKeyCount + ";";
|
|
|
+
|
|
|
+ result += mDriver.Sensor_Value.Sensor_Sensitivity + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_DetectTime + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_LedMode + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_RSSI_Read + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_RSSI_Write + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_DetectRatio + ";";
|
|
|
+ result += mDriver.Sensor_Value.Sensor_CameraMode;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ result = "FAIL;"+APIErrorCode.EXCEPTION;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception Error] RefreshResult");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ result = "FAIL;"+APIErrorCode.EXCEPTION;
|
|
|
+ }
|
|
|
+ DeviceLog(" RefreshResult_Sample return : "+result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // Protocol Command Send Func
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 기기 정보 요청 응답.
|
|
|
+ *
|
|
|
+ * @return (InfoList) null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private InfoList Send_GetDeviceInfo() {
|
|
|
+ DeviceLog("[Send_GetDeviceInfo] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = null;
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable((byte)(DEVICE_ADDRESS), CMDList.Req.GetDeviceInfo, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+ boolean bError = false;
|
|
|
+ while (true) {
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[GetDeviceInfo_RepParsing] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Reply.length != 9) {
|
|
|
+ Log.w(TAG, "[GetDeviceInfo_RepParsing] Reply.length fail ... " + Reply.length);
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.2. Details Data Check
|
|
|
+ data = 0x00;
|
|
|
+ index = 0;
|
|
|
+
|
|
|
+ // - D1 : 기능 지원 정보#1
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte) (BIT6 | BIT7)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_GetDeviceInfo] D1:Unused Bit Set !!! " + String.format("0x%02X", Reply[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ // - D2 : 기능 지원 정보#2
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // - D3 : 제조사구분정보
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // - D4 : 펌웨어 Build Date (Year)
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // - D5 : 펌웨어 Build Date (Month)
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data > 12) || (data <= 0)) {
|
|
|
+ Log.w(TAG, "[GetDeviceInfo_RepParsing] D5 (Build Date - Month) : Out of Range !!! (data:" + data + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // - D6 : 펌웨어 Build Date (Day)
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data > 31) || (data <= 0)) {
|
|
|
+ Log.w(TAG, "[GetDeviceInfo_RepParsing] D6 (Build Date - Day) : Out of Range !!! (data:" + data + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // - D7 : 펌웨어 Build Date (Number)
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // - D8 : Protocol 버전정보 (Main)
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // - D9 : Protocol 버전정보 (Sub)
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_GetDeviceInfo] FAIL");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 5. Data return
|
|
|
+ InfoList Info = new InfoList();
|
|
|
+ index = 0;
|
|
|
+ data = 0;
|
|
|
+
|
|
|
+ // - D1 : 기능 지원 정보#1
|
|
|
+ if ((Reply[index] & BIT0) != 0x00) Info.bSensorUsage = true;
|
|
|
+ else Info.bSensorUsage = false;
|
|
|
+
|
|
|
+ if ((Reply[index] & BIT1) != 0x00) Info.bLEDLightCtrlable = true;
|
|
|
+ else Info.bLEDLightCtrlable = false;
|
|
|
+
|
|
|
+ if ((Reply[index] & BIT2) != 0x00) Info.bRSSICtrlable = true;
|
|
|
+ else Info.bRSSICtrlable = false;
|
|
|
+
|
|
|
+ if ((Reply[index] & BIT3) != 0x00) Info.bCameraCtrlable = true;
|
|
|
+ else Info.bCameraCtrlable = false;
|
|
|
+
|
|
|
+ if ((Reply[index] & BIT4) != 0x00) Info.bPIRSensorUsage = true;
|
|
|
+ else Info.bPIRSensorUsage = false;
|
|
|
+
|
|
|
+ if ((Reply[index] & BIT5) != 0x00) Info.bTimeUsage = true;
|
|
|
+ else Info.bTimeUsage = false;
|
|
|
+
|
|
|
+ index++;
|
|
|
+ // - D2 : 기능 지원 정보#2
|
|
|
+ index++;
|
|
|
+
|
|
|
+ // - D3 : 제조사 구분정보
|
|
|
+ Info.hVendor = Reply[index++];
|
|
|
+ // - D4 : 펌웨어 Build Date (Year)
|
|
|
+ Info.hFWVer_Year = Reply[index++];
|
|
|
+ // - D5 : 펌웨어 Build Date (Month)
|
|
|
+ Info.hFWVer_Month = Reply[index++];
|
|
|
+ // - D6 : 펌웨어 Build Date (Day)
|
|
|
+ Info.hFWVer_Date = Reply[index++];
|
|
|
+ // - D7 : 펌웨어 Build Date (Number)
|
|
|
+ Info.hFWVer_No = Reply[index++];
|
|
|
+ // - D8 : Protocol 버전정보 (Main)
|
|
|
+ Info.hProtocolVer_Main = Reply[index++];
|
|
|
+ // - D9 : Protocol 버전정보 (Sub)
|
|
|
+ Info.hProtocolVer_Sub = Reply[index++];
|
|
|
+
|
|
|
+ DeviceLog("[Send_GetDeviceInfo] END");
|
|
|
+ return Info;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 기본상태 요청 응답.
|
|
|
+ *
|
|
|
+ * @return (StatusList) null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private StatusList Send_GetStatus(byte[] RandomKey, boolean bSendTime) {
|
|
|
+ DeviceLog("[Send_GetStatus] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if (RandomKey == null) {
|
|
|
+ Log.w(TAG, "[Send_GetStatus] Param - RandomKey is null !!!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (RandomKey.length != 2) {
|
|
|
+ Log.w(TAG, "[Send_GetStatus] Param - RandomKey length Not Match !!! (length:" + RandomKey.length + ")");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte[] ReqData = new byte [] { RandomKey[0], RandomKey[1] };
|
|
|
+ if (bSendTime) {
|
|
|
+ byte[] TempReqData = new byte[8];
|
|
|
+ Calendar cal = new GregorianCalendar();
|
|
|
+ int index = 0;
|
|
|
+ TempReqData[index++] = RandomKey[0];
|
|
|
+ TempReqData[index++] = RandomKey[1];
|
|
|
+ TempReqData[index++] = (byte) (cal.get(Calendar.YEAR) - 2000);
|
|
|
+ TempReqData[index++] = (byte) (cal.get(Calendar.MONTH) + 1);
|
|
|
+ TempReqData[index++] = (byte) cal.get(Calendar.DAY_OF_MONTH);
|
|
|
+ TempReqData[index++] = (byte) cal.get(Calendar.HOUR_OF_DAY);
|
|
|
+ TempReqData[index++] = (byte) cal.get(Calendar.MINUTE);
|
|
|
+ TempReqData[index++] = (byte) cal.get(Calendar.SECOND);
|
|
|
+ ReqData = TempReqData;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ byte[] TempReqData = new byte [] { RandomKey[0], RandomKey[1] };
|
|
|
+ ReqData = TempReqData;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable((byte) (DEVICE_ADDRESS), CMDList.Req.GetStatus, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ boolean bError = false;
|
|
|
+ while (true) {
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[GetStatus_RepParsing] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Reply.length != 2) {
|
|
|
+ Log.w(TAG, "[GetStatus_RepParsing] Reply.length fail ... " + Reply.length);
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.2. Details Data Check
|
|
|
+ // - D1 : 현관카메라 상태
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (BIT6)) != 0x00) {
|
|
|
+ Log.w(TAG, "[GetStatus_RepParsing] D1 (Mode) : Unused Bit Set !!! " + String.format("0x%02X", data));
|
|
|
+ //bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // - D2 : 인식된 RF 스마트키 개수
|
|
|
+ data = Reply[index++];
|
|
|
+ if (!((data >= 0) && (data <= 5))) {
|
|
|
+ Log.w(TAG, "[GetStatus_RepParsing] D2 (KeyCount) : Out Of Range !!! " + String.format("0x%02X", data));
|
|
|
+ //bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_GetStatus] FAIL");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 5. Data return
|
|
|
+ StatusList Status = new StatusList();
|
|
|
+ index = 0;
|
|
|
+ data = 0;
|
|
|
+
|
|
|
+ // - D1 : 현관카메라 상태
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((byte)(data & BIT0) != 0x00) Status.bDoorBtnStatus = true;
|
|
|
+ else Status.bDoorBtnStatus = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT1) != 0x00) Status.bSensorDetect = true;
|
|
|
+ else Status.bSensorDetect = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT2) != 0x00) Status.bLedStatus = true;
|
|
|
+ else Status.bLedStatus = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT3) != 0x00) Status.bCameraStatus = true;
|
|
|
+ else Status.bCameraStatus = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT4) != 0x00) Status.bLedAuto = true;
|
|
|
+ else Status.bLedAuto = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT5) != 0x00) Status.bCameraAuto = true;
|
|
|
+ else Status.bCameraAuto = false;
|
|
|
+
|
|
|
+ if ((byte)(data & BIT7) != 0x00) Status.bError = true;
|
|
|
+ else Status.bError = false;
|
|
|
+
|
|
|
+ // - D2 : 인식된 RF 스마트키 개수
|
|
|
+ data = Reply[index++];
|
|
|
+ if (!((data >= 0) && (data <= 5))) {
|
|
|
+ // 현관카메라 버그로 인한 예외처리 요구사항
|
|
|
+ Log.w(TAG, "[GetStatus_RepParsing] Status.SmartKeyCount will be 5 ");
|
|
|
+ data = 5;
|
|
|
+ }
|
|
|
+ Status.SmartKeyCount = data;
|
|
|
+
|
|
|
+ DeviceLog("[Send_GetStatus] END");
|
|
|
+ return Status;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 기본상태값 해제 요청
|
|
|
+ *
|
|
|
+ * @return (boolean) true : 정상 , false : 실패
|
|
|
+ */
|
|
|
+ private boolean Send_SetStatusClr(StatusList ClearStatus) {
|
|
|
+ DeviceLog("[Send_SetStatusClr] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if (ClearStatus == null) {
|
|
|
+ Log.w(TAG, "[Send_SetStatusClr] Param - ClearStatus is null !!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = new byte [] { 0x00 };
|
|
|
+
|
|
|
+ if (ClearStatus.bDoorBtnStatus || firstSensor) ReqData[0] |= BIT0;
|
|
|
+ if (ClearStatus.bSensorDetect || firstSensor) ReqData[0] |= BIT1;
|
|
|
+ if (ClearStatus.bError || firstSensor) ReqData[0] |= BIT7;
|
|
|
+
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetStatusClr, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+ while (true) {
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetStatusClr] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Reply.length != 1) {
|
|
|
+ Log.w(TAG, "[Send_SetStatusClr] Reply.length fail ... " + Reply.length);
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.2. Details Data Check
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+ // - D1 : 현관카메라 상태
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte)( BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_SetStatusClr] D1 (Mode) : Unused Bit Set !!! " + String.format("0x%02X", data));
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetStatusClr] FAIL");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetStatusClr] END");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트 키값 요청/반환
|
|
|
+ *
|
|
|
+ * @param ReqSmartKeyCount - (byte) 요청할 스마트RF키 개수
|
|
|
+ *
|
|
|
+ * @return (KeyDataList) 응답받은 KayData : null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private KeyDataList Send_GetSmartKey(byte ReqSmartKeyCount) {
|
|
|
+ DeviceLog("[Send_GetSmartKey] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if ((ReqSmartKeyCount <= 0) || (ReqSmartKeyCount > MAX_SMARTKEY_COUNT)) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKey] Param - ClearStatus is null !!!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = new byte [] { ReqSmartKeyCount };
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKey, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_GetSmartKey] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ // Length Check
|
|
|
+
|
|
|
+ //Reply[0] bit7 Clear 필요 (현관카메라 버그로 인한 예외처리 요구사항)
|
|
|
+ Reply[0] = (byte) (Reply[0] & 0x7F); //7번 비트 Clear
|
|
|
+
|
|
|
+ int CalcLen = (int) ((byte)(Reply[0] * 16) + 1);
|
|
|
+ if (Reply.length != CalcLen) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKey] Reply.length fail ... (length:" + Reply.length + ", CalcLen:" + CalcLen + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ // D1 : 응답할 스마트RF키 개수
|
|
|
+ data = Reply[index++];
|
|
|
+ if (data != ReqSmartKeyCount) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKey] D1 : Req/Rep SmartKeyCount Not Match!!! ReqSmartKeyCount:" + ReqSmartKeyCount + " RepSmartKeyCount:" + data);
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_GetSmartKey] FAIL");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 5. Data return
|
|
|
+ KeyDataList keyDataList = new KeyDataList(ReqSmartKeyCount);
|
|
|
+ try {
|
|
|
+ for (byte i = 0; i < ReqSmartKeyCount; i++) {
|
|
|
+ keyDataList.Encryption[i].Input(Reply, (int)(1+(i*16)));
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Send_GetSmartKey] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ DeviceLog("[Send_GetSmartKey] END");
|
|
|
+ return keyDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트 키값 요청/반환
|
|
|
+ *
|
|
|
+ * @param ReqKeyData - (KeyDataList) 확인 요청할 스마트키 Class
|
|
|
+ *
|
|
|
+ * @return (KeyDataList) 응답받은 KayData : null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private boolean Send_SetSmartKeyVerify(KeyDataList ReqKeyData) {
|
|
|
+ DeviceLog("[Send_SetSmartKeyVerify] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if (ReqKeyData == null) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyVerify] Param - ReqKeyData is null !!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = ReqKeyData.getByteArray();
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyVerify, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetSmartKeyVerify] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply.length != 3) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyVerify] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ // D1 : 응답할 스마트RF키 개수
|
|
|
+ data = Reply[index++];
|
|
|
+ if (data != ReqKeyData.Count) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyVerify] D1 : Req/Rep SmartKeyCount Not Match!!! ReqSmartKeyCount:" + ReqKeyData.Count + " RepSmartKeyCount:" + data);
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetSmartKeyVerify] FAIL");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 5. 데이터 확인
|
|
|
+ byte[] Result = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ if (i < 4) Result[i] = (byte)((byte)(Reply[1] >> (i * 2)) & (byte)(BIT0 | BIT1)); // 0 ~ 4
|
|
|
+ else Result[i] = (byte)((byte)(Reply[2] >> 0) & (byte)(BIT0 | BIT1)); // 5
|
|
|
+ }
|
|
|
+
|
|
|
+ for (byte i = 0; i < Reply[0]; i++) {
|
|
|
+ switch (Result[i]) {
|
|
|
+ case 0x00:
|
|
|
+ Log.w(TAG, "Send_SetSmartKeyVerify - CheckVerify Error0( Index:" + i + ", data:" + String.format("0x%02X", Result[i]) + ")");
|
|
|
+ return false;
|
|
|
+
|
|
|
+ case 0x01:
|
|
|
+ // 정상
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 0x02:
|
|
|
+ // 오류
|
|
|
+ Log.w(TAG, "Send_SetSmartKeyVerify - CheckVerify Error2( Index:" + i + ", data:" + String.format("0x%02X", Result[i]) + ")");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetSmartKeyVerify] END");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 등록모드 시작 요청
|
|
|
+ *
|
|
|
+ * @return (int) 진입결과 - >=0 : 성공(0:미진입 , 1:진입) , <0 : 실패
|
|
|
+ */
|
|
|
+ private int Send_SetSmartKeyRegisterStart() {
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterStart] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = null;
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyRegisterStart, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+ boolean bError = false;
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterStart] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply.length != 1) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterStart] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ data = 0x00;
|
|
|
+ index = 0;
|
|
|
+
|
|
|
+ // D1 : 등록모드 시작 상태값
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte)(BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterStart] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterStart] FAIL");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 데이터 확인
|
|
|
+ data = 0x00;
|
|
|
+ index = 0;
|
|
|
+ // D1 : 등록모드 시작 상태값
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((byte)(data & BIT7) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterStart] D1 : Error Bit Set !!!");
|
|
|
+ return -10;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((byte)(data & BIT0) != 0x00) {
|
|
|
+ // 진입 성공
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterStart] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 진입 실패
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterStart] END");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 등록 스마트 키값 요청/응답
|
|
|
+ *
|
|
|
+ * @return (GetRegisterDataList) null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private GetRegisterDataList Send_GetSmartKeyRegister(SetRegisterDataList setRegisterData) {
|
|
|
+ DeviceLog("[Send_GetSmartKeyRegister] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if (setRegisterData == null) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKeyRegister] Param - RegisterData is null !!!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = setRegisterData.getByteArray();
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKeyRegister, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ byte RegResult = 0;
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_GetSmartKeyRegister] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply.length < 1) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKeyRegister] Reply.length fail #1... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ index = 0;
|
|
|
+
|
|
|
+ // D1 : 등록모드 상태값
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte)(BIT4 | BIT5 | BIT6 | BIT7)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKeyRegister] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((data & BIT0) != 0x00) {
|
|
|
+ if (Reply.length != (int)(1+16)) {
|
|
|
+ Log.w(TAG, "[Send_GetSmartKeyRegister] Reply.length fail #2... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ RegResult = (byte)((data >> 2) & (byte)(BIT0|BIT1));
|
|
|
+ switch (RegResult) {
|
|
|
+ case 0x00: case 0x01: case 0x02: break;
|
|
|
+ default:
|
|
|
+ Log.w(TAG, "[Send_GetSmartKeyRegister] RegResult Out Of Range !!!(RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_GetSmartKeyRegister] FAIL");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 데이터 확인
|
|
|
+ index = 0;
|
|
|
+ GetRegisterDataList getRegisterDataList = new GetRegisterDataList();
|
|
|
+
|
|
|
+ data = Reply[index++];
|
|
|
+
|
|
|
+ // D1 : BIT0 - 등록데이터 준재여부
|
|
|
+ if ((byte)(data & BIT0) != 0x00) {
|
|
|
+ getRegisterDataList.Encryption = new EncryptionList();
|
|
|
+ getRegisterDataList.Encryption.Input(Reply, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // BIT1 - 종료 여부
|
|
|
+ if ((byte)(data & BIT1) != 0x00) {
|
|
|
+ getRegisterDataList.Exit = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // BIT2 ~ BIT3 - 등록 결과
|
|
|
+ getRegisterDataList.RegResult = RegResult;
|
|
|
+
|
|
|
+ DeviceLog("[Send_GetSmartKeyRegister] END");
|
|
|
+ return getRegisterDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 등록모드 종료 요청
|
|
|
+ *
|
|
|
+ * @return (int) 진입결과 - >=0 : 성공(0:미진입 , 1:진입) , <0 : 실패
|
|
|
+ */
|
|
|
+ private int Send_SetSmartKeyRegisterEnd() {
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterEnd] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = null;
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSmartKeyRegisterEnd, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterEnd] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply.length != 1) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ // D1 : 등록모드 시작 상태값
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte)(BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterEnd] FAIL");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 데이터 확인
|
|
|
+ if ((byte)(Reply[0] & BIT7) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_SetSmartKeyRegisterEnd] D1 : Error Bit Set !!!");
|
|
|
+ return -10;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((byte)(Reply[0] & BIT0) != 0x00) {
|
|
|
+ // 종료 성공
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterEnd] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 종료 실패
|
|
|
+ DeviceLog("[Send_SetSmartKeyRegisterEnd] END");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 센서 감도/시간 설정 보내기
|
|
|
+ *
|
|
|
+ * @return (int) >0 : 성공, <0 : 실패
|
|
|
+ */
|
|
|
+ private int Send_SetSensorConfig(byte Sensivity, byte Time) {
|
|
|
+ DeviceLog("[Send_SetSensorConfig] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if ((Sensivity < 1 || Sensivity > 5)) {
|
|
|
+ if ((Sensivity == (byte)0xFF)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.e(TAG, "[SetSensorConfig] - Sensing Range ERROR : " + Sensivity);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((getInt(Time) < 1 || getInt(Time) > 250)) {
|
|
|
+ if ((Time == (byte)0xFF)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.e(TAG, "[SetSensorConfig] - Time Range ERROR :" + Time);
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = {Sensivity, Time};
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.SetSensorStatus, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetSensorConfig] Reply is null");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply != null && Reply.length != 2) {
|
|
|
+ DeviceLog("[Send_SetSensorConfig] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetSensorConfig] FAIL");
|
|
|
+ return -3;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ byte data = 0x00;
|
|
|
+
|
|
|
+ /*for(int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ Log.i(TAG, "SmartDcam Reply[" + i + "] = " + Reply[i]);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ // D1 : 센서 감도
|
|
|
+ data = Reply[0];
|
|
|
+ if (data < 1 || data > 5) {
|
|
|
+ if ((data == (byte)0xFF)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[Send_SetSensorConfig] D1 : Range Error (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // D1 정상 수신
|
|
|
+ //Log.d(TAG, "[Send_SetSensorConfig] D1 Accepted ~");
|
|
|
+ mDriver.Sensor_Value.Sensor_Sensitivity = data;
|
|
|
+ }
|
|
|
+
|
|
|
+ data = Reply[1];
|
|
|
+ if (data < 1 || data > 250) {
|
|
|
+ if ((data == (byte)0xFF)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[Send_SetSensorConfig] D2 : Range Error (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // D2 정상 수신
|
|
|
+ //Log.d(TAG, "[Send_SetSensorConfig] D2 Accepted ~");
|
|
|
+ mDriver.Sensor_Value.Sensor_DetectTime = data;
|
|
|
+ }
|
|
|
+
|
|
|
+ CompareStatus_Sensivity_DetectTime();
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetSensorConfig] END");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CompareStatus_Sensivity_DetectTime() {
|
|
|
+ if (mDriver.Sensor_Value == null) { return;}
|
|
|
+
|
|
|
+ int sensitivity = -1;
|
|
|
+ int dura = -1;
|
|
|
+
|
|
|
+ if (mDriver.Sensor_Value.Sensor_Sensitivity > 0) {
|
|
|
+ // DB 저장
|
|
|
+ try {
|
|
|
+ WallpadStatusData wsd = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
+ sensitivity = wsd.GetSmartDoorCamSensorSensitivity();
|
|
|
+
|
|
|
+ if (sensitivity != mDriver.Sensor_Value.Sensor_Sensitivity) {
|
|
|
+ wsd.SetSmartDoorSensorSensitivity(mDriver.Sensor_Value.Sensor_Sensitivity);
|
|
|
+ }
|
|
|
+ wsd.closeDB();
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDriver.Sensor_Value.Sensor_DetectTime > 0) {
|
|
|
+ // DB 저장
|
|
|
+ try {
|
|
|
+ WallpadStatusData wsd = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
+ dura = wsd.GetSmartDoorCamSensorDuration();
|
|
|
+
|
|
|
+ if (dura != mDriver.Sensor_Value.Sensor_DetectTime) {
|
|
|
+ wsd.SetSmartDoorSensorDuration(mDriver.Sensor_Value.Sensor_DetectTime);
|
|
|
+ }
|
|
|
+ wsd.closeDB();
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * LED 제어 기능이 있는 현관카메라의 LED 모드를 제어한다.
|
|
|
+ * @param mode 범위(0~6, FF)
|
|
|
+ * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
+ */
|
|
|
+ private int Send_SetLedMode(byte mode) {
|
|
|
+ DeviceLog("[Send_SetLedMode] Start");
|
|
|
+
|
|
|
+ if (mode < 0 || mode > 6) {
|
|
|
+ if (mode == (byte)0xFF) {
|
|
|
+ //Log.i(TAG, "[Send_SetLedMode] 0xFF : Get Value");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[Send_SetLedMode] mode range error");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = {mode};
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetLedMode, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetLedMode] Reply is null");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply != null && Reply.length != 2) {
|
|
|
+ DeviceLog("[Send_SetLedMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ //Log.w(TAG,"[Send_SetLedMode] bError fail");
|
|
|
+ DeviceLog("[Send_SetLedMode] FAIL");
|
|
|
+ AddDoCount(false);
|
|
|
+ return -100;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 동작 성공 여부 확인
|
|
|
+ // 스마트현관카메라 버그 : LED 제어명령에 대해 D1을 00(실패)로 무조건 응답함 -> 주석처리 : 2019.06.17
|
|
|
+ /*if(Reply[0] == 0)
|
|
|
+ {
|
|
|
+ Log.w(TAG, "[Send_SetLedMode] Device Act Fail !!!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if(Reply[0] == 1)*/
|
|
|
+ {
|
|
|
+ //Log.d(TAG, "[Send_SetLedMode] Device Act Run ~~~");
|
|
|
+
|
|
|
+ if (Reply[1] == mode || mode == (byte)0xFF) {
|
|
|
+ //Log.d(TAG, "[Send_SetLedMode] Device Act Success ~~~");
|
|
|
+ //Log.d(TAG, "[Send_SetLedMode] Device LED mode Same : " + Reply[1]);
|
|
|
+ mDriver.Sensor_Value.Sensor_LedMode = Reply[1];
|
|
|
+ StatusChanged();
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetLedMode] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Log.d(TAG, "[Send_SetLedMode] Device LED mode Diff : " + Reply[1]);
|
|
|
+ DeviceLog("[Send_SetLedMode] END");
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * RSSI 제어 기능이 있는 현관카메라의 RSSI 모드, 단계를 제어한다.
|
|
|
+ * @param mode 범위(0~2 , FF)
|
|
|
+ * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
+ */
|
|
|
+ private int Send_SetRSSIMode(byte mode, byte level) {
|
|
|
+ DeviceLog("[Send_SetRSSIMode] Start");
|
|
|
+
|
|
|
+ if (mode < (byte)0 || mode > (byte)2) {
|
|
|
+ Log.w(TAG, "[Send_SetRSSIMode] mode range error");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (level < (byte)-100 || level > (byte)100) {
|
|
|
+ if (mode == (byte)0xFF) {
|
|
|
+ DeviceLog("[Send_SetRSSIMode] 0xFF : Get Value");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DeviceLog("[Send_SetRSSIMode] level range error");
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = {mode, level};
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable(DEVICE_ADDRESS, CMDList.Req.SetRssiMode, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetRSSIMode] Reply is null");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply != null && Reply.length != 2) {
|
|
|
+ DeviceLog("[Send_SetRSSIMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ //Log.w(TAG, "[Send_SetRSSIMode] bError fail");
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetRSSIMode] FAIL");
|
|
|
+ return -100;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 동작 성공 여부 확인
|
|
|
+ if (Reply[0] == 0) {
|
|
|
+ Log.w(TAG, "[Send_SetRSSIMode] Device Act Fail !!!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (Reply[0] == 1) {
|
|
|
+ //Log.d(TAG, "[Send_SetRSSIMode] Device Act Run ~~~");
|
|
|
+
|
|
|
+ if (Reply[1] == level || level == (byte)0xFF) {
|
|
|
+ // 변경한 단계와 동일하거나, 현재상태값을 요청이 성공한 경우
|
|
|
+ //Log.d(TAG, "[Send_SetRSSIMode] Device Act Success ~~~");
|
|
|
+ //Log.d(TAG, "[Send_SetRSSIMode] Device RSSI level Same : " + Reply[1]);
|
|
|
+
|
|
|
+ if (mode == 1) {
|
|
|
+ // 읽기 모드
|
|
|
+ mDriver.Sensor_Value.Sensor_RSSI_Read = Reply[1];
|
|
|
+ }
|
|
|
+ else if (mode == 2) {
|
|
|
+ // 쓰기 모드
|
|
|
+ mDriver.Sensor_Value.Sensor_RSSI_Write = Reply[1];
|
|
|
+ }
|
|
|
+ StatusChanged();
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetRSSIMode] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Log.d(TAG, "[Send_SetRSSIMode] Device RSSI level Diff : " + Reply[1]);
|
|
|
+ DeviceLog("[Send_SetRSSIMode] END");
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 판별 감지빈도 제어 기능이 있는 현관카메라의 빈도(%)를 제어한다.
|
|
|
+ * @param level 범위(0~4, FF)
|
|
|
+ * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
+ */
|
|
|
+ private int Send_SetDetectRatio(byte level) {
|
|
|
+ DeviceLog("[Send_SetDetectRatio] Start");
|
|
|
+ //Log.i(TAG, "[Send_SetDetectRatio] Start");
|
|
|
+
|
|
|
+ if (level < (byte)0 || level > (byte)100) {
|
|
|
+ if (level == (byte)0xFF) {
|
|
|
+ //Log.i(TAG, "[Send_SetDetectRatio] 0xFF : Get Value");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[Send_SetDetectRatio] level range error");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = {level };
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetDetectRatio, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetDetectRatio] Reply is null");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply != null && Reply.length != 2) {
|
|
|
+ DeviceLog("[Send_SetDetectRatio] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetDetectRatio] FAIL");
|
|
|
+ return -100;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 동작 성공 여부 확인
|
|
|
+ if (Reply[0] == 0) {
|
|
|
+ Log.w(TAG, "[Send_SetDetectRatio] Device Act Fail !!!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (Reply[0] == 1) {
|
|
|
+ //Log.d(TAG, "[Send_SetDetectRatio] Device Act Run ~~~");
|
|
|
+ if (Reply[1] == level || level == (byte)0xFF) {
|
|
|
+ //Log.d(TAG, "[Send_SetDetectRatio] Device Act Success ~~~");
|
|
|
+ //Log.d(TAG, "[Send_SetDetectRatio] Device DetectRatio level Same : " + Reply[1]);
|
|
|
+ mDriver.Sensor_Value.Sensor_DetectRatio = Reply[1];
|
|
|
+ StatusChanged();
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetDetectRatio] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Log.d(TAG, "[Send_SetDetectRatio] Device DetectRatio level Diff : " + Reply[1]);.
|
|
|
+ DeviceLog("[Send_SetDetectRatio] END");
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 카메라 상태 제어 기능이 있는 현관카메라의 카메라모드를 제어한다.
|
|
|
+ * @param mode 범위(0~3, FF)
|
|
|
+ * @return (- : 에러), (0 : 실패) , (1 : 성공), (2 : 모드값 설정안됨)
|
|
|
+ */
|
|
|
+ private int Send_SetCameraMode(byte mode) {
|
|
|
+ DeviceLog("[Send_SetCameraMode] Start");
|
|
|
+
|
|
|
+ if (mode < (byte)0 || mode > (byte)3) {
|
|
|
+ if (mode == (byte)0xFF) {
|
|
|
+ //Log.i(TAG, "[Send_SetCameraMode] 0xFF : Get Value");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "[Send_SetCameraMode] mode range error");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = {mode };
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (DEVICE_ADDRESS), CMDList.Req.SetCameraMode, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_SetCameraMode] Reply is null");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply != null && Reply.length != 2) {
|
|
|
+ DeviceLog("[Send_SetCameraMode] Reply.length fail ... (length:" + Reply.length + ")");
|
|
|
+ bError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ //Log.w(TAG, "[Send_SetCameraMode] bError fail");
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_SetCameraMode] FAIL");
|
|
|
+ return -100;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+ // 동작 성공 여부 확인
|
|
|
+ if (Reply[0] == (byte)0) {
|
|
|
+ Log.w(TAG, "[Send_SetCameraMode] Device Act Fail !!!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (Reply[0] == (byte)1) {
|
|
|
+ //Log.d(TAG, "[Send_SetCameraMode] Device Act Run ~~~");
|
|
|
+
|
|
|
+ if (Reply[1] == mode || mode == (byte)0xFF) {
|
|
|
+ //Log.d(TAG, "[Send_SetCameraMode] Device Act Success ~~~");
|
|
|
+ //Log.d(TAG, "[Send_SetCameraMode] Device DetectRatio level Same : " + Reply[1]);
|
|
|
+ mDriver.Sensor_Value.Sensor_CameraMode = Reply[1];
|
|
|
+ StatusChanged();
|
|
|
+
|
|
|
+ DeviceLog("[Send_SetCameraMode] END");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Log.d(TAG, "[Send_SetCameraMode] Device DetectRatio level Diff : " + Reply[1]);
|
|
|
+ DeviceLog("[Send_SetCameraMode] END");
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트키 삭제
|
|
|
+ *
|
|
|
+ * @return (boolean) false - Error , true - OK
|
|
|
+ */
|
|
|
+ private boolean Send_DeleteKey(SetRegisterDataList setRegisterData) {
|
|
|
+ DeviceLog("[Send_DeleteKey] Start");
|
|
|
+
|
|
|
+ // 1. In 파라미터 확인
|
|
|
+ if (setRegisterData == null) {
|
|
|
+ Log.w(TAG, "[Send_DeleteKey] Param - RegisterData is null !!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 패킷 데이터 만들기
|
|
|
+ byte [] ReqData = setRegisterData.getByteArray();
|
|
|
+
|
|
|
+ // 3. 데이터 전송 및 응답
|
|
|
+ byte [] Reply = SendNRead_Variable( (byte)(DEVICE_ADDRESS), CMDList.Req.GetSmartKeyRegister, ReqData);
|
|
|
+
|
|
|
+ // 4. 수신데이터 파싱
|
|
|
+ boolean bError = false;
|
|
|
+ byte data = 0x00;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ byte RegResult = 0;
|
|
|
+ while (true) {
|
|
|
+ // null Check
|
|
|
+ if (Reply == null) {
|
|
|
+ DeviceLog("[Send_DeleteKey] Reply is null");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Length Check
|
|
|
+ if (Reply.length < 1) {
|
|
|
+ Log.w(TAG, "[Send_DeleteKey] Reply.length fail #1... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ index = 0;
|
|
|
+
|
|
|
+ // D1 : 등록모드 상태값
|
|
|
+ data = Reply[index++];
|
|
|
+ if ((data & (byte)(BIT4 | BIT5 | BIT6 | BIT7)) != 0x00) {
|
|
|
+ Log.w(TAG, "[Send_DeleteKey] D1 : Unused BIT SET (data:" + String.format("0x%02X", data) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((data & BIT0) != 0x00) {
|
|
|
+ if (Reply.length != (int)(1 + 16)) {
|
|
|
+ Log.w(TAG, "[Send_DeleteKey] Reply.length fail #2... (length:" + Reply.length + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ RegResult = (byte)((data >> 2) & (byte)(BIT0|BIT1));
|
|
|
+ switch (RegResult) {
|
|
|
+ case 0x00: case 0x01: case 0x02: break;
|
|
|
+ default:
|
|
|
+ Log.w(TAG, "[Send_DeleteKey] RegResult Out Of Range !!!(RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
+ bError = true; break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bError) {
|
|
|
+ AddDoCount(false);
|
|
|
+ DeviceLog("[Send_DeleteKey] FAIL");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ AddDoCount(true);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 데이터 확인
|
|
|
+ if (RegResult == 0) {
|
|
|
+ Log.i(TAG, "[Send_DeleteKey] Delete success");
|
|
|
+ DeviceLog("[Send_DeleteKey] END");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.i(TAG, "[Send_DeleteKey] Delete Fail -> RegResult:" + String.format("0x%02X", RegResult) + ")");
|
|
|
+ DeviceLog("[Send_DeleteKey] END");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // CMDList
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ /**
|
|
|
+ * 명령어 리스트
|
|
|
+ */
|
|
|
+ public static class CMDList {
|
|
|
+ public static final class Req {
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ // Board
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ /** 기기 정보 요청 */
|
|
|
+ public final static byte GetDeviceInfo = 0x01;
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ // 기본 상태 커맨드
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ /** 기본상태 요청 */
|
|
|
+ public final static byte GetStatus = 0x11;
|
|
|
+ /** 기본상태값 해제 요청 */
|
|
|
+ public final static byte SetStatusClr = 0x12;
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ // 스마트 키값 읽기 커맨드
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ /** 스마트 키값 요청 */
|
|
|
+ public final static byte GetSmartKey = 0x21;
|
|
|
+ /** 스마트 키값 확인 요청 */
|
|
|
+ public final static byte SetSmartKeyVerify = 0x22;
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ // 스마트키 등록 커맨드
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ /** 등록모드 시작 요청 */
|
|
|
+ public final static byte SetSmartKeyRegisterStart = 0x31;
|
|
|
+ /** 등록 스마트 키값 요청 */
|
|
|
+ public final static byte GetSmartKeyRegister = 0x32;
|
|
|
+ /** 등록모드 종료 요청 */
|
|
|
+ public final static byte SetSmartKeyRegisterEnd = 0x33;
|
|
|
+
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ // 센서 관련 커맨드
|
|
|
+ /////////////////////////////////////////////////////////
|
|
|
+ /** 센서상태 요청 및 제어 */
|
|
|
+ public final static byte SetSensorStatus = 0x41;
|
|
|
+ /** LED 모드 제어 */
|
|
|
+ public final static byte SetLedMode = 0x42;
|
|
|
+ /** RSSI 모드 제어 */
|
|
|
+ public final static byte SetRssiMode = 0x43;
|
|
|
+ /** 판별감도 제어 */
|
|
|
+ public final static byte SetDetectRatio = 0x44;
|
|
|
+ /** 카메라 상태 제어 */
|
|
|
+ public final static byte SetCameraMode = 0x45;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // UpdateVariables
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ /**
|
|
|
+ * [현관콜 , 에러]를 업데이트 한다.
|
|
|
+ *
|
|
|
+ * @param Status - (StatusList) 업데이트할 기본상태 응답 클래스
|
|
|
+ *
|
|
|
+ * @return (boolean) 데이터 변경여부 (true:변경 , false:미변경)
|
|
|
+ */
|
|
|
+ private boolean UpdateVariables(StatusList Status) {
|
|
|
+ DeviceLog("[UpdateVariables] (Status) Start");
|
|
|
+ if (Status == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean bChanged = false;
|
|
|
+
|
|
|
+ // 1. 현관콜
|
|
|
+ if (mDriver.Status.bDoorBtnStatus != Status.bDoorBtnStatus) {
|
|
|
+ if ((!mDriver.Status.bDoorBtnStatus) && (Status.bDoorBtnStatus)) {
|
|
|
+ if (GetDoorStdOpenMode()) {
|
|
|
+ SetDoorStdOpenMode(false);
|
|
|
+
|
|
|
+ Log.i(TAG, "*****************************");
|
|
|
+ Log.i(TAG, "* DLOCK_STANDBYOPEN(RF) *");
|
|
|
+ Log.i(TAG, "*****************************");
|
|
|
+
|
|
|
+ int ret = -1;
|
|
|
+
|
|
|
+ // 도어락 열기
|
|
|
+ if (Version.getGatewayUsage()) {
|
|
|
+ if (ServiceMain.dataBaseLoader.data.wallpadDeviceSet.Get_DoorLock_Info[1] == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
+ ret = driverInterOpAPI.FPdLock_SetDoorOpen();
|
|
|
+ Log.i(TAG, "[UpdateVariables] FPdLock_SetDoorOpen - ret : " + ret);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ret = driverInterOpAPI.IGW_SetWddrCont(true);
|
|
|
+ Log.i(TAG, "[UpdateVariables] IGW_SetWddrCont - ret : " + ret);
|
|
|
+ }
|
|
|
+ // 현산향 모델에도 무선도어락이 적용되기에
|
|
|
+ // 도어락을 터치해서 문을 열 수 없다.
|
|
|
+ WallPadInterface devioctr = new WallPadInterface();
|
|
|
+ TurnOnDcamPower(devioctr); //현재 통화 상태에서는 동작 X
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ WallPadInterface devioctr = new WallPadInterface();
|
|
|
+ devioctr.DoorLockControl(true);
|
|
|
+ TurnOnDcamPower(devioctr); // 현재 통화 상태에서는 동작 X
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ret >= 0) {
|
|
|
+ // 출입 데이터 기록 (스마트키에 의한 문열림)
|
|
|
+ WallpadAccessData WpadAccessData = new WallpadAccessData(ServiceMain.svcContext);
|
|
|
+ String sn = SmartKeyRfDoor_Controller.GetCheckSmartKeySn();
|
|
|
+ ret = WpadAccessData.Insert(WallpadAccessData.KIND.SMART_KEY, sn);
|
|
|
+ WpadAccessData.closeDB();
|
|
|
+ Log.d(TAG, "WpadAccessData.Insert(SMART_KEY) - ret:" + ret);
|
|
|
+
|
|
|
+
|
|
|
+ // 최근사용일자 갱신
|
|
|
+ WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
+ byte no = SmartKeyRfDoor_Controller.GetCheckSmartKeyNo();
|
|
|
+ ret = WpadSmartKeyRegData.UpdateLastUseDate(no);
|
|
|
+ Log.d(TAG, "WpadAccessData.UpdateLastUseDate(" + no + ") - ret:" + ret);
|
|
|
+ WpadSmartKeyRegData.closeDB();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (CallAppEnable) {
|
|
|
+ // 현관콜 시작
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+ Log.i(TAG, " DOOR CALL");
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+
|
|
|
+ setSendEventBR(WallPadInterface.BTN_DOOR);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.w(TAG, "CallAppEnable FALSE -> DoorLock Opening, Wait until Turn off the Dcam Light");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mDriver.Status.bDoorBtnStatus = Status.bDoorBtnStatus;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 거동수상자 감지
|
|
|
+ boolean sensorClear = false;
|
|
|
+ if (mDriver.Status.bSensorDetect != Status.bSensorDetect) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - Wpad sensor data : " + mDriver.Status.bSensorDetect);
|
|
|
+ Log.i(TAG, "[UpdateVariables] - new receive sensor data : " + Status.bSensorDetect);
|
|
|
+ // (월패드 : 감지안됨) && (스마트현관 : 감지됨) 인 경우에만 동작 : 거동수상자 발생
|
|
|
+ if ((!mDriver.Status.bSensorDetect) && (Status.bSensorDetect)) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - Sensor Detect Occur !!!");
|
|
|
+
|
|
|
+ Intent mIntent = new Intent();
|
|
|
+ mIntent.setAction(define.NOTIFY_ACNAME);
|
|
|
+ mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_DETECT);
|
|
|
+ ServiceMain.svcContext.sendBroadcast(mIntent);
|
|
|
+
|
|
|
+ sensorClear = true;
|
|
|
+
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+ Log.i(TAG, " STRANGE DETECT !");
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+ }
|
|
|
+ // (월패드 : 감지됨) && (스마트현관 : 감지안됨) 인 경우에만 동작 : 거동수상자 해소
|
|
|
+ else if ((mDriver.Status.bSensorDetect) && (!Status.bSensorDetect)) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - Sensor Detect Release !!!");
|
|
|
+
|
|
|
+ Intent mIntent = new Intent();
|
|
|
+ mIntent.setAction(define.NOTIFY_ACNAME);
|
|
|
+ mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_RELEASE);
|
|
|
+ ServiceMain.svcContext.sendBroadcast(mIntent);
|
|
|
+
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+ Log.i(TAG, " STRANGE RELEASE~~");
|
|
|
+ Log.i(TAG, "============================================");
|
|
|
+ }
|
|
|
+
|
|
|
+ mDriver.Status.bSensorDetect = Status.bSensorDetect;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. LED 상태
|
|
|
+ if (mDriver.Status.bLedStatus != Status.bLedStatus) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - past Wpad LedStatus data : " + mDriver.Status.bLedStatus);
|
|
|
+ Log.i(TAG, "[UpdateVariables] - new receive LedStatus data : " + Status.bLedStatus);
|
|
|
+ mDriver.Status.bLedStatus = Status.bLedStatus;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 카메라 상태
|
|
|
+ if (mDriver.Status.bCameraStatus != Status.bCameraStatus) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - past Wpad CameraStatus data : " + mDriver.Status.bCameraStatus);
|
|
|
+ Log.i(TAG, "[UpdateVariables] - new receive CameraStatus data : " + Status.bCameraStatus);
|
|
|
+ mDriver.Status.bCameraStatus = Status.bCameraStatus;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. LED Auto 상태
|
|
|
+ if (mDriver.Status.bLedAuto != Status.bLedAuto) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - past Wpad LedAuto data : " + mDriver.Status.bLedAuto);
|
|
|
+ Log.i(TAG, "[UpdateVariables] - new receive LedAuto data : " + Status.bLedAuto);
|
|
|
+ mDriver.Status.bLedAuto = Status.bLedAuto;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 카메라 Auto 상태
|
|
|
+ if (mDriver.Status.bCameraAuto != Status.bCameraAuto) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] - past Wpad CameraAuto data : " + mDriver.Status.bCameraAuto);
|
|
|
+ Log.i(TAG, "[UpdateVariables] - new receive CameraAuto data : " + Status.bCameraAuto);
|
|
|
+ mDriver.Status.bCameraAuto = Status.bCameraAuto;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 에러
|
|
|
+ if (mDriver.Status.bError != Status.bError) {
|
|
|
+ if ((!mDriver.Status.bError) && (Status.bError)) {
|
|
|
+ Log.i(TAG, "UpdateVariables - ERROR Detection !!!");
|
|
|
+ }
|
|
|
+ else if ((mDriver.Status.bError) && (!Status.bError)) {
|
|
|
+ Log.i(TAG, "UpdateVariables - ERROR Clear !!!");
|
|
|
+ }
|
|
|
+ mDriver.Status.bError = Status.bError;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 상태 클리어
|
|
|
+ if (Status.bDoorBtnStatus || Status.bError || sensorClear) {
|
|
|
+ Send_SetStatusClr(Status);
|
|
|
+ bChanged = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ DeviceLog("[UpdateVariables] (Status) End");
|
|
|
+ return bChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int[] DoorLock_OpenDelayTime = { 3, 4, 5 };
|
|
|
+ private boolean ismDoorOpenDelay = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 자동문 대기 모드 신호가 자주오는것을 방지 하기 위해 막음
|
|
|
+ */
|
|
|
+ Handler openDelayHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ ismDoorOpenDelay = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트키값이 등록된 키값인지 비교한다.
|
|
|
+ *
|
|
|
+ * @param KeyData - (KeyDataList) 인식된 스마트키값 클래스
|
|
|
+ *
|
|
|
+ * @return (boolean) 데이터 변경여부 (true:변경 , false:미변경)
|
|
|
+ */
|
|
|
+ private boolean UpdateVariables(KeyDataList KeyData) {
|
|
|
+ if (KeyData == null) return false;
|
|
|
+ if (KeyData.Count <= 0) return false;
|
|
|
+ if (KeyData.Encryption == null) return false;
|
|
|
+
|
|
|
+ boolean FindKey = false;
|
|
|
+ for (byte i=0; i < KeyData.Count; i++) {
|
|
|
+ if (KeyData.Encryption[i] != null) {
|
|
|
+ FindKey = CheckSmartKey(KeyData.Encryption[i].Data);
|
|
|
+ if (FindKey) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (FindKey) {
|
|
|
+ // 등록된키값 인식
|
|
|
+ // 도어락 문열림대기모드 시작
|
|
|
+ Log.i(TAG, "[UpdateVariables] FindKey !!!");
|
|
|
+
|
|
|
+ int ret = -1;
|
|
|
+ if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] mDoorLockType 1 : " + mDoorLockType);
|
|
|
+ ret = driverInterOpAPI.DLock_SetDoorOpenStandbyMode(true, DLOCK_STANDBYMODE_SEC);
|
|
|
+ Log.i(TAG, "[UpdateVariables] DLock_SetDoorOpenStandbyMode - ret : " + ret);
|
|
|
+ }
|
|
|
+ else if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_RF) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] mDoorLockType 2 : " + mDoorLockType);
|
|
|
+ if (mDoorOpenDelay) {
|
|
|
+ WallpadStatusData statusData = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
+ int openDelayTime = statusData.Get_DoorOpen_WaitTime();
|
|
|
+ statusData.closeDB();
|
|
|
+ Log.i(TAG, "[UpdateVariables] openDelayTime [" + openDelayTime + "]");
|
|
|
+ // 문열림 대기모드 동작 신 시나리오 (무선 도어락 터치 시 문열림)
|
|
|
+ ret = driverInterOpAPI.IGW_SetWddrOpenDelayCont(openDelayTime);
|
|
|
+ Log.i(TAG, "[UpdateVariables] IGW200D_SetWddrOpenDelayCont - ret : " + ret);
|
|
|
+
|
|
|
+ if (openDelayTime == 5) openDelayTime = DoorLock_OpenDelayTime[1];
|
|
|
+ else if (openDelayTime == 10) openDelayTime = DoorLock_OpenDelayTime[2];
|
|
|
+ Log.i(TAG, "[UpdateVariables] openDelayTime [" + openDelayTime + "]");
|
|
|
+
|
|
|
+ // DB에서 문열림 대기모드 설정값을 가져와서 JNI를 통해 신호를 전달한다.
|
|
|
+ // param nValue 0: 등록, 1: 문열림, 2: 문열림 대기 미설정, 3: 문열림 대기 3초, 4: 문열림 대기 5초, 5: 문열림 대기 10초
|
|
|
+ // 문열림 대기모드이므로, 3(3초)/4(5초)/5(10초) 중 하나를 전달한다.
|
|
|
+ if (openDelayTime >= 3 && openDelayTime <= 5) {
|
|
|
+ WallPadInterface mWallPadInterface = new WallPadInterface();
|
|
|
+ if(!ismDoorOpenDelay) {
|
|
|
+ mWallPadInterface.ctrlDoorlockOpenStandbyMode(openDelayTime);
|
|
|
+ ismDoorOpenDelay = true;
|
|
|
+ Message msg = openDelayHandler.obtainMessage();
|
|
|
+ int delay_time = openDelayTime;
|
|
|
+ if(openDelayTime == 4)
|
|
|
+ {
|
|
|
+ delay_time = 5;
|
|
|
+ }
|
|
|
+ else if(openDelayTime == 5)
|
|
|
+ {
|
|
|
+ delay_time = 10;
|
|
|
+ }
|
|
|
+ int time = delay_time*1000 * 2;
|
|
|
+ openDelayHandler.sendMessageDelayed(msg, time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 문열림 대기모드 동작 구 시나리오 (현관카메라 버튼 누를 시 문열림)
|
|
|
+ SetDoorStdOpenMode(true);
|
|
|
+ }
|
|
|
+ Log.i(TAG, "[UpdateVariables] SetDoorStdOpenMode(ON) 1");
|
|
|
+ }
|
|
|
+ else if (mDoorLockType == WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT) {
|
|
|
+ Log.i(TAG, "[UpdateVariables] mDoorLockType 3 : " + mDoorLockType);
|
|
|
+ SetDoorStdOpenMode(true);
|
|
|
+ Log.i(TAG, "[UpdateVariables] SetDoorStdOpenMode(ON) 2");
|
|
|
+ }
|
|
|
+
|
|
|
+ WallpadStatusData wallpadStatusData = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
+ boolean SmartKeyDetectionAlarm = wallpadStatusData.GetSmartKeyDetectionAlarm();
|
|
|
+ wallpadStatusData.closeDB();
|
|
|
+ if (SmartKeyDetectionAlarm) {
|
|
|
+ // DB 저장 (스마트키감지)
|
|
|
+ WallpadAccessData WpadAccessData = new WallpadAccessData(ServiceMain.svcContext);
|
|
|
+ WpadAccessData.setMaxCount(1000);
|
|
|
+ ret = WpadAccessData.Insert(WallpadAccessData.KIND.SMART_KEY_DETECTION, CheckSmartKeySn);
|
|
|
+ WpadAccessData.closeDB();
|
|
|
+ Log.d(TAG, "[UpdateVariables] WpadAccessData.Insert(SMART_KEY_DETECTION) - ret:" + ret);
|
|
|
+
|
|
|
+ // 사운드 알람
|
|
|
+ WpadSound Sound = new WpadSound(ServiceMain.svcContext);
|
|
|
+ Sound.PlayMent(WpadSound.SND.effect.EFFECT1);
|
|
|
+
|
|
|
+ // LCD 를 Normal 상태로 변경하는 기능 추가
|
|
|
+ //PowerManager pm = (PowerManager) (ServiceMain.svcContext).getSystemService(Context.POWER_SERVICE);
|
|
|
+ //pm.userActivity(1, true);
|
|
|
+
|
|
|
+ // 인텐트를 전송하여 제어 UI 혹은 스마트키등록 화면에서 flag를 세우도록 설정하기
|
|
|
+ //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
+
|
|
|
+ // Toast 메시지 표시
|
|
|
+ Toast.makeText(ServiceMain.svcContext,
|
|
|
+ "SmartKey Detection : [" + CheckSmartKeySn + "]",
|
|
|
+ Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 등록모드 시작버튼 체크
|
|
|
+ *
|
|
|
+ * @param RegisterModeStart - (int) 체크할 시작버튼 상태 (1:감지)
|
|
|
+ */
|
|
|
+ private void UpdateVariables(int RegisterModeStart) {
|
|
|
+ if (RegisterModeStart == 1) {
|
|
|
+ Log.i(TAG, "UpdateVariables - Start Button DETECTION !!!");
|
|
|
+
|
|
|
+ if (!mDriver.RegisterInitMode) {
|
|
|
+ int id = DB_GetId();
|
|
|
+ if (id <= 0) {
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ Log.w(TAG, "UpdateVariables - DB_GetId Out Of Range (id:" + id + ")");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ mDriver.CardRegNo = (byte)id;
|
|
|
+ super.StatusChanged( (byte)(STATUS_REGMODE_START | mDriver.CardRegNo));
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ super.StatusChanged(STATUS_REGMODE_START);
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Register);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @param GetRegisterData
|
|
|
+ */
|
|
|
+ private void UpdateVariables(GetRegisterDataList GetRegisterData) {
|
|
|
+ if (GetRegisterData == null) return;
|
|
|
+
|
|
|
+ // 1. 스마트RF현관카메라 에서 종료
|
|
|
+ if (GetRegisterData.Exit) {
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.Normal);
|
|
|
+ Log.i(TAG, "UpdateVariables - END Button DETECTION !!!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 에러체크
|
|
|
+ if (GetRegisterData.RegResult != 0x00) {
|
|
|
+ switch (GetRegisterData.RegResult) {
|
|
|
+ case 0x01:
|
|
|
+ // 이미 등록된 키
|
|
|
+ super.StatusChanged(STATUS_REGMODE_KEY_ALREADY);
|
|
|
+ Log.i(TAG, "UpdateVariables - STATUS_REGMODE_KEY_ALREADY");
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 0x02:
|
|
|
+ // 무선 통신 실패
|
|
|
+ super.StatusChanged(STATUS_REGMODE_ER_WIRELESSCOMMFAIL);
|
|
|
+ Log.i(TAG, "UpdateVariables - STATUS_REGMODE_ER_WIRELESSCOMMFAIL");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 등록 데이터 체크
|
|
|
+ if (!(GetRegisterData.Exit) && (GetRegisterData.RegResult == 0x00)) {
|
|
|
+ if (GetRegisterData.Encryption != null) {
|
|
|
+ if (!mDriver.RegisterInitMode) {
|
|
|
+ byte Status = 0;
|
|
|
+ int ret = SaveSmartKey(GetRegisterData.Encryption.Data);
|
|
|
+ if (ret > 0) {
|
|
|
+ Status = STATUS_REGMODE_KEY_COMPLETE;
|
|
|
+ Status |= (byte)ret;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Status = STATUS_REGMODE_ER_DBWRITE;
|
|
|
+ }
|
|
|
+ super.StatusChanged(Status);
|
|
|
+
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterPause);
|
|
|
+ Log.i(TAG, "UpdateVariables - STATUS_REGMODE_KEY_COMPLETE (Status:" + String.format("0x%02X", Status) + ")");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ super.StatusChanged(STATUS_REGMODE_KEY_COMPLETE);
|
|
|
+ mDriver.Polling.SetStatus(Driver.PollingList.STATUS.RegisterPause);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // DB
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ private int DB_GetId() {
|
|
|
+ try {
|
|
|
+ WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
+ int id = WpadSmartKeyRegData.GetEmptyId();
|
|
|
+ WpadSmartKeyRegData.closeDB();
|
|
|
+ return id;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return -1000;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[DB_GetId] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return -1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int DB_Register(byte id, byte[] Uid, byte[] SiteCode, byte[] DongHo) {
|
|
|
+ try {
|
|
|
+ WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
+ int ret = WpadSmartKeyRegData.Register((byte) id, Uid, SiteCode, DongHo);
|
|
|
+ WpadSmartKeyRegData.closeDB();
|
|
|
+ return ret;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return -1000;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[DB_Register] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return -1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String DB_isExist(byte id, byte[] Uid, byte[] SiteCode, byte[] DongHo) {
|
|
|
+ try {
|
|
|
+ WallpadSmartKeyRegData WpadSmartKeyRegData = new WallpadSmartKeyRegData(ServiceMain.svcContext);
|
|
|
+ String sn = WpadSmartKeyRegData.isExist(id, Uid, SiteCode, DongHo);
|
|
|
+ WpadSmartKeyRegData.closeDB();
|
|
|
+ return sn;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[DB_Register] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ // Util
|
|
|
+ ///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트키 데이터를 등록데이터와 비교 체크한다.
|
|
|
+ *
|
|
|
+ * @param Input - (byte []) 읽은 스마트키 데이터 배열
|
|
|
+ *
|
|
|
+ * @return (boolean) 결과 - true:있음 , false:아님
|
|
|
+ */
|
|
|
+ private boolean CheckSmartKey(byte [] Input) {
|
|
|
+ boolean DEBUG = false;
|
|
|
+
|
|
|
+ if (DEBUG) Log.d(TAG, "[CheckSmartKey] Start");
|
|
|
+ try {
|
|
|
+ // 1. 복호화 체크
|
|
|
+ byte [] Output = null;
|
|
|
+
|
|
|
+ if (ServiceMain.dataBaseLoader.data.wallpadDeviceSet.Get_BLE_SmartKey == false) {
|
|
|
+ // 기존 스마트키 사용일 경우
|
|
|
+ Output = AES_128.Encrypt(AES_128.ENCRYPTTYPE.SMARTKEY_CAM, Input);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // BLE스마트키 사용일 경우
|
|
|
+ Output = AES_128.Decrypt_ECB(AES_128.ENCRYPTTYPE.SMARTKEY_CAM, Input);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DEBUG) Log.d(TAG, "[CheckSmartKey] Input - " + super.ToByteString(Input));
|
|
|
+ if (DEBUG) Log.d(TAG, "[CheckSmartKey] Output - " + super.ToByteString(Output));
|
|
|
+ if (Output == null) {
|
|
|
+ Log.w(TAG, "[CheckSmartKey] AES_128.Encrypt - Output is null !!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 복호화 데이터 길이 체크
|
|
|
+ if (Output.length != 16) {
|
|
|
+ Log.w(TAG, "[CheckSmartKey] Output.length Not Match !!! (length:" + Output.length + ")");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. RandomKey 체크
|
|
|
+ if ((Output[0] != mDriver.Polling.RandomKeyBuffer[0]) || (Output[15] != mDriver.Polling.RandomKeyBuffer[1])) {
|
|
|
+ Log.w(TAG, "[CheckSmartKey] RandomKey Data Not Match !!!");
|
|
|
+
|
|
|
+ Log.i(TAG, "[CheckSmartKey] RandomKeyValue " + "1:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[0]) + ", " + "2:" + String.format("0x%02X", mDriver.Polling.RandomKeyBuffer[1]));
|
|
|
+ Log.i(TAG, "[CheckSmartKey] ReadRandomKeyValue " + "1:" + String.format("0x%02X", Output[0]) + ", " + "2:" + String.format("0x%02X", Output[15]));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. Uid 암호화 및 그외 데이터 분리
|
|
|
+ byte [] Uid = new byte [] { Output[1], Output[2], Output[3], Output[4] };
|
|
|
+ byte [] EncryptUid = AES_128.Encrypt(AES_128.ENCRYPTTYPE.NORMAL, Uid);
|
|
|
+ if (DEBUG) Log.d(TAG, "[CheckSmartKey] EncryptUid - " + super.ToByteString(EncryptUid));
|
|
|
+ byte [] SiteCode = new byte [] { Output[5], Output[6], Output[7], Output[8] };
|
|
|
+ byte [] DongHo = new byte [] { Output[9], Output[10], Output[11], Output[12] };
|
|
|
+ byte CardRegNo = Output[13];
|
|
|
+
|
|
|
+ // 5. 존재유무 DB 확인
|
|
|
+ String sn = DB_isExist(CardRegNo, EncryptUid, SiteCode, DongHo);
|
|
|
+ if (sn != null) {
|
|
|
+ CheckSmartKeyNo = CardRegNo;
|
|
|
+ CheckSmartKeySn = sn;
|
|
|
+ if (DEBUG) Log.d(TAG, "[CheckSmartKey] DB_isExist - true");
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else return false;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[CheckSmartKey] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int SaveSmartKey(byte [] Input) {
|
|
|
+ boolean DEBUG = true;
|
|
|
+
|
|
|
+ if (DEBUG) Log.d(TAG, "[SaveSmartKey] Start");
|
|
|
+ try {
|
|
|
+ if (Input == null) return -1;
|
|
|
+ if (Input.length != 16) return -2;
|
|
|
+
|
|
|
+ // 1. D1 : 0xCA 체크
|
|
|
+ // if(DEBUG) Log.d(TAG, "[SaveSmartKey] Step1 : D1 Check");
|
|
|
+ // if(Input[0] != (byte)0xCA)
|
|
|
+ // {
|
|
|
+ // Log.w(TAG, "[SaveSmartKey] D1 : Data Not Match !!!");
|
|
|
+ // return -11;
|
|
|
+ // }
|
|
|
+
|
|
|
+ boolean bRet = false;
|
|
|
+
|
|
|
+ // 2. SiteCode 체크
|
|
|
+ if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step2 : SiteCode Check");
|
|
|
+ byte [] SiteCode = new byte [] { Input[5], Input[6], Input[7], Input[8] };
|
|
|
+ bRet = CompareByteArray(SiteCode, mDriver.SiteCodeBCD);
|
|
|
+ if (!bRet) {
|
|
|
+ Log.w(TAG, "[SaveSmartKey] SiteCode : Data Not Match !!!");
|
|
|
+ return -12;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. DongHo 체크
|
|
|
+ if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step3 : DongHo Check");
|
|
|
+ byte [] DongHo = new byte [] { Input[9], Input[10], Input[11], Input[12] };
|
|
|
+ bRet = CompareByteArray(DongHo, mDriver.DongHoBCD);
|
|
|
+ if (!bRet) {
|
|
|
+ Log.w(TAG, "[SaveSmartKey] DongHo : Data Not Match !!!");
|
|
|
+ return -13;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. Card Reg No. 체크
|
|
|
+ if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step4 : Card Reg No Check");
|
|
|
+ byte CardRegNo = Input[13];
|
|
|
+ if (CardRegNo != mDriver.CardRegNo) {
|
|
|
+ Log.w(TAG, "[SaveSmartKey] CardRegNo : Data Not Match !!!");
|
|
|
+ return -14;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. Uid 복호화
|
|
|
+ byte [] Uid = new byte [] { Input[1], Input[2], Input[3], Input[4] };
|
|
|
+ byte [] NormalUid = AES_128.Encrypt(AES_128.ENCRYPTTYPE.NORMAL, Uid);
|
|
|
+ if (DEBUG) {
|
|
|
+ Log.d(TAG, "[SaveSmartKey] Step5 : Uid");
|
|
|
+ Log.d(TAG, " Uid - " + super.ToByteString(Uid));
|
|
|
+ Log.d(TAG, " NormalUid - " + super.ToByteString(NormalUid));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. DB 저장
|
|
|
+ int ret = DB_Register(CardRegNo, NormalUid, SiteCode, DongHo);
|
|
|
+ if (DEBUG) Log.d(TAG, "[SaveSmartKey] Step6 : DB_Register = " + ret);
|
|
|
+ if (ret >= 0) {
|
|
|
+ return (int) CardRegNo;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return -1000;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[SaveSmartKey] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return -1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
|
|
|
+ *
|
|
|
+ * @param code - (int) 송신할 keycode
|
|
|
+ * @return (int) - >=0 : 성공, <0 : 실패
|
|
|
+ */
|
|
|
+ private int setSendEventBR(int code) {
|
|
|
+ try {
|
|
|
+ KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code);
|
|
|
+ Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
|
|
|
+ intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
|
|
|
+ intent.putExtra("keycode",code);
|
|
|
+ ServiceMain.svcContext.sendBroadcast(intent);
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return -100;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[setSendEventBR] - [Exception Error] code:" + code);
|
|
|
+ Log.e(TAG, "[setSendEventBR] - " + e.toString());
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return -100;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 동호 데이터를 BCD Code 로 가져온다.
|
|
|
+ *
|
|
|
+ * @return (byte []) null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private byte [] getDongHo_BCD() {
|
|
|
+ try {
|
|
|
+ wallpaddbmgr dbmgr = new wallpaddbmgr(ServiceMain.svcContext);
|
|
|
+ AddressSet addc = dbmgr.getAddressMGR();
|
|
|
+ dbmgr.closeDB();
|
|
|
+
|
|
|
+ byte [] RetBytes = new byte [] { 0, 0, 0, 0 };
|
|
|
+ byte [] Temp = new byte [] { '0', '0', '0', '0' };
|
|
|
+ int offset = 0;
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ // DONG
|
|
|
+ byte [] DongBytes = addc.Dong.getBytes();
|
|
|
+ if(DongBytes == null) return null;
|
|
|
+
|
|
|
+ offset = 0;
|
|
|
+ switch (DongBytes.length) {
|
|
|
+ case 1: offset = 3; break;
|
|
|
+ case 2: offset = 2; break;
|
|
|
+ case 3: offset = 1; break;
|
|
|
+ case 4: offset = 0; break;
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ index = 0;
|
|
|
+ for (int i = offset; i < 4; i++) Temp[i] = DongBytes[index++];
|
|
|
+
|
|
|
+ RetBytes[0] = (byte)((((Temp[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[0] |= (byte)((((Temp[1] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ RetBytes[1] = (byte)((((Temp[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[1] |= (byte)((((Temp[3] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ // HO
|
|
|
+ byte [] HoBytes = null;
|
|
|
+ if (addc.UseOrNotRentHouse == true) {
|
|
|
+ String temp = addc.Ho.substring(0, (addc.Ho.length() - 2));
|
|
|
+ HoBytes = temp.getBytes();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ HoBytes = addc.Ho.getBytes();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (HoBytes == null) return null;
|
|
|
+
|
|
|
+ Temp = new byte [] { '0', '0', '0', '0' };
|
|
|
+ offset = 0;
|
|
|
+ switch (HoBytes.length) {
|
|
|
+ case 1: offset = 3; break;
|
|
|
+ case 2: offset = 2; break;
|
|
|
+ case 3: offset = 1; break;
|
|
|
+ case 4: offset = 0; break;
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ index = 0;
|
|
|
+ for (int i = offset; i < 4; i++) Temp[i] = HoBytes[index++];
|
|
|
+
|
|
|
+ RetBytes[2] = (byte)((((Temp[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[2] |= (byte)((((Temp[1] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ RetBytes[3] = (byte)((((Temp[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[3] |= (byte)((((Temp[3] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ return RetBytes;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[getDongHo_BCD] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SiteCode 를 String 으로 가져온다.
|
|
|
+ *
|
|
|
+ * @return (String) SiteCode
|
|
|
+ */
|
|
|
+ private String getSiteCode_String() {
|
|
|
+ String[] getData = null;
|
|
|
+ String strSiteCode = null;
|
|
|
+
|
|
|
+ WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
+ getData = devset.GetSettingData("site_code");
|
|
|
+ devset.closeDB();
|
|
|
+
|
|
|
+ if ((getData != null) && getData.length > 1) {
|
|
|
+ strSiteCode = getData[1];
|
|
|
+ }
|
|
|
+ return strSiteCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SiteCode 를 BCD 데이터로 가져온다.
|
|
|
+ *
|
|
|
+ * @return (byte []) null - Error , Not null - OK
|
|
|
+ */
|
|
|
+ private byte [] getSiteCode_BCD() {
|
|
|
+ try {
|
|
|
+ String SiteCodeStr = getSiteCode_String();
|
|
|
+ if (SiteCodeStr == null) return null;
|
|
|
+
|
|
|
+ byte [] RetBytes = new byte [] { 0, 0, 0, 0 };
|
|
|
+ byte [] SiteCodeBytes = SiteCodeStr.getBytes();
|
|
|
+
|
|
|
+ if (SiteCodeBytes == null) return null;
|
|
|
+ if (SiteCodeBytes.length != 8) return null;
|
|
|
+
|
|
|
+ RetBytes[0] = (byte)((((SiteCodeBytes[0] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[0] |= (byte)((((SiteCodeBytes[1] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ RetBytes[1] = (byte)((((SiteCodeBytes[2] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[1] |= (byte)((((SiteCodeBytes[3] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ RetBytes[2] = (byte)((((SiteCodeBytes[4] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[2] |= (byte)((((SiteCodeBytes[5] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ RetBytes[3] = (byte)((((SiteCodeBytes[6] - '0') & 0x0F) << 4) & (byte)0xF0);
|
|
|
+ RetBytes[3] |= (byte)((((SiteCodeBytes[7] - '0') & 0x0F) << 0) );
|
|
|
+
|
|
|
+ return RetBytes;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[getSiteCode_BCD] - [Exception Error] ");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 도어락 타입을 반환한다.
|
|
|
+ *
|
|
|
+ * @return (int) - >=0 : 도어락 타입, <0 : 실패
|
|
|
+ */
|
|
|
+ private int getDoorLockType() {
|
|
|
+ // 1. get DB
|
|
|
+ WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
+ int[] Doorinfo = devset.Get_DoorLock_Info();
|
|
|
+ devset.closeDB();
|
|
|
+
|
|
|
+ // 2. Check
|
|
|
+ if (Doorinfo == null) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Doorinfo.length < 2) {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Doorinfo[0] == 0) {
|
|
|
+ return -3;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. return
|
|
|
+ switch (Doorinfo[1]) {
|
|
|
+ case WallpadDeviceSet.DOORLOCK_TYPE_RF:
|
|
|
+ case WallpadDeviceSet.DOORLOCK_TYPE_NORMAL:
|
|
|
+ case WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT:
|
|
|
+ return Doorinfo[1];
|
|
|
+ default:
|
|
|
+ return -4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 무선 도어락 문열림 대기모드 사용여부
|
|
|
+ *
|
|
|
+ * @return (int) - >0 : 무선 도어락 문열림 대기모드 사용, <0 : 실패 또는 미사용
|
|
|
+ */
|
|
|
+ private int getDoorLockOpenDelayUse() {
|
|
|
+ // 1. get DB
|
|
|
+ WallpadDeviceSet devset = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
+ int Doorinfo = devset.GetDeviceSetted("무선도어락문열림대기모드");
|
|
|
+ devset.closeDB();
|
|
|
+
|
|
|
+ // 2. Check
|
|
|
+ if (Doorinfo == WallpadDeviceSet.DEV_DATA_ENABLE) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else if (Doorinfo == WallpadDeviceSet.DEV_DATA_DISABLE) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else if (Doorinfo == WallpadDeviceSet.DEV_DATA_NONE) {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return -3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean CompareByteArray(byte [] a, byte [] b) {
|
|
|
+ if ((a == null) && (b == null)) return true;
|
|
|
+ if ((a == null) || (b == null)) return false;
|
|
|
+ if (a.length != b.length) return false;
|
|
|
+ for(int i = 0; i < a.length; i++) { if(a[i] != b[i]) return false; }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 스마트키 인식하여 문이 열릴 경우,<br>
|
|
|
+ * 현관카메라에서 3초간 전원이 유지되도록 한다.
|
|
|
+ * @param devioctr (WallPadInterface)
|
|
|
+ */
|
|
|
+ private void TurnOnDcamPower(final WallPadInterface devioctr) {
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Start");
|
|
|
+
|
|
|
+ String topActivityName = getTopActivity();
|
|
|
+ if(topActivityName!=null)
|
|
|
+ {
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] getTopActivity : " + topActivityName);
|
|
|
+
|
|
|
+ if (topActivityName.equals(strWallPadCallPakageName) || getCallAppRunningStatus()) {
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Now WallPadCall ON");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (PowerOnTimer != null) PowerOnTimer.cancel();
|
|
|
+
|
|
|
+ CallAppEnable = false; // 문열림 동작 중에는 WallpadCall이 실행되지 않도록 false
|
|
|
+
|
|
|
+ // 현관카메라 조명 3초동안 점등 유지한 후, 다시 소등
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Camera Power ON !!!");
|
|
|
+ int[] camType = {};
|
|
|
+ try {
|
|
|
+ WallpadDeviceSet wds = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
+ camType = wds.Get_RFDoorCAM_Info();
|
|
|
+ wds.closeDB();
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
|
|
|
+ // 여기서 제어하면 안되고
|
|
|
+ // 플래그만 세워야 됨
|
|
|
+ // 실제 패킷 전송은 폴링구조 안에서 해야함
|
|
|
+ /*Send_SetLedMode( (byte)0x01 ); // LED ON*/
|
|
|
+ driverInterOpAPI.SmartIotDCam_CtrLed(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|
|
|
+ || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|
|
|
+ || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF)
|
|
|
+ {
|
|
|
+ driverInterOpAPI.IGW_SetLedOnOff(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ devioctr.cameraPowerControll(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PowerOnTimer = new CountDownTimer(2 * 1000, 1000) {
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] PowerOnTimer Start");
|
|
|
+ if (getTopActivity().equals(strWallPadCallPakageName) || getCallAppRunningStatus()) {
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Now WallPadCall ON");
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Do Not TURN LED OFF !!!");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ WallpadDeviceSet wds = new WallpadDeviceSet(ServiceMain.svcContext);
|
|
|
+ int[] camTypes = wds.Get_RFDoorCAM_Info();
|
|
|
+ wds.closeDB();
|
|
|
+
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] Camera Power OFF !!!");
|
|
|
+ if (camTypes[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
|
|
|
+ int ret = driverInterOpAPI.SmartIotDCam_CtrLed(false);
|
|
|
+ if (ret < 0) {
|
|
|
+ Log.w(TAG, "[TurnOnDcamPower] Camera Off Timer ERROR !!!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|
|
|
+ || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|
|
|
+ || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
|
|
|
+ driverInterOpAPI.IGW_SetLedOnOff(false);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ devioctr.cameraPowerControll(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CallAppEnable = true; // 현관카메라 파워 off시, WallpadCall 호출 가능
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] PowerOnTimer END");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTick(long arg0) {
|
|
|
+ }
|
|
|
+ };
|
|
|
+ PowerOnTimer.cancel();
|
|
|
+ PowerOnTimer.start();
|
|
|
+
|
|
|
+ Log.d(TAG, "[TurnOnDcamPower] END");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 최 상위 activity 가져오기
|
|
|
+ */
|
|
|
+ private String getTopActivity() {
|
|
|
+ try {
|
|
|
+ ActivityManager mActivityManager = (ActivityManager)ServiceMain.svcContext.getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
+ List<RunningTaskInfo> mTaskInfo = null;
|
|
|
+ if (mActivityManager != null) {
|
|
|
+ mTaskInfo = mActivityManager.getRunningTasks(5);
|
|
|
+ }
|
|
|
+ if(mTaskInfo!=null)
|
|
|
+ {
|
|
|
+ ComponentName mComponentName = mTaskInfo.get(0).topActivity;
|
|
|
+ return mComponentName.getPackageName();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] getTopActivity()");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean getCallAppRunningStatus() {
|
|
|
+ boolean bRunning = false;
|
|
|
+
|
|
|
+ try {
|
|
|
+ WallpadStatusData DBMGR = new WallpadStatusData(ServiceMain.svcContext);
|
|
|
+ bRunning = DBMGR.GetCallAPKStatusRunning();
|
|
|
+ DBMGR.closeDB();
|
|
|
+
|
|
|
+ Log.d(TAG, "[getCallAppRunningStatus] - CALL Running : " + bRunning);
|
|
|
+ return bRunning;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.d(TAG, "[Exception] getCallAppRunningStatus()");
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);//e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|