|
@@ -48,6 +48,7 @@ import java.net.Socket;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.AirconControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.AirconControl;
|
|
@@ -57,6 +58,7 @@ import kr.co.icontrols.wallpadmulticontrolservice.control.KnxAirconControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.LightControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.LightControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.VentiControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.control.VentiControl;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.data.BasicData;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.data.BasicData;
|
|
|
|
+import kr.co.icontrols.wallpadmulticontrolservice.data.MobileSyncData;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.data.RequestData;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.data.RequestData;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.Common.JSON;
|
|
import kr.co.icontrols.wallpadmulticontrolservice.Common.JSON;
|
|
import kr.co.icontrols.wallpadsupport.Version;
|
|
import kr.co.icontrols.wallpadsupport.Version;
|
|
@@ -340,7 +342,8 @@ public class DataSenderService extends Service {
|
|
outputStream.writeObject(json);
|
|
outputStream.writeObject(json);
|
|
outputStream.close();
|
|
outputStream.close();
|
|
Log.d("ServerThread", "result 보냄 : " + result);
|
|
Log.d("ServerThread", "result 보냄 : " + result);
|
|
- } else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getReason() == JSON.REASON.Status) {
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getReason() == JSON.REASON.Status) {
|
|
try {
|
|
try {
|
|
JSONObject result = updateRequest(basicData.getMenu(), basicData.getKind(), basicData.getPosition());
|
|
JSONObject result = updateRequest(basicData.getMenu(), basicData.getKind(), basicData.getPosition());
|
|
Random rand = new Random();
|
|
Random rand = new Random();
|
|
@@ -474,7 +477,8 @@ public class DataSenderService extends Service {
|
|
outputStream.close();
|
|
outputStream.close();
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- } else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getMenu() == JSON.MENU.PASSWORD) {
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getMenu() == JSON.MENU.PASSWORD) {
|
|
//비밀번호 변경 요청
|
|
//비밀번호 변경 요청
|
|
int result = passwordChangeRequest(basicData.getNumber());
|
|
int result = passwordChangeRequest(basicData.getNumber());
|
|
String json = "";
|
|
String json = "";
|
|
@@ -488,7 +492,7 @@ public class DataSenderService extends Service {
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
try {
|
|
try {
|
|
- jsonObject.accumulate("type", "controlResponse");
|
|
|
|
|
|
+ jsonObject.accumulate("type", "passwordResponse");
|
|
jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
|
|
jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
|
|
jsonObject.accumulate("ip", myIP);
|
|
jsonObject.accumulate("ip", myIP);
|
|
jsonObject.accumulate("menu", basicData.getMenu());
|
|
jsonObject.accumulate("menu", basicData.getMenu());
|
|
@@ -502,9 +506,10 @@ public class DataSenderService extends Service {
|
|
outputStream.writeObject(json);
|
|
outputStream.writeObject(json);
|
|
outputStream.close();
|
|
outputStream.close();
|
|
Log.d("ServerThread", "result 보냄 : " + result);
|
|
Log.d("ServerThread", "result 보냄 : " + result);
|
|
- } else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getMenu() == JSON.MENU.MOBILE) {
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (data != null && !data.trim().equals("") && basicData.getType().equalsIgnoreCase("request") && basicData.getMenu() == JSON.MENU.MOBILE) {
|
|
//모바일 등록 관련
|
|
//모바일 등록 관련
|
|
- int result = updateMobile(basicData.getReason(), basicData.getName(), basicData.getId());
|
|
|
|
|
|
+ int result = updateMobile(allObject, basicData.getReason(), basicData.getName(), basicData.getId());
|
|
String json = "";
|
|
String json = "";
|
|
String resultStr = "ok";
|
|
String resultStr = "ok";
|
|
if (result == JSON.RESULT.Success) {
|
|
if (result == JSON.RESULT.Success) {
|
|
@@ -516,7 +521,7 @@ public class DataSenderService extends Service {
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
try {
|
|
try {
|
|
- jsonObject.accumulate("type", "controlResponse");
|
|
|
|
|
|
+ jsonObject.accumulate("type", "mobileResponse");
|
|
jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
|
|
jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
|
|
jsonObject.accumulate("ip", myIP);
|
|
jsonObject.accumulate("ip", myIP);
|
|
jsonObject.accumulate("menu", basicData.getMenu());
|
|
jsonObject.accumulate("menu", basicData.getMenu());
|
|
@@ -1949,14 +1954,15 @@ public class DataSenderService extends Service {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private int updateMobile(int reason, String name, String id) {
|
|
|
|
|
|
+ private int updateMobile(JSONObject requestData, int reason, String name, String id) {
|
|
|
|
+ Gson gson = new Gson();
|
|
try {
|
|
try {
|
|
WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
|
|
WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
|
|
- if (reason == JSON.REASON.MobileRegister) {
|
|
|
|
|
|
+ if (reason == JSON.REASON.MobileRegister && name!=null && id!=null) {
|
|
//모바일 등록
|
|
//모바일 등록
|
|
//DB에 저장 필요
|
|
//DB에 저장 필요
|
|
wallpadMobileDeviceData.Register(id, name);
|
|
wallpadMobileDeviceData.Register(id, name);
|
|
- } else if (reason == JSON.REASON.MobileDelete) {
|
|
|
|
|
|
+ } else if (reason == JSON.REASON.MobileDelete && id!=null) {
|
|
//모바일 전체 삭제
|
|
//모바일 전체 삭제
|
|
if (id.equals("all")) {
|
|
if (id.equals("all")) {
|
|
wallpadMobileDeviceData.UnRegisterAll();
|
|
wallpadMobileDeviceData.UnRegisterAll();
|
|
@@ -1965,6 +1971,14 @@ public class DataSenderService extends Service {
|
|
else {
|
|
else {
|
|
wallpadMobileDeviceData.DeleteEachUid(id);
|
|
wallpadMobileDeviceData.DeleteEachUid(id);
|
|
}
|
|
}
|
|
|
|
+ } else if (reason == JSON.REASON.MobileSync) {
|
|
|
|
+ //모바일 동기화
|
|
|
|
+ wallpadMobileDeviceData.UnRegisterAll();
|
|
|
|
+ MobileSyncData reqData = gson.fromJson(requestData.toString(), MobileSyncData.class);
|
|
|
|
+ for(int i = 0; i<reqData.getArrayData().size() ; i++){
|
|
|
|
+ String[] mobileData = reqData.getArrayData().get(i).split("\\|");
|
|
|
|
+ wallpadMobileDeviceData.Register(mobileData[1], mobileData[0]+"@");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
wallpadMobileDeviceData.closeDB();
|
|
wallpadMobileDeviceData.closeDB();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|